Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/auth0_terraform_generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ auth0 terraform generate [flags]
```
--force Skip confirmation.
-o, --output-dir string Output directory for the generated Terraform config files. If not provided, the files will be saved in the current working directory. (default "./")
-r, --resources strings Resource types to generate Terraform config for. If not provided, config files for all available resources will be generated. (default [auth0_action,auth0_attack_protection,auth0_branding,auth0_phone_provider,auth0_client,auth0_client_grant,auth0_connection,auth0_custom_domain,auth0_flow,auth0_flow_vault_connection,auth0_form,auth0_email_provider,auth0_email_template,auth0_guardian,auth0_log_stream,auth0_network_acl,auth0_organization,auth0_pages,auth0_prompt,auth0_prompt_custom_text,auth0_prompt_screen_renderer,auth0_resource_server,auth0_role,auth0_self_service_profile,auth0_tenant,auth0_trigger_actions])
-r, --resources strings Resource types to generate Terraform config for. If not provided, config files for all available resources will be generated. (default [auth0_action,auth0_attack_protection,auth0_branding,auth0_phone_provider,auth0_client,auth0_client_grant,auth0_connection,auth0_custom_domain,auth0_flow,auth0_flow_vault_connection,auth0_form,auth0_email_provider,auth0_email_template,auth0_guardian,auth0_log_stream,auth0_network_acl,auth0_organization,auth0_pages,auth0_prompt,auth0_prompt_custom_text,auth0_prompt_screen_renderer,auth0_resource_server,auth0_role,auth0_self_service_profile,auth0_tenant,auth0_trigger_actions,auth0_user_attribute_profile])
-v, --tf-version string Terraform version that ought to be used while generating the terraform files for resources. If not provided, 1.5.0 is used by default (default "1.5.0")
```

Expand Down
112 changes: 57 additions & 55 deletions internal/auth0/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,69 @@ import (
// API mimics `management.Management`s general interface, except it refers to
// the interfaces instead of the concrete structs.
type API struct {
Action ActionAPI
Anomaly AnomalyAPI
AttackProtection AttackProtectionAPI
Branding BrandingAPI
BrandingTheme BrandingThemeAPI
Client ClientAPI
ClientGrant ClientGrantAPI
Connection ConnectionAPI
CustomDomain CustomDomainAPI
EmailTemplate EmailTemplateAPI
EmailProvider EmailProviderAPI
EventStream EventStreamAPI
Flow FlowAPI
FlowVaultConnection FlowVaultConnectionAPI
Form FormAPI
Log LogAPI
LogStream LogStreamAPI
Organization OrganizationAPI
NetworkACL NetworkACLAPI
Prompt PromptAPI
ResourceServer ResourceServerAPI
Role RoleAPI
Rule RuleAPI
Tenant TenantAPI
User UserAPI
Jobs JobsAPI
SelfServiceProfile SelfServiceProfileAPI
Action ActionAPI
Anomaly AnomalyAPI
AttackProtection AttackProtectionAPI
Branding BrandingAPI
BrandingTheme BrandingThemeAPI
Client ClientAPI
ClientGrant ClientGrantAPI
Connection ConnectionAPI
CustomDomain CustomDomainAPI
EmailTemplate EmailTemplateAPI
EmailProvider EmailProviderAPI
EventStream EventStreamAPI
Flow FlowAPI
FlowVaultConnection FlowVaultConnectionAPI
Form FormAPI
Log LogAPI
LogStream LogStreamAPI
Organization OrganizationAPI
NetworkACL NetworkACLAPI
Prompt PromptAPI
ResourceServer ResourceServerAPI
Role RoleAPI
Rule RuleAPI
Tenant TenantAPI
User UserAPI
Jobs JobsAPI
SelfServiceProfile SelfServiceProfileAPI
UserAttributeProfile UserAttributeProfilesAPI

HTTPClient HTTPClientAPI
}

func NewAPI(m *management.Management) *API {
return &API{
Action: m.Action,
Anomaly: m.Anomaly,
AttackProtection: m.AttackProtection,
Branding: m.Branding,
BrandingTheme: m.BrandingTheme,
Client: m.Client,
ClientGrant: m.ClientGrant,
Connection: m.Connection,
CustomDomain: m.CustomDomain,
EmailTemplate: m.EmailTemplate,
EmailProvider: m.EmailProvider,
EventStream: m.EventStream,
Flow: m.Flow,
FlowVaultConnection: m.Flow.Vault,
Form: m.Form,
Log: m.Log,
LogStream: m.LogStream,
Organization: m.Organization,
NetworkACL: m.NetworkACL,
Prompt: m.Prompt,
ResourceServer: m.ResourceServer,
Role: m.Role,
Rule: m.Rule,
Tenant: m.Tenant,
User: m.User,
Jobs: m.Job,
SelfServiceProfile: m.SelfServiceProfile,
HTTPClient: m,
Action: m.Action,
Anomaly: m.Anomaly,
AttackProtection: m.AttackProtection,
Branding: m.Branding,
BrandingTheme: m.BrandingTheme,
Client: m.Client,
ClientGrant: m.ClientGrant,
Connection: m.Connection,
CustomDomain: m.CustomDomain,
EmailTemplate: m.EmailTemplate,
EmailProvider: m.EmailProvider,
EventStream: m.EventStream,
Flow: m.Flow,
FlowVaultConnection: m.Flow.Vault,
Form: m.Form,
Log: m.Log,
LogStream: m.LogStream,
Organization: m.Organization,
NetworkACL: m.NetworkACL,
Prompt: m.Prompt,
ResourceServer: m.ResourceServer,
Role: m.Role,
Rule: m.Rule,
Tenant: m.Tenant,
User: m.User,
Jobs: m.Job,
SelfServiceProfile: m.SelfServiceProfile,
UserAttributeProfile: m.UserAttributeProfile,
HTTPClient: m,
}
}

Expand Down
173 changes: 173 additions & 0 deletions internal/auth0/mock/user_attribute_profiles.go

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

25 changes: 25 additions & 0 deletions internal/auth0/user_attribute_profiles.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:generate mockgen -source=user_attribute_profiles.go -destination=mock/user_attribute_profiles.go -package=mock

package auth0

import (
"context"

"github.com/auth0/go-auth0/management"
)

type UserAttributeProfilesAPI interface {
Create(ctx context.Context, p *management.UserAttributeProfile, opts ...management.RequestOption) error

List(ctx context.Context, opts ...management.RequestOption) (p *management.UserAttributeProfileList, err error)

Read(ctx context.Context, id string, opts ...management.RequestOption) (p *management.UserAttributeProfile, err error)

Update(ctx context.Context, id string, p *management.UserAttributeProfile, opts ...management.RequestOption) error

Delete(ctx context.Context, id string, opts ...management.RequestOption) error

ListTemplates(ctx context.Context, opts ...management.RequestOption) (p *management.UserAttributeProfileTemplateList, err error)

GetTemplate(ctx context.Context, id string, opts ...management.RequestOption) (p *management.UserAttributeProfileTemplateItem, err error)
}
2 changes: 2 additions & 0 deletions internal/cli/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func (i *terraformInputs) parseResourceFetchers(api *auth0.API) ([]resourceDataF
fetchers = append(fetchers, &tenantResourceFetcher{})
case "auth0_trigger_actions":
fetchers = append(fetchers, &triggerActionsResourceFetcher{api})
case "auth0_user_attribute_profile":
fetchers = append(fetchers, &userAttributeProfilesResourceFetcher{api})
default:
err = errors.Join(err, fmt.Errorf("unsupported resource type: %s", resource))
}
Expand Down
33 changes: 32 additions & 1 deletion internal/cli/terraform_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var (
defaultResources = []string{"auth0_action", "auth0_attack_protection", "auth0_branding", "auth0_phone_provider", "auth0_client", "auth0_client_grant", "auth0_connection", "auth0_custom_domain", "auth0_flow", "auth0_flow_vault_connection", "auth0_form", "auth0_email_provider", "auth0_email_template", "auth0_guardian", "auth0_log_stream", "auth0_network_acl", "auth0_organization", "auth0_pages", "auth0_prompt", "auth0_prompt_custom_text", "auth0_prompt_screen_renderer", "auth0_resource_server", "auth0_role", "auth0_self_service_profile", "auth0_tenant", "auth0_trigger_actions"}
defaultResources = []string{"auth0_action", "auth0_attack_protection", "auth0_branding", "auth0_phone_provider", "auth0_client", "auth0_client_grant", "auth0_connection", "auth0_custom_domain", "auth0_flow", "auth0_flow_vault_connection", "auth0_form", "auth0_email_provider", "auth0_email_template", "auth0_guardian", "auth0_log_stream", "auth0_network_acl", "auth0_organization", "auth0_pages", "auth0_prompt", "auth0_prompt_custom_text", "auth0_prompt_screen_renderer", "auth0_resource_server", "auth0_role", "auth0_self_service_profile", "auth0_tenant", "auth0_trigger_actions", "auth0_user_attribute_profile"}
)

type (
Expand Down Expand Up @@ -116,6 +116,10 @@ type (
triggerActionsResourceFetcher struct {
api *auth0.API
}

userAttributeProfilesResourceFetcher struct {
api *auth0.API
}
)

func (f *attackProtectionResourceFetcher) FetchData(_ context.Context) (importDataList, error) {
Expand Down Expand Up @@ -688,6 +692,33 @@ func (f *triggerActionsResourceFetcher) FetchData(ctx context.Context) (importDa
return data, nil
}

func (f *userAttributeProfilesResourceFetcher) FetchData(ctx context.Context) (importDataList, error) {
var data importDataList

from := ""
for {
profiles, err := f.api.UserAttributeProfile.List(ctx, management.From(from))
if err != nil {
return nil, err
}

for _, profile := range profiles.UserAttributeProfiles {
data = append(data, importDataItem{
ResourceName: "auth0_user_attribute_profile." + sanitizeResourceName(profile.GetName()),
ImportID: profile.GetID(),
})
}

if !profiles.HasNext() {
break
}

from = profiles.Next
}

return data, nil
}

func (f *actionResourceFetcher) FetchData(ctx context.Context) (importDataList, error) {
var data importDataList

Expand Down
Loading
Loading