Skip to content

Commit

Permalink
Reintroduce support for salesforce client addon
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Jun 29, 2023
1 parent ed2627f commit 4a131d4
Show file tree
Hide file tree
Showing 9 changed files with 715 additions and 225 deletions.
33 changes: 33 additions & 0 deletions docs/data-sources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Read-Only:
- `newrelic` (List of Object) (see [below for nested schema](#nestedobjatt--addons--newrelic))
- `office365` (List of Object) (see [below for nested schema](#nestedobjatt--addons--office365))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `salesforce` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce))
- `salesforce_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce_api))
- `salesforce_sandbox_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce_sandbox_api))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))

Expand Down Expand Up @@ -189,6 +192,36 @@ Read-Only:
- `url` (String)


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

Read-Only:

- `entity_id` (String)


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

Read-Only:

- `client_id` (String)
- `community_name` (String)
- `community_url_section` (String)
- `principal` (String)


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

Read-Only:

- `client_id` (String)
- `community_name` (String)
- `community_url_section` (String)
- `principal` (String)


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

Expand Down
33 changes: 33 additions & 0 deletions docs/data-sources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ Read-Only:
- `newrelic` (List of Object) (see [below for nested schema](#nestedobjatt--addons--newrelic))
- `office365` (List of Object) (see [below for nested schema](#nestedobjatt--addons--office365))
- `rms` (List of Object) (see [below for nested schema](#nestedobjatt--addons--rms))
- `salesforce` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce))
- `salesforce_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce_api))
- `salesforce_sandbox_api` (List of Object) (see [below for nested schema](#nestedobjatt--addons--salesforce_sandbox_api))
- `sentry` (List of Object) (see [below for nested schema](#nestedobjatt--addons--sentry))
- `slack` (List of Object) (see [below for nested schema](#nestedobjatt--addons--slack))

Expand Down Expand Up @@ -178,6 +181,36 @@ Read-Only:
- `url` (String)


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

Read-Only:

- `entity_id` (String)


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

Read-Only:

- `client_id` (String)
- `community_name` (String)
- `community_url_section` (String)
- `principal` (String)


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

Read-Only:

- `client_id` (String)
- `community_name` (String)
- `community_url_section` (String)
- `principal` (String)


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

Expand Down
33 changes: 33 additions & 0 deletions docs/resources/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ Optional:
- `newrelic` (Block List, Max: 1) New Relic SSO configuration. (see [below for nested schema](#nestedblock--addons--newrelic))
- `office365` (Block List, Max: 1) Microsoft Office 365 SSO configuration. (see [below for nested schema](#nestedblock--addons--office365))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `salesforce` (Block List, Max: 1) Salesforce SSO configuration. (see [below for nested schema](#nestedblock--addons--salesforce))
- `salesforce_api` (Block List, Max: 1) Salesforce API addon configuration. (see [below for nested schema](#nestedblock--addons--salesforce_api))
- `salesforce_sandbox_api` (Block List, Max: 1) Salesforce Sandbox addon configuration. (see [below for nested schema](#nestedblock--addons--salesforce_sandbox_api))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `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))

Expand Down Expand Up @@ -251,6 +254,36 @@ Optional:
- `url` (String) URL of your Rights Management Server. It can be internal or external, but users will have to be able to reach it.


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

Optional:

- `entity_id` (String) Arbitrary logical URL that identifies the Saleforce resource, for example `https://acme-org.com`.


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

Optional:

- `client_id` (String, Sensitive) Consumer Key assigned by Salesforce to the Connected App.
- `community_name` (String) Community name.
- `community_url_section` (String) Community URL section.
- `principal` (String, Sensitive) Name of the property in the user object that maps to a Salesforce username, for example `email`.


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

Optional:

- `client_id` (String, Sensitive) Consumer Key assigned by Salesforce to the Connected App.
- `community_name` (String) Community name.
- `community_url_section` (String) Community URL section.
- `principal` (String, Sensitive) Name of the property in the user object that maps to a Salesforce username, for example `email`.


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

Expand Down
33 changes: 33 additions & 0 deletions docs/resources/global_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Optional:
- `newrelic` (Block List, Max: 1) New Relic SSO configuration. (see [below for nested schema](#nestedblock--addons--newrelic))
- `office365` (Block List, Max: 1) Microsoft Office 365 SSO configuration. (see [below for nested schema](#nestedblock--addons--office365))
- `rms` (Block List, Max: 1) Active Directory Rights Management Service SSO configuration. (see [below for nested schema](#nestedblock--addons--rms))
- `salesforce` (Block List, Max: 1) Salesforce SSO configuration. (see [below for nested schema](#nestedblock--addons--salesforce))
- `salesforce_api` (Block List, Max: 1) Salesforce API addon configuration. (see [below for nested schema](#nestedblock--addons--salesforce_api))
- `salesforce_sandbox_api` (Block List, Max: 1) Salesforce Sandbox addon configuration. (see [below for nested schema](#nestedblock--addons--salesforce_sandbox_api))
- `sentry` (Block List, Max: 1) Sentry SSO configuration. (see [below for nested schema](#nestedblock--addons--sentry))
- `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))

Expand Down Expand Up @@ -194,6 +197,36 @@ Optional:
- `url` (String) URL of your Rights Management Server. It can be internal or external, but users will have to be able to reach it.


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

Optional:

- `entity_id` (String) Arbitrary logical URL that identifies the Saleforce resource, for example `https://acme-org.com`.


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

Optional:

- `client_id` (String, Sensitive) Consumer Key assigned by Salesforce to the Connected App.
- `community_name` (String) Community name.
- `community_url_section` (String) Community URL section.
- `principal` (String, Sensitive) Name of the property in the user object that maps to a Salesforce username, for example `email`.


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

Optional:

- `client_id` (String, Sensitive) Consumer Key assigned by Salesforce to the Connected App.
- `community_name` (String) Community name.
- `community_url_section` (String) Community URL section.
- `principal` (String, Sensitive) Name of the property in the user object that maps to a Salesforce username, for example `email`.


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

Expand Down
51 changes: 51 additions & 0 deletions internal/auth0/client/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ func expandClientAddons(d *schema.ResourceData) *management.ClientAddons {
addons.Firebase = expandClientAddonFirebase(addonsCfg.GetAttr("firebase"))
addons.NewRelic = expandClientAddonNewRelic(addonsCfg.GetAttr("newrelic"))
addons.Office365 = expandClientAddonOffice365(addonsCfg.GetAttr("office365"))
addons.Salesforce = expandClientAddonSalesforce(addonsCfg.GetAttr("salesforce"))
addons.SalesforceAPI = expandClientAddonSalesforceAPI(addonsCfg.GetAttr("salesforce_api"))
addons.SalesforceSandboxAPI = expandClientAddonSalesforceSandboxAPI(addonsCfg.GetAttr("salesforce_sandbox_api"))
return stop
})

Expand Down Expand Up @@ -470,6 +473,54 @@ func expandClientAddonOffice365(office365Cfg cty.Value) *management.Office365Cli
return &office365Addon
}

func expandClientAddonSalesforce(salesforceCfg cty.Value) *management.SalesforceClientAddon {
var salesforceAddon management.SalesforceClientAddon

salesforceCfg.ForEachElement(func(_ cty.Value, salesforceCfg cty.Value) (stop bool) {
salesforceAddon = management.SalesforceClientAddon{
EntityID: value.String(salesforceCfg.GetAttr("entity_id")),
}

return stop
})

return &salesforceAddon
}

func expandClientAddonSalesforceAPI(salesforceCfg cty.Value) *management.SalesforceAPIClientAddon {
var salesforceAddon management.SalesforceAPIClientAddon

salesforceCfg.ForEachElement(func(_ cty.Value, salesforceCfg cty.Value) (stop bool) {
salesforceAddon = management.SalesforceAPIClientAddon{
ClientID: value.String(salesforceCfg.GetAttr("client_id")),
Principal: value.String(salesforceCfg.GetAttr("principal")),
CommunityName: value.String(salesforceCfg.GetAttr("community_name")),
CommunityURLSection: value.String(salesforceCfg.GetAttr("community_url_section")),
}

return stop
})

return &salesforceAddon
}

func expandClientAddonSalesforceSandboxAPI(salesforceCfg cty.Value) *management.SalesforceSandboxAPIClientAddon {
var salesforceAddon management.SalesforceSandboxAPIClientAddon

salesforceCfg.ForEachElement(func(_ cty.Value, salesforceCfg cty.Value) (stop bool) {
salesforceAddon = management.SalesforceSandboxAPIClientAddon{
ClientID: value.String(salesforceCfg.GetAttr("client_id")),
Principal: value.String(salesforceCfg.GetAttr("principal")),
CommunityName: value.String(salesforceCfg.GetAttr("community_name")),
CommunityURLSection: value.String(salesforceCfg.GetAttr("community_url_section")),
}

return stop
})

return &salesforceAddon
}

func clientHasChange(c *management.Client) bool {
return c.String() != "{}"
}
55 changes: 44 additions & 11 deletions internal/auth0/client/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,20 @@ func flattenClientAddons(addons *management.ClientAddons) []interface{} {
}

m := map[string]interface{}{
"aws": nil,
"azure_blob": nil,
"azure_sb": nil,
"rms": nil,
"mscrm": nil,
"slack": nil,
"sentry": nil,
"echosign": nil,
"egnyte": nil,
"firebase": nil,
"office365": nil,
"aws": nil,
"azure_blob": nil,
"azure_sb": nil,
"rms": nil,
"mscrm": nil,
"slack": nil,
"sentry": nil,
"echosign": nil,
"egnyte": nil,
"firebase": nil,
"office365": nil,
"salesforce": nil,
"salesforce_api": nil,
"salesforce_sandbox_api": nil,
}

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

if addons.GetSalesforce() != nil {
m["salesforce"] = []interface{}{
map[string]interface{}{
"entity_id": addons.GetSalesforce().GetEntityID(),
},
}
}

if addons.GetSalesforceAPI() != nil {
m["salesforce_api"] = []interface{}{
map[string]interface{}{
"client_id": addons.GetSalesforceAPI().GetClientID(),
"principal": addons.GetSalesforceAPI().GetPrincipal(),
"community_name": addons.GetSalesforceAPI().GetCommunityName(),
"community_url_section": addons.GetSalesforceAPI().GetCommunityURLSection(),
},
}
}

if addons.GetSalesforceSandboxAPI() != nil {
m["salesforce_sandbox_api"] = []interface{}{
map[string]interface{}{
"client_id": addons.GetSalesforceSandboxAPI().GetClientID(),
"principal": addons.GetSalesforceSandboxAPI().GetPrincipal(),
"community_name": addons.GetSalesforceSandboxAPI().GetCommunityName(),
"community_url_section": addons.GetSalesforceSandboxAPI().GetCommunityURLSection(),
},
}
}

return []interface{}{m}
}
Loading

0 comments on commit 4a131d4

Please sign in to comment.