diff --git a/docs/resources/zenduty_account_role.md b/docs/resources/zenduty_account_role.md new file mode 100644 index 0000000..38198d0 --- /dev/null +++ b/docs/resources/zenduty_account_role.md @@ -0,0 +1,76 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "Zenduty: CustomRole" +subcategory: "" +description: |- + Provides a Zenduty CustomRole Resource. This allows CustomRole(rbac) to be created, updated, deleted. + +--- + +# Resource : zenduty_account_role + +Provides a Zenduty CustomRole Resource. This allows CustomRole(rbac) to be created, updated, deleted. + + +## Example Usage +```hcl +resource "zenduty_account_role" "sre" { + description = "view all incidents in account" + name = "sre" + permissions = [ + "incident_read", + ] +} +``` + + + +## Argument Reference + +* `name` (Required) - Name of the CustomRoke +* `description` (Required) - +* `permissions` (Required) - List of permissions this role is granted + +### Permissions + +Please refer to the following link for detailed documentation https://docs.zenduty.com/rbac + +- "analytics_read", +- "escalation_policy_read", +- "escalation_policy_write", +- "incident_read", +- "incident_write", +- "incident_role_read", +- "incident_role_write", +- "integration_read", +- "integration_write", +- "maintenance_read", +- "maintenance_write", +- "member_read", +- "member_write", +- "postmortem_read", +- "postmortem_write", +- "priority_read", +- "priority_write", +- "schedule_read", +- "schedule_write", +- "service_read", +- "service_write", +- "sla_read", +- "sla_write", +- "stakeholder_template_read", +- "stakeholder_template_write", +- "tag_read", +- "tag_write", +- "task_template_read", +- "task_template_write", +- "team_read", + + +## Attributes Reference + +The following attributes are exported: + +* `id` - The UniqueID of the Zenduty Account Role. + + diff --git a/docs/resources/zenduty_alertrules.md b/docs/resources/zenduty_alertrules.md index 02a7423..c008956 100644 --- a/docs/resources/zenduty_alertrules.md +++ b/docs/resources/zenduty_alertrules.md @@ -51,7 +51,7 @@ resource "zenduty_alertrules" "example_alertrules" { * `integration_id` (Required) - The unique_id of the integration to create the alert rule in. * `description` (Required) - The description of the alert rule. * `rule_json` (Required)(string) - The rule json of the alert rule.You cannot construct the rule json in terraform as of now.One can construct the rule json in Zenduty's UI.Create an dummy alert rule in Zenduty and copy the rule_json from the UI. -* `actions` (Optional) - The rules of the escalation policy. (see [below for nested schema](#nestedblock--actions)) +* `actions` (Optional) - The actions to be performed when the rule matches. (see [below for nested schema](#nestedblock--actions)) diff --git a/docs/resources/zenduty_assign_account_role.md b/docs/resources/zenduty_assign_account_role.md new file mode 100644 index 0000000..05dfc57 --- /dev/null +++ b/docs/resources/zenduty_assign_account_role.md @@ -0,0 +1,42 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "Zenduty: AssignAccountRole" +subcategory: "" +description: |- + Provides a Zenduty AssignAccountRole Resource. This allows you to assign role to user +--- + +# Resource : zenduty_assign_account_role + +This Resource allows you to assign a custom role to user + +--- + +## Example Usage +```hcl +resource "zenduty_account_role" "sre" { + description = "view all incidents in account" + name = "sre" + permissions = [ + "incident_read", + ] +} + +data "zenduty_user" "user1" { + email = "demouser@gmail.com" +} + + +resource "zenduty_assign_account_role" "demouser" { + username = data.zenduty_user.user1.users[0].username + account_role = zenduty_account_role.sre.id +} + +``` + + + +## Argument Reference + +* `username` (Required) - Username of the User +* `account_role`(Required) - UniqueID of the AccountRole \ No newline at end of file diff --git a/docs/resources/zenduty_globalrouter.md b/docs/resources/zenduty_globalrouter.md new file mode 100644 index 0000000..1600227 --- /dev/null +++ b/docs/resources/zenduty_globalrouter.md @@ -0,0 +1,58 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "Zenduty: GlobalRouter" +subcategory: "" +description: |- + Provides a Zenduty GlobalRouter Resource. This allows you to users to create a Router.which allows you to route alerts based on the rules +--- + +# Resource : zenduty_globalrouter + +An Global Router allows users to create a Router. The Router evaluates events sent to this Router against each of its rules, one at a time, and routes the event to a specific Integration based on the first rule that matches. + +--- + +## Example Usage +```hcl + +resource "zenduty_globalrouter" "router" { + name = "demorouter" + description = "This is a demo router" +} + +``` + + + +## Argument Reference + +* `name` (Required) - Name of the Router +* `description`(Required) - Description of the Router +* `is_optional` (Optional) - Enable or Disable the router + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the GlobalRouter. +* `integration_key` - The integration key of the GlobalRouter. + + +## Import + +GlobalRouter can be imported using the `router_id`(ie. UniqueID of the router), e.g. + +```hcl + resource "zenduty_globalrouter" "router" { + + } + +``` + +`$ terraform import zenduty_globalrouter.router router_id` + +`$ terraform state show zenduty_globalrouter.router` + +`copy the output data and paste inside zenduty_globalrouter.router resource block and remove the id,integration_key attribute` + +`$ terraform plan` to verify the import diff --git a/docs/resources/zenduty_globalrouting_rule.md b/docs/resources/zenduty_globalrouting_rule.md new file mode 100644 index 0000000..02b8753 --- /dev/null +++ b/docs/resources/zenduty_globalrouting_rule.md @@ -0,0 +1,76 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "Zenduty: GlobalRoutingRule" +subcategory: "" +description: |- + Provides a Zenduty GlobalRoutingRule Resource. This allows you to users to create routing rules.which allows you to route alerts based on the rules +--- + +# Resource : zenduty_globalrouting_rule + +An Global Router allows users to create routing rules. The Router evaluates events sent to this Router against each of its rules, one at a time, and routes the event to a specific Integration based on the first rule that matches. + +--- + +## Example Usage +```hcl + +resource "zenduty_globalrouter" "router" { + name = "demorouter" + description = "This is a demo router" +} + +resource "zenduty_globalrouting_rule" "demorules" { + router_id = zenduty_globalrouter.router.id + name = "demorule" + rule_json = "" + actions { + action_type = 0 + integration = "unique_id of integration" + } +} + +resource "zenduty_globalrouting_rule" "supressrule" { + router_id = zenduty_globalrouter.router.id + name = "supress" + rule_json = "" + actions { + action_type = 1 + } +} +``` + + + +## Argument Reference + +* `name` (Required) - Name of the Routing Rule +* `router_id` - UniqueID of the GlobalRouter +* `rule_json` (Required)(string) - The rule json of the routing rule.You cannot construct the rule json in terraform as of now.One can construct the rule json in Zenduty's UI.Create an dummy alert rule in Zenduty and copy the rule_json from the UI. +* `actions` (Optional) - The actions to be performed when the rule matches.values are `0` route to integration `1` supress the alert + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the GlobalRouterRule. + + +## Import + +GlobalRouterRule can be imported using the `router_id/rule_id`(ie. UniqueID of the router,rule), e.g. + +```hcl + resource "zenduty_globalrouting_rule" "rule1" { + + } + +``` + +`$ terraform import zenduty_globalrouting_rule.rule1 router_id/rule_id` + +`$ terraform state show zenduty_globalrouting_rule.rule1` + +`copy the output data and paste inside zenduty_globalrouting_rule.rule1 resource block and remove the id attribute` + +`$ terraform plan` to verify the import diff --git a/go.mod b/go.mod index 16b5654..852d001 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module terraform-provider-zenduty go 1.17 require ( - github.com/Zenduty/zenduty-go-sdk v0.1.5 + github.com/Zenduty/zenduty-go-sdk v0.1.7 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 ) diff --git a/go.sum b/go.sum index 953dbdd..4b7ee55 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,7 @@ cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6 cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.61.0 h1:NLQf5e1OMspfNT1RAHOB3ublr1TW3YTXO8OiWwVjK2U= cloud.google.com/go v0.61.0/go.mod h1:XukKJg4Y7QsUu0Hxg3qQKUWR4VuWivmyMK2+rUyxAqw= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= @@ -28,6 +29,7 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -40,30 +42,15 @@ github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/ github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/Zenduty/zenduty-go-sdk v0.1.0 h1:KBAuuNC7AbQzQmpYYxyTL0nWvruZsR7fhe+WJdGZs74= -github.com/Zenduty/zenduty-go-sdk v0.1.0/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= -github.com/Zenduty/zenduty-go-sdk v0.1.1 h1:8j7/qHr5W53s1y2TXprF1ec+Fxsktsqq/J4F6vKQ/A4= -github.com/Zenduty/zenduty-go-sdk v0.1.1/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= -github.com/Zenduty/zenduty-go-sdk v0.1.2 h1:LdD0hUFov59V4JTTaRCSgzQ3jkbtgjppH9w9TIjnzMc= -github.com/Zenduty/zenduty-go-sdk v0.1.2/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= -github.com/Zenduty/zenduty-go-sdk v0.1.3 h1:vuOCKnABg9nsOG8Q/Dndg311zAz6jTEkXDAvlHgbQew= -github.com/Zenduty/zenduty-go-sdk v0.1.3/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= -github.com/Zenduty/zenduty-go-sdk v0.1.4 h1:sFGzfNolu10lu71c6JDWJGrJ8nfBpodv2YpE/8LVN00= -github.com/Zenduty/zenduty-go-sdk v0.1.4/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= -github.com/Zenduty/zenduty-go-sdk v0.1.5 h1:VHBW8vZJnKpMy2yz2Rwvrd/LbX+AxOXTLnDv5h88/5A= -github.com/Zenduty/zenduty-go-sdk v0.1.5/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= -github.com/Zenduty/zenduty-go-sdk v0.2.0 h1:dkLA/7pvwpEoMQCTu6EKjDCol0Ips2nOz6Wo4UBP5Mk= -github.com/Zenduty/zenduty-go-sdk v0.2.0/go.mod h1:AGpdVF88uQvIYkNu5BQcbPkwPZX6egn34tRZd08mizo= +github.com/Zenduty/zenduty-go-sdk v0.1.7 h1:IojKvlQAKI6/5GnicYCFLtz7+J6vnG+PsHlUB5aZAGk= +github.com/Zenduty/zenduty-go-sdk v0.1.7/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= -github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= @@ -76,22 +63,18 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= +github.com/aws/aws-sdk-go v1.25.3 h1:uM16hIw9BotjZKMZlX05SN2EFtaWfi/NonPKIARiBLQ= github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -101,15 +84,10 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= @@ -127,6 +105,7 @@ github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -149,10 +128,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -164,8 +139,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -178,12 +151,10 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -192,22 +163,19 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.16.1 h1:IVQwpTGNRRIHafnTs2dQLIk4ENtneRIEEJWOVDqz99o= github.com/hashicorp/go-hclog v0.16.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.1.0 h1:QsGcniKx5/LuX2eYoeL+Np3UKYPNaN7YKpTh29h8rbw= -github.com/hashicorp/go-hclog v1.1.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= github.com/hashicorp/go-plugin v1.4.1 h1:6UltRQlLN9iZO513VveELp5xyaFxVD2+1OVylE+2E+w= github.com/hashicorp/go-plugin v1.4.1/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= -github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= -github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= +github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= @@ -216,45 +184,31 @@ github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= -github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hc-install v0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk= github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak= github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= -github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= -github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.15.0 h1:cqjh4d8HYNQrDoEmlSGelHmg2DYDh5yayckvJ5bV18E= github.com/hashicorp/terraform-exec v0.15.0/go.mod h1:H4IG8ZxanU+NW0ZpDRNsvh9f0ul7C0nHP+rUR/CHs7I= -github.com/hashicorp/terraform-exec v0.16.0 h1:XUh9pJPcbfZsuhReVvmRarQTaiiCnYogFCCjOvEYuug= -github.com/hashicorp/terraform-exec v0.16.0/go.mod h1:wB5JHmjxZ/YVNZuv9npAXKmz5pGyxy8PSi0GRR0+YjA= github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY= github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= github.com/hashicorp/terraform-plugin-go v0.5.0 h1:+gCDdF0hcYCm0YBTxrP4+K1NGIS5ZKZBKDORBewLJmg= github.com/hashicorp/terraform-plugin-go v0.5.0/go.mod h1:PAVN26PNGpkkmsvva1qfriae5Arky3xl3NfzKa8XFVM= -github.com/hashicorp/terraform-plugin-go v0.7.1 h1:sZxEVwqkGxoYFu+vs9NI3qR1s0JGjG5DwV/n8PehIPQ= -github.com/hashicorp/terraform-plugin-go v0.7.1/go.mod h1:gP1vMbBqUmOWdZKJzNSAVr2G5G5pkCIK0Uoih0tqcbw= github.com/hashicorp/terraform-plugin-log v0.2.0 h1:rjflRuBqCnSk3UHOR25MP1G5BDLKktTA6lNjjcAnBfI= github.com/hashicorp/terraform-plugin-log v0.2.0/go.mod h1:E1kJmapEHzqu1x6M++gjvhzM2yMQNXPVWZRCB8sgYjg= -github.com/hashicorp/terraform-plugin-log v0.2.1 h1:hl0G6ctSx7DRTE62VNsPWrq7d+JWy1kjk9ApOFrCq3I= -github.com/hashicorp/terraform-plugin-log v0.2.1/go.mod h1:RW/n0x4dyITmenuirZ1ViPQGP5JQdPTZ4Wwc0rLKi94= github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 h1:B9AocC+dxrCqcf4vVhztIkSkt3gpRjUkEka8AmZWGlQ= github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1/go.mod h1:FjM9DXWfP0w/AeOtJoSKHBZ01LqmaO6uP4bXhv3fekw= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= -github.com/hashicorp/terraform-registry-address v0.0.0-20220131103327-5c1c5e123275 h1:x/8cnK295F9NK18FXxsJxU1bz2PusWH52DDDsuao+88= -github.com/hashicorp/terraform-registry-address v0.0.0-20220131103327-5c1c5e123275/go.mod h1:bdLC+qQlJIBHKbCMA6GipcuaKjmjcvZlnVdpU583z3Y= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/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/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= @@ -266,12 +220,15 @@ github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -288,17 +245,11 @@ github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlW github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= @@ -314,12 +265,8 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= -github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -328,15 +275,12 @@ github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= -github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= @@ -350,19 +294,16 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= -github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -370,18 +311,15 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.9.1 h1:viqrgQwFl5UpSxc046qblj78wZXVDFnSOufaOTER+cc= github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -394,8 +332,6 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220209155544-dad33157f4bf h1:gdgmgieTI2lLaGI2N+xEiaCMUgo2XFmAS0rlF8HZoso= -golang.org/x/crypto v0.0.0-20220209155544-dad33157f4bf/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -417,6 +353,7 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -425,6 +362,7 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -454,19 +392,15 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -494,7 +428,6 @@ golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -509,19 +442,10 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220207234003-57398862261d h1:Bm7BNOQt2Qv7ZqysjeLjgCBanX+88Z/OtdvsrEv1Djc= -golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -529,9 +453,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -572,12 +493,12 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed h1:+qzWo37K31KxduIYaBeMqJ8MUOyTayOQKpH9aDPLMSY= golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -592,6 +513,7 @@ google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/ google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0 h1:BaiDisFir8O4IJxvAabCGGkQ6yCJegNQqSVoYUNAnbk= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -600,8 +522,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -626,14 +546,11 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200711021454-869866162049 h1:YFTFpQhgvrLrmxtiIncJxFXeCyq84ixuKWVCaCAi9Oc= google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20220208230804-65c12eb4c068 h1:pwzFiZfBTH/GjBWz1BcDwMBaHBo8mZvpLa7eBKJpFAk= -google.golang.org/genproto v0.0.0-20220208230804-65c12eb4c068/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -648,10 +565,6 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.44.0 h1:weqSxi/TMs1SqFRMHCtBgXRs8k3X39QIDEZ0pRcttUg= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -663,10 +576,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -678,7 +587,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/main.go b/main.go index c746aff..ab138fd 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "terraform-provider-zenduty/zenduty" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" ) diff --git a/zenduty/config.go b/zenduty/config.go index 789c5b9..cd75ece 100644 --- a/zenduty/config.go +++ b/zenduty/config.go @@ -13,17 +13,14 @@ type Config struct { BaseURL string } -const invalidCreds = ` -No valid credentials found for zenduty provider. -` +const invalidCreds = "no valid credentials found for zenduty provider" func (c *Config) Client() (*client.Client, error) { if c.Token == "" { return nil, fmt.Errorf(invalidCreds) } - var httpClient *http.Client - httpClient = http.DefaultClient + httpClient := http.DefaultClient config := &client.Config{ BaseURL: c.BaseURL, diff --git a/zenduty/data_source_alertrules.go b/zenduty/data_source_alertrules.go index b972e88..10053c9 100644 --- a/zenduty/data_source_alertrules.go +++ b/zenduty/data_source_alertrules.go @@ -114,14 +114,14 @@ func dataSourceAlertRules() *schema.Resource { func dataSourceAlertRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) - service_id := d.Get("service_id").(string) - integration_id := d.Get("integration_id").(string) - alert_rule_id := d.Get("alert_rule_id").(string) + teamID := d.Get("team_id").(string) + serviceID := d.Get("service_id").(string) + integrationID := d.Get("integration_id").(string) + alertRuleID := d.Get("alert_rule_id").(string) var diags diag.Diagnostics - if alert_rule_id != "" { - rule, err := apiclient.AlertRules.GetAlertRule(team_id, service_id, integration_id, alert_rule_id) + if alertRuleID != "" { + rule, err := apiclient.AlertRules.GetAlertRule(teamID, serviceID, integrationID, alertRuleID) if err != nil { return diag.FromErr(err) } @@ -130,21 +130,21 @@ func dataSourceAlertRulesRead(ctx context.Context, d *schema.ResourceData, m int item := make(map[string]interface{}) item["position"] = rule.Position - item["rule_json"] = rule.RuleJson + item["rule_json"] = rule.RuleJSON item["rule_type"] = rule.RuleType item["stop"] = rule.Stop - item["unique_id"] = rule.Unique_Id + item["unique_id"] = rule.UniqueID item["description"] = rule.Description actions := make([]map[string]interface{}, len(rule.Actions)) for j, action := range rule.Actions { rule := make(map[string]interface{}) - rule["unique_id"] = action.UniqueId + rule["unique_id"] = action.UniqueID rule["action_type"] = action.ActionType rule["key"] = action.Key rule["value"] = action.Value rule["escalation_policy"] = action.EscalationPolicy - rule["assign_to"] = action.Assigned_To + rule["assign_to"] = action.AssignedTo rule["schedule"] = action.Schedule rule["sla"] = action.SLA rule["team_priority"] = action.TeamPriority @@ -161,7 +161,7 @@ func dataSourceAlertRulesRead(ctx context.Context, d *schema.ResourceData, m int return diags } else { - rules, err := apiclient.AlertRules.GetAlertRules(team_id, service_id, integration_id) + rules, err := apiclient.AlertRules.GetAlertRules(teamID, serviceID, integrationID) if err != nil { return diag.FromErr(err) } @@ -170,21 +170,21 @@ func dataSourceAlertRulesRead(ctx context.Context, d *schema.ResourceData, m int item := make(map[string]interface{}) item["position"] = rule.Position - item["rule_json"] = rule.RuleJson + item["rule_json"] = rule.RuleJSON item["rule_type"] = rule.RuleType item["stop"] = rule.Stop - item["unique_id"] = rule.Unique_Id + item["unique_id"] = rule.UniqueID item["description"] = rule.Description actions := make([]map[string]interface{}, len(rule.Actions)) for j, action := range rule.Actions { rule := make(map[string]interface{}) - rule["unique_id"] = action.UniqueId + rule["unique_id"] = action.UniqueID rule["action_type"] = action.ActionType rule["key"] = action.Key rule["value"] = action.Value rule["escalation_policy"] = action.EscalationPolicy - rule["assign_to"] = action.Assigned_To + rule["assign_to"] = action.AssignedTo rule["schedule"] = action.Schedule rule["sla"] = action.SLA rule["team_priority"] = action.TeamPriority diff --git a/zenduty/data_source_contactmethod.go b/zenduty/data_source_contactmethod.go index a22be57..a980ebd 100644 --- a/zenduty/data_source_contactmethod.go +++ b/zenduty/data_source_contactmethod.go @@ -43,7 +43,7 @@ func dataSourceNotificationRulesRead(ctx context.Context, d *schema.ResourceData return diag.Errorf("username is required") } - contact_type := d.Get("contact_type").(int) + contactType := d.Get("contact_type").(int) value := d.Get("value").(string) var diags diag.Diagnostics @@ -53,27 +53,27 @@ func dataSourceNotificationRulesRead(ctx context.Context, d *schema.ResourceData return diag.Errorf("Error getting contactmethod: %s", err) } if len(contactmethod) == 0 { - return diag.Errorf("No contactmethod found for contact_type %s", strconv.Itoa(contact_type)) + return diag.Errorf("No contactmethod found for contact_type %s", strconv.Itoa(contactType)) } if value != "" { for _, contactmethod := range contactmethod { - if contactmethod.Value == value && contactmethod.ContactType == contact_type { + if contactmethod.Value == value && contactmethod.ContactType == contactType { d.SetId(contactmethod.UniqueID) d.Set("value", contactmethod.Value) d.Set("name", contactmethod.Name) return diags } } - return diag.Errorf("No contactmethod found for contact_type %s and value %s", contact_type, value) + return diag.Errorf("No contactmethod found for contact_type %s and value %s", strconv.Itoa(contactType), value) } for _, contactmethod := range contactmethod { - if contactmethod.ContactType == contact_type { + if contactmethod.ContactType == contactType { d.SetId(contactmethod.UniqueID) d.Set("value", contactmethod.Value) d.Set("name", contactmethod.Name) return diags } } - return diag.Errorf("No contactmethod found for contact_type %s", contact_type) + return diag.Errorf("No contactmethod found for contact_type %s", strconv.Itoa(contactType)) } diff --git a/zenduty/data_source_esp.go b/zenduty/data_source_esp.go index 6a31003..4bf8de4 100644 --- a/zenduty/data_source_esp.go +++ b/zenduty/data_source_esp.go @@ -104,18 +104,18 @@ func dataSourceEsp() *schema.Resource { func dataSourceEspsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) - esp_id := d.Get("esp_id").(string) + teamID := d.Get("team_id").(string) + espID := d.Get("esp_id").(string) var diags diag.Diagnostics - if esp_id != "" { - esp, err := apiclient.Esp.GetEscalationPolicyById(team_id, esp_id) + if espID != "" { + esp, err := apiclient.Esp.GetEscalationPolicyByID(teamID, espID) if err != nil { return diag.FromErr(err) } items := make([]map[string]interface{}, 1) item := make(map[string]interface{}) - item["unique_id"] = esp.Unique_Id + item["unique_id"] = esp.UniqueID item["name"] = esp.Name item["summary"] = esp.Summary item["description"] = esp.Description @@ -125,14 +125,14 @@ func dataSourceEspsRead(ctx context.Context, d *schema.ResourceData, m interface rules[j] = map[string]interface{}{ "delay": rule.Delay, "position": rule.Position, - "unique_id": rule.Unique_Id, + "unique_id": rule.UniqueID, } if rule.Targets != nil { targets := make([]map[string]interface{}, len(rule.Targets)) for k, target := range rule.Targets { targets[k] = map[string]interface{}{ - "target_type": target.Target_type, - "target_id": target.Target_id, + "target_type": target.TargetType, + "target_id": target.TargetID, } } rules[j]["targets"] = targets @@ -151,14 +151,14 @@ func dataSourceEspsRead(ctx context.Context, d *schema.ResourceData, m interface return diags } else { - esps, err := apiclient.Esp.GetEscalationPolicy(team_id) + esps, err := apiclient.Esp.GetEscalationPolicy(teamID) if err != nil { return diag.FromErr(err) } items := make([]map[string]interface{}, len(esps)) for i, esp := range esps { item := make(map[string]interface{}) - item["unique_id"] = esp.Unique_Id + item["unique_id"] = esp.UniqueID item["name"] = esp.Name item["summary"] = esp.Summary item["description"] = esp.Description @@ -168,14 +168,14 @@ func dataSourceEspsRead(ctx context.Context, d *schema.ResourceData, m interface rules[j] = map[string]interface{}{ "delay": rule.Delay, "position": rule.Position, - "unique_id": rule.Unique_Id, + "unique_id": rule.UniqueID, } if rule.Targets != nil { targets := make([]map[string]interface{}, len(rule.Targets)) for k, target := range rule.Targets { targets[k] = map[string]interface{}{ - "target_type": target.Target_type, - "target_id": target.Target_id, + "target_type": target.TargetType, + "target_id": target.TargetID, } } rules[j]["targets"] = targets diff --git a/zenduty/data_source_incidents.go b/zenduty/data_source_incidents.go index b19a216..eea03de 100644 --- a/zenduty/data_source_incidents.go +++ b/zenduty/data_source_incidents.go @@ -210,31 +210,31 @@ func dataSourceIncidentRead(ctx context.Context, d *schema.ResourceData, m inter item := make(map[string]interface{}) item["summary"] = result.Summary - item["incident_number"] = result.Incident_Number - item["creation_date"] = result.Creation_Date + item["incident_number"] = result.IncidentNumber + item["creation_date"] = result.CreationDate item["status"] = result.Status - item["unique_id"] = result.Unique_Id - item["service_object_name"] = result.Service_Object.Name - item["service_object_unique_id"] = result.Service_Object.Unique_Id - item["service_object_creation_date"] = result.Service_Object.Creation_Date - item["service_object_status"] = result.Service_Object.Status - item["service_object_team"] = result.Service_Object.Team - item["service_object_summary"] = result.Service_Object.Summary - item["service_object_description"] = result.Service_Object.Description - item["service_object_acknowledgement_timeout"] = result.Service_Object.Acknowledgment_Timeout - item["service_object_auto_resolve_timeout"] = result.Service_Object.Auto_Resolve_Timeouts - item["service_object_created_by"] = result.Service_Object.Created_By - item["service_object_team_priority"] = result.Service_Object.Team_Priority - item["service_object_task_template"] = result.Service_Object.Task_Template - item["service_object_escalation_policy"] = result.Service_Object.EscalationPolicy - item["service_object_team"] = result.Service_Object.Team - item["service_object_sla"] = result.Service_Object.Sla - item["service_object_collation_time"] = result.Service_Object.Collation_Time - item["service_object_collation"] = result.Service_Object.Collation - item["team_priority"] = result.Team_Priority - item["team_priority_object"] = result.Team_Priority_Object + item["unique_id"] = result.UniqueID + item["service_object_name"] = result.ServiceObject.Name + item["service_object_unique_id"] = result.ServiceObject.UniqueID + item["service_object_creation_date"] = result.ServiceObject.CreationDate + item["service_object_status"] = result.ServiceObject.Status + item["service_object_team"] = result.ServiceObject.Team + item["service_object_summary"] = result.ServiceObject.Summary + item["service_object_description"] = result.ServiceObject.Description + item["service_object_acknowledgement_timeout"] = result.ServiceObject.AcknowledgmentTimeout + item["service_object_auto_resolve_timeout"] = result.ServiceObject.AutoResolveTimeouts + item["service_object_created_by"] = result.ServiceObject.CreatedBy + item["service_object_team_priority"] = result.ServiceObject.TeamPriority + item["service_object_task_template"] = result.ServiceObject.TaskTemplate + item["service_object_escalation_policy"] = result.ServiceObject.EscalationPolicy + item["service_object_team"] = result.ServiceObject.Team + item["service_object_sla"] = result.ServiceObject.SLA + item["service_object_collation_time"] = result.ServiceObject.CollationTime + item["service_object_collation"] = result.ServiceObject.Collation + item["team_priority"] = result.TeamPriority + item["team_priority_object"] = result.TeamPriorityObject item["title"] = result.Title - item["incident_key"] = result.Incident_Key + item["incident_key"] = result.IncidentKey item["service"] = result.Service item["urgency"] = result.Urgency items[i] = item diff --git a/zenduty/data_source_integrations.go b/zenduty/data_source_integrations.go index 2da8c7c..f5ed778 100644 --- a/zenduty/data_source_integrations.go +++ b/zenduty/data_source_integrations.go @@ -104,28 +104,28 @@ func dataSourceIncidentReads(ctx context.Context, d *schema.ResourceData, m inte items[0] = map[string]interface{}{ "name": integration.Name, - "creation_date": integration.Creation_Date, + "creation_date": integration.CreationDate, "summary": integration.Summary, - "unique_id": integration.Unique_Id, + "unique_id": integration.UniqueID, "service": integration.Service, "application": integration.Application, "application_reference": map[string]interface{}{ - "name": integration.Application_Reference.Name, - "icon_url": integration.Application_Reference.Icon_Url, - "summary": integration.Application_Reference.Summary, - "description": integration.Application_Reference.Description, - "unique_id": integration.Application_Reference.Unique_Id, - "setup_instructions": integration.Application_Reference.Setup_Instructions, - "extension": integration.Application_Reference.Extension, - "categories": integration.Application_Reference.Categories, - "documentation_link": integration.Application_Reference.Documentation_Link, + "name": integration.ApplicationReference.Name, + "icon_url": integration.ApplicationReference.IconURL, + "summary": integration.ApplicationReference.Summary, + "description": integration.ApplicationReference.Description, + "unique_id": integration.ApplicationReference.UniqueID, + "setup_instructions": integration.ApplicationReference.SetupInstructions, + "extension": integration.ApplicationReference.Extension, + "categories": integration.ApplicationReference.Categories, + "documentation_link": integration.ApplicationReference.DocumentationLink, }, - "integration_key": integration.Integration_key, - "webhook_url": integration.Webhook_url, - "created_by": integration.Created_By, - "create_incidents_for": integration.Create_Incident_For, - "integration_type": integration.Integration_Type, - "default_urgency": integration.Default_Urgency, + "integration_key": integration.IntegrationKey, + "webhook_url": integration.WebhookURL, + "created_by": integration.CreatedBy, + "create_incidents_for": integration.CreateIncidentFor, + "integration_type": integration.IntegrationType, + "default_urgency": integration.DefaultUrgency, } if err := d.Set("integrations", items); err != nil { @@ -145,28 +145,28 @@ func dataSourceIncidentReads(ctx context.Context, d *schema.ResourceData, m inte items[i] = map[string]interface{}{ "name": integration.Name, - "creation_date": integration.Creation_Date, + "creation_date": integration.CreationDate, "summary": integration.Summary, - "unique_id": integration.Unique_Id, + "unique_id": integration.UniqueID, "service": integration.Service, "application": integration.Application, "application_reference": map[string]interface{}{ - "name": integration.Application_Reference.Name, - "icon_url": integration.Application_Reference.Icon_Url, - "summary": integration.Application_Reference.Summary, - "description": integration.Application_Reference.Description, - "unique_id": integration.Application_Reference.Unique_Id, - "setup_instructions": integration.Application_Reference.Setup_Instructions, - "extension": integration.Application_Reference.Extension, - "categories": integration.Application_Reference.Categories, - "documentation_link": integration.Application_Reference.Documentation_Link, + "name": integration.ApplicationReference.Name, + "icon_url": integration.ApplicationReference.IconURL, + "summary": integration.ApplicationReference.Summary, + "description": integration.ApplicationReference.Description, + "unique_id": integration.ApplicationReference.UniqueID, + "setup_instructions": integration.ApplicationReference.SetupInstructions, + "extension": integration.ApplicationReference.Extension, + "categories": integration.ApplicationReference.Categories, + "documentation_link": integration.ApplicationReference.DocumentationLink, }, - "integration_key": integration.Integration_key, - "webhook_url": integration.Webhook_url, - "created_by": integration.Created_By, - "create_incidents_for": integration.Create_Incident_For, - "integration_type": integration.Integration_Type, - "default_urgency": integration.Default_Urgency, + "integration_key": integration.IntegrationKey, + "webhook_url": integration.WebhookURL, + "created_by": integration.CreatedBy, + "create_incidents_for": integration.CreateIncidentFor, + "integration_type": integration.IntegrationType, + "default_urgency": integration.DefaultUrgency, } } diff --git a/zenduty/data_source_maintenance.go b/zenduty/data_source_maintenance.go index cfb729a..afac589 100644 --- a/zenduty/data_source_maintenance.go +++ b/zenduty/data_source_maintenance.go @@ -80,11 +80,11 @@ func dataSourceMaintenanceWindow() *schema.Resource { func dataSourceManintenanceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) var diags diag.Diagnostics - maintenances, err := apiclient.MaintenanceWindow.GetMaintenanceWindows(team_id) + maintenances, err := apiclient.MaintenanceWindow.GetMaintenanceWindows(teamID) if err != nil { return diag.FromErr(err) } @@ -94,7 +94,7 @@ func dataSourceManintenanceRead(ctx context.Context, d *schema.ResourceData, m i item := make(map[string]interface{}) item["unique_id"] = maintenance.UniqueID item["name"] = maintenance.Name - item["creation_date"] = maintenance.Creation_Date + item["creation_date"] = maintenance.CreationDate item["start_time"] = maintenance.StartTime item["end_time"] = maintenance.EndTime item["repeat_interval"] = maintenance.RepeatInterval diff --git a/zenduty/data_source_priority.go b/zenduty/data_source_priority.go index 247945d..269dcc6 100644 --- a/zenduty/data_source_priority.go +++ b/zenduty/data_source_priority.go @@ -58,9 +58,9 @@ func dataSourcePriorityRead(ctx context.Context, d *schema.ResourceData, m inter var diags diag.Diagnostics - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) - priorities, err := apiclient.Priority.GetPriority(team_id) + priorities, err := apiclient.Priority.GetPriority(teamID) if err != nil { return diag.FromErr(err) } @@ -69,9 +69,9 @@ func dataSourcePriorityRead(ctx context.Context, d *schema.ResourceData, m inter for i, priority := range priorities { item := make(map[string]interface{}) item["team"] = priority.Team - item["unique_id"] = priority.Unique_Id + item["unique_id"] = priority.UniqueID item["name"] = priority.Name - item["creation_date"] = priority.Creation_Date + item["creation_date"] = priority.CreationDate item["description"] = priority.Description items[i] = item } @@ -79,7 +79,7 @@ func dataSourcePriorityRead(ctx context.Context, d *schema.ResourceData, m inter if err := d.Set("priorities", items); err != nil { return diag.FromErr(err) } - d.SetId(team_id) + d.SetId(teamID) return diags diff --git a/zenduty/data_source_roles.go b/zenduty/data_source_roles.go index 70d009c..0bbf62c 100644 --- a/zenduty/data_source_roles.go +++ b/zenduty/data_source_roles.go @@ -57,9 +57,9 @@ func dataSourceOrderRead(ctx context.Context, d *schema.ResourceData, m interfac var diags diag.Diagnostics - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) - roles, err := apiclient.Roles.GetRoles(team_id) + roles, err := apiclient.Roles.GetRoles(teamID) if err != nil { return diag.FromErr(err) } @@ -68,9 +68,9 @@ func dataSourceOrderRead(ctx context.Context, d *schema.ResourceData, m interfac for i, role := range roles { item := make(map[string]interface{}) item["team"] = role.Team - item["unique_id"] = role.Unique_Id + item["unique_id"] = role.UniqueID item["title"] = role.Title - item["creation_date"] = role.Creation_Date + item["creation_date"] = role.CreationDate item["description"] = role.Description item["rank"] = role.Rank items[i] = item @@ -79,7 +79,7 @@ func dataSourceOrderRead(ctx context.Context, d *schema.ResourceData, m interfac if err := d.Set("roles", items); err != nil { return diag.FromErr(err) } - d.SetId(team_id) + d.SetId(teamID) return diags diff --git a/zenduty/data_source_schedules.go b/zenduty/data_source_schedules.go index d355b1f..50bf181 100644 --- a/zenduty/data_source_schedules.go +++ b/zenduty/data_source_schedules.go @@ -173,22 +173,22 @@ func dataSourceSchedules() *schema.Resource { func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) - schedule_id := d.Get("schedule_id").(string) + teamID := d.Get("team_id").(string) + scheduleID := d.Get("schedule_id").(string) var diags diag.Diagnostics - if schedule_id != "" { - schedule, err := apiclient.Schedules.GetScheduleByID(team_id, schedule_id) + if scheduleID != "" { + schedule, err := apiclient.Schedules.GetScheduleByID(teamID, scheduleID) if err != nil { return diag.FromErr(err) } items := make([]map[string]interface{}, 1) item := make(map[string]interface{}) - item["unique_id"] = schedule.Unique_Id + item["unique_id"] = schedule.UniqueID item["name"] = schedule.Name item["summary"] = schedule.Summary item["description"] = schedule.Description - item["time_zone"] = schedule.Time_zone + item["time_zone"] = schedule.TimeZone item["team"] = schedule.Team layers := make([]map[string]interface{}, len(schedule.Layers)) for j, layer := range schedule.Layers { @@ -197,7 +197,7 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte "name": layer.Name, "rotation_start_time": layer.RotationStartTime, "rotation_end_time": layer.RotationEndTime, - "unique_id": layer.UniqueId, + "unique_id": layer.UniqueID, "last_edited": layer.LastEdited, "restriction_type": layer.RestrictionType, "is_active": layer.IsActive, @@ -209,7 +209,7 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte "duration": restriction.Duration, "start_day_of_week": restriction.StartDayOfWeek, "start_time_of_day": restriction.StartTimeOfDay, - "unique_id": restriction.Unique_Id, + "unique_id": restriction.UniqueID, } } layers[j]["restrictions"] = restrictions @@ -234,7 +234,7 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte "user": override.User, "start_time": override.StartTime, "end_time": override.EndTime, - "unique_id": override.Unique_Id, + "unique_id": override.UniqueID, } } item["overrides"] = overrides @@ -249,18 +249,18 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte return diags } else { - schedules, err := apiclient.Schedules.GetSchedules(team_id) + schedules, err := apiclient.Schedules.GetSchedules(teamID) if err != nil { return diag.FromErr(err) } items := make([]map[string]interface{}, len(schedules)) for i, schedule := range schedules { item := make(map[string]interface{}) - item["unique_id"] = schedule.Unique_Id + item["unique_id"] = schedule.UniqueID item["name"] = schedule.Name item["summary"] = schedule.Summary item["description"] = schedule.Description - item["time_zone"] = schedule.Time_zone + item["time_zone"] = schedule.TimeZone item["team"] = schedule.Team layers := make([]map[string]interface{}, len(schedule.Layers)) for j, layer := range schedule.Layers { @@ -269,7 +269,7 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte "name": layer.Name, "rotation_start_time": layer.RotationStartTime, "rotation_end_time": layer.RotationEndTime, - "unique_id": layer.UniqueId, + "unique_id": layer.UniqueID, "last_edited": layer.LastEdited, "restriction_type": layer.RestrictionType, "is_active": layer.IsActive, @@ -281,7 +281,7 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte "duration": restriction.Duration, "start_day_of_week": restriction.StartDayOfWeek, "start_time_of_day": restriction.StartTimeOfDay, - "unique_id": restriction.Unique_Id, + "unique_id": restriction.UniqueID, } } layers[j]["restrictions"] = restrictions @@ -306,7 +306,7 @@ func dataSourceScheduleReads(ctx context.Context, d *schema.ResourceData, m inte "user": override.User, "start_time": override.StartTime, "end_time": override.EndTime, - "unique_id": override.Unique_Id, + "unique_id": override.UniqueID, } } item["overrides"] = overrides diff --git a/zenduty/data_source_services.go b/zenduty/data_source_services.go index 616e6c8..5548837 100644 --- a/zenduty/data_source_services.go +++ b/zenduty/data_source_services.go @@ -104,14 +104,14 @@ func dataSourceServices() *schema.Resource { func dataSourceServicesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Get("service_id").(string) - if team_id == "" { + if teamID == "" { return diag.Errorf("team_id is required") } var diags diag.Diagnostics if id != "" { - service, err := apiclient.Services.GetServicesById(team_id, id) + service, err := apiclient.Services.GetServicesByID(teamID, id) if err != nil { return diag.FromErr(err) } @@ -119,22 +119,22 @@ func dataSourceServicesRead(ctx context.Context, d *schema.ResourceData, m inter items[0] = map[string]interface{}{ "name": service.Name, - "escalation_policy": service.Escalation_Policy, + "escalation_policy": service.EscalationPolicy, "team": service.Team, "description": service.Description, "summary": service.Summary, "collation": service.Collation, - "collation_time": service.Collation_Time, - "sla": service.Sla, - "task_template": service.Task_Template, - "team_priority": service.Team_Priority, - "creation_date": service.Creation_Date, - "unique_id": service.Unique_Id, - "auto_resolve_timeout": service.Auto_Resolve_Timeout, - "created_by": service.Created_By, - "acknowledgement_timeout": service.Acknowledgment_Timeout, + "collation_time": service.CollationTime, + "sla": service.SLA, + "task_template": service.TaskTemplate, + "team_priority": service.TeamPriority, + "creation_date": service.CreationDate, + "unique_id": service.UniqueID, + "auto_resolve_timeout": service.AutoResolveTimeout, + "created_by": service.CreatedBy, + "acknowledgement_timeout": service.AcknowledgmentTimeout, "status": service.Status, - "under_maintenance": service.Under_Maintenance, + "under_maintenance": service.UnderMaintenance, } if err := d.Set("services", items); err != nil { return diag.FromErr(err) @@ -144,7 +144,7 @@ func dataSourceServicesRead(ctx context.Context, d *schema.ResourceData, m inter } else { // id := d.Get("id").(string) - services, err := apiclient.Services.GetServices(team_id) + services, err := apiclient.Services.GetServices(teamID) if err != nil { return diag.FromErr(err) } @@ -152,22 +152,22 @@ func dataSourceServicesRead(ctx context.Context, d *schema.ResourceData, m inter for i, service := range services { items[i] = map[string]interface{}{ "name": service.Name, - "escalation_policy": service.Escalation_Policy, + "escalation_policy": service.EscalationPolicy, "team": service.Team, "description": service.Description, "summary": service.Summary, "collation": service.Collation, - "collation_time": service.Collation_Time, - "sla": service.Sla, - "task_template": service.Task_Template, - "team_priority": service.Team_Priority, - "creation_date": service.Creation_Date, - "unique_id": service.Unique_Id, - "auto_resolve_timeout": service.Auto_Resolve_Timeout, - "created_by": service.Created_By, - "acknowledgement_timeout": service.Acknowledgment_Timeout, + "collation_time": service.CollationTime, + "sla": service.SLA, + "task_template": service.TaskTemplate, + "team_priority": service.TeamPriority, + "creation_date": service.CreationDate, + "unique_id": service.UniqueID, + "auto_resolve_timeout": service.AutoResolveTimeout, + "created_by": service.CreatedBy, + "acknowledgement_timeout": service.AcknowledgmentTimeout, "status": service.Status, - "under_maintenance": service.Under_Maintenance, + "under_maintenance": service.UnderMaintenance, } } if err := d.Set("services", items); err != nil { diff --git a/zenduty/data_source_tags.go b/zenduty/data_source_tags.go index bf6b13b..a75570f 100644 --- a/zenduty/data_source_tags.go +++ b/zenduty/data_source_tags.go @@ -54,9 +54,9 @@ func dataSourceTagsRead(ctx context.Context, d *schema.ResourceData, m interface var diags diag.Diagnostics - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) - tags, err := apiclient.Tags.GetTags(team_id) + tags, err := apiclient.Tags.GetTags(teamID) if err != nil { return diag.FromErr(err) } @@ -65,16 +65,16 @@ func dataSourceTagsRead(ctx context.Context, d *schema.ResourceData, m interface for i, tag := range tags { item := make(map[string]interface{}) item["team"] = tag.Team - item["unique_id"] = tag.Unique_Id + item["unique_id"] = tag.UniqueID item["name"] = tag.Name - item["creation_date"] = tag.Creation_Date + item["creation_date"] = tag.CreationDate items[i] = item } if err := d.Set("tags", items); err != nil { return diag.FromErr(err) } - d.SetId(team_id) + d.SetId(teamID) return diags diff --git a/zenduty/data_source_teams.go b/zenduty/data_source_teams.go index 8d1a1bc..b6eb6e1 100644 --- a/zenduty/data_source_teams.go +++ b/zenduty/data_source_teams.go @@ -113,27 +113,27 @@ func dataSourceTeams() *schema.Resource { func dataSourceTeamReads(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) - if team_id != "" { + teamID := d.Get("team_id").(string) + if teamID != "" { var diags diag.Diagnostics - team, err := apiclient.Teams.GetTeamById(team_id) + team, err := apiclient.Teams.GetTeamByID(teamID) if err != nil { return diag.FromErr(err) } items := make([]map[string]interface{}, 1) item := make(map[string]interface{}) - item["unique_id"] = team.Unique_Id + item["unique_id"] = team.UniqueID item["name"] = team.Name item["owner"] = team.Owner item["account"] = team.Account - item["creation_date"] = team.Creation_Date + item["creation_date"] = team.CreationDate roles := make([]map[string]interface{}, len(team.Roles)) for j, role := range team.Roles { roles[j] = map[string]interface{}{ - "unique_id": role.Unique_Id, + "unique_id": role.UniqueID, "title": role.Title, "description": role.Description, - "creation_date": role.Creation_Date, + "creation_date": role.CreationDate, "rank": role.Rank, } } @@ -143,14 +143,14 @@ func dataSourceTeamReads(ctx context.Context, d *schema.ResourceData, m interfac members := make([]map[string]interface{}, len(team.Members)) for j, member := range team.Members { members[j] = map[string]interface{}{ - "unique_id": member.Unique_Id, + "unique_id": member.UniqueID, "team": member.Team, - "joining_date": member.Joining_Date, + "joining_date": member.JoiningDate, "role": member.Role, "user": map[string]interface{}{ "username": member.User.Username, - "first_name": member.User.First_Name, - "last_name": member.User.Last_Name, + "first_name": member.User.FirstName, + "last_name": member.User.LastName, "email": member.User.Email, }, } @@ -176,16 +176,16 @@ func dataSourceTeamReads(ctx context.Context, d *schema.ResourceData, m interfac items := make([]map[string]interface{}, len(teams)) for i, team := range teams { item := make(map[string]interface{}) - item["unique_id"] = team.Unique_Id + item["unique_id"] = team.UniqueID item["name"] = team.Name item["owner"] = team.Owner roles := make([]map[string]interface{}, len(team.Roles)) for j, role := range team.Roles { roles[j] = map[string]interface{}{ - "unique_id": role.Unique_Id, + "unique_id": role.UniqueID, "title": role.Title, "description": role.Description, - "creation_date": role.Creation_Date, + "creation_date": role.CreationDate, "rank": role.Rank, } } @@ -194,14 +194,14 @@ func dataSourceTeamReads(ctx context.Context, d *schema.ResourceData, m interfac members := make([]map[string]interface{}, len(team.Members)) for j, member := range team.Members { members[j] = map[string]interface{}{ - "unique_id": member.Unique_Id, + "unique_id": member.UniqueID, "team": member.Team, - "joining_date": member.Joining_Date, + "joining_date": member.JoiningDate, "role": member.Role, "user": map[string]interface{}{ "username": member.User.Username, - "first_name": member.User.First_Name, - "last_name": member.User.Last_Name, + "first_name": member.User.FirstName, + "last_name": member.User.LastName, "email": member.User.Email, }, } diff --git a/zenduty/data_source_user.go b/zenduty/data_source_user.go index c9f1186..a001ac7 100644 --- a/zenduty/data_source_user.go +++ b/zenduty/data_source_user.go @@ -67,10 +67,10 @@ func dataSourceUserReads(ctx context.Context, d *schema.ResourceData, m interfac items := make([]map[string]interface{}, len(users)) for i, user := range users { item := make(map[string]interface{}) - item["unique_id"] = user.Unique_Id + item["unique_id"] = user.UniqueID item["email"] = user.User.Email - item["first_name"] = user.User.First_Name - item["last_name"] = user.User.Last_Name + item["first_name"] = user.User.FirstName + item["last_name"] = user.User.LastName item["username"] = user.User.Username items[i] = item diff --git a/zenduty/helpers.go b/zenduty/helpers.go index 7810a55..9969638 100644 --- a/zenduty/helpers.go +++ b/zenduty/helpers.go @@ -62,8 +62,8 @@ func ValidateUUID() schema.SchemaValidateDiagFunc { } func isEmailValid(e string) bool { - emailRegex := regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`) - return emailRegex.MatchString(e) + emailRegex := regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`) + return emailRegex.MatchString(e) } func ValidateEmail() schema.SchemaValidateDiagFunc { @@ -105,7 +105,7 @@ func ValidateRequired() schema.SchemaValidateDiagFunc { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, Summary: "This field is required", - Detail: fmt.Sprintf("This field cannot be empty"), + Detail: "This field cannot be empty", }) } @@ -113,4 +113,3 @@ func ValidateRequired() schema.SchemaValidateDiagFunc { } } - diff --git a/zenduty/provider.go b/zenduty/provider.go index 8a21345..f8812f3 100644 --- a/zenduty/provider.go +++ b/zenduty/provider.go @@ -23,21 +23,25 @@ func Provider() *schema.Provider { }, }, ResourcesMap: map[string]*schema.Resource{ - "zenduty_teams": resourceTeam(), - "zenduty_roles": resourceRoles(), - "zenduty_services": resourceServices(), - "zenduty_integrations": resourceIntegrations(), - "zenduty_schedules": resourceSchedules(), - "zenduty_esp": resourceEsp(), - "zenduty_incidents": resourceIncidents(), - "zenduty_invite": resourceInvite(), - "zenduty_member": resourceMembers(), - "zenduty_alertrules": resourceAlertRules(), - "zenduty_tags": resourceTags(), - "zenduty_priorities": resourcePriority(), - "zenduty_maintenance_window": resourceMaintenanceWindow(), - "zenduty_notification_rules": resourceNotificationRules(), - "zenduty_user": resourceUser(), + "zenduty_teams": resourceTeam(), + "zenduty_roles": resourceRoles(), + "zenduty_services": resourceServices(), + "zenduty_integrations": resourceIntegrations(), + "zenduty_schedules": resourceSchedules(), + "zenduty_esp": resourceEsp(), + "zenduty_incidents": resourceIncidents(), + "zenduty_invite": resourceInvite(), + "zenduty_member": resourceMembers(), + "zenduty_alertrules": resourceAlertRules(), + "zenduty_tags": resourceTags(), + "zenduty_priorities": resourcePriority(), + "zenduty_maintenance_window": resourceMaintenanceWindow(), + "zenduty_notification_rules": resourceNotificationRules(), + "zenduty_user": resourceUser(), + "zenduty_account_role": resourceAccountRole(), + "zenduty_assign_account_role": resourceAssignAccountRole(), + "zenduty_globalrouter": resourceGlobalRouter(), + "zenduty_globalrouting_rule": resourceGlobalRoutingRules(), }, DataSourcesMap: map[string]*schema.Resource{ @@ -61,12 +65,12 @@ func Provider() *schema.Provider { func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { token := d.Get("token").(string) - baseUrl := d.Get("base_url").(string) + baseURL := d.Get("base_url").(string) var diags diag.Diagnostics if token != "" { client := Config{ Token: token, - BaseURL: baseUrl, + BaseURL: baseURL, } return &client, diags } diff --git a/zenduty/resource_account_role.go b/zenduty/resource_account_role.go new file mode 100644 index 0000000..54b6954 --- /dev/null +++ b/zenduty/resource_account_role.go @@ -0,0 +1,154 @@ +package zenduty + +import ( + "context" + "errors" + "fmt" + + "github.com/Zenduty/zenduty-go-sdk/client" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceAccountRole() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceCreateAccountRole, + ReadContext: resourceReadAccountRole, + UpdateContext: resourceUpdateAccountRole, + DeleteContext: resourceDeleteAccountRole, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Required: true, + }, + "permissions": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + } +} + +func validateAccountRoles(Ctx context.Context, d *schema.ResourceData, m interface{}) (*client.AccountRole, diag.Diagnostics) { + permissionsList := []string{ + "analytics_read", + "escalation_policy_read", + "escalation_policy_write", + "incident_read", + "incident_write", + "incident_role_read", + "incident_role_write", + "integration_read", + "integration_write", + "maintenance_read", + "maintenance_write", + "member_read", + "member_write", + "postmortem_read", + "postmortem_write", + "priority_read", + "priority_write", + "schedule_read", + "schedule_write", + "service_read", + "service_write", + "sla_read", + "sla_write", + "stakeholder_template_read", + "stakeholder_template_write", + "tag_read", + "tag_write", + "task_template_read", + "task_template_write", + "team_read", + } + + name := d.Get("name").(string) + description := d.Get("description").(string) + permissions := d.Get("permissions").([]interface{}) + newRole := &client.AccountRole{} + + newRole.Name = name + newRole.Description = description + for _, permission := range permissions { + if permission.(string) == "" { + return nil, diag.FromErr(errors.New("permission must not be empty")) + } + if !checkList(permission.(string), permissionsList) { + return nil, diag.FromErr(fmt.Errorf("invalid permission received %s", permission.(string))) + } + newRole.Permissions = append(newRole.Permissions, permission.(string)) + } + + return newRole, nil +} + +func resourceCreateAccountRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + newrole, validationerr := validateAccountRoles(ctx, d, m) + if validationerr != nil { + return validationerr + } + role, err := apiclient.AccountRole.CreateAccountRole(newrole) + if err != nil { + return diag.FromErr(err) + } + d.SetId(role.UniqueID) + return nil +} + +func resourceUpdateAccountRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + newrole, validationerr := validateAccountRoles(ctx, d, m) + if validationerr != nil { + return validationerr + } + role, err := apiclient.AccountRole.UpdateAccountRole(d.Id(), newrole) + if err != nil { + return diag.FromErr(err) + } + d.SetId(role.UniqueID) + return nil +} + +func resourceDeleteAccountRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + err := apiclient.AccountRole.DeleteAccountRole(d.Id()) + if err != nil { + return diag.FromErr(err) + } + return nil +} + +func resourceReadAccountRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + role, err := apiclient.AccountRole.GetAccountRoleByID(d.Id()) + if err != nil { + return diag.FromErr(err) + } + d.SetId(role.UniqueID) + d.Set("name", role.Name) + d.Set("description", role.Description) + d.Set("permissions", flattenPermissions(role.Permissions)) + return nil +} + +func flattenPermissions(permissions []string) []string { + var permissionList []string + permissionList = append(permissionList, permissions...) + return permissionList +} diff --git a/zenduty/resource_alertrules.go b/zenduty/resource_alertrules.go index e1b7eea..a84a2fb 100644 --- a/zenduty/resource_alertrules.go +++ b/zenduty/resource_alertrules.go @@ -73,34 +73,34 @@ func AlertRuleAction(Ctx context.Context, d *schema.ResourceData, m interface{}, actions := d.Get("actions").([]interface{}) newAlertRule.Actions = make([]client.AlertAction, len(actions)) for i, action := range actions { - rule_map := action.(map[string]interface{}) - new_action := client.AlertAction{} + ruleMap := action.(map[string]interface{}) + newAction := client.AlertAction{} var value, key string - if v, ok := rule_map["action_type"]; ok { - new_action.ActionType = v.(int) + if v, ok := ruleMap["action_type"]; ok { + newAction.ActionType = v.(int) } - if (new_action.ActionType > 15) || (new_action.ActionType < 1) { + if (newAction.ActionType > 15) || (newAction.ActionType < 1) { return nil, diag.FromErr(errors.New("action_type is not valid")) } - if v, ok := rule_map["value"]; ok { + if v, ok := ruleMap["value"]; ok { value = v.(string) } - if (new_action.ActionType == 1) || (new_action.ActionType == 2) || (new_action.ActionType == 3) || (new_action.ActionType == 4) || (new_action.ActionType == 5) || (new_action.ActionType == 6) || (new_action.ActionType == 7) || (new_action.ActionType == 8) || (new_action.ActionType == 9) || (new_action.ActionType == 10) || (new_action.ActionType == 11) || (new_action.ActionType == 12) || (new_action.ActionType == 13) || (new_action.ActionType == 14) || (new_action.ActionType == 15) { - if (new_action.ActionType != 3) && (value == "") { + if (newAction.ActionType == 1) || (newAction.ActionType == 2) || (newAction.ActionType == 3) || (newAction.ActionType == 4) || (newAction.ActionType == 5) || (newAction.ActionType == 6) || (newAction.ActionType == 7) || (newAction.ActionType == 8) || (newAction.ActionType == 9) || (newAction.ActionType == 10) || (newAction.ActionType == 11) || (newAction.ActionType == 12) || (newAction.ActionType == 13) || (newAction.ActionType == 14) || (newAction.ActionType == 15) { + if (newAction.ActionType != 3) && (value == "") { return nil, diag.FromErr(errors.New("value is required")) } - if ((new_action.ActionType == 4) || (new_action.ActionType == 12) || (new_action.ActionType == 13) || (new_action.ActionType == 14) || (new_action.ActionType == 15)) && (!IsValidUUID(value)) { + if ((newAction.ActionType == 4) || (newAction.ActionType == 12) || (newAction.ActionType == 13) || (newAction.ActionType == 14) || (newAction.ActionType == 15)) && (!IsValidUUID(value)) { return nil, diag.FromErr(errors.New(value + " is not a valid UUID")) } - if (new_action.ActionType == 7) && (!(value == "0" || value == "1")) { + if (newAction.ActionType == 7) && (!(value == "0" || value == "1")) { return nil, diag.FromErr(errors.New("incident urgency should be 0 or 1")) } - if new_action.ActionType == 1 { + if newAction.ActionType == 1 { i, err := strconv.Atoi(value) if i < 0 || i > 5 { return nil, diag.FromErr(errors.New("value should be between 0 and 5")) @@ -108,18 +108,18 @@ func AlertRuleAction(Ctx context.Context, d *schema.ResourceData, m interface{}, if err != nil { return nil, diag.FromErr(errors.New("value is not valid")) } - new_action.Value = value - } else if new_action.ActionType == 3 { + newAction.Value = value + } else if newAction.ActionType == 3 { value = "" - } else if new_action.ActionType == 4 { - new_action.EscalationPolicy = value + } else if newAction.ActionType == 4 { + newAction.EscalationPolicy = value value = "" - } else if new_action.ActionType == 6 { + } else if newAction.ActionType == 6 { - new_action.Assigned_To = value + newAction.AssignedTo = value value = "" - } else if new_action.ActionType == 11 { - if v, ok := rule_map["key"]; ok { + } else if newAction.ActionType == 11 { + if v, ok := ruleMap["key"]; ok { key = v.(string) } if key == "" { @@ -129,31 +129,31 @@ func AlertRuleAction(Ctx context.Context, d *schema.ResourceData, m interface{}, return nil, diag.FromErr(errors.New("key(ie..role_id) is not valid UUID")) } - new_action.Key = key + newAction.Key = key - } else if new_action.ActionType == 14 { - new_action.SLA = value + } else if newAction.ActionType == 14 { + newAction.SLA = value value = "" - if new_action.SLA == "" { + if newAction.SLA == "" { return nil, diag.FromErr(errors.New("sla is required")) - } else if !IsValidUUID(new_action.SLA) { + } else if !IsValidUUID(newAction.SLA) { return nil, diag.FromErr(errors.New("sla is not valid UUID")) } - } else if new_action.ActionType == 15 { - new_action.TeamPriority = value + } else if newAction.ActionType == 15 { + newAction.TeamPriority = value value = "" - if new_action.TeamPriority == "" { + if newAction.TeamPriority == "" { return nil, diag.FromErr(errors.New("team_priority is required")) - } else if !IsValidUUID(new_action.TeamPriority) { + } else if !IsValidUUID(newAction.TeamPriority) { return nil, diag.FromErr(errors.New("team_priority is not valid UUID")) } } - new_action.Value = value + newAction.Value = value } - newAlertRule.Actions[i] = new_action + newAlertRule.Actions[i] = newAction } return newAlertRule.Actions, nil @@ -168,21 +168,21 @@ func ValidateAncCreateAlertRules(Ctx context.Context, d *schema.ResourceData, m } if v, ok := d.GetOk("rule_json"); ok { - newAlertRule.RuleJson = v.(string) + newAlertRule.RuleJSON = v.(string) } if newAlertRule.Description == "" { return nil, diag.FromErr(errors.New("description is required")) } - if newAlertRule.RuleJson == "" { + if newAlertRule.RuleJSON == "" { return nil, diag.FromErr(errors.New("rule_json is required")) } - if !isJSONString(newAlertRule.RuleJson) { + if !isJSONString(newAlertRule.RuleJSON) { return nil, diag.FromErr(errors.New("rule_json is not valid JSON")) } - actions, action_err := AlertRuleAction(Ctx, d, m, newAlertRule) - if action_err != nil { - return nil, action_err + actions, actionErr := AlertRuleAction(Ctx, d, m, newAlertRule) + if actionErr != nil { + return nil, actionErr } newAlertRule.Actions = actions @@ -193,41 +193,41 @@ func ValidateAncCreateAlertRules(Ctx context.Context, d *schema.ResourceData, m func resourceCreateAlertRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() var diags diag.Diagnostics - var team_id, service_id, integration_id string + var teamID, serviceID, integrationID string - team_id = d.Get("team_id").(string) - service_id = d.Get("service_id").(string) - integration_id = d.Get("integration_id").(string) + teamID = d.Get("team_id").(string) + serviceID = d.Get("service_id").(string) + integrationID = d.Get("integration_id").(string) - new_rule, rule_err := ValidateAncCreateAlertRules(Ctx, d, m) - if rule_err != nil { - return rule_err + newRule, ruleErr := ValidateAncCreateAlertRules(Ctx, d, m) + if ruleErr != nil { + return ruleErr } - alert_rule, err := apiclient.AlertRules.CreateAlertRule(team_id, service_id, integration_id, new_rule) + alertRule, err := apiclient.AlertRules.CreateAlertRule(teamID, serviceID, integrationID, newRule) if err != nil { return diag.FromErr(err) } - d.SetId(alert_rule.Unique_Id) + d.SetId(alertRule.UniqueID) return diags } func resourceUpdateAlertRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() var diags diag.Diagnostics - var team_id, service_id, integration_id string + var teamID, serviceID, integrationID string - team_id = d.Get("team_id").(string) - service_id = d.Get("service_id").(string) - integration_id = d.Get("integration_id").(string) + teamID = d.Get("team_id").(string) + serviceID = d.Get("service_id").(string) + integrationID = d.Get("integration_id").(string) - new_rule, rule_err := ValidateAncCreateAlertRules(Ctx, d, m) - if rule_err != nil { - return rule_err + newRule, ruleErr := ValidateAncCreateAlertRules(Ctx, d, m) + if ruleErr != nil { + return ruleErr } - _, err := apiclient.AlertRules.UpdateAlertRule(team_id, service_id, integration_id, d.Id(), new_rule) + _, err := apiclient.AlertRules.UpdateAlertRule(teamID, serviceID, integrationID, d.Id(), newRule) if err != nil { return diag.FromErr(err) } @@ -238,55 +238,55 @@ func resourceUpdateAlertRules(Ctx context.Context, d *schema.ResourceData, m int func resourceReadAlertRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() var diags diag.Diagnostics - var team_id, service_id, integration_id string + var teamID, serviceID, integrationID string - team_id = d.Get("team_id").(string) - service_id = d.Get("service_id").(string) - integration_id = d.Get("integration_id").(string) + teamID = d.Get("team_id").(string) + serviceID = d.Get("service_id").(string) + integrationID = d.Get("integration_id").(string) - rule, err := apiclient.AlertRules.GetAlertRule(team_id, service_id, integration_id, d.Id()) + rule, err := apiclient.AlertRules.GetAlertRule(teamID, serviceID, integrationID, d.Id()) if err != nil { return diag.FromErr(err) } - d.SetId(rule.Unique_Id) - d.Set("rule_json", rule.RuleJson) + d.SetId(rule.UniqueID) + d.Set("rule_json", rule.RuleJSON) d.Set("actions", flattenAlertActions(rule)) d.Set("description", rule.Description) return diags } func flattenAlertActions(rule *client.AlertRule) []map[string]interface{} { - var actions_list []map[string]interface{} + var actionsList []map[string]interface{} for _, action := range rule.Actions { - new_action := map[string]interface{}{} - new_action["action_type"] = action.ActionType + newAction := map[string]interface{}{} + newAction["action_type"] = action.ActionType if action.ActionType != 3 { if action.ActionType == 4 { - new_action["value"] = action.EscalationPolicy + newAction["value"] = action.EscalationPolicy } else if action.ActionType == 6 { - new_action["value"] = action.Assigned_To + newAction["value"] = action.AssignedTo } else if action.ActionType == 14 { - new_action["value"] = action.SLA + newAction["value"] = action.SLA } else if action.ActionType == 15 { - new_action["value"] = action.TeamPriority + newAction["value"] = action.TeamPriority } else { - new_action["value"] = action.Value + newAction["value"] = action.Value } } if action.ActionType == 11 { - new_action["key"] = action.Key + newAction["key"] = action.Key } - actions_list = append(actions_list, new_action) + actionsList = append(actionsList, newAction) } - return actions_list + return actionsList } func resourceDeleteAlertRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics apiclient, _ := m.(*Config).Client() - team_id, service_id, integration_id, unique_id := d.Get("team_id").(string), d.Get("service_id").(string), d.Get("integration_id").(string), d.Id() + teamID, serviceID, integrationID, uniqueID := d.Get("team_id").(string), d.Get("service_id").(string), d.Get("integration_id").(string), d.Id() - err := apiclient.AlertRules.DeleteAlertRule(team_id, service_id, integration_id, unique_id) + err := apiclient.AlertRules.DeleteAlertRule(teamID, serviceID, integrationID, uniqueID) if err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_assign_role.go b/zenduty/resource_assign_role.go new file mode 100644 index 0000000..21c5e7d --- /dev/null +++ b/zenduty/resource_assign_role.go @@ -0,0 +1,97 @@ +package zenduty + +import ( + "context" + "errors" + "regexp" + + "github.com/Zenduty/zenduty-go-sdk/client" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceAssignAccountRole() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceAssignRole, + ReadContext: resourceReadRole, + UpdateContext: resourceUpdateAssignRole, + DeleteContext: resourceRemoveAssignedRole, + Schema: map[string]*schema.Schema{ + "account_role": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: ValidateUUID(), + }, + "username": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{1}$`), "must be a valid username"), + }, + }, + } +} + +func resourceAssignRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + role := &client.AddRoleToUser{} + + if v, ok := d.GetOk("account_role"); ok { + AccountRole := v.(string) + role.AccountRole = &AccountRole + } + username := d.Get("username").(string) + + userrole, err := apiclient.AccountRole.AssignRoleToUser(username, role) + if err != nil { + return diag.FromErr(err) + } + d.SetId(userrole.Username) + return nil +} + +func resourceUpdateAssignRole(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + role := &client.AddRoleToUser{} + + var diags diag.Diagnostics + + if v, ok := d.GetOk("account_role"); ok { + AccountRole := v.(string) + role.AccountRole = &AccountRole + } + username := d.Get("username").(string) + if username != d.Id() { + return diag.FromErr(errors.New("cannot update username")) + } + + _, err := apiclient.AccountRole.AssignRoleToUser(username, role) + if err != nil { + return diag.FromErr(err) + } + return diags + +} + +func resourceRemoveAssignedRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + role := &client.AddRoleToUser{AccountRole: nil} + + var diags diag.Diagnostics + username := d.Get("username").(string) + _, err := apiclient.AccountRole.AssignRoleToUser(username, role) + if err != nil { + return diag.FromErr(err) + } + return diags +} + +func resourceReadRole(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + return diags +} diff --git a/zenduty/resource_esp.go b/zenduty/resource_esp.go index c4b1f97..56df1a8 100644 --- a/zenduty/resource_esp.go +++ b/zenduty/resource_esp.go @@ -84,69 +84,69 @@ func resourceEsp() *schema.Resource { } func CreateEsp(Ctx context.Context, d *schema.ResourceData, m interface{}) (*client.EscalationPolicy, diag.Diagnostics) { - new_esp := &client.EscalationPolicy{} + newEsp := &client.EscalationPolicy{} rules := d.Get("rules").([]interface{}) if v, ok := d.GetOk("name"); ok { - new_esp.Name = v.(string) + newEsp.Name = v.(string) } if v, ok := d.GetOk("summary"); ok { - new_esp.Summary = v.(string) + newEsp.Summary = v.(string) } if v, ok := d.GetOk("description"); ok { - new_esp.Description = v.(string) - if emptyString(new_esp.Description) { + newEsp.Description = v.(string) + if emptyString(newEsp.Description) { return nil, diag.FromErr(errors.New("description is empty")) } } if v, ok := d.GetOk("team_id"); ok { - new_esp.Team = v.(string) + newEsp.Team = v.(string) } if v, ok := d.GetOk("repeat_policy"); ok { - new_esp.Repeat_Policy = v.(int) + newEsp.RepeatPolicy = v.(int) } if v, ok := d.GetOk("move_to_next"); ok { - new_esp.Move_To_Next = v.(bool) + newEsp.MoveToNext = v.(bool) } - new_esp.Rules = make([]client.Rules, len(rules)) - old_delay := 0 + newEsp.Rules = make([]client.Rules, len(rules)) + oldDelay := 0 for i, rule := range rules { - rule_map := rule.(map[string]interface{}) - new_rule := client.Rules{} - if v, ok := rule_map["delay"]; ok { - if i == 0 && new_rule.Delay != 0 { + ruleMap := rule.(map[string]interface{}) + newRule := client.Rules{} + if v, ok := ruleMap["delay"]; ok { + if i == 0 && newRule.Delay != 0 { return nil, diag.FromErr(errors.New("delay is not 0 for first rule")) } - new_rule.Delay = v.(int) - if new_rule.Delay < old_delay && i != 0 { - return nil, diag.FromErr(fmt.Errorf("delay must be greater than previous %d should be greater than %d", new_rule.Delay, old_delay)) + newRule.Delay = v.(int) + if newRule.Delay < oldDelay && i != 0 { + return nil, diag.FromErr(fmt.Errorf("delay must be greater than previous %d should be greater than %d", newRule.Delay, oldDelay)) } - old_delay = new_rule.Delay + oldDelay = newRule.Delay } - // if v, ok := rule_map["position"]; ok { - // new_rule.Position = v.(int) + // if v, ok := ruleMap["position"]; ok { + // newRule.Position = v.(int) // } - // if v, ok := rule_map["unique_id"]; ok { - // new_rule.Unique_Id = v.(string) + // if v, ok := ruleMap["unique_id"]; ok { + // newRule.UniqueID = v.(string) // } - if v, ok := rule_map["targets"]; ok { + if v, ok := ruleMap["targets"]; ok { targets := v.([]interface{}) - new_rule.Targets = make([]client.Targets, len(targets)) + newRule.Targets = make([]client.Targets, len(targets)) for j, target := range targets { - target_map := target.(map[string]interface{}) - new_target := client.Targets{} - if v, ok := target_map["target_type"]; ok { - new_target.Target_type = v.(int) + targetMap := target.(map[string]interface{}) + newTarget := client.Targets{} + if v, ok := targetMap["target_type"]; ok { + newTarget.TargetType = v.(int) } - if v, ok := target_map["target_id"]; ok { - new_target.Target_id = v.(string) + if v, ok := targetMap["target_id"]; ok { + newTarget.TargetID = v.(string) } - new_rule.Targets[j] = new_target + newRule.Targets[j] = newTarget } } - new_esp.Rules[i] = new_rule + newEsp.Rules[i] = newRule } - return new_esp, nil + return newEsp, nil } @@ -167,8 +167,8 @@ func flattenTargets(targets []client.Targets) []map[string]interface{} { result := make([]map[string]interface{}, len(targets)) for i, target := range targets { result[i] = map[string]interface{}{ - "target_type": target.Target_type, - "target_id": target.Target_id, + "target_type": target.TargetType, + "target_id": target.TargetID, } } return result @@ -178,17 +178,17 @@ func resourceCreateEsp(Ctx context.Context, d *schema.ResourceData, m interface{ apiclient, _ := m.(*Config).Client() var diags diag.Diagnostics - new_esp, createErr := CreateEsp(Ctx, d, m) + newEsp, createErr := CreateEsp(Ctx, d, m) if createErr != nil { return createErr } - esp, err := apiclient.Esp.CreateEscalationPolicy(new_esp.Team, new_esp) + esp, err := apiclient.Esp.CreateEscalationPolicy(newEsp.Team, newEsp) if err != nil { return diag.FromErr(err) } - d.SetId(esp.Unique_Id) + d.SetId(esp.UniqueID) readErr := resourceReadEsp(Ctx, d, m) if readErr != nil { @@ -202,14 +202,14 @@ func resourceCreateEsp(Ctx context.Context, d *schema.ResourceData, m interface{ func resourceUpdateEsp(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - new_esp, createErr := CreateEsp(Ctx, d, m) + newEsp, createErr := CreateEsp(Ctx, d, m) if createErr != nil { return createErr } id := d.Id() var diags diag.Diagnostics - _, err := apiclient.Esp.UpdateEscalationPolicy(new_esp.Team, id, new_esp) + _, err := apiclient.Esp.UpdateEscalationPolicy(newEsp.Team, id, newEsp) if err != nil { return diag.FromErr(err) @@ -220,14 +220,14 @@ func resourceUpdateEsp(Ctx context.Context, d *schema.ResourceData, m interface{ func resourceDeleteEsp(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) - log.Printf("team_idss: %s", team_id) + teamID := d.Get("team_id").(string) + log.Printf("team_idss: %s", teamID) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } var diags diag.Diagnostics - err := apiclient.Esp.DeleteEscalationPolicy(team_id, id) + err := apiclient.Esp.DeleteEscalationPolicy(teamID, id) if err != nil { return diag.FromErr(err) } @@ -236,19 +236,19 @@ func resourceDeleteEsp(Ctx context.Context, d *schema.ResourceData, m interface{ func resourceReadEsp(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) if v, ok := d.GetOk("team_id"); ok { - team_id = v.(string) + teamID = v.(string) } - log.Printf("team_id: %s", team_id) + log.Printf("team_id: %s", teamID) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required ")) } var diags diag.Diagnostics - esp, err := apiclient.Esp.GetEscalationPolicyById(team_id, id) + esp, err := apiclient.Esp.GetEscalationPolicyByID(teamID, id) if err != nil { return diag.FromErr(err) } @@ -256,8 +256,8 @@ func resourceReadEsp(Ctx context.Context, d *schema.ResourceData, m interface{}) d.Set("team_id", esp.Team) d.Set("summary", esp.Summary) d.Set("description", esp.Description) - d.Set("repeat_policy", esp.Repeat_Policy) - d.Set("move_to_next", esp.Move_To_Next) + d.Set("repeat_policy", esp.RepeatPolicy) + d.Set("move_to_next", esp.MoveToNext) if err := d.Set("rules", flattenRules(esp.Rules)); err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_global_routing_rules.go b/zenduty/resource_global_routing_rules.go new file mode 100644 index 0000000..17af9f2 --- /dev/null +++ b/zenduty/resource_global_routing_rules.go @@ -0,0 +1,211 @@ +package zenduty + +import ( + "context" + "errors" + "fmt" + "strings" + + "github.com/Zenduty/zenduty-go-sdk/client" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceGlobalRoutingRules() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceCreateRoutingRules, + UpdateContext: resourceUpdateRoutingRules, + DeleteContext: resourceDeleteRoutingRules, + ReadContext: resourceReadRoutingRules, + Importer: &schema.ResourceImporter{ + State: resourceRouterRulesImporter, + }, + Schema: map[string]*schema.Schema{ + "router_id": { + Type: schema.TypeString, + Required: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "rule_json": { + Type: schema.TypeString, + Optional: true, + }, + "actions": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action_type": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(0, 1), + }, + "integration": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} +func CreateRoutingRuleAction(Ctx context.Context, d *schema.ResourceData, m interface{}, newAlertRule *client.GlobalRoutingRule) ([]client.GlobalRoutingRuleAction, diag.Diagnostics) { + actions := d.Get("actions").([]interface{}) + newAlertRule.Actions = make([]client.GlobalRoutingRuleAction, len(actions)) + for i, action := range actions { + ruleMap := action.(map[string]interface{}) + newAction := client.GlobalRoutingRuleAction{} + + if v, ok := ruleMap["action_type"]; ok { + newAction.ActionType = v.(int) + } + + if newAction.ActionType == 0 { + if v, ok := ruleMap["integration"]; ok { + newAction.Integration = v.(string) + } + if newAction.Integration == "" { + return nil, diag.FromErr(errors.New("integration is required")) + } + + } + + newAlertRule.Actions[i] = newAction + + } + return newAlertRule.Actions, nil + +} + +func ValidateAndCreateRoutingRules(Ctx context.Context, d *schema.ResourceData, m interface{}) (*client.GlobalRoutingRule, diag.Diagnostics) { + newAlertRule := &client.GlobalRoutingRule{} + + if v, ok := d.GetOk("name"); ok { + newAlertRule.Name = v.(string) + + } + if v, ok := d.GetOk("rule_json"); ok { + newAlertRule.RuleJSON = v.(string) + + } + if newAlertRule.Name == "" { + return nil, diag.FromErr(errors.New("description is required")) + } + if newAlertRule.RuleJSON == "" { + return nil, diag.FromErr(errors.New("rule_json is required")) + } + if !isJSONString(newAlertRule.RuleJSON) { + return nil, diag.FromErr(errors.New("rule_json is not valid JSON")) + } + actions, actionErr := CreateRoutingRuleAction(Ctx, d, m, newAlertRule) + if actionErr != nil { + return nil, actionErr + } + + newAlertRule.Actions = actions + + return newAlertRule, nil +} + +func resourceCreateRoutingRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + var diags diag.Diagnostics + var routerID string + + newRule, ruleErr := ValidateAndCreateRoutingRules(Ctx, d, m) + if ruleErr != nil { + return ruleErr + } + if v, ok := d.GetOk("router_id"); ok { + routerID = v.(string) + } + + alertRule, err := apiclient.GlobalRouter.CreateGlobalRoutingRule(routerID, newRule) + + if err != nil { + return diag.FromErr(err) + } + d.SetId(alertRule.UniqueID) + return diags +} + +func resourceUpdateRoutingRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + var diags diag.Diagnostics + + var routerID string + if v, ok := d.GetOk("router_id"); ok { + routerID = v.(string) + } + + newRule, ruleErr := ValidateAndCreateRoutingRules(Ctx, d, m) + if ruleErr != nil { + return ruleErr + } + + _, err := apiclient.GlobalRouter.UpdateGlobalRoutingRule(routerID, d.Id(), newRule) + if err != nil { + return diag.FromErr(err) + } + + return diags +} + +func resourceReadRoutingRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + var diags diag.Diagnostics + + routerID := d.Get("router_id").(string) + rule, err := apiclient.GlobalRouter.GetGlobalRoutingRule(routerID, d.Id()) + if err != nil { + return diag.FromErr(err) + } + d.SetId(rule.UniqueID) + d.Set("rule_json", rule.RuleJSON) + d.Set("actions", flattenRoutingActions(rule)) + d.Set("name", rule.Name) + + return diags +} +func flattenRoutingActions(rule *client.GlobalRoutingRule) []map[string]interface{} { + var actionsList []map[string]interface{} + for _, action := range rule.Actions { + newAction := map[string]interface{}{} + newAction["action_type"] = action.ActionType + newAction["integration"] = action.IntegrationObject.UniqueID + actionsList = append(actionsList, newAction) + } + return actionsList +} + +func resourceDeleteRoutingRules(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + apiclient, _ := m.(*Config).Client() + routerID, uniqueID := d.Get("router_id").(string), d.Id() + + err := apiclient.GlobalRouter.DeleteGlobalRoutingRule(routerID, uniqueID) + if err != nil { + return diag.FromErr(err) + } + return diags +} + +func resourceRouterRulesImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + parts := strings.Split(d.Id(), "/") + if len(parts) != 2 { + return nil, fmt.Errorf("unexpected format of id (%q), expected /", d.Id()) + } else if !IsValidUUID(parts[0]) { + return nil, fmt.Errorf("invalid router_id (%q)", parts[0]) + } else if !IsValidUUID(parts[1]) { + return nil, fmt.Errorf("invalid rule_id (%q)", parts[1]) + } + d.SetId(parts[1]) + d.Set("router_id", parts[0]) + + return []*schema.ResourceData{d}, nil +} diff --git a/zenduty/resource_globalrouter.go b/zenduty/resource_globalrouter.go new file mode 100644 index 0000000..950e285 --- /dev/null +++ b/zenduty/resource_globalrouter.go @@ -0,0 +1,129 @@ +package zenduty + +import ( + "context" + + "github.com/Zenduty/zenduty-go-sdk/client" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalRouter() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceGlobalRouterCreate, + UpdateContext: resourceGlobalRouterUpdate, + DeleteContext: resourceGlobalRouterDelete, + ReadContext: resourceGlobalRouterRead, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Required: true, + }, + "integration_key": { + Type: schema.TypeString, + Computed: true, + }, + "is_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + }, + } +} + +func resourceGlobalRouterCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + newGlobalRouter := &client.GlobalRouterPayload{} + var diags diag.Diagnostics + + if v, ok := d.GetOk("name"); ok { + newGlobalRouter.Name = v.(string) + } + if v, ok := d.GetOk("description"); ok { + newGlobalRouter.Description = v.(string) + } + if v, ok := d.GetOk("is_enabled"); ok { + newGlobalRouter.IsEnabled = v.(bool) + } + + router, err := apiclient.GlobalRouter.CreateGlobalRouter(newGlobalRouter) + if err != nil { + return diag.FromErr(err) + } + d.SetId(router.UniqueID) + // added integration_key in response output + d.Set("integration_key", router.IntegrationKey) + d.Set("is_enabled", router.IsEnabled) + d.Set("description", router.Description) + + return diags +} + +func resourceGlobalRouterUpdate(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + newGlobalRouter := &client.GlobalRouterPayload{} + var diags diag.Diagnostics + + if v, ok := d.GetOk("name"); ok { + newGlobalRouter.Name = v.(string) + } + if v, ok := d.GetOk("description"); ok { + newGlobalRouter.Description = v.(string) + } + if v, ok := d.GetOk("is_enabled"); ok { + newGlobalRouter.IsEnabled = v.(bool) + } + + router, err := apiclient.GlobalRouter.UpdateGlobalRouter(d.Id(), newGlobalRouter) + if err != nil { + return diag.FromErr(err) + } + d.SetId(router.UniqueID) + // added integration_key in response output + d.Set("integration_key", router.IntegrationKey) + d.Set("is_enabled", router.IsEnabled) + d.Set("description", router.Description) + + return diags +} + +func resourceGlobalRouterDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + apiclient, _ := m.(*Config).Client() + + id := d.Id() + var diags diag.Diagnostics + err := apiclient.GlobalRouter.DeleteGlobalRouter(id) + if err != nil { + return diag.FromErr(err) + } + + return diags +} + +func resourceGlobalRouterRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + + var diags diag.Diagnostics + id := d.Id() + apiclient, _ := m.(*Config).Client() + + router, err := apiclient.GlobalRouter.GetGlobalRouter(id) + if err != nil { + return diag.FromErr(err) + } + d.Set("name", router.Name) + d.Set("integration_key", router.IntegrationKey) + d.Set("is_enabled", router.IsEnabled) + d.Set("description", router.Description) + + return diags +} diff --git a/zenduty/resource_incidents.go b/zenduty/resource_incidents.go index 68f1b43..08bebca 100644 --- a/zenduty/resource_incidents.go +++ b/zenduty/resource_incidents.go @@ -49,30 +49,30 @@ func resourceIncidents() *schema.Resource { func resourceIncidentsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - new_incident := &client.Incident{} + newIncident := &client.Incident{} var diags diag.Diagnostics summary := d.Get("summary").(string) if summary != "" { - new_incident.Summary = summary + newIncident.Summary = summary } if v, ok := d.GetOk("title"); ok { - new_incident.Title = v.(string) + newIncident.Title = v.(string) } if v, ok := d.GetOk("user"); ok { - new_incident.User = v.(string) + newIncident.User = v.(string) } if v, ok := d.GetOk("escalation_policy"); ok { - new_incident.EscalationPolicy = v.(string) + newIncident.EscalationPolicy = v.(string) } if v, ok := d.GetOk("service"); ok { - new_incident.Service = v.(string) + newIncident.Service = v.(string) } - incident, err := apiclient.Incidents.CreateIncident(new_incident) + incident, err := apiclient.Incidents.CreateIncident(newIncident) if err != nil { return diag.FromErr(err) } - d.SetId(strconv.Itoa(incident.Incident_Number)) + d.SetId(strconv.Itoa(incident.IncidentNumber)) return diags } @@ -82,8 +82,8 @@ func resourceIncidentUpdate(Ctx context.Context, d *schema.ResourceData, m inter apiclient, _ := m.(*Config).Client() id := d.Id() - new_status := &client.IncidentStatus{} - _, err := apiclient.Incidents.UpdateIncident(id, new_status) + newStatus := &client.IncidentStatus{} + _, err := apiclient.Incidents.UpdateIncident(id, newStatus) if err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_inivite.go b/zenduty/resource_inivite.go index bb2b794..d66f312 100644 --- a/zenduty/resource_inivite.go +++ b/zenduty/resource_inivite.go @@ -57,21 +57,21 @@ func resourceInviteCreate(ctx context.Context, d *schema.ResourceData, m interfa if v, ok := d.GetOk("team"); ok { newinvite.Team = v.(string) } - email_accounts := d.Get("email_accounts").([]interface{}) + emailAccounts := d.Get("email_accounts").([]interface{}) var diags diag.Diagnostics - newinvite.EmailAccounts = make([]client.EmailAccounts, len(email_accounts)) - for i, user := range email_accounts { - email_account := user.(map[string]interface{}) - if v, ok := email_account["email"]; ok { + newinvite.EmailAccounts = make([]client.EmailAccounts, len(emailAccounts)) + for i, user := range emailAccounts { + emailAccount := user.(map[string]interface{}) + if v, ok := emailAccount["email"]; ok { newinvite.EmailAccounts[i].Email = v.(string) } - if v, ok := email_account["first_name"]; ok { - newinvite.EmailAccounts[i].First_Name = v.(string) + if v, ok := emailAccount["first_name"]; ok { + newinvite.EmailAccounts[i].FirstName = v.(string) } - if v, ok := email_account["last_name"]; ok { - newinvite.EmailAccounts[i].Last_Name = v.(string) + if v, ok := emailAccount["last_name"]; ok { + newinvite.EmailAccounts[i].LastName = v.(string) } - if v, ok := email_account["role"]; ok { + if v, ok := emailAccount["role"]; ok { newinvite.EmailAccounts[i].Role = v.(int) } diff --git a/zenduty/resource_integrations.go b/zenduty/resource_integrations.go index 32a697f..8bdc540 100644 --- a/zenduty/resource_integrations.go +++ b/zenduty/resource_integrations.go @@ -81,8 +81,8 @@ func resourceIntegrationCreate(ctx context.Context, d *schema.ResourceData, m in newIntegration := &client.IntegrationCreate{} var diags diag.Diagnostics - team_id := d.Get("team_id").(string) - service_id := d.Get("service_id").(string) + teamID := d.Get("team_id").(string) + serviceID := d.Get("service_id").(string) summary := d.Get("summary").(string) if summary != "" { newIntegration.Summary = summary @@ -95,24 +95,24 @@ func resourceIntegrationCreate(ctx context.Context, d *schema.ResourceData, m in newIntegration.Application = v.(string) } if v, ok := d.GetOk("is_enabled"); ok { - newIntegration.Is_Enabled = v.(bool) + newIntegration.IsEnabled = v.(bool) } if v, ok := d.GetOk("create_incident_for"); ok { - newIntegration.Create_Incident_For = v.(int) + newIntegration.CreateIncidentFor = v.(int) } if v, ok := d.GetOk("default_urgency"); ok { - newIntegration.Default_Urgency = v.(int) + newIntegration.DefaultUrgency = v.(int) } - integration, err := apiclient.Integrations.CreateIntegration(team_id, service_id, newIntegration) + integration, err := apiclient.Integrations.CreateIntegration(teamID, serviceID, newIntegration) if err != nil { return diag.FromErr(err) } - d.SetId(integration.Unique_Id) + d.SetId(integration.UniqueID) // added integration_key in response output - d.Set("integration_key", integration.Integration_key) - d.Set("is_enabled", integration.Is_Enabled) - d.Set("webhook_url", integration.Webhook_url) + d.Set("integration_key", integration.IntegrationKey) + d.Set("is_enabled", integration.IsEnabled) + d.Set("webhook_url", integration.WebhookURL) return diags } @@ -123,8 +123,8 @@ func resourceIntegrationUpdate(Ctx context.Context, d *schema.ResourceData, m in newIntegration := &client.IntegrationCreate{} var diags diag.Diagnostics - team_id := d.Get("team_id").(string) - service_id := d.Get("service_id").(string) + teamID := d.Get("team_id").(string) + serviceID := d.Get("service_id").(string) summary := d.Get("summary").(string) if summary != "" { newIntegration.Summary = summary @@ -137,22 +137,22 @@ func resourceIntegrationUpdate(Ctx context.Context, d *schema.ResourceData, m in newIntegration.Application = v.(string) } if v, ok := d.GetOk("is_enabled"); ok { - newIntegration.Is_Enabled = v.(bool) + newIntegration.IsEnabled = v.(bool) } if v, ok := d.GetOk("create_incident_for"); ok { - newIntegration.Create_Incident_For = v.(int) + newIntegration.CreateIncidentFor = v.(int) } if v, ok := d.GetOk("default_urgency"); ok { - newIntegration.Default_Urgency = v.(int) + newIntegration.DefaultUrgency = v.(int) } - integration, err := apiclient.Integrations.UpdateIntegration(team_id, service_id, id, newIntegration) + integration, err := apiclient.Integrations.UpdateIntegration(teamID, serviceID, id, newIntegration) if err != nil { return diag.FromErr(err) } - d.Set("integration_key", integration.Integration_key) - d.Set("is_enabled", integration.Is_Enabled) - d.Set("webhook_url", integration.Webhook_url) + d.Set("integration_key", integration.IntegrationKey) + d.Set("is_enabled", integration.IsEnabled) + d.Set("webhook_url", integration.WebhookURL) // added integration_key in response output return diags @@ -162,16 +162,16 @@ func resourceIntegrationDelete(ctx context.Context, d *schema.ResourceData, m in apiclient, _ := m.(*Config).Client() id := d.Id() - team_id := d.Get("team_id").(string) - service_id := d.Get("service_id").(string) + teamID := d.Get("team_id").(string) + serviceID := d.Get("service_id").(string) var diags diag.Diagnostics - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } - if service_id == "" { + if serviceID == "" { return diag.FromErr(errors.New("service_id is required")) } - err := apiclient.Integrations.DeleteIntegration(team_id, service_id, id) + err := apiclient.Integrations.DeleteIntegration(teamID, serviceID, id) if err != nil { return diag.FromErr(err) } @@ -183,22 +183,22 @@ func resourceIntegrationRead(ctx context.Context, d *schema.ResourceData, m inte var diags diag.Diagnostics id := d.Id() - team_id := d.Get("team_id").(string) - service_id := d.Get("service_id").(string) + teamID := d.Get("team_id").(string) + serviceID := d.Get("service_id").(string) apiclient, _ := m.(*Config).Client() - integration, err := apiclient.Integrations.GetIntegrationByID(team_id, service_id, id) + integration, err := apiclient.Integrations.GetIntegrationByID(teamID, serviceID, id) if err != nil { return diag.FromErr(err) } d.Set("name", integration.Name) d.Set("application", integration.Application) d.Set("summary", integration.Summary) - d.Set("integration_key", integration.Integration_key) - d.Set("webhook_url", integration.Webhook_url) - d.Set("is_enabled", integration.Is_Enabled) - d.Set("create_incident_for", integration.Create_Incident_For) - d.Set("default_urgency", integration.Default_Urgency) + d.Set("integration_key", integration.IntegrationKey) + d.Set("webhook_url", integration.WebhookURL) + d.Set("is_enabled", integration.IsEnabled) + d.Set("create_incident_for", integration.CreateIncidentFor) + d.Set("default_urgency", integration.DefaultUrgency) return diags } diff --git a/zenduty/resource_maintenance_window.go b/zenduty/resource_maintenance_window.go index 1131841..a1f4d3d 100644 --- a/zenduty/resource_maintenance_window.go +++ b/zenduty/resource_maintenance_window.go @@ -65,20 +65,20 @@ func resourceMaintenanceWindow() *schema.Resource { } func ValidateMaintenanceWindow(Ctx context.Context, d *schema.ResourceData, m interface{}) (*client.MaintenanceWindow, diag.Diagnostics) { - new_manintence := &client.MaintenanceWindow{} + newManintence := &client.MaintenanceWindow{} services := d.Get("services").([]interface{}) if v, ok := d.GetOk("name"); ok { if v.(string) == "" { return nil, diag.FromErr(errors.New("name must not be empty")) } - new_manintence.Name = v.(string) + newManintence.Name = v.(string) } if v, ok := d.GetOk("timezone"); ok { if v.(string) == "" { return nil, diag.FromErr(errors.New("timezone must not be empty")) } - new_manintence.TimeZone = v.(string) + newManintence.TimeZone = v.(string) } if v, ok := d.GetOk("start_time"); ok { @@ -86,42 +86,42 @@ func ValidateMaintenanceWindow(Ctx context.Context, d *schema.ResourceData, m in return nil, diag.FromErr(errors.New("start_time is invalid")) } - new_manintence.StartTime = v.(string) + newManintence.StartTime = v.(string) - loc, zone_err := time.LoadLocation(new_manintence.TimeZone) - if zone_err != nil { - return nil, diag.FromErr(errors.New(zone_err.Error())) + loc, zoneErr := time.LoadLocation(newManintence.TimeZone) + if zoneErr != nil { + return nil, diag.FromErr(errors.New(zoneErr.Error())) } - parsed_time, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) + parsedTime, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) if err != nil { return nil, diag.FromErr(errors.New(err.Error())) } - new_manintence.StartTime = parsed_time.In(time.UTC).Format(time.RFC3339) + newManintence.StartTime = parsedTime.In(time.UTC).Format(time.RFC3339) } if v, ok := d.GetOk("end_time"); ok { if !validateDate(v.(string)) { return nil, diag.FromErr(errors.New("end_time is invalid")) } - new_manintence.EndTime = v.(string) + newManintence.EndTime = v.(string) - loc, zone_err := time.LoadLocation(new_manintence.TimeZone) - if zone_err != nil { - return nil, diag.FromErr(errors.New(zone_err.Error())) + loc, zoneErr := time.LoadLocation(newManintence.TimeZone) + if zoneErr != nil { + return nil, diag.FromErr(errors.New(zoneErr.Error())) } - parsed_time, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) + parsedTime, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) if err != nil { return nil, diag.FromErr(errors.New(err.Error())) } - new_manintence.EndTime = parsed_time.In(time.UTC).Format(time.RFC3339) + newManintence.EndTime = parsedTime.In(time.UTC).Format(time.RFC3339) } if v, ok := d.GetOk("repeat_interval"); ok { if v.(int) <= 0 { return nil, diag.FromErr(errors.New("repeat_interval must be greater than 0")) } - new_manintence.RepeatInterval = v.(int) + newManintence.RepeatInterval = v.(int) } if v, ok := d.GetOk("repeat_until"); ok { if v.(string) == "" { @@ -131,16 +131,16 @@ func ValidateMaintenanceWindow(Ctx context.Context, d *schema.ResourceData, m in return nil, diag.FromErr(errors.New("repeat_until is invalid")) } - loc, zone_err := time.LoadLocation(new_manintence.TimeZone) - if zone_err != nil { - return nil, diag.FromErr(errors.New(zone_err.Error())) + loc, zoneErr := time.LoadLocation(newManintence.TimeZone) + if zoneErr != nil { + return nil, diag.FromErr(errors.New(zoneErr.Error())) } - parsed_time, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) + parsedTime, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) if err != nil { return nil, diag.FromErr(errors.New(err.Error())) } - new_manintence.RepeatUntil = parsed_time.In(time.UTC).Format(time.RFC3339) + newManintence.RepeatUntil = parsedTime.In(time.UTC).Format(time.RFC3339) } for _, service := range services { if service.(string) == "" { @@ -149,9 +149,9 @@ func ValidateMaintenanceWindow(Ctx context.Context, d *schema.ResourceData, m in if !IsValidUUID(service.(string)) { return nil, diag.FromErr(errors.New("services must be a valid UUID")) } - new_manintence.Services = append(new_manintence.Services, client.ServiceMaintenance{Service: service.(string)}) + newManintence.Services = append(newManintence.Services, client.ServiceMaintenance{Service: service.(string)}) } - return new_manintence, nil + return newManintence, nil } // if v, ok := d.GetOk("services"); ok { @@ -168,20 +168,20 @@ func ValidateMaintenanceWindow(Ctx context.Context, d *schema.ResourceData, m in // } func resourceCreateManintenances(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var team_id string + var teamID string if v, ok := d.GetOk("team_id"); ok { if !IsValidUUID(v.(string)) { return diag.FromErr(errors.New("team_id must be a valid UUID")) } - team_id = v.(string) + teamID = v.(string) } apiclient, _ := m.(*Config).Client() - new_manintence, diags := ValidateMaintenanceWindow(ctx, d, m) + newManintence, diags := ValidateMaintenanceWindow(ctx, d, m) if diags != nil { return diags } - maintenance, err := apiclient.MaintenanceWindow.CreateMaintenanceWindow(team_id, new_manintence) + maintenance, err := apiclient.MaintenanceWindow.CreateMaintenanceWindow(teamID, newManintence) if err != nil { return diag.FromErr(err) } @@ -190,19 +190,19 @@ func resourceCreateManintenances(ctx context.Context, d *schema.ResourceData, m } func resourceUpdateManintenances(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var team_id string + var teamID string if v, ok := d.GetOk("team_id"); ok { if !IsValidUUID(v.(string)) { return diag.FromErr(errors.New("team_id must be a valid UUID")) } - team_id = v.(string) + teamID = v.(string) } apiclient, _ := m.(*Config).Client() - new_manintence, diags := ValidateMaintenanceWindow(ctx, d, m) + newManintence, diags := ValidateMaintenanceWindow(ctx, d, m) if diags != nil { return diags } - maintenance, err := apiclient.MaintenanceWindow.UpdateMaintenanceWindow(team_id, d.Id(), new_manintence) + maintenance, err := apiclient.MaintenanceWindow.UpdateMaintenanceWindow(teamID, d.Id(), newManintence) if err != nil { return diag.FromErr(err) } @@ -211,30 +211,30 @@ func resourceUpdateManintenances(ctx context.Context, d *schema.ResourceData, m } func resourceReadManintenances(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var team_id string + var teamID string if v, ok := d.GetOk("team_id"); ok { if !IsValidUUID(v.(string)) { return diag.FromErr(errors.New("team_id must be a valid UUID")) } - team_id = v.(string) + teamID = v.(string) } apiclient, _ := m.(*Config).Client() - maintenance, err := apiclient.MaintenanceWindow.GetMaintenanceWindowById(team_id, d.Id()) + maintenance, err := apiclient.MaintenanceWindow.GetMaintenanceWindowByID(teamID, d.Id()) if err != nil { return diag.FromErr(err) } d.Set("name", maintenance.Name) d.Set("repeat_interval", maintenance.RepeatInterval) - start_time, time_err := createMaintenanceTimeFormat(maintenance.StartTime, maintenance.TimeZone) - end_time, end_time_err := createMaintenanceTimeFormat(maintenance.EndTime, maintenance.TimeZone) - repeat_until, repeat_until_err := createMaintenanceTimeFormat(maintenance.RepeatUntil, maintenance.TimeZone) - if repeat_until_err == nil { - d.Set("repeat_until", repeat_until) + startTime, timeErr := createMaintenanceTimeFormat(maintenance.StartTime, maintenance.TimeZone) + endTime, endTimeErr := createMaintenanceTimeFormat(maintenance.EndTime, maintenance.TimeZone) + RepeatUntil, RepeatUntilErr := createMaintenanceTimeFormat(maintenance.RepeatUntil, maintenance.TimeZone) + if RepeatUntilErr == nil { + d.Set("repeat_until", RepeatUntil) } - if time_err == nil && end_time_err == nil { - d.Set("start_time", start_time) - d.Set("end_time", end_time) + if timeErr == nil && endTimeErr == nil { + d.Set("start_time", startTime) + d.Set("end_time", endTime) } d.Set("services", flattenServices(maintenance.Services)) d.Set("timezone", maintenance.TimeZone) @@ -243,22 +243,22 @@ func resourceReadManintenances(ctx context.Context, d *schema.ResourceData, m in } func flattenServices(services []client.ServiceMaintenance) []interface{} { - var services_list []interface{} + var servicesList []interface{} for _, service := range services { - services_list = append(services_list, service.Service) + servicesList = append(servicesList, service.Service) } - return services_list + return servicesList } func createMaintenanceTimeFormat(timestamp, Zone string) (string, error) { RFC3339local := "2006-01-02T15:04:05Z" - loc, zone_err := time.LoadLocation(Zone) - if zone_err != nil { - return "", zone_err + loc, zoneErr := time.LoadLocation(Zone) + if zoneErr != nil { + return "", zoneErr } - t, parse_err := time.ParseInLocation(RFC3339local, timestamp, time.UTC) - if parse_err != nil { - return "", parse_err + t, parseErr := time.ParseInLocation(RFC3339local, timestamp, time.UTC) + if parseErr != nil { + return "", parseErr } return t.In(loc).Format("2006-01-02 15:04"), nil @@ -266,15 +266,15 @@ func createMaintenanceTimeFormat(timestamp, Zone string) (string, error) { } func resourceDeleteManintenances(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var team_id string + var teamID string if v, ok := d.GetOk("team_id"); ok { if !IsValidUUID(v.(string)) { return diag.FromErr(errors.New("team_id must be a valid UUID")) } - team_id = v.(string) + teamID = v.(string) } apiclient, _ := m.(*Config).Client() - err := apiclient.MaintenanceWindow.DeleteMaintenanceWindow(team_id, d.Id()) + err := apiclient.MaintenanceWindow.DeleteMaintenanceWindow(teamID, d.Id()) if err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_members.go b/zenduty/resource_members.go index c9666a4..c5209b4 100644 --- a/zenduty/resource_members.go +++ b/zenduty/resource_members.go @@ -38,52 +38,52 @@ func resourceMembers() *schema.Resource { func resourceMemberCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - new_members := &client.Member{} + newMembers := &client.Member{} role := d.Get("role").(int) if role == 0 { - new_members.Role = 2 + newMembers.Role = 2 } else { - new_members.Role = role + newMembers.Role = role } var diags diag.Diagnostics if v, ok := d.GetOk("team"); ok { - new_members.Team = v.(string) + newMembers.Team = v.(string) } if v, ok := d.GetOk("user"); ok { - new_members.User = v.(string) + newMembers.User = v.(string) } - member, err := apiclient.Members.CreateTeamMember(new_members.Team, new_members) + member, err := apiclient.Members.CreateTeamMember(newMembers.Team, newMembers) if err != nil { return diag.FromErr(err) } - d.SetId(member.Unique_Id) + d.SetId(member.UniqueID) return diags } func resourceMemberUpdate(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - new_members := &client.Member{} + newMembers := &client.Member{} id := d.Id() - new_members.Unique_Id = id + newMembers.UniqueID = id var diags diag.Diagnostics if v, ok := d.GetOk("user"); ok { - new_members.User = v.(string) + newMembers.User = v.(string) } if v, ok := d.GetOk("role"); ok { if v.(int) == 0 { - new_members.Role = 2 + newMembers.Role = 2 } else { - new_members.Role = v.(int) + newMembers.Role = v.(int) } } if v, ok := d.GetOk("team"); ok { - new_members.Team = v.(string) + newMembers.Team = v.(string) } - _, err := apiclient.Members.UpdateTeamMember(new_members) + _, err := apiclient.Members.UpdateTeamMember(newMembers) if err != nil { return diag.FromErr(err) } @@ -114,7 +114,7 @@ func resourceMemberRead(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return diag.FromErr(err) } - d.SetId(member.Unique_Id) + d.SetId(member.UniqueID) d.Set("team", member.Team) d.Set("user", member.User) d.Set("role", member.Role) diff --git a/zenduty/resource_notification_rules.go b/zenduty/resource_notification_rules.go index f0d7dac..dc67ad8 100644 --- a/zenduty/resource_notification_rules.go +++ b/zenduty/resource_notification_rules.go @@ -45,22 +45,22 @@ func resourceNotificationRules() *schema.Resource { func resourceCreateNotificationRule(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - new_notificationRule := &client.CreateNotificationRules{} + newNotificationRule := &client.CreateNotificationRules{} var diags diag.Diagnostics var username string if v, ok := d.GetOk("username"); ok { username = v.(string) } if v, ok := d.GetOk("urgency"); ok { - new_notificationRule.Urgency = v.(int) + newNotificationRule.Urgency = v.(int) } if v, ok := d.GetOk("contact"); ok { - new_notificationRule.Contact = v.(string) + newNotificationRule.Contact = v.(string) } if v, ok := d.GetOk("delay"); ok { - new_notificationRule.StartDelay = v.(int) + newNotificationRule.StartDelay = v.(int) } - notificationRule, err := apiclient.NotificationRules.CreateNotificationRules(username, new_notificationRule) + notificationRule, err := apiclient.NotificationRules.CreateNotificationRules(username, newNotificationRule) if err != nil { return diag.FromErr(err) } @@ -70,22 +70,22 @@ func resourceCreateNotificationRule(Ctx context.Context, d *schema.ResourceData, func resourceUpdateNotificationRule(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - new_notificationRule := &client.NotificationRules{} + newNotificationRule := &client.NotificationRules{} var diags diag.Diagnostics var username string if v, ok := d.GetOk("username"); ok { username = v.(string) } if v, ok := d.GetOk("urgency"); ok { - new_notificationRule.Urgency = v.(int) + newNotificationRule.Urgency = v.(int) } if v, ok := d.GetOk("contact"); ok { - new_notificationRule.Contact = v.(string) + newNotificationRule.Contact = v.(string) } if v, ok := d.GetOk("delay"); ok { - new_notificationRule.StartDelay = v.(int) + newNotificationRule.StartDelay = v.(int) } - notificationRule, err := apiclient.NotificationRules.UpdateNotificationRules(username, d.Id(), new_notificationRule) + notificationRule, err := apiclient.NotificationRules.UpdateNotificationRules(username, d.Id(), newNotificationRule) if err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_priority.go b/zenduty/resource_priority.go index ce68ce9..6cbdf6b 100644 --- a/zenduty/resource_priority.go +++ b/zenduty/resource_priority.go @@ -49,7 +49,7 @@ func validatePriority(Ctx context.Context, d *schema.ResourceData, m interface{} team := d.Get("team_id").(string) description := d.Get("description").(string) - new_priority := &client.Priority{} + newPriority := &client.Priority{} if !IsValidUUID(team) { return nil, diag.FromErr(errors.New("team_id must be a valid UUID")) } @@ -57,11 +57,11 @@ func validatePriority(Ctx context.Context, d *schema.ResourceData, m interface{} return nil, diag.FromErr(errors.New("color must be one of the following: magenta, red, volcano, orange, gold, lime, green, cyan, blue, geekblue, purple")) } - new_priority.Name = name - new_priority.Color = color - new_priority.Description = description + newPriority.Name = name + newPriority.Color = color + newPriority.Description = description - return new_priority, nil + return newPriority, nil } func resourceCreatePriority(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -75,7 +75,7 @@ func resourceCreatePriority(ctx context.Context, d *schema.ResourceData, m inter if err != nil { return diag.FromErr(err) } - d.SetId(tag.Unique_Id) + d.SetId(tag.UniqueID) return nil } @@ -90,7 +90,7 @@ func resourceUpdatePriority(ctx context.Context, d *schema.ResourceData, m inter if err != nil { return diag.FromErr(err) } - d.SetId(tag.Unique_Id) + d.SetId(tag.UniqueID) return nil } @@ -108,11 +108,11 @@ func resourceDeletePriority(ctx context.Context, d *schema.ResourceData, m inter func resourceReadPriority(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() team := d.Get("team_id").(string) - tag, err := apiclient.Priority.GetPriorityById(team, d.Id()) + tag, err := apiclient.Priority.GetPriorityByID(team, d.Id()) if err != nil { return diag.FromErr(err) } - d.SetId(tag.Unique_Id) + d.SetId(tag.UniqueID) d.Set("name", tag.Name) d.Set("color", tag.Color) d.Set("team_id", tag.Team) diff --git a/zenduty/resource_roles.go b/zenduty/resource_roles.go index 3e9a6fa..16dafae 100644 --- a/zenduty/resource_roles.go +++ b/zenduty/resource_roles.go @@ -85,7 +85,7 @@ func resourceRoleCreate(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return diag.FromErr(err) } - d.SetId(role.Unique_Id) + d.SetId(role.UniqueID) return diags } @@ -93,9 +93,9 @@ func resourceRoleUpdate(Ctx context.Context, d *schema.ResourceData, m interface apiclient, _ := m.(*Config).Client() newrole := &client.Roles{} - var team_id string + var teamID string id := d.Id() - newrole.Unique_Id = id + newrole.UniqueID = id var diags diag.Diagnostics if v, ok := d.GetOk("description"); ok { newrole.Description = v.(string) @@ -105,7 +105,7 @@ func resourceRoleUpdate(Ctx context.Context, d *schema.ResourceData, m interface newrole.Title = v.(string) } if v, ok := d.GetOk("team"); ok { - team_id = v.(string) + teamID = v.(string) } if v, ok := d.GetOk("rank"); ok { newrole.Rank = v.(int) @@ -116,7 +116,7 @@ func resourceRoleUpdate(Ctx context.Context, d *schema.ResourceData, m interface return diag.Errorf("Rank should be between 1 and 10") } } - _, err := apiclient.Roles.UpdateRoles(team_id, newrole) + _, err := apiclient.Roles.UpdateRoles(teamID, newrole) if err != nil { return diag.FromErr(err) } @@ -128,10 +128,10 @@ func resourceRoleDelete(ctx context.Context, d *schema.ResourceData, m interface apiclient, _ := m.(*Config).Client() id := d.Id() - team_id := d.Get("team").(string) + teamID := d.Get("team").(string) var diags diag.Diagnostics - err := apiclient.Roles.DeleteRole(team_id, id) + err := apiclient.Roles.DeleteRole(teamID, id) if err != nil { return diag.FromErr(err) } @@ -140,9 +140,9 @@ func resourceRoleDelete(ctx context.Context, d *schema.ResourceData, m interface func resourceRoleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() id := d.Id() - team_id := d.Get("team").(string) + teamID := d.Get("team").(string) var diags diag.Diagnostics - role, err := apiclient.Roles.GetRolesById(team_id, id) + role, err := apiclient.Roles.GetRolesByID(teamID, id) if err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_schedules.go b/zenduty/resource_schedules.go index d2edfa7..af1e897 100644 --- a/zenduty/resource_schedules.go +++ b/zenduty/resource_schedules.go @@ -137,244 +137,244 @@ func resourceSchedules() *schema.Resource { } } -func buildScheduleLayerRescrition(new_layer *client.CreateLayers, layer_map map[string]interface{}, d *schema.ResourceData) ([]client.Restrictions, diag.Diagnostics) { - if v, ok := layer_map["restriction_type"]; ok { - new_layer.RestrictionType = v.(int) +func buildScheduleLayerRescrition(newLayer *client.CreateLayers, layerMap map[string]interface{}, d *schema.ResourceData) ([]client.Restrictions, diag.Diagnostics) { + if v, ok := layerMap["restriction_type"]; ok { + newLayer.RestrictionType = v.(int) } - if v, ok := layer_map["restrictions"]; ok { + if v, ok := layerMap["restrictions"]; ok { restrictions := v.([]interface{}) Restrictions := make([]client.Restrictions, len(restrictions)) for j, restriction := range restrictions { - if new_layer.RestrictionType == 0 { + if newLayer.RestrictionType == 0 { return nil, diag.FromErr(errors.New("restrictions must be set to add restrictions.. ie daily(1) or weekly(2)")) } - restriction_map := restriction.(map[string]interface{}) - new_restriction := client.Restrictions{} - if v, ok := restriction_map["duration"]; ok { - new_restriction.Duration = v.(int) - if new_layer.RestrictionType == 1 && new_restriction.Duration >= 86400 { + restrictionMap := restriction.(map[string]interface{}) + newRestriction := client.Restrictions{} + if v, ok := restrictionMap["duration"]; ok { + newRestriction.Duration = v.(int) + if newLayer.RestrictionType == 1 && newRestriction.Duration >= 86400 { return nil, diag.FromErr(errors.New("duration must be less than 86400 for daily restriction ie 24 hours")) - } else if new_layer.RestrictionType == 2 && new_restriction.Duration >= 604800 { + } else if newLayer.RestrictionType == 2 && newRestriction.Duration >= 604800 { return nil, diag.FromErr(errors.New("duration must be less than 604800 for weekly restriction ie 7 days")) } } - if v, ok := restriction_map["start_day_of_week"]; ok { + if v, ok := restrictionMap["start_day_of_week"]; ok { - if new_layer.RestrictionType == 1 { - new_restriction.StartDayOfWeek = 7 + if newLayer.RestrictionType == 1 { + newRestriction.StartDayOfWeek = 7 } else { - new_restriction.StartDayOfWeek = v.(int) + newRestriction.StartDayOfWeek = v.(int) } } - if v, ok := restriction_map["start_time_of_day"]; ok { - new_restriction.StartTimeOfDay = v.(string) + if v, ok := restrictionMap["start_time_of_day"]; ok { + newRestriction.StartTimeOfDay = v.(string) } - Restrictions[j] = new_restriction + Restrictions[j] = newRestriction } return Restrictions, nil } return nil, nil } -func buildScheduleLayer(TimeZone string, ctx context.Context, d *schema.ResourceData) ([]client.CreateLayers, diag.Diagnostics) { +func buildScheduleLayer(ctx context.Context, d *schema.ResourceData, TimeZone string) ([]client.CreateLayers, diag.Diagnostics) { layers := d.Get("layers").([]interface{}) Layers := make([]client.CreateLayers, len(layers)) for i, layer := range layers { - layer_map := layer.(map[string]interface{}) - new_layer := client.CreateLayers{} + layerMap := layer.(map[string]interface{}) + newLayer := client.CreateLayers{} - if v, ok := layer_map["name"]; ok { + if v, ok := layerMap["name"]; ok { if v.(string) == "" { return nil, diag.FromErr(errors.New("name must not be empty")) } - new_layer.Name = v.(string) + newLayer.Name = v.(string) } - // if v, ok := layer_map["time_zone"]; ok { - // new_layer.Time_zone = v.(string) + // if v, ok := layerMap["time_zone"]; ok { + // newLayer.TimeZone = v.(string) // } - if v, ok := layer_map["shift_length"]; ok { + if v, ok := layerMap["shift_length"]; ok { - new_layer.ShiftLength = v.(int) + newLayer.ShiftLength = v.(int) } - if v, ok := layer_map["rotation_start_time"]; ok { + if v, ok := layerMap["rotation_start_time"]; ok { - new_layer.RotationStartTime = v.(string) + newLayer.RotationStartTime = v.(string) loc, _ := time.LoadLocation(TimeZone) - parsed_time, parse_err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) - if parse_err == nil { - new_layer.RotationStartTime = parsed_time.In(time.UTC).Format(time.RFC3339) + parsedTime, parseErr := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) + if parseErr == nil { + newLayer.RotationStartTime = parsedTime.In(time.UTC).Format(time.RFC3339) } } - if v, ok := layer_map["rotation_end_time"]; ok { - new_layer.RotationEndTime = v.(string) + if v, ok := layerMap["rotation_end_time"]; ok { + newLayer.RotationEndTime = v.(string) loc, _ := time.LoadLocation(TimeZone) - parsed_time, parsed_err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) - if parsed_err == nil { - new_layer.RotationEndTime = parsed_time.In(time.UTC).Format(time.RFC3339) + parsedTime, parsedErr := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) + if parsedErr == nil { + newLayer.RotationEndTime = parsedTime.In(time.UTC).Format(time.RFC3339) } } - if v, ok := layer_map["users"]; ok { + if v, ok := layerMap["users"]; ok { users := v.([]interface{}) - new_layer.Users = make([]client.CreateUserLayer, len(users)) + newLayer.Users = make([]client.CreateUserLayer, len(users)) for j, user := range users { - new_user := client.CreateUserLayer{} - new_user.User = user.(string) - new_layer.Users[j] = new_user + newUser := client.CreateUserLayer{} + newUser.User = user.(string) + newLayer.Users[j] = newUser } } - new_restriction, restrictionErr := buildScheduleLayerRescrition(&new_layer, layer_map, d) + newRestriction, restrictionErr := buildScheduleLayerRescrition(&newLayer, layerMap, d) if restrictionErr != nil { return nil, restrictionErr } - if new_restriction != nil { - new_layer.Restrictions = new_restriction + if newRestriction != nil { + newLayer.Restrictions = newRestriction } - Layers[i] = new_layer + Layers[i] = newLayer } return Layers, nil } -func buildScheduleOverride(new_schedule *client.CreateSchedule, d *schema.ResourceData) ([]client.Overrides, diag.Diagnostics) { +func buildScheduleOverride(newSchedule *client.CreateSchedule, d *schema.ResourceData) ([]client.Overrides, diag.Diagnostics) { overrides := d.Get("overrides").([]interface{}) Overrides := make([]client.Overrides, len(overrides)) for o, override := range overrides { override := override.(map[string]interface{}) - new_override := client.Overrides{} + newOverride := client.Overrides{} if v, ok := override["name"]; ok { - new_override.Name = v.(string) + newOverride.Name = v.(string) } if v, ok := override["start_time"]; ok { - new_override.StartTime = v.(string) + newOverride.StartTime = v.(string) - loc, zone_err := time.LoadLocation(new_schedule.Time_zone) - if zone_err != nil { - return nil, diag.FromErr(errors.New(zone_err.Error())) + loc, zoneErr := time.LoadLocation(newSchedule.TimeZone) + if zoneErr != nil { + return nil, diag.FromErr(errors.New(zoneErr.Error())) } - parsed_time, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) + parsedTime, err := time.ParseInLocation("2006-01-02 15:04", v.(string), loc) if err != nil { return nil, diag.FromErr(errors.New(err.Error())) } - new_override.StartTime = parsed_time.In(time.UTC).Format(time.RFC3339) + newOverride.StartTime = parsedTime.In(time.UTC).Format(time.RFC3339) } if v, ok := override["end_time"]; ok { - new_override.EndTime = v.(string) + newOverride.EndTime = v.(string) - loc, zone_err := time.LoadLocation(new_schedule.Time_zone) - if zone_err != nil { - return nil, diag.FromErr(errors.New(zone_err.Error())) + loc, zoneErr := time.LoadLocation(newSchedule.TimeZone) + if zoneErr != nil { + return nil, diag.FromErr(errors.New(zoneErr.Error())) } - parsed_end_time, err := time.ParseInLocation("2006-01-02 15:04", new_override.EndTime, loc) + parsedEndTime, err := time.ParseInLocation("2006-01-02 15:04", newOverride.EndTime, loc) if err != nil { return nil, diag.FromErr(errors.New(err.Error())) } - new_override.EndTime = parsed_end_time.In(time.UTC).Format(time.RFC3339) + newOverride.EndTime = parsedEndTime.In(time.UTC).Format(time.RFC3339) } if v, ok := override["user"]; ok { - new_override.User = v.(string) + newOverride.User = v.(string) } - Overrides[o] = new_override + Overrides[o] = newOverride } return Overrides, nil } func createSchedule(Ctx context.Context, d *schema.ResourceData, m interface{}) (*client.CreateSchedule, diag.Diagnostics) { - new_schedule := &client.CreateSchedule{} + newSchedule := &client.CreateSchedule{} if v, ok := d.GetOk("name"); ok { if v.(string) == "" { return nil, diag.FromErr(errors.New("name must not be empty")) } - new_schedule.Name = v.(string) + newSchedule.Name = v.(string) } if v, ok := d.GetOk("summary"); ok { - new_schedule.Summary = v.(string) + newSchedule.Summary = v.(string) } if v, ok := d.GetOk("description"); ok { - new_schedule.Description = v.(string) + newSchedule.Description = v.(string) } if v, ok := d.GetOk("time_zone"); ok { if emptyString(v.(string)) { return nil, diag.FromErr(errors.New("time_zone must not be empty")) } - _, zone_err := time.LoadLocation(v.(string)) - if zone_err != nil { - return nil, diag.FromErr(errors.New(zone_err.Error())) + _, zoneErr := time.LoadLocation(v.(string)) + if zoneErr != nil { + return nil, diag.FromErr(errors.New(zoneErr.Error())) } - new_schedule.Time_zone = v.(string) + newSchedule.TimeZone = v.(string) } if v, ok := d.GetOk("team_id"); ok { if emptyString(v.(string)) { return nil, diag.FromErr(errors.New("team_id must not be empty")) } - new_schedule.Team = v.(string) + newSchedule.Team = v.(string) } - Layers, layerErr := buildScheduleLayer(new_schedule.Time_zone, Ctx, d) + Layers, layerErr := buildScheduleLayer(Ctx, d, newSchedule.TimeZone) if layerErr != nil { return nil, layerErr } - Overrides, overrideErr := buildScheduleOverride(new_schedule, d) + Overrides, overrideErr := buildScheduleOverride(newSchedule, d) if overrideErr != nil { return nil, overrideErr } - new_schedule.Overrides = Overrides - new_schedule.Layers = Layers + newSchedule.Overrides = Overrides + newSchedule.Layers = Layers - return new_schedule, nil + return newSchedule, nil } func resourceCreateSchedule(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() var diags diag.Diagnostics - new_schedule, create_error := createSchedule(Ctx, d, m) - if create_error != nil { - return create_error + newSchedule, createError := createSchedule(Ctx, d, m) + if createError != nil { + return createError } - schedule, err := apiclient.Schedules.CreateSchedule(new_schedule.Team, new_schedule) + schedule, err := apiclient.Schedules.CreateSchedule(newSchedule.Team, newSchedule) if err != nil { return diag.FromErr(err) } - d.SetId(schedule.Unique_Id) + d.SetId(schedule.UniqueID) return diags } func resourceUpdateSchedule(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } var diags diag.Diagnostics - new_schedule, create_error := createSchedule(Ctx, d, m) - if create_error != nil { - return create_error + newSchedule, createError := createSchedule(Ctx, d, m) + if createError != nil { + return createError } - _, err := apiclient.Schedules.UpdateScheduleByID(team_id, id, new_schedule) + _, err := apiclient.Schedules.UpdateScheduleByID(teamID, id, newSchedule) if err != nil { return diag.FromErr(err) } @@ -384,13 +384,13 @@ func resourceUpdateSchedule(Ctx context.Context, d *schema.ResourceData, m inter func resourceDeleteSchedule(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } var diags diag.Diagnostics - err := apiclient.Schedules.DeleteScheduleByID(team_id, id) + err := apiclient.Schedules.DeleteScheduleByID(teamID, id) if err != nil { return diag.FromErr(err) } @@ -400,25 +400,25 @@ func resourceDeleteSchedule(Ctx context.Context, d *schema.ResourceData, m inter func resourceReadSchedule(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } var diags diag.Diagnostics - service, err := apiclient.Schedules.GetScheduleByID(team_id, id) + service, err := apiclient.Schedules.GetScheduleByID(teamID, id) if err != nil { return diag.FromErr(err) } d.Set("name", service.Name) d.Set("summary", service.Summary) d.Set("description", service.Description) - d.Set("time_zone", service.Time_zone) + d.Set("time_zone", service.TimeZone) d.Set("team_id", service.Team) - if err := d.Set("layers", flattenLayer(service.Time_zone, service.Layers)); err != nil { + if err := d.Set("layers", flattenLayer(service.TimeZone, service.Layers)); err != nil { return diag.FromErr(err) } - if err := d.Set("overrides", flattenScheduleOverrides(service.Time_zone, service.Overrides)); err != nil { + if err := d.Set("overrides", flattenScheduleOverrides(service.TimeZone, service.Overrides)); err != nil { return diag.FromErr(err) } @@ -427,12 +427,12 @@ func resourceReadSchedule(Ctx context.Context, d *schema.ResourceData, m interfa func flattenLayer(TimeZone string, layers []client.Layers) []map[string]interface{} { - var layer_list []map[string]interface{} + var layerList []map[string]interface{} for i, layer := range layers { if emptyString(layer.Name) { layer.Name = fmt.Sprintf("Layer-%d", i+1) } - layer_list = append(layer_list, map[string]interface{}{ + layerList = append(layerList, map[string]interface{}{ "name": layer.Name, "shift_length": layer.ShiftLength, "rotation_start_time": createScheduleLayerTimeFormat(layer.RotationStartTime, TimeZone), @@ -442,18 +442,18 @@ func flattenLayer(TimeZone string, layers []client.Layers) []map[string]interfac "restrictions": flattenLayerRestrictions(layer.Restrictions), }) } - return layer_list + return layerList } func createScheduleLayerTimeFormat(timestamp, Zone string) string { RFC3339local := "2006-01-02T15:04:05Z" - loc, zone_err := time.LoadLocation(Zone) - if zone_err != nil { + loc, zoneErr := time.LoadLocation(Zone) + if zoneErr != nil { return timestamp } - t, parse_err := time.ParseInLocation(RFC3339local, timestamp, time.UTC) - if parse_err != nil { + t, parseErr := time.ParseInLocation(RFC3339local, timestamp, time.UTC) + if parseErr != nil { return timestamp } @@ -463,39 +463,39 @@ func createScheduleLayerTimeFormat(timestamp, Zone string) string { func flattenLayerUsers(users []client.Users) []string { - var user_list []string + var userList []string for _, user := range users { - user_list = append(user_list, user.User) + userList = append(userList, user.User) } - return user_list + return userList } func flattenLayerRestrictions(restrictions []client.Restrictions) []map[string]interface{} { - var restriction_list []map[string]interface{} + var restrictionList []map[string]interface{} for _, restriction := range restrictions { if restriction.Duration == 0 { restriction.Duration = 1 } - restriction_list = append(restriction_list, map[string]interface{}{ + restrictionList = append(restrictionList, map[string]interface{}{ "duration": restriction.Duration, "start_day_of_week": restriction.StartDayOfWeek, "start_time_of_day": restriction.StartTimeOfDay, }) } - return restriction_list + return restrictionList } func flattenScheduleOverrides(TimeZone string, overrides []client.Overrides) []map[string]interface{} { - var override_list []map[string]interface{} + var overrideList []map[string]interface{} for i, override := range overrides { if emptyString(override.Name) { override.Name = fmt.Sprintf("Override-%d", i+1) } - override_list = append(override_list, map[string]interface{}{ + overrideList = append(overrideList, map[string]interface{}{ "name": override.Name, "start_time": createScheduleLayerTimeFormat(override.StartTime, TimeZone), "end_time": createScheduleLayerTimeFormat(override.EndTime, TimeZone), @@ -503,7 +503,7 @@ func flattenScheduleOverrides(TimeZone string, overrides []client.Overrides) []m }) } - return override_list + return overrideList } func resourceScheduleImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { diff --git a/zenduty/resource_services.go b/zenduty/resource_services.go index 1484d9d..586ba06 100644 --- a/zenduty/resource_services.go +++ b/zenduty/resource_services.go @@ -75,65 +75,65 @@ func resourceServices() *schema.Resource { } func CreateServices(Ctx context.Context, d *schema.ResourceData, m interface{}) (*client.Services, error) { - new_service := &client.Services{} + newService := &client.Services{} if v, ok := d.GetOk("name"); ok { - new_service.Name = v.(string) + newService.Name = v.(string) } if v, ok := d.GetOk("escalation_policy"); ok { - new_service.Escalation_Policy = v.(string) + newService.EscalationPolicy = v.(string) } if v, ok := d.GetOk("description"); ok { - new_service.Description = v.(string) + newService.Description = v.(string) } if v, ok := d.GetOk("summary"); ok { - new_service.Summary = v.(string) + newService.Summary = v.(string) } if v, ok := d.GetOk("collation"); ok { - new_service.Collation = v.(int) + newService.Collation = v.(int) } if v, ok := d.GetOk("collation_time"); ok { - new_service.Collation_Time = v.(int) + newService.CollationTime = v.(int) } if v, ok := d.GetOk("sla"); ok { - new_service.Sla = v.(string) + newService.SLA = v.(string) } if v, ok := d.GetOk("task_template"); ok { - new_service.Task_Template = v.(string) + newService.TaskTemplate = v.(string) } if v, ok := d.GetOk("team_priority"); ok { - new_service.Team_Priority = v.(string) + newService.TeamPriority = v.(string) } - if new_service.Collation == 1 && new_service.Collation_Time == 0 { + if newService.Collation == 1 && newService.CollationTime == 0 { return nil, fmt.Errorf("collation_time is required when collation is enabled") } - return new_service, nil + return newService, nil } func resourceCreateServices(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) - if team_id == "" { + teamID := d.Get("team_id").(string) + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } - new_service, serviceErr := CreateServices(Ctx, d, m) + newService, serviceErr := CreateServices(Ctx, d, m) if serviceErr != nil { return diag.FromErr(serviceErr) } var diags diag.Diagnostics - service, err := apiclient.Services.CreateService(team_id, new_service) + service, err := apiclient.Services.CreateService(teamID, newService) if err != nil { return diag.FromErr(err) } - d.SetId(service.Unique_Id) - d.Set("team_id", team_id) + d.SetId(service.UniqueID) + d.Set("team_id", teamID) return diags } @@ -141,18 +141,18 @@ func resourceCreateServices(Ctx context.Context, d *schema.ResourceData, m inter func resourceUpdateServices(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } - new_service, serviceErr := CreateServices(Ctx, d, m) + newService, serviceErr := CreateServices(Ctx, d, m) if serviceErr != nil { return diag.FromErr(serviceErr) } - _, err := apiclient.Services.UpdateService(team_id, id, new_service) + _, err := apiclient.Services.UpdateService(teamID, id, newService) if err != nil { return diag.FromErr(err) } @@ -162,13 +162,13 @@ func resourceUpdateServices(Ctx context.Context, d *schema.ResourceData, m inter func resourceDeleteServices(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Id() - if team_id == "" { + if teamID == "" { return diag.FromErr(errors.New("team_id is required")) } var diags diag.Diagnostics - err := apiclient.Services.DeleteService(team_id, id) + err := apiclient.Services.DeleteService(teamID, id) if err != nil { return diag.FromErr(err) } @@ -178,26 +178,26 @@ func resourceDeleteServices(Ctx context.Context, d *schema.ResourceData, m inter func resourceReadServices(Ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() - team_id := d.Get("team_id").(string) + teamID := d.Get("team_id").(string) id := d.Id() - if emptyString(team_id) { + if emptyString(teamID) { return diag.FromErr(errors.New("team_id is required")) } var diags diag.Diagnostics - service, err := apiclient.Services.GetServicesById(team_id, id) + service, err := apiclient.Services.GetServicesByID(teamID, id) if err != nil { return diag.FromErr(err) } d.Set("name", service.Name) - d.Set("escalation_policy", service.Escalation_Policy) + d.Set("escalation_policy", service.EscalationPolicy) d.Set("description", service.Description) d.Set("summary", service.Summary) d.Set("collation", service.Collation) - d.Set("collation_time", service.Collation_Time) - d.Set("sla", service.Sla) - d.Set("task_template", service.Task_Template) - d.Set("team_priority", service.Team_Priority) - d.Set("team_id", team_id) + d.Set("collation_time", service.CollationTime) + d.Set("sla", service.SLA) + d.Set("task_template", service.TaskTemplate) + d.Set("team_priority", service.TeamPriority) + d.Set("team_id", teamID) return diags } diff --git a/zenduty/resource_tags.go b/zenduty/resource_tags.go index 9ed2fe0..ed64564 100644 --- a/zenduty/resource_tags.go +++ b/zenduty/resource_tags.go @@ -43,7 +43,7 @@ func validateTags(Ctx context.Context, d *schema.ResourceData, m interface{}) (* name := d.Get("name").(string) color := d.Get("color").(string) team := d.Get("team_id").(string) - new_tag := &client.Tag{} + newTag := &client.Tag{} if !IsValidUUID(team) { return nil, diag.FromErr(errors.New("team_id must be a valid UUID")) } @@ -51,10 +51,10 @@ func validateTags(Ctx context.Context, d *schema.ResourceData, m interface{}) (* return nil, diag.FromErr(errors.New("color must be one of the following: magenta, red, volcano, orange, gold, lime, green, cyan, blue, geekblue, purple")) } - new_tag.Name = name - new_tag.Color = color + newTag.Name = name + newTag.Color = color - return new_tag, nil + return newTag, nil } func resourceCreateTags(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -68,7 +68,7 @@ func resourceCreateTags(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return diag.FromErr(err) } - d.SetId(tag.Unique_Id) + d.SetId(tag.UniqueID) return nil } @@ -83,7 +83,7 @@ func resourceUpdateTags(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return diag.FromErr(err) } - d.SetId(tag.Unique_Id) + d.SetId(tag.UniqueID) return nil } @@ -101,11 +101,11 @@ func resourceDeleteTags(ctx context.Context, d *schema.ResourceData, m interface func resourceReadTag(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { apiclient, _ := m.(*Config).Client() team := d.Get("team_id").(string) - tag, err := apiclient.Tags.GetTagId(team, d.Id()) + tag, err := apiclient.Tags.GetTagID(team, d.Id()) if err != nil { return diag.FromErr(err) } - d.SetId(tag.Unique_Id) + d.SetId(tag.UniqueID) d.Set("name", tag.Name) d.Set("color", tag.Color) d.Set("team_id", tag.Team) diff --git a/zenduty/resource_team.go b/zenduty/resource_team.go index 75b9a31..465089c 100644 --- a/zenduty/resource_team.go +++ b/zenduty/resource_team.go @@ -46,7 +46,7 @@ func resourceTeamCreate(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return resource.RetryableError(err) } else if task != nil { - d.SetId(task.Unique_Id) + d.SetId(task.UniqueID) } return nil }) @@ -60,7 +60,7 @@ func resourceTeamCreate(ctx context.Context, d *schema.ResourceData, m interface // if err != nil { // return diag.FromErr(err) // } - // d.SetId(task.Unique_Id) + // d.SetId(task.UniqueID) // return diags } @@ -69,7 +69,7 @@ func resourceTeamUpdate(Ctx context.Context, d *schema.ResourceData, m interface newteam := &client.CreateTeams{} id := d.Id() - newteam.Unique_Id = id + newteam.UniqueID = id var diags diag.Diagnostics if v, ok := d.GetOk("name"); ok { newteam.Name = v.(string) @@ -81,7 +81,7 @@ func resourceTeamUpdate(Ctx context.Context, d *schema.ResourceData, m interface if err != nil { return resource.RetryableError(err) } else if task != nil { - d.SetId(task.Unique_Id) + d.SetId(task.UniqueID) } return nil }) @@ -115,7 +115,7 @@ func resourceTeamRead(ctx context.Context, d *schema.ResourceData, m interface{} id := d.Id() var diags diag.Diagnostics - t, err := apiclient.Teams.GetTeamById(id) + t, err := apiclient.Teams.GetTeamByID(id) if err != nil { return diag.FromErr(err) } diff --git a/zenduty/resource_user.go b/zenduty/resource_user.go index 629ddf6..7b61fe5 100644 --- a/zenduty/resource_user.go +++ b/zenduty/resource_user.go @@ -21,13 +21,13 @@ func resourceUser() *schema.Resource { }, Schema: map[string]*schema.Schema{ "team": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, ValidateDiagFunc: ValidateUUID(), }, "first_name": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateDiagFunc: ValidateRequired(), }, "last_name": { @@ -35,15 +35,15 @@ func resourceUser() *schema.Resource { Required: true, }, "email": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, ValidateDiagFunc: ValidateEmail(), }, "role": { - Type: schema.TypeInt, - Optional: true, + Type: schema.TypeInt, + Optional: true, ValidateFunc: validation.IntBetween(2, 3), - Default: 3, + Default: 3, }, }, } @@ -52,20 +52,20 @@ func resourceUser() *schema.Resource { func resourceCreateUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { team := d.Get("team").(string) - first_name := d.Get("first_name").(string) - last_name := d.Get("last_name").(string) + firstName := d.Get("first_name").(string) + lastName := d.Get("last_name").(string) if emptyString(team) { return diag.FromErr(errors.New("team is required")) } - if emptyString(last_name){ + if emptyString(lastName) { return diag.FromErr(errors.New("last_name is required")) } email := d.Get("email").(string) apiclient, _ := m.(*Config).Client() - new_user := &client.UserObj{First_Name: first_name, Last_Name: last_name, Email: email, Role: 3} - new_userobj := &client.CreateUser{Team: team, User: *new_user} + newUser := &client.UserObj{FirstName: firstName, LastName: lastName, Email: email, Role: 3} + newUserobj := &client.CreateUser{Team: team, User: *newUser} - user, err := apiclient.Users.CreateUser(new_userobj) + user, err := apiclient.Users.CreateUser(newUserobj) if err != nil { return diag.FromErr(err) } @@ -77,36 +77,36 @@ func resourceCreateUser(ctx context.Context, d *schema.ResourceData, m interface func resourceUpdateUser(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { role := d.Get("role").(int) - first_name := d.Get("first_name").(string) - last_name := d.Get("last_name").(string) + firstName := d.Get("first_name").(string) + lastName := d.Get("last_name").(string) email := d.Get("email").(string) apiclient, _ := m.(*Config).Client() - new_user := &client.UserObj{First_Name: first_name, Last_Name: last_name, Email: email, Role: role} - - user, err := apiclient.Users.UpdateUser(d.Id(),new_user) + newUser := &client.UserObj{FirstName: firstName, LastName: lastName, Email: email, Role: role} + + user, err := apiclient.Users.UpdateUser(d.Id(), newUser) if err != nil { return diag.FromErr(err) } d.SetId(user.User.Username) d.Set("role", user.Role) - d.Set("first_name", user.User.First_Name) - d.Set("last_name", user.User.Last_Name) + d.Set("first_name", user.User.FirstName) + d.Set("last_name", user.User.LastName) d.Set("email", user.User.Email) return nil } func resourceUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - apiclient, _ := m.(*Config).Client() + apiclient, _ := m.(*Config).Client() user, err := apiclient.Users.GetUser(d.Id()) if err != nil { return diag.FromErr(err) } d.SetId(user.User.Username) d.Set("role", user.Role) - d.Set("first_name", user.User.First_Name) - d.Set("last_name", user.User.Last_Name) + d.Set("first_name", user.User.FirstName) + d.Set("last_name", user.User.LastName) d.Set("email", user.User.Email) return nil }