Skip to content

Commit

Permalink
Reintroduce support for zendesk client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 29, 2023
1 parent 6ea5bcd commit ac73fd7
Show file tree
Hide file tree
Showing 9 changed files with 493 additions and 250 deletions.
9 changes: 9 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Read-Only:
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))
- `springcm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--springcm))
- `wams` (List of Object) (see [below for nested schema](#nestedobjatt--addons--wams))
- `zendesk` (List of Object) (see [below for nested schema](#nestedobjatt--addons--zendesk))

<a id="nestedobjatt--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -294,6 +295,14 @@ Read-Only:
- `master_key` (String)


<a id="nestedobjatt--addons--zendesk"></a>
### Nested Schema for `addons.zendesk`

Read-Only:

- `account_name` (String)



<a id="nestedatt--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
9 changes: 9 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Read-Only:
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))
- `springcm` (List of Object) (see [below for nested schema](#nestedobjatt--addons--springcm))
- `wams` (List of Object) (see [below for nested schema](#nestedobjatt--addons--wams))
- `zendesk` (List of Object) (see [below for nested schema](#nestedobjatt--addons--zendesk))

<a id="nestedobjatt--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -283,6 +284,14 @@ Read-Only:
- `master_key` (String)


<a id="nestedobjatt--addons--zendesk"></a>
### Nested Schema for `addons.zendesk`

Read-Only:

- `account_name` (String)



<a id="nestedatt--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
9 changes: 9 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Optional:
- `slack` (Block List, Max: 1) Slack team or workspace name usually first segment in your Slack URL, for example `https://acme-org.slack.com` would be `acme-org`. (see [below for nested schema](#nestedblock--addons--slack))
- `springcm` (Block List, Max: 1) SpringCM SSO configuration. (see [below for nested schema](#nestedblock--addons--springcm))
- `wams` (Block List, Max: 1) Windows Azure Mobile Services addon configuration. (see [below for nested schema](#nestedblock--addons--wams))
- `zendesk` (Block List, Max: 1) Zendesk SSO configuration. (see [below for nested schema](#nestedblock--addons--zendesk))

<a id="nestedblock--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -359,6 +360,14 @@ Optional:
- `master_key` (String, Sensitive) Your master key for Windows Azure Mobile Services.


<a id="nestedblock--addons--zendesk"></a>
### Nested Schema for `addons.zendesk`

Optional:

- `account_name` (String) Zendesk account name. Usually the first segment in your Zendesk URL, for example `https://acme-org.zendesk.com` would be `acme-org`.



<a id="nestedblock--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
9 changes: 9 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Optional:
- `slack` (Block List, Max: 1) Slack team or workspace name usually first segment in your Slack URL, for example `https://acme-org.slack.com` would be `acme-org`. (see [below for nested schema](#nestedblock--addons--slack))
- `springcm` (Block List, Max: 1) SpringCM SSO configuration. (see [below for nested schema](#nestedblock--addons--springcm))
- `wams` (Block List, Max: 1) Windows Azure Mobile Services addon configuration. (see [below for nested schema](#nestedblock--addons--wams))
- `zendesk` (Block List, Max: 1) Zendesk SSO configuration. (see [below for nested schema](#nestedblock--addons--zendesk))

<a id="nestedblock--addons--aws"></a>
### Nested Schema for `addons.aws`
Expand Down Expand Up @@ -302,6 +303,14 @@ Optional:
- `master_key` (String, Sensitive) Your master key for Windows Azure Mobile Services.


<a id="nestedblock--addons--zendesk"></a>
### Nested Schema for `addons.zendesk`

Optional:

- `account_name` (String) Zendesk account name. Usually the first segment in your Zendesk URL, for example `https://acme-org.zendesk.com` would be `acme-org`.



<a id="nestedblock--jwt_configuration"></a>
### Nested Schema for `jwt_configuration`
Expand Down
15 changes: 15 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.SharePoint = expandClientAddonSharepoint(addonsCfg.GetAttr("sharepoint"))
addons.SpringCM = expandClientAddonSpringCM(addonsCfg.GetAttr("springcm"))
addons.WAMS = expandClientAddonWAMS(addonsCfg.GetAttr("wams"))
addons.Zendesk = expandClientAddonZendesk(addonsCfg.GetAttr("zendesk"))
return stop
})

Expand Down Expand Up @@ -610,6 +611,20 @@ func expandClientAddonWAMS(wamsCfg cty.Value) *management.WAMSClientAddon {
return &wamsAddon
}

func expandClientAddonZendesk(zendeskCfg cty.Value) *management.ZendeskClientAddon {
var zendeskAddon management.ZendeskClientAddon

zendeskCfg.ForEachElement(func(_ cty.Value, zendeskCfg cty.Value) (stop bool) {
zendeskAddon = management.ZendeskClientAddon{
AccountName: value.String(zendeskCfg.GetAttr("account_name")),
}

return stop
})

return &zendeskAddon
}

func clientHasChange(c *management.Client) bool {
return c.String() != "{}"
}
9 changes: 9 additions & 0 deletions internal/auth0/client/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
"sharepoint": nil,
"springcm": nil,
"wams": nil,
"zendesk": nil,
}

if addons.GetAWS() != nil {
Expand Down Expand Up @@ -316,5 +317,13 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
}
}

if addons.GetZendesk() != nil {
m["zendesk"] = []interface{}{
map[string]interface{}{
"account_name": addons.GetZendesk().GetAccountName(),
},
}
}

return []interface{}{m}
}
17 changes: 17 additions & 0 deletions internal/auth0/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,23 @@ func NewResource() *schema.Resource {
},
},
},
"zendesk": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: "Zendesk SSO configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"account_name": {
Description: "Zendesk account name. Usually the first segment in your Zendesk URL, " +
"for example `https://acme-org.zendesk.com` would be `acme-org`.",
Type: schema.TypeString,
Optional: true,
},
},
},
},
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions internal/auth0/client/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,19 @@ resource "auth0_client" "my_client" {
}
`

const testAccUpdateClientWithAddonsZendesk = `
resource "auth0_client" "my_client" {
name = "Acceptance Test - SSO Integration - {{.testName}}"
app_type = "sso_integration"
addons {
zendesk {
account_name = "acmeorg"
}
}
}
`

func TestAccClientAddons(t *testing.T) {
acctest.Test(t, resource.TestCase{
Steps: []resource.TestStep{
Expand Down Expand Up @@ -1228,6 +1241,15 @@ func TestAccClientAddons(t *testing.T) {
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.wams.0.master_key", "master-key"),
),
},
{
Config: acctest.ParseTestName(testAccUpdateClientWithAddonsZendesk, t.Name()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_client.my_client", "name", fmt.Sprintf("Acceptance Test - SSO Integration - %s", t.Name())),
resource.TestCheckResourceAttr("auth0_client.my_client", "app_type", "sso_integration"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.#", "1"),
resource.TestCheckResourceAttr("auth0_client.my_client", "addons.0.zendesk.0.account_name", "acmeorg"),
),
},
},
})
}
Expand Down
Loading

0 comments on commit ac73fd7

Please sign in to comment.