Skip to content

Commit

Permalink
Metrics configurator (#182)
Browse files Browse the repository at this point in the history
* patch - metric and logs archive
  • Loading branch information
OrNovo authored Dec 18, 2023
1 parent a49ff57 commit 4cb6fd7
Show file tree
Hide file tree
Showing 34 changed files with 4,194 additions and 886 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,10 @@ Breaking Changes:
## Release 1.10.6
New Features:
#### resource/coralogix_archive_retentions
* Adding support for `coralogix_archive_retentions` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/archive_retentions.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/archive_retentions.md).
* Adding support for `coralogix_archive_retentions` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/archive_retentions.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/archive_retentions.md).

## Release 1.10.7
New Features:
#### resource/coralogix_archive_logs
* Adding support for `coralogix_archive_logs` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/archive_logs.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/archive_logs.md).
* Adding support for `coralogix_archive_metrics` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/archive_metrics.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/archive_metrics.md).
41 changes: 41 additions & 0 deletions coralogix/clientset/archive-logs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package clientset

import (
"context"

archiveLogs "terraform-provider-coralogix/coralogix/clientset/grpc/archive-logs"
)

type ArchiveLogsClient struct {
callPropertiesCreator *CallPropertiesCreator
}

func (c ArchiveLogsClient) UpdateArchiveLogs(ctx context.Context, req *archiveLogs.SetTargetRequest) (*archiveLogs.SetTargetResponse, error) {
callProperties, err := c.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := archiveLogs.NewTargetServiceClient(conn)

return client.SetTarget(callProperties.Ctx, req, callProperties.CallOptions...)
}

func (c ArchiveLogsClient) GetArchiveLogs(ctx context.Context) (*archiveLogs.GetTargetResponse, error) {
callProperties, err := c.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := archiveLogs.NewTargetServiceClient(conn)

return client.GetTarget(callProperties.Ctx, &archiveLogs.GetTargetRequest{}, callProperties.CallOptions...)
}

func NewArchiveLogsClient(c *CallPropertiesCreator) *ArchiveLogsClient {
return &ArchiveLogsClient{callPropertiesCreator: c}
}
42 changes: 42 additions & 0 deletions coralogix/clientset/archive-metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package clientset

import (
"context"

"google.golang.org/protobuf/types/known/emptypb"
archiveMetrics "terraform-provider-coralogix/coralogix/clientset/grpc/archive-metrics"
)

type ArchiveMetricsClient struct {
callPropertiesCreator *CallPropertiesCreator
}

func (c ArchiveMetricsClient) UpdateArchiveMetrics(ctx context.Context, req *archiveMetrics.ConfigureTenantRequest) (*emptypb.Empty, error) {
callProperties, err := c.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := archiveMetrics.NewMetricsConfiguratorPublicServiceClient(conn)

return client.ConfigureTenant(callProperties.Ctx, req, callProperties.CallOptions...)
}

func (c ArchiveMetricsClient) GetArchiveMetrics(ctx context.Context) (*archiveMetrics.GetTenantConfigResponseV2, error) {
callProperties, err := c.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := archiveMetrics.NewMetricsConfiguratorPublicServiceClient(conn)

return client.GetTenantConfig(callProperties.Ctx, &emptypb.Empty{}, callProperties.CallOptions...)
}

func NewArchiveMetricsClient(c *CallPropertiesCreator) *ArchiveMetricsClient {
return &ArchiveMetricsClient{callPropertiesCreator: c}
}
12 changes: 12 additions & 0 deletions coralogix/clientset/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type ClientSet struct {
events2Metrics *Events2MetricsClient
slis *SLIClient
archiveRetentions *ArchiveRetentionsClient
archiveMetrics *ArchiveMetricsClient
archiveLogs *ArchiveLogsClient
}

func (c *ClientSet) RuleGroups() *RuleGroupsClient {
Expand Down Expand Up @@ -74,6 +76,14 @@ func (c *ClientSet) ArchiveRetentions() *ArchiveRetentionsClient {

}

func (c *ClientSet) ArchiveMetrics() *ArchiveMetricsClient {
return c.archiveMetrics
}

func (c *ClientSet) ArchiveLogs() *ArchiveLogsClient {
return c.archiveLogs
}

func NewClientSet(targetUrl, apiKey, teamsApiKey string) *ClientSet {
apikeyCPC := NewCallPropertiesCreator(targetUrl, apiKey)
_ = NewCallPropertiesCreator(targetUrl, teamsApiKey)
Expand All @@ -93,5 +103,7 @@ func NewClientSet(targetUrl, apiKey, teamsApiKey string) *ClientSet {
webhooks: NewWebhooksClient(apikeyCPC),
slis: NewSLIsClient(apikeyCPC),
archiveRetentions: NewArchiveRetentionsClient(apikeyCPC),
archiveMetrics: NewArchiveMetricsClient(apikeyCPC),
archiveLogs: NewArchiveLogsClient(apikeyCPC),
}
}
203 changes: 203 additions & 0 deletions coralogix/clientset/grpc/archive-logs/target.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4cb6fd7

Please sign in to comment.