Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support for Squadcast provider #1473

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
12fb182
feat: Added user resource to squadcast provider
roshan8 Aug 16, 2022
6e7d369
fix: Api url
roshan8 Aug 16, 2022
7af74ae
refactor
roshan8 Aug 16, 2022
467b4cc
add refresh-token, region, team-name flag
Lucifer8729 Aug 17, 2022
68e0d33
fix: updated logic to get host
Aug 17, 2022
d1e6578
feat: added team resource to squadcast provider
Lucifer8729 Aug 17, 2022
aa9a7f3
fix: added logic for different region
Lucifer8729 Aug 18, 2022
658ea6b
fix: Pass region env variable to terraform provider
roshan8 Aug 18, 2022
5a2da86
fix: user service for eu is fixed
Lucifer8729 Aug 18, 2022
e18869d
feat: added team roles and escalation policy to squadcast provider
Lucifer8729 Aug 19, 2022
621efc6
feat: added team member resource to squadcast provider
Lucifer8729 Aug 19, 2022
0715a89
feat: added service resource to squadcast provider
Lucifer8729 Aug 19, 2022
e9b9b10
fix: overriding refresh token through cli
Lucifer8729 Aug 19, 2022
9056a67
feat: Added all resources and refactored code
Aug 19, 2022
bb066ee
Added Squadcast docs
Aug 22, 2022
e8f0f88
Added Squadcast to README
Aug 22, 2022
bc8dceb
Added Squadcast docs
Aug 22, 2022
0d45478
Added Squadcast docs
Aug 22, 2022
00f14dd
updated Squadcast docs
Aug 22, 2022
dcbd371
Added squadcast provider
Aug 23, 2022
fcf100c
added new branch
Aug 23, 2022
882e1a6
Added support for custom server url
Aug 24, 2022
2ba0193
fix: removed api-endpoint for now
Aug 24, 2022
4fc47c8
Merge branch 'master' into squadcast-terraformer
Aug 24, 2022
47d6ef0
feat: added tagging rules to squadcast
Lucifer8729 Aug 29, 2022
0b9617d
fix: fixed invalid service ID
Lucifer8729 Aug 29, 2022
d77b44c
feat: added routing rules to squadcast provider
Lucifer8729 Aug 29, 2022
1291d0e
feat: deduplication rules resource added to squadcast provider
Lucifer8729 Aug 29, 2022
d883b04
fixed routing rules file name
Lucifer8729 Aug 29, 2022
99174d4
feat: added suppression rules resource to squadcast provider
Lucifer8729 Aug 29, 2022
572bb41
fix: fixed all suggested changes
Aug 30, 2022
29decc0
feat: added tagging rules to squadcast
Lucifer8729 Aug 29, 2022
4dd3f6d
fix: fixed invalid service ID
Lucifer8729 Aug 29, 2022
42dfa3d
feat: added routing rules to squadcast provider
Lucifer8729 Aug 29, 2022
afaff94
feat: deduplication rules resource added to squadcast provider
Lucifer8729 Aug 29, 2022
ad1a502
fixed routing rules file name
Lucifer8729 Aug 29, 2022
467ff9f
feat: added suppression rules resource to squadcast provider
Lucifer8729 Aug 29, 2022
021fc9c
Merge branch 'milestone-4-resources' of https://github.com/SquadcastH…
Lucifer8729 Aug 30, 2022
c5ed56a
refactored the code
Lucifer8729 Aug 30, 2022
bfca59c
fix: refactored code
Sep 1, 2022
36847ed
fix: merged request functions
Sep 2, 2022
097908c
fix: updated dependency from genereateRequest to Request function for…
Lucifer8729 Sep 2, 2022
a18ffc2
fix: refactored code
Lucifer8729 Sep 2, 2022
d8a3452
feat: added tagging rules to squadcast
Lucifer8729 Aug 29, 2022
2fb401b
fix: fixed invalid service ID
Lucifer8729 Aug 29, 2022
71e7f7e
feat: added routing rules to squadcast provider
Lucifer8729 Aug 29, 2022
7cf0382
feat: deduplication rules resource added to squadcast provider
Lucifer8729 Aug 29, 2022
5832864
fixed routing rules file name
Lucifer8729 Aug 29, 2022
98427d8
feat: added suppression rules resource to squadcast provider
Lucifer8729 Aug 29, 2022
26df8e4
feat: added routing rules to squadcast provider
Lucifer8729 Aug 29, 2022
d83b8c6
fixed routing rules file name
Lucifer8729 Aug 29, 2022
a1a8d13
refactored the code
Lucifer8729 Aug 30, 2022
035a310
fix: refactored code
Sep 1, 2022
5990e68
Merge branch 'milestone-4-resources' of https://github.com/SquadcastH…
Lucifer8729 Sep 2, 2022
d31ade4
fix: switched from generateRequest to Request function
Lucifer8729 Sep 2, 2022
8a3b7e1
Merge pull request #1 from SquadcastHub/squadcast-terraformer
roshan8 Sep 5, 2022
2d7bbe0
fix: renamed squadcast_schedule.go to schedule.go to follow the conve…
Lucifer8729 Sep 5, 2022
384a69f
fix: updated squadcast provider doc
Lucifer8729 Sep 5, 2022
0df2d0b
fix: added links in squadcast doc
Lucifer8729 Sep 5, 2022
b4cba21
fix: removed schedules reference from the doc
Lucifer8729 Sep 5, 2022
fe2eda4
fix: removed --schedule-name flag
Sep 6, 2022
18cb9a5
fix: refactored code
Lucifer8729 Sep 6, 2022
dedff0f
Merge pull request #2 from SquadcastHub/milestone-4-resources
Lucifer8729 Sep 6, 2022
a8e0f6f
fix: updated main README file
Lucifer8729 Sep 6, 2022
2561358
Merge branch 'master' of github-squadcast:GoogleCloudPlatform/terrafo…
Sep 7, 2022
96d164c
Merge branch 'master' of github-squadcast:GoogleCloudPlatform/terrafo…
mohammadmuazam Sep 9, 2022
3518475
fix: refactored code
mohammadmuazam Sep 9, 2022
e4aa226
fix: refactored code
Lucifer8729 Sep 9, 2022
84e2d09
Merge branch 'master' of github-squadcast:GoogleCloudPlatform/terrafo…
mohammadmuazam Sep 12, 2022
5d1a06d
Merge branch 'master' of github-squadcast:SquadcastHub/terraformer
mohammadmuazam Sep 12, 2022
f4cdbf9
feat: added support for .tech
mohammadmuazam Sep 12, 2022
d2f34e5
Merge branch 'master' of github-squadcast:GoogleCloudPlatform/terrafo…
mohammadmuazam Sep 15, 2022
8268239
fix: update --team-name flag and README
mohammadmuazam Sep 16, 2022
7f1c1ac
feat: generate automation rules for all services under a specified te…
Lucifer8729 Sep 17, 2022
79c07c0
updated squadcast.md in docs
Lucifer8729 Sep 19, 2022
4934723
Merge pull request #3 from GoogleCloudPlatform/master
Lucifer8729 Sep 20, 2022
feb1f82
fix: removed schedule resource
Lucifer8729 Sep 20, 2022
07621bf
fix: fixed some golangci-lint error
Lucifer8729 Sep 20, 2022
7148232
fix: renamed SquadcastSevice to SCService and SqaudcastProvider to SC…
Lucifer8729 Sep 21, 2022
490b0e7
Merge pull request #4 from GoogleCloudPlatform/master
Lucifer8729 Sep 26, 2022
3e8b2d2
fix: error handling
mohammadmuazam Mar 15, 2023
24ab8ad
Merge pull request #5 from SquadcastHub/fix/error-handling
mohammadmuazam Mar 24, 2023
aa90dee
Merge branch 'master' of github.com:GoogleCloudPlatform/terraformer
mohammadmuazam May 13, 2024
ff020d8
feat: add support for new resources
mohammadmuazam May 15, 2024
59d3bcc
Merge branch 'master' of github.com:GoogleCloudPlatform/terraformer
mohammadmuazam May 15, 2024
31cb064
Merge branch 'master' of github.com:SquadcastHub/terraformer into fea…
mohammadmuazam May 15, 2024
c1aee7b
minor change
mohammadmuazam May 15, 2024
2603fb6
implement pagination
mohammadmuazam May 15, 2024
2433691
update services url
mohammadmuazam May 17, 2024
ba8014c
Merge pull request #6 from SquadcastHub/feat/add-new-resources
mohammadmuazam May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
262 changes: 144 additions & 118 deletions README.md

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions cmd/provider_cmd_squadcast.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
squadcast_terraforming "github.com/GoogleCloudPlatform/terraformer/providers/squadcast"

"github.com/GoogleCloudPlatform/terraformer/terraformutils"
"github.com/spf13/cobra"
)

func newCmdSquadcastImporter(options ImportOptions) *cobra.Command {
var refreshToken, teamName, region, serviceName string

cmd := &cobra.Command{
Use: "squadcast",
Short: "Import current state to Terraform configuration from Squadcast",
Long: "Import current state to Terraform configuration from Squadcast",
RunE: func(cmd *cobra.Command, args []string) error {
provider := newSquadcastProvider()
options.PathPattern += region + "/"
err := Import(provider, options, []string{refreshToken, region, teamName, serviceName})
if err != nil {
return err
}
return nil
},
}
cmd.AddCommand(listCmd(newSquadcastProvider()))
baseProviderFlags(cmd.PersistentFlags(), &options, "user", "")
cmd.PersistentFlags().StringVarP(&refreshToken, "refresh-token", "", "", "YOUR_SQUADCAST_REFRESH_TOKEN or env variable SQUADCAST_REFRESH_TOKEN")
cmd.PersistentFlags().StringVarP(&region, "region", "", "", "eu or us")
cmd.PersistentFlags().StringVarP(&teamName, "team-name", "", "", "Squadcast team name")
cmd.PersistentFlags().StringVarP(&serviceName, "service-name", "", "", "Squadcast service name")
return cmd
}

func newSquadcastProvider() terraformutils.ProviderGenerator {
return &squadcast_terraforming.SCProvider{}
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func providerImporterSubcommands() []func(options ImportOptions) *cobra.Command
newCmdPagerDutyImporter,
newCmdOpsgenieImporter,
newCmdHoneycombioImporter,
newCmdSquadcastImporter,
newCmdOpalImporter,
// Community
newCmdKeycloakImporter,
Expand Down
143 changes: 143 additions & 0 deletions docs/squadcast.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Use with Squadcast

Syntax:

`export SQUADCAST_REFRESH_TOKEN=<YOUR_SQUADCAST_REFRESH_TOKEN>`

OR

Add `--refresh-token` flag in cmd

```
terraformer import squadcast --resources=<SERVICE_NAMES> --region=SQUADCAST_REGION
```

### Examples:

- `Import Resource by providing refresh-token as a flag`

```
terraformer import squadcast --resources=team --region=us --team-name="Default Team" --refresh-token=YOUR_REFRESH_TOKEN
```

- `Import User Resource`

```
terraformer import squadcast --resources=user --region=us --team-name="Defualt Team"
```

- `Import Squad Resource`

```
terraformer import squadcast --resources=team --region=us --team-name="Default Team"
```

- `Import Deduplication Rules Resource` (without `--service-name` flag)
- Deduplication Rules for all the services under Default Team will be generated.

```
terraformer import squadcast --resources=deduplication_rules --region=us --team-name="Default Team"
```

- `Import Deduplication Rules Resource`
- Deduplication Rules only for Example Service will be generated.

```
terraformer import squadcast --resources=deduplication_rules --region=us --team-name="Default Team" --service-name="Example Service"
```

### In order to use terraform files:

- Update version and add source in `provider.tf`
- Go to `/generated/squadcast/<RESOURCE>/<REGION>/provider.tf`
- Add `source = "SquadcastHub/squadcast"` to squadcast inside `required_providers`
- Update `version` in `required_providers` by removing `.exe` (Windows users only)
- Update `terraform_version`
- `cd /generated/squadcast/<RESOURCE>/<REGION>`
- `terraform state replace-provider -auto-approve "registry.terraform.io/-/squadcast" "SquadcastHub/squadcast"`

### Example:

```
terraform {
required_providers {
squadcast = {
version = "~> 2.0.1"
source = "SquadcastHub/squadcast"
}
}
}
```

### Flags:

- `--team-name`

- Required for the following resources:
- deduplication_rules
- escalation_policy
- routing_rules
- runbook
- service
- slo
- squad
- suppression_rules
- tagging_rules
- team_member
- team_roles
- user
- webform
- schedules_v2
- global_event_rules
- status_pages
- status_page_components
- status_page_groups

- `--region`

- Supported Values:
- `us`
- `eu`

- `--service-name` (optional)

- Supported for the following resources:
- deduplication_rules
- routing_rules
- suppression_rules
- tagging_rules
- deduplication_rules_v2
- routing_rules_v2
- suppression_rules_v2
- tagging_rules_v2
- If service name is not provided, resources for specified automation rule for all the service within the specified team will be generated. However it will only generate for a specific service when this flag is used. [see examples](squadcast.md:36)

- `--refresh-token` (optional)
- Supported Values:
- <YOUR_SQUADCAST_REFRESH_TOKEN>

### Supported resources:

- [`deduplication_rules`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/deduplication_rules)
- [`deduplication_rule_v2`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/deduplication_rule_v2)
- [`escalation_policy`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/escalation_policy)
- [`routing_rules`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/routing_rules)
- [`routing_rule_v2`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/routing_rule_v2)
- [`runbook`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/runbook)
- [`service`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/service)
- [`slo`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/slo)
- [`squad`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/squad)
- [`suppression_rules`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/suppression_rules)
- [`suppression_rule_v2`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/suppression_rule_v2)
- [`tagging_rules`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/tagging_rules)
- [`tagging_rule_v2`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/tagging_rule_v2)
- [`team`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/team)
- [`team_member`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/team_member)
- [`team_roles`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/team_role)
- [`user`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/user)
- [`webforms`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/webform)
- [`status_pages`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/status_page)
- [`status_page_components`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/status_page_component)
- [`status_page_groups`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/status_page_group)
- [`global_event_rules`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/ger)
- [`schedules_v2`](https://registry.terraform.io/providers/SquadcastHub/squadcast/latest/docs/resources/schedule_v2)
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/jsonapi v1.0.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down Expand Up @@ -389,11 +389,13 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
nhooyr.io/websocket v1.8.10 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
)

require (
github.com/gofrs/uuid/v3 v3.1.2
github.com/hasura/go-graphql-client v0.12.1
github.com/ionos-cloud/sdk-go-cert-manager v1.0.0
github.com/ionos-cloud/sdk-go-container-registry v1.0.0
github.com/ionos-cloud/sdk-go-dataplatform v1.0.1
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg=
Expand Down Expand Up @@ -1036,6 +1038,8 @@ github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bA
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 h1:xixZ2bWeofWV68J+x6AzmKuVM/JWCQwkWm6GW/MUR6I=
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hasura/go-graphql-client v0.12.1 h1:tL+BCoyubkYYyaQ+tJz+oPe/pSxYwOJHwe5SSqqi6WI=
github.com/hasura/go-graphql-client v0.12.1/go.mod h1:F4N4kR6vY8amio3gEu3tjSZr8GPOXJr3zj72DKixfLE=
github.com/heimweh/go-pagerduty v0.0.0-20210930203304-530eff2acdc6 h1:/D0VtHEOCdotE1vSB9XznceAjIGkUieZ4BF6VKUIqNU=
github.com/heimweh/go-pagerduty v0.0.0-20210930203304-530eff2acdc6/go.mod h1:JtJGtgN0y9KOCaqFMZFaBCWskpO/KK3Ro9TwjP9ss6w=
github.com/heroku/heroku-go/v5 v5.4.1 h1:J1nNnR3/571b2iUDHl+y1B3VkhKm6YOXIq9GGzQUv5s=
Expand Down Expand Up @@ -2416,6 +2420,8 @@ k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42/go.mod h1:Z/45zLw8lUo4wdi
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
84 changes: 84 additions & 0 deletions providers/squadcast/deduplication_rules.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package squadcast

import (
"fmt"

"github.com/GoogleCloudPlatform/terraformer/terraformutils"
)

type DeduplicationRulesGenerator struct {
SCService
}

type DeduplicationRules struct {
ID string `json:"id"`
ServiceID string `json:"service_id"`
Rules []*DeduplicationRule `json:"rules"`
}

type DeduplicationRule struct {
ID string `json:"rule_id"`
}

func (g *DeduplicationRulesGenerator) createResources(deduplicationRules DeduplicationRules) []terraformutils.Resource {
var resourceList []terraformutils.Resource
for _, rule := range deduplicationRules.Rules {
resourceList = append(resourceList, terraformutils.NewResource(
rule.ID,
fmt.Sprintf("deduplication_rule_%s", rule.ID),
"squadcast_deduplication_rules",
g.GetProviderName(),
map[string]string{
"team_id": g.Args["team_id"].(string),
"service_id": deduplicationRules.ServiceID,
},
[]string{},
map[string]interface{}{},
))
}
return resourceList
}

func (g *DeduplicationRulesGenerator) InitResources() error {
if len(g.Args["service_name"].(string)) == 0 {
req := TRequest{
URL: "/v3/services",
AccessToken: g.Args["access_token"].(string),
Region: g.Args["region"].(string),
IsAuthenticated: true,
}
responseService, _, err := Request[[]Service](req)
if err != nil {
return err
}

for _, service := range *responseService {
req := TRequest{
URL: fmt.Sprintf("/v3/services/%s/deduplication-rules", service.ID),
AccessToken: g.Args["access_token"].(string),
Region: g.Args["region"].(string),
IsAuthenticated: true,
}
response, _, err := Request[DeduplicationRules](req)
if err != nil {
return err
}

g.Resources = append(g.Resources, g.createResources(*response)...)
}
} else {
req := TRequest{
URL: fmt.Sprintf("/v3/services/%s/deduplication-rules", g.Args["service_id"]),
AccessToken: g.Args["access_token"].(string),
Region: g.Args["region"].(string),
IsAuthenticated: true,
}
response, _, err := Request[DeduplicationRules](req)
if err != nil {
return err
}

g.Resources = g.createResources(*response)
}
return nil
}