From ebe182466c3dd15a9277ae47c00639e3e9edc1de Mon Sep 17 00:00:00 2001 From: Christopher Nellis Date: Wed, 11 Dec 2024 02:50:24 -0500 Subject: [PATCH] Update expand and flatten files for connection object --- internal/auth0/connection/expand.go | 38 ++++++++++++++++++++++++++++ internal/auth0/connection/flatten.go | 1 + 2 files changed, 39 insertions(+) diff --git a/internal/auth0/connection/expand.go b/internal/auth0/connection/expand.go index b26dbbd8..c46b4705 100644 --- a/internal/auth0/connection/expand.go +++ b/internal/auth0/connection/expand.go @@ -180,6 +180,43 @@ func expandConnectionOptionsGitHub(data *schema.ResourceData, config cty.Value) return options, diag.FromErr(err) } +func expandConnectionOptionsAuthenticationMethods(config cty.Value) *management.AuthenticationMethods { + var authMethods *management.AuthenticationMethods + config.ForEachElement( + func(_ cty.Value, attributes cty.Value) (stop bool) { + authMethods = &management.AuthenticationMethods{ + Password: expandConnectionOptionsAuthenticationMethodsPassword(attributes), + Passkey: expandConnectionOptionsAuthenticationMethodsPasskey(attributes), + } + return stop + }) + return authMethods +} + +func expandConnectionOptionsAuthenticationMethodsPassword(config cty.Value) *management.PasswordAuthenticationMethod { + var passwordAuth *management.PasswordAuthenticationMethod + config.ForEachElement( + func(_ cty.Value, attributes cty.Value) (stop bool) { + passwordAuth = &management.PasswordAuthenticationMethod{ + Enabled: value.Bool(config.GetAttr("enabled")), + } + return stop + }) + return passwordAuth +} + +func expandConnectionOptionsAuthenticationMethodsPasskey(config cty.Value) *management.PasskeyAuthenticationMethod { + var passwordAuth *management.PasskeyAuthenticationMethod + config.ForEachElement( + func(_ cty.Value, attributes cty.Value) (stop bool) { + passwordAuth = &management.PasskeyAuthenticationMethod{ + Enabled: value.Bool(config.GetAttr("enabled")), + } + return stop + }) + return passwordAuth +} + func expandConnectionOptionsAttributes(config cty.Value) *management.ConnectionOptionsAttributes { var coa *management.ConnectionOptionsAttributes config.ForEachElement( @@ -330,6 +367,7 @@ func expandConnectionOptionsAuth0(_ *schema.ResourceData, config cty.Value) (int Precedence: value.Strings(config.GetAttr("precedence")), Attributes: expandConnectionOptionsAttributes(config.GetAttr("attributes")), StrategyVersion: value.Int(config.GetAttr("strategy_version")), + AuthenticationMethods: expandConnectionOptionsAuthenticationMethods(config.GetAttr("authentication_methods")), } config.GetAttr("validation").ForEachElement( diff --git a/internal/auth0/connection/flatten.go b/internal/auth0/connection/flatten.go index 4d97e315..48675aa3 100644 --- a/internal/auth0/connection/flatten.go +++ b/internal/auth0/connection/flatten.go @@ -324,6 +324,7 @@ func flattenConnectionOptionsAuth0( "upstream_params": upstreamParams, "precedence": options.GetPrecedence(), "strategy_version": options.GetStrategyVersion(), + "authentication_methods": options.GetAuthenticationMethods(), } if options.Attributes != nil {