Skip to content

Commit

Permalink
roles users and groups managed by api-key (#206)
Browse files Browse the repository at this point in the history
* patch - users, roles and groups are manged by api-key
  • Loading branch information
OrNovo authored Feb 21, 2024
1 parent 47f02a2 commit 8b805c1
Show file tree
Hide file tree
Showing 68 changed files with 631 additions and 691 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,20 @@ New Features:
#### resource/coralogix_user
* Adding `coralogix_user` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/user.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/user.md).
#### resource/coralogix_group
* Adding `coralogix_user_group` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/group.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/group.md).
* Adding `coralogix_user_group` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/group.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/group.md).

## Release 1.11.10
New Features:
#### resource/coralogix_custom_role
* Adding `coralogix_custom_role` [resource](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/resources/custom_role.md) and [data-source](https://github.com/coralogix/terraform-provider-coralogix/tree/master/docs/data-sources/custom_role.md).

## Release 1.11.11
Breaking Changes:
#### resource/coralogix_user, resource/coralogix_group and resource/coralogix_custom_role
* `team_id` was removed. managed by (team's) api-key with the right permissions.

Bug fixing:
#### resource/coralogix_events2metric
* fixing `buckets` type-conversion bug (from float32 to float64).
#### resource/coralogix_dashboard
* fixing `time_frame.relative.duration` flattening bug when set to `seconds:0`.
6 changes: 3 additions & 3 deletions coralogix/clientset/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func NewClientSet(targetUrl, apiKey, orgKey string) *ClientSet {
slos: NewSLOsClient(apikeyCPC),
dahboardsFolders: NewDashboardsFoldersClient(apikeyCPC),
apiKeys: NewApiKeysClient(teamsCPC),
groups: NewGroupsClient(teamsCPC),
users: NewUsersClient(teamsCPC),
customRole: NewRolesClient(teamsCPC),
groups: NewGroupsClient(apikeyCPC),
users: NewUsersClient(apikeyCPC),
customRole: NewRolesClient(apikeyCPC),
}
}
16 changes: 8 additions & 8 deletions coralogix/clientset/groups-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ type SCIMGroupMember struct {
Value string `json:"value"`
}

func (c GroupsClient) CreateGroup(ctx context.Context, teamID string, groupReq *SCIMGroup) (*SCIMGroup, error) {
func (c GroupsClient) CreateGroup(ctx context.Context, groupReq *SCIMGroup) (*SCIMGroup, error) {
body, err := json.Marshal(groupReq)
if err != nil {
return nil, err
}

bodyResp, err := c.client.Post(ctx, "", "application/json", string(body), "cgx-team-id", teamID)
bodyResp, err := c.client.Post(ctx, "", "application/json", string(body))
if err != nil {
return nil, err
}
Expand All @@ -45,8 +45,8 @@ func (c GroupsClient) CreateGroup(ctx context.Context, teamID string, groupReq *
return &groupResp, nil
}

func (c GroupsClient) GetGroup(ctx context.Context, teamID, groupID string) (*SCIMGroup, error) {
bodyResp, err := c.client.Get(ctx, fmt.Sprintf("/%s", groupID), "cgx-team-id", teamID)
func (c GroupsClient) GetGroup(ctx context.Context, groupID string) (*SCIMGroup, error) {
bodyResp, err := c.client.Get(ctx, fmt.Sprintf("/%s", groupID))
if err != nil {
return nil, err
}
Expand All @@ -60,13 +60,13 @@ func (c GroupsClient) GetGroup(ctx context.Context, teamID, groupID string) (*SC
return &groupResp, nil
}

func (c GroupsClient) UpdateGroup(ctx context.Context, teamID, groupID string, groupReq *SCIMGroup) (*SCIMGroup, error) {
func (c GroupsClient) UpdateGroup(ctx context.Context, groupID string, groupReq *SCIMGroup) (*SCIMGroup, error) {
body, err := json.Marshal(groupReq)
if err != nil {
return nil, err
}

bodyResp, err := c.client.Put(ctx, fmt.Sprintf("/%s", groupID), "application/json", string(body), "cgx-team-id", teamID)
bodyResp, err := c.client.Put(ctx, fmt.Sprintf("/%s", groupID), "application/json", string(body))
if err != nil {
return nil, err
}
Expand All @@ -80,8 +80,8 @@ func (c GroupsClient) UpdateGroup(ctx context.Context, teamID, groupID string, g
return &groupResp, nil
}

func (c GroupsClient) DeleteGroup(ctx context.Context, teamID, groupID string) error {
_, err := c.client.Delete(ctx, fmt.Sprintf("/%s", groupID), "cgx-team-id", teamID)
func (c GroupsClient) DeleteGroup(ctx context.Context, groupID string) error {
_, err := c.client.Delete(ctx, fmt.Sprintf("/%s", groupID))
return err

}
Expand Down
Loading

0 comments on commit 8b805c1

Please sign in to comment.