Skip to content

Commit

Permalink
New Service: Scopes (#245)
Browse files Browse the repository at this point in the history
* initial

* rebase

* scope data source

* test
+ example

* works better

* updated example

* default expression

* added scope_id to groups

* more additions

* docs

* docs

* removed v1

* update v1

* docs

* examples

* updates

* fixing tests

* fixing tests

* fixing tests

* groups api fix

* fixed a test

* destroy check fixed

* changelog update

* typo

* typo
  • Loading branch information
celaus authored Jul 29, 2024
1 parent 6a163d7 commit ee62d75
Show file tree
Hide file tree
Showing 19 changed files with 2,280 additions and 18 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,17 @@ New Features:
* added support for more than one `section`.
* added support for `query` option in `multi_select` variables.


## Release 1.16.4
Bug fixing:
#### resource/coralogix_dashboard
* changing `pie_chart` and `horizontal_bar_chart` `query.logs.group_names` to Optional.
* changing `pie_chart` and `horizontal_bar_chart` `query.logs.group_names` to Optional.

## Release 1.17

New Features:
#### resource/coralogix_scope
* added Scope support

#### resource/coralogix_group
* added support for associated scopes

14 changes: 10 additions & 4 deletions coralogix/clientset/clientset.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 Coralogix Ltd.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -38,6 +38,7 @@ type ClientSet struct {
groups *GroupsClient
users *UsersClient
customRole *RolesClient
scopes *ScopesClient
}

func (c *ClientSet) RuleGroups() *RuleGroupsClient {
Expand Down Expand Up @@ -132,6 +133,10 @@ func (c *ClientSet) Users() *UsersClient {
return c.users
}

func (c *ClientSet) Scopes() *ScopesClient {
return c.scopes
}

func NewClientSet(targetUrl, apiKey string) *ClientSet {
apikeyCPC := NewCallPropertiesCreator(targetUrl, apiKey)

Expand Down Expand Up @@ -159,5 +164,6 @@ func NewClientSet(targetUrl, apiKey string) *ClientSet {
groups: NewGroupsClient(apikeyCPC),
users: NewUsersClient(apikeyCPC),
customRole: NewRolesClient(apikeyCPC),
scopes: NewScopesClient(apikeyCPC),
}
}
7 changes: 7 additions & 0 deletions coralogix/clientset/groups-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"strings"

"terraform-provider-coralogix/coralogix/clientset/rest"
Expand All @@ -33,6 +34,7 @@ type SCIMGroup struct {
DisplayName string `json:"displayName"`
Members []SCIMGroupMember `json:"members"`
Role string `json:"role"`
ScopeID string `json:"nextGenScopeId"`
}

type SCIMGroupMember struct {
Expand All @@ -44,11 +46,13 @@ func (c GroupsClient) CreateGroup(ctx context.Context, groupReq *SCIMGroup) (*SC
if err != nil {
return nil, err
}
log.Printf("[INFO] Creating Group: %s", body)

bodyResp, err := c.client.Post(ctx, "", "application/json", string(body))
if err != nil {
return nil, err
}
log.Printf("[INFO] Received Group: %s", bodyResp)

var groupResp SCIMGroup
err = json.Unmarshal([]byte(bodyResp), &groupResp)
Expand Down Expand Up @@ -84,6 +88,7 @@ func (c GroupsClient) UpdateGroup(ctx context.Context, groupID string, groupReq
if err != nil {
return nil, err
}
log.Printf("[INFO] Received Group: %s", bodyResp)

var groupResp SCIMGroup
err = json.Unmarshal([]byte(bodyResp), &groupResp)
Expand All @@ -95,6 +100,8 @@ func (c GroupsClient) UpdateGroup(ctx context.Context, groupID string, groupReq
}

func (c GroupsClient) DeleteGroup(ctx context.Context, groupID string) error {
log.Printf("[INFO] Deleting Group: %s", groupID)

_, err := c.client.Delete(ctx, fmt.Sprintf("/%s", groupID))
return err

Expand Down
133 changes: 133 additions & 0 deletions coralogix/clientset/grpc/scopes/entity_type.pb.go

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

Loading

0 comments on commit ee62d75

Please sign in to comment.