Skip to content

Commit

Permalink
create keys (#199)
Browse files Browse the repository at this point in the history
* create keys

* update

* Hashed formatting

* fix error messages

* fix get key value from plan

* add data and tests

* rm stg

* docs

* PlanModifier
  • Loading branch information
mbedulli authored Feb 12, 2024
1 parent 99a5658 commit 049befc
Show file tree
Hide file tree
Showing 14 changed files with 2,015 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/acc-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ jobs:
env:
CORALOGIX_ENV: ${{ secrets.CORALOGIX_ENV }}
CORALOGIX_API_KEY: ${{ secrets.CORALOGIX_API_KEY }}
CORALOGIX_ORG_KEY: ${{ secrets.CORALOGIX_ORG_KEY }}

run: |
make testacc
66 changes: 66 additions & 0 deletions coralogix/clientset/apikeys-client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package clientset

import (
"context"
apikeys "terraform-provider-coralogix/coralogix/clientset/grpc/apikeys"
)

type ApikeysClient struct {
callPropertiesCreator *CallPropertiesCreator
}

func (t ApikeysClient) CreateApiKey(ctx context.Context, req *apikeys.CreateApiKeyRequest) (*apikeys.CreateApiKeyResponse, error) {
callProperties, err := t.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := apikeys.NewApiKeysServiceClient(conn)

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

func (t ApikeysClient) GetApiKey(ctx context.Context, req *apikeys.GetApiKeyRequest) (*apikeys.GetApiKeyResponse, error) {
callProperties, err := t.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := apikeys.NewApiKeysServiceClient(conn)

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

func (t ApikeysClient) UpdateApiKey(ctx context.Context, req *apikeys.UpdateApiKeyRequest) (*apikeys.UpdateApiKeyResponse, error) {
callProperties, err := t.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := apikeys.NewApiKeysServiceClient(conn)

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

func (t ApikeysClient) DeleteApiKey(ctx context.Context, req *apikeys.DeleteApiKeyRequest) (*apikeys.DeleteApiKeyResponse, error) {
callProperties, err := t.callPropertiesCreator.GetCallProperties(ctx)
if err != nil {
return nil, err
}

conn := callProperties.Connection
defer conn.Close()
client := apikeys.NewApiKeysServiceClient(conn)

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

func NewApiKeysClient(c *CallPropertiesCreator) *ApikeysClient {
return &ApikeysClient{callPropertiesCreator: c}
}
6 changes: 6 additions & 0 deletions coralogix/clientset/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ClientSet struct {
teams *TeamsClient
slos *SLOsClient
dahboardsFolders *DashboardsFoldersClient
apiKeys *ApikeysClient
}

func (c *ClientSet) RuleGroups() *RuleGroupsClient {
Expand Down Expand Up @@ -90,6 +91,10 @@ func (c *ClientSet) Teams() *TeamsClient {
return c.teams
}

func (c *ClientSet) ApiKeys() *ApikeysClient {
return c.apiKeys
}

func (c *ClientSet) SLOs() *SLOsClient {
return c.slos
}
Expand Down Expand Up @@ -122,5 +127,6 @@ func NewClientSet(targetUrl, apiKey, orgKey string) *ClientSet {
teams: NewTeamsClient(teamsCPC),
slos: NewSLOsClient(apikeyCPC),
dahboardsFolders: NewDashboardsFoldersClient(apikeyCPC),
apiKeys: NewApiKeysClient(teamsCPC),
}
}
Loading

0 comments on commit 049befc

Please sign in to comment.