From 6e923b371326956fccb37dd8e6a3a655009124fb Mon Sep 17 00:00:00 2001 From: Tien Nguyen Date: Fri, 9 Feb 2024 13:44:09 -0500 Subject: [PATCH] upgrade to sdk v4 and fix the enum issue that inhibit the creation process --- go.mod | 2 +- go.sum | 4 +- okta/brand.go | 2 +- okta/config.go | 2 +- okta/customization.go | 6 +-- okta/data_source_okta_auth_server_scopes.go | 2 +- okta/data_source_okta_brand.go | 2 +- okta/data_source_okta_email_template.go | 2 +- okta/data_source_okta_email_templates.go | 2 +- okta/data_source_okta_log_stream.go | 2 +- okta/email_customization.go | 2 +- okta/email_template.go | 2 +- okta/provider_sweeper_test.go | 2 +- okta/provider_test.go | 2 +- ...ource_okta_app_access_policy_assignment.go | 2 +- okta/resource_okta_auth_server_scope.go | 14 ++----- okta/resource_okta_brand.go | 2 +- okta/resource_okta_domain.go | 10 ++--- okta/resource_okta_email_customization.go | 2 +- okta/resource_okta_email_domain.go | 2 +- okta/resource_okta_log_stream.go | 14 +++---- ...okta_policy_device_assurance_android_os.go | 22 ++++------ ...kta_policy_device_assurance_chromeos_os.go | 22 +++------- ...rce_okta_policy_device_assurance_ios_os.go | 14 +++---- ...e_okta_policy_device_assurance_macos_os.go | 40 +++++-------------- ...okta_policy_device_assurance_windows_os.go | 38 +++++------------- okta/resource_okta_theme.go | 22 +++++----- okta/theme.go | 2 +- okta/utils.go | 2 +- 29 files changed, 81 insertions(+), 161 deletions(-) diff --git a/go.mod b/go.mod index 1858920d4..7e12f8ee5 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 github.com/jarcoal/httpmock v1.3.1 github.com/kelseyhightower/envconfig v1.4.0 - github.com/okta/okta-sdk-golang/v3 v3.0.19 + github.com/okta/okta-sdk-golang/v4 v4.0.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/stretchr/testify v1.8.4 gopkg.in/dnaeon/go-vcr.v3 v3.1.2 diff --git a/go.sum b/go.sum index cf5fefa9e..fc92ff8d0 100644 --- a/go.sum +++ b/go.sum @@ -173,8 +173,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= 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/okta/okta-sdk-golang/v3 v3.0.19 h1:xedRIGAJ3j89JgE9TSgKjtiN/CNKTTTPqURVDLuMfrI= -github.com/okta/okta-sdk-golang/v3 v3.0.19/go.mod h1:G9c5Rn6odsHI6XSC6PBa91Z5CicB8dv8zOfceeTRaWA= +github.com/okta/okta-sdk-golang/v4 v4.0.0 h1:XwIy1WxIUJJd63q5ObFuJgfxRosXNF++yjXPyay2/4c= +github.com/okta/okta-sdk-golang/v4 v4.0.0/go.mod h1:IIYXqbNgAg3IOuSidey7NJkkg8Ozb1x5QHQTKMZfeHo= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= diff --git a/okta/brand.go b/okta/brand.go index cf530371d..b80463c78 100644 --- a/okta/brand.go +++ b/okta/brand.go @@ -6,7 +6,7 @@ import ( "errors" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) var brandDataSourceSchema = map[string]*schema.Schema{ diff --git a/okta/config.go b/okta/config.go index a87ddf75a..138264a9e 100644 --- a/okta/config.go +++ b/okta/config.go @@ -18,7 +18,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" "github.com/okta/terraform-provider-okta/okta/internal/apimutex" "github.com/okta/terraform-provider-okta/okta/internal/transport" "github.com/okta/terraform-provider-okta/sdk" diff --git a/okta/customization.go b/okta/customization.go index e5af90872..3aa68441b 100644 --- a/okta/customization.go +++ b/okta/customization.go @@ -8,7 +8,7 @@ import ( resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) type signinPageModel struct { @@ -96,7 +96,7 @@ func mapSignInPageToState(ctx context.Context, data *okta.SignInPage, state *sig widgetCustomizations.AuthenticatorPageCustomLinkLabel = types.StringPointerValue(customization.AuthenticatorPageCustomLinkLabel) widgetCustomizations.AuthenticatorPageCustomLinkURL = types.StringPointerValue(customization.AuthenticatorPageCustomLinkUrl) widgetCustomizations.ClassicRecoveryFlowEmailOrUsernameLabel = types.StringPointerValue(customization.ClassicRecoveryFlowEmailOrUsernameLabel) - widgetCustomizations.WidgetGeneration = types.StringPointerValue((*string)(customization.WidgetGeneration.Ptr())) + widgetCustomizations.WidgetGeneration = types.StringPointerValue(customization.WidgetGeneration) } customizationValue, diags := types.ObjectValueFrom(ctx, state.WidgetCustomizations.AttributeTypes(ctx), widgetCustomizations) if diags.HasError() { @@ -136,7 +136,7 @@ func buildSignInPageRequest(ctx context.Context, model signinPageModel) (okta.Si wc.AuthenticatorPageCustomLinkLabel = wcm.AuthenticatorPageCustomLinkLabel.ValueStringPointer() wc.AuthenticatorPageCustomLinkUrl = wcm.AuthenticatorPageCustomLinkURL.ValueStringPointer() wc.ClassicRecoveryFlowEmailOrUsernameLabel = wcm.ClassicRecoveryFlowEmailOrUsernameLabel.ValueStringPointer() - wc.SetWidgetGeneration(okta.WidgetGeneration(wcm.WidgetGeneration.ValueString())) + wc.SetWidgetGeneration(wcm.WidgetGeneration.ValueString()) sp.SetWidgetCustomizations(wc) return sp, nil diff --git a/okta/data_source_okta_auth_server_scopes.go b/okta/data_source_okta_auth_server_scopes.go index c14c33bc3..9be6a2538 100644 --- a/okta/data_source_okta_auth_server_scopes.go +++ b/okta/data_source_okta_auth_server_scopes.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func dataSourceAuthServerScopes() *schema.Resource { diff --git a/okta/data_source_okta_brand.go b/okta/data_source_okta_brand.go index 70da463b7..a7fb00120 100644 --- a/okta/data_source_okta_brand.go +++ b/okta/data_source_okta_brand.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func dataSourceBrand() *schema.Resource { diff --git a/okta/data_source_okta_email_template.go b/okta/data_source_okta_email_template.go index 09016b2b5..1ec0cc89d 100644 --- a/okta/data_source_okta_email_template.go +++ b/okta/data_source_okta_email_template.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func dataSourceEmailTemplate() *schema.Resource { diff --git a/okta/data_source_okta_email_templates.go b/okta/data_source_okta_email_templates.go index 420ddcb19..c2ddcf59f 100644 --- a/okta/data_source_okta_email_templates.go +++ b/okta/data_source_okta_email_templates.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func dataSourceEmailTemplates() *schema.Resource { diff --git a/okta/data_source_okta_log_stream.go b/okta/data_source_okta_log_stream.go index 8b8c04080..fce3edf03 100644 --- a/okta/data_source_okta_log_stream.go +++ b/okta/data_source_okta_log_stream.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func NewLogStreamDataSource() datasource.DataSource { diff --git a/okta/email_customization.go b/okta/email_customization.go index fff81bc8a..6b18c8914 100644 --- a/okta/email_customization.go +++ b/okta/email_customization.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) var emailCustomizationsDataSourceSchema = map[string]*schema.Schema{ diff --git a/okta/email_template.go b/okta/email_template.go index 8b09b5443..3082d2493 100644 --- a/okta/email_template.go +++ b/okta/email_template.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) var emailTemplatesDataSourceSchema = map[string]*schema.Schema{ diff --git a/okta/provider_sweeper_test.go b/okta/provider_sweeper_test.go index ef6bb72c3..ee17e8f98 100644 --- a/okta/provider_sweeper_test.go +++ b/okta/provider_sweeper_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" "github.com/okta/terraform-provider-okta/sdk" "github.com/okta/terraform-provider-okta/sdk/query" ) diff --git a/okta/provider_test.go b/okta/provider_test.go index 579089273..5bf9b5933 100644 --- a/okta/provider_test.go +++ b/okta/provider_test.go @@ -26,7 +26,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" "github.com/okta/terraform-provider-okta/sdk" "gopkg.in/dnaeon/go-vcr.v3/cassette" "gopkg.in/dnaeon/go-vcr.v3/recorder" diff --git a/okta/resource_okta_app_access_policy_assignment.go b/okta/resource_okta_app_access_policy_assignment.go index a6a665590..ce383a96d 100644 --- a/okta/resource_okta_app_access_policy_assignment.go +++ b/okta/resource_okta_app_access_policy_assignment.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) // Ensure the implementation satisfies the expected interfaces. diff --git a/okta/resource_okta_auth_server_scope.go b/okta/resource_okta_auth_server_scope.go index f6f19c51d..4b964e43e 100644 --- a/okta/resource_okta_auth_server_scope.go +++ b/okta/resource_okta_auth_server_scope.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func resourceAuthServerScope() *schema.Resource { @@ -126,19 +126,11 @@ func resourceAuthServerScopeDelete(ctx context.Context, d *schema.ResourceData, func buildAuthServerScope(d *schema.ResourceData) (okta.OAuth2Scope, error) { scope := okta.OAuth2Scope{} if consent, ok := d.GetOk("consent"); ok { - consentStr, err := okta.NewOAuth2ScopeConsentTypeFromValue(consent.(string)) - if err != nil { - return okta.OAuth2Scope{}, err - } - scope.SetConsent(*consentStr) + scope.SetConsent(consent.(string)) } scope.SetDescription(d.Get("description").(string)) if metadataPublish, ok := d.GetOk("metadata_publish"); ok { - metadataPublishStr, err := okta.NewOAuth2ScopeMetadataPublishFromValue(metadataPublish.(string)) - if err != nil { - return okta.OAuth2Scope{}, err - } - scope.SetMetadataPublish(*metadataPublishStr) + scope.SetMetadataPublish(metadataPublish.(string)) } scope.SetName(d.Get("name").(string)) scope.SetDisplayName(d.Get("display_name").(string)) diff --git a/okta/resource_okta_brand.go b/okta/resource_okta_brand.go index 3af47e97c..97a5603c5 100644 --- a/okta/resource_okta_brand.go +++ b/okta/resource_okta_brand.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func NewBrandResource() resource.Resource { diff --git a/okta/resource_okta_domain.go b/okta/resource_okta_domain.go index 7301a35fc..8d9b7b492 100644 --- a/okta/resource_okta_domain.go +++ b/okta/resource_okta_domain.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func resourceDomain() *schema.Resource { @@ -132,7 +132,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, m interface if err != nil { return diag.Errorf("failed to set DNS records: %v", err) } - if domain.GetValidationStatus() == okta.DOMAINVALIDATIONSTATUS_COMPLETED || domain.GetValidationStatus() == okta.DOMAINVALIDATIONSTATUS_IN_PROGRESS || domain.GetValidationStatus() == okta.DOMAINVALIDATIONSTATUS_COMPLETED { + if domain.GetValidationStatus() == "IN_PROGRESS" || domain.GetValidationStatus() == "VERIFIED" || domain.GetValidationStatus() == "COMPLETED" { return nil } @@ -172,12 +172,8 @@ func validateDomain(ctx context.Context, d *schema.ResourceData, m interface{}, } func buildDomain(d *schema.ResourceData) (okta.DomainRequest, error) { - certSourceType, err := okta.NewDomainCertificateSourceTypeFromValue(d.Get("certificate_source_type").(string)) - if err != nil { - return okta.DomainRequest{}, err - } return okta.DomainRequest{ Domain: d.Get("name").(string), - CertificateSourceType: *certSourceType, + CertificateSourceType: (d.Get("certificate_source_type").(string)), }, nil } diff --git a/okta/resource_okta_email_customization.go b/okta/resource_okta_email_customization.go index 111d550bc..6362ecc2c 100644 --- a/okta/resource_okta_email_customization.go +++ b/okta/resource_okta_email_customization.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func resourceEmailCustomization() *schema.Resource { diff --git a/okta/resource_okta_email_domain.go b/okta/resource_okta_email_domain.go index 26070d4aa..04436fc06 100644 --- a/okta/resource_okta_email_domain.go +++ b/okta/resource_okta_email_domain.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func resourceEmailDomain() *schema.Resource { diff --git a/okta/resource_okta_log_stream.go b/okta/resource_okta_log_stream.go index 55b924ba2..981fb2043 100644 --- a/okta/resource_okta_log_stream.go +++ b/okta/resource_okta_log_stream.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) const ( @@ -410,7 +410,7 @@ func buildLogStreamCreateBody(ctx context.Context, m *logStreamModel) *okta.List Id: m.ID.ValueString(), Name: m.Name.ValueString(), Status: m.Status.ValueString(), - Type: okta.LogStreamType(m.Type.ValueString()), + Type: m.Type.ValueString(), } settings := &logStreamSettingsModel{} @@ -421,7 +421,7 @@ func buildLogStreamCreateBody(ctx context.Context, m *logStreamModel) *okta.List var settingAws okta.LogStreamSettingsAws settingAws.AccountId = settings.AccountID.ValueString() settingAws.EventSourceName = settings.EventSourceName.ValueString() - settingAws.Region = okta.AwsRegion(settings.Region.ValueString()) + settingAws.Region = settings.Region.ValueString() return &okta.ListLogStreams200ResponseInner{ LogStreamAws: &okta.LogStreamAws{ LogStream: ls, @@ -430,7 +430,7 @@ func buildLogStreamCreateBody(ctx context.Context, m *logStreamModel) *okta.List } case logStreamTypeSplunk: var settingSplunk okta.LogStreamSettingsSplunk - settingSplunk.Edition = okta.SplunkEdition(settings.Edition.ValueString()) + settingSplunk.Edition = settings.Edition.ValueString() settingSplunk.Host = settings.Host.ValueString() settingSplunk.Token = settings.Token.ValueString() return &okta.ListLogStreams200ResponseInner{ @@ -447,7 +447,7 @@ func buildLogStreamReplaceBody(ctx context.Context, m *logStreamModel) *okta.Rep _type := m.Type.ValueString() ls := okta.LogStreamPutSchema{ Name: m.Name.ValueString(), - Type: okta.LogStreamType(m.Type.ValueString()), + Type: m.Type.ValueString(), } settings := &logStreamSettingsModel{} @@ -458,7 +458,7 @@ func buildLogStreamReplaceBody(ctx context.Context, m *logStreamModel) *okta.Rep var settingAws okta.LogStreamSettingsAws settingAws.AccountId = settings.AccountID.ValueString() settingAws.EventSourceName = settings.EventSourceName.ValueString() - settingAws.Region = okta.AwsRegion(settings.Region.ValueString()) + settingAws.Region = settings.Region.ValueString() return &okta.ReplaceLogStreamRequest{ LogStreamAwsPutSchema: &okta.LogStreamAwsPutSchema{ LogStreamPutSchema: ls, @@ -467,7 +467,7 @@ func buildLogStreamReplaceBody(ctx context.Context, m *logStreamModel) *okta.Rep } case logStreamTypeSplunk: var settingSplunk okta.LogStreamSettingsSplunkPut - settingSplunk.Edition = okta.SplunkEdition(settings.Edition.ValueString()) + settingSplunk.Edition = settings.Edition.ValueString() settingSplunk.Host = settings.Host.ValueString() return &okta.ReplaceLogStreamRequest{ LogStreamSplunkPutSchema: &okta.LogStreamSplunkPutSchema{ diff --git a/okta/resource_okta_policy_device_assurance_android_os.go b/okta/resource_okta_policy_device_assurance_android_os.go index eb4cf34f1..b4dada22b 100644 --- a/okta/resource_okta_policy_device_assurance_android_os.go +++ b/okta/resource_okta_policy_device_assurance_android_os.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) // Ensure the implementation satisfies the expected interfaces. @@ -280,30 +280,22 @@ func (r *policyDeviceAssuranceAndroidResource) Update(ctx context.Context, req r func buildDeviceAssuranceAndroidPolicyRequest(model policyDeviceAssuranceAndroidResourceModel) (okta.ListDeviceAssurancePolicies200ResponseInner, error) { android := &okta.DeviceAssuranceAndroidPlatform{} android.SetName(model.Name.ValueString()) - android.SetPlatform(okta.PLATFORM_ANDROID) + android.SetPlatform("ANDROID") if len(model.DiskEncryptionType) > 0 { - diskEncryptionType := make([]okta.DiskEncryptionTypeAndroid, 0) + diskEncryptionType := make([]string, 0) for _, det := range model.DiskEncryptionType { - v, err := okta.NewDiskEncryptionTypeAndroidFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceAndroidPlatform: android}, err - } - diskEncryptionType = append(diskEncryptionType, *v) + diskEncryptionType = append(diskEncryptionType, det.ValueString()) } android.DiskEncryptionType = &okta.DeviceAssuranceAndroidPlatformAllOfDiskEncryptionType{Include: diskEncryptionType} } android.Jailbreak = model.JailBreak.ValueBoolPointer() if !model.OsVersion.IsNull() { - android.OsVersion = &okta.OSVersionFourComponents{Minimum: model.OsVersion.ValueStringPointer()} + android.OsVersion = &okta.OSVersion{Minimum: model.OsVersion.ValueStringPointer()} } if len(model.ScreenLockType) > 0 { - screenlockType := make([]okta.ScreenLockType, 0) + screenlockType := make([]string, 0) for _, det := range model.ScreenLockType { - v, err := okta.NewScreenLockTypeFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceAndroidPlatform: android}, err - } - screenlockType = append(screenlockType, *v) + screenlockType = append(screenlockType, det.ValueString()) } android.ScreenLockType = &okta.DeviceAssuranceAndroidPlatformAllOfScreenLockType{Include: screenlockType} } diff --git a/okta/resource_okta_policy_device_assurance_chromeos_os.go b/okta/resource_okta_policy_device_assurance_chromeos_os.go index 8f3d45e93..9b303fe1d 100644 --- a/okta/resource_okta_policy_device_assurance_chromeos_os.go +++ b/okta/resource_okta_policy_device_assurance_chromeos_os.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) // Ensure the implementation satisfies the expected interfaces. @@ -278,7 +278,7 @@ func (r *policyDeviceAssuranceChromeOSResource) Update(ctx context.Context, req func buildDeviceAssuranceChromeOSPolicyRequest(model policyDeviceAssuranceChromeOSResourceModel) (okta.ListDeviceAssurancePolicies200ResponseInner, error) { chromeOS := &okta.DeviceAssuranceChromeOSPlatform{} chromeOS.SetName(model.Name.ValueString()) - chromeOS.SetPlatform(okta.PLATFORM_CHROMEOS) + chromeOS.SetPlatform("CHROMEOS") var thirdPartySignalProviders okta.DeviceAssuranceChromeOSPlatformAllOfThirdPartySignalProviders var dtc okta.DTCChromeOS @@ -291,30 +291,18 @@ func buildDeviceAssuranceChromeOSPolicyRequest(model policyDeviceAssuranceChrome dtc.DeviceEnrollmentDomain = model.TpspDeviceEnrollmentDomain.ValueStringPointer() dtc.DiskEncrypted = model.TpspDiskEncrypted.ValueBoolPointer() if !model.TpspKeyTrustLevel.IsNull() { - v, err := okta.NewKeyTrustLevelOSModeFromValue(model.TpspKeyTrustLevel.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceChromeOSPlatform: chromeOS}, err - } - dtc.KeyTrustLevel = v + dtc.KeyTrustLevel = model.TpspKeyTrustLevel.ValueStringPointer() } dtc.OsFirewall = model.TpspOsFirewall.ValueBoolPointer() if !model.TpspOsVersion.IsNull() { dtc.OsVersion = &okta.OSVersionFourComponents{Minimum: model.TpspOsVersion.ValueStringPointer()} } if !model.TpspPasswordProtectionWarningTrigger.IsNull() { - v, err := okta.NewPasswordProtectionWarningTriggerFromValue(model.TpspPasswordProtectionWarningTrigger.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceChromeOSPlatform: chromeOS}, err - } - dtc.PasswordProtectionWarningTrigger = v + dtc.PasswordProtectionWarningTrigger = model.TpspPasswordProtectionWarningTrigger.ValueStringPointer() } dtc.RealtimeUrlCheckMode = model.TpspRealtimeURLCheckMode.ValueBoolPointer() if !model.TpspSafeBrowsingProtectionLevel.IsNull() { - v, err := okta.NewSafeBrowsingProtectionLevelFromValue(model.TpspSafeBrowsingProtectionLevel.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceChromeOSPlatform: chromeOS}, err - } - dtc.SafeBrowsingProtectionLevel = v + dtc.SafeBrowsingProtectionLevel = model.TpspSafeBrowsingProtectionLevel.ValueStringPointer() } dtc.ScreenLockSecured = model.TpspScreenLockSecured.ValueBoolPointer() dtc.SiteIsolationEnabled = model.TpspSiteIsolationEnabled.ValueBoolPointer() diff --git a/okta/resource_okta_policy_device_assurance_ios_os.go b/okta/resource_okta_policy_device_assurance_ios_os.go index 47cd97a4d..cd396207b 100644 --- a/okta/resource_okta_policy_device_assurance_ios_os.go +++ b/okta/resource_okta_policy_device_assurance_ios_os.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) // Ensure the implementation satisfies the expected interfaces. @@ -243,20 +243,16 @@ func (r *policyDeviceAssuranceIOSResource) Update(ctx context.Context, req resou func buildDeviceAssuranceIOSPolicyRequest(model policyDeviceAssuranceIOSResourceModel) (okta.ListDeviceAssurancePolicies200ResponseInner, error) { iOS := &okta.DeviceAssuranceIOSPlatform{} iOS.SetName(model.Name.ValueString()) - iOS.SetPlatform(okta.PLATFORM_IOS) + iOS.SetPlatform("IOS") iOS.Jailbreak = model.JailBreak.ValueBoolPointer() if !model.OsVersion.IsNull() { - iOS.OsVersion = &okta.OSVersionThreeComponents{Minimum: model.OsVersion.ValueStringPointer()} + iOS.OsVersion = &okta.OSVersion{Minimum: model.OsVersion.ValueStringPointer()} } if len(model.ScreenLockType) > 0 { - screenlockType := make([]okta.ScreenLockType, 0) + screenlockType := make([]string, 0) for _, det := range model.ScreenLockType { - v, err := okta.NewScreenLockTypeFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceIOSPlatform: iOS}, err - } - screenlockType = append(screenlockType, *v) + screenlockType = append(screenlockType, det.ValueString()) } iOS.ScreenLockType = &okta.DeviceAssuranceAndroidPlatformAllOfScreenLockType{Include: screenlockType} } diff --git a/okta/resource_okta_policy_device_assurance_macos_os.go b/okta/resource_okta_policy_device_assurance_macos_os.go index 07a266f5d..da5c44166 100644 --- a/okta/resource_okta_policy_device_assurance_macos_os.go +++ b/okta/resource_okta_policy_device_assurance_macos_os.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) // Ensure the implementation satisfies the expected interfaces. @@ -333,29 +333,21 @@ func (r *policyDeviceAssuranceMacOSResource) Update(ctx context.Context, req res func buildDeviceAssuranceMacOSPolicyRequest(model policyDeviceAssuranceMacOSResourceModel) (okta.ListDeviceAssurancePolicies200ResponseInner, error) { macos := &okta.DeviceAssuranceMacOSPlatform{} macos.SetName(model.Name.ValueString()) - macos.SetPlatform(okta.PLATFORM_MACOS) + macos.SetPlatform("MACOS") if len(model.DiskEncryptionType) > 0 { - diskEncryptionType := make([]okta.DiskEncryptionTypeDesktop, 0) + diskEncryptionType := make([]string, 0) for _, det := range model.DiskEncryptionType { - v, err := okta.NewDiskEncryptionTypeDesktopFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceMacOSPlatform: macos}, err - } - diskEncryptionType = append(diskEncryptionType, *v) + diskEncryptionType = append(diskEncryptionType, det.ValueString()) } macos.DiskEncryptionType = &okta.DeviceAssuranceMacOSPlatformAllOfDiskEncryptionType{Include: diskEncryptionType} } if !model.OsVersion.IsNull() { - macos.OsVersion = &okta.OSVersionThreeComponents{Minimum: model.OsVersion.ValueStringPointer()} + macos.OsVersion = &okta.OSVersion{Minimum: model.OsVersion.ValueStringPointer()} } if len(model.ScreenLockType) > 0 { - screenlockType := make([]okta.ScreenLockType, 0) + screenlockType := make([]string, 0) for _, det := range model.ScreenLockType { - v, err := okta.NewScreenLockTypeFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceMacOSPlatform: macos}, err - } - screenlockType = append(screenlockType, *v) + screenlockType = append(screenlockType, det.ValueString()) } macos.ScreenLockType = &okta.DeviceAssuranceAndroidPlatformAllOfScreenLockType{Include: screenlockType} } @@ -372,30 +364,18 @@ func buildDeviceAssuranceMacOSPolicyRequest(model policyDeviceAssuranceMacOSReso dtc.DeviceEnrollmentDomain = model.TpspDeviceEnrollmentDomain.ValueStringPointer() dtc.DiskEncrypted = model.TpspDiskEncrypted.ValueBoolPointer() if !model.TpspKeyTrustLevel.IsNull() { - v, err := okta.NewKeyTrustLevelBrowserKeyFromValue(model.TpspKeyTrustLevel.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceMacOSPlatform: macos}, err - } - dtc.KeyTrustLevel = v + dtc.KeyTrustLevel = model.TpspKeyTrustLevel.ValueStringPointer() } dtc.OsFirewall = model.TpspOsFirewall.ValueBoolPointer() if !model.TpspOsVersion.IsNull() { dtc.OsVersion = &okta.OSVersionThreeComponents{Minimum: model.TpspOsVersion.ValueStringPointer()} } if !model.TpspPasswordProtectionWarningTrigger.IsNull() { - v, err := okta.NewPasswordProtectionWarningTriggerFromValue(model.TpspPasswordProtectionWarningTrigger.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceMacOSPlatform: macos}, err - } - dtc.PasswordProtectionWarningTrigger = v + dtc.PasswordProtectionWarningTrigger = model.TpspPasswordProtectionWarningTrigger.ValueStringPointer() } dtc.RealtimeUrlCheckMode = model.TpspRealtimeURLCheckMode.ValueBoolPointer() if !model.TpspSafeBrowsingProtectionLevel.IsNull() { - v, err := okta.NewSafeBrowsingProtectionLevelFromValue(model.TpspSafeBrowsingProtectionLevel.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceMacOSPlatform: macos}, err - } - dtc.SafeBrowsingProtectionLevel = v + dtc.SafeBrowsingProtectionLevel = model.TpspSafeBrowsingProtectionLevel.ValueStringPointer() } dtc.ScreenLockSecured = model.TpspScreenLockSecured.ValueBoolPointer() dtc.SiteIsolationEnabled = model.TpspSiteIsolationEnabled.ValueBoolPointer() diff --git a/okta/resource_okta_policy_device_assurance_windows_os.go b/okta/resource_okta_policy_device_assurance_windows_os.go index bc04d2fc3..7adfd992e 100644 --- a/okta/resource_okta_policy_device_assurance_windows_os.go +++ b/okta/resource_okta_policy_device_assurance_windows_os.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) // Ensure the implementation satisfies the expected interfaces. @@ -363,15 +363,11 @@ func (r *policyDeviceAssuranceWindowsResource) Update(ctx context.Context, req r func buildDeviceAssuranceWindowsPolicyRequest(model policyDeviceAssuranceWindowsResourceModel) (okta.ListDeviceAssurancePolicies200ResponseInner, error) { windows := &okta.DeviceAssuranceWindowsPlatform{} windows.SetName(model.Name.ValueString()) - windows.SetPlatform(okta.PLATFORM_WINDOWS) + windows.SetPlatform("WINDOWS") if len(model.DiskEncryptionType) > 0 { - diskEncryptionType := make([]okta.DiskEncryptionTypeDesktop, 0) + diskEncryptionType := make([]string, 0) for _, det := range model.DiskEncryptionType { - v, err := okta.NewDiskEncryptionTypeDesktopFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceWindowsPlatform: windows}, err - } - diskEncryptionType = append(diskEncryptionType, *v) + diskEncryptionType = append(diskEncryptionType, det.ValueString()) } windows.DiskEncryptionType = &okta.DeviceAssuranceMacOSPlatformAllOfDiskEncryptionType{Include: diskEncryptionType} } @@ -379,13 +375,9 @@ func buildDeviceAssuranceWindowsPolicyRequest(model policyDeviceAssuranceWindows windows.OsVersion = &okta.OSVersionFourComponents{Minimum: model.OsVersion.ValueStringPointer()} } if len(model.ScreenLockType) > 0 { - screenlockType := make([]okta.ScreenLockType, 0) + screenlockType := make([]string, 0) for _, det := range model.ScreenLockType { - v, err := okta.NewScreenLockTypeFromValue(det.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceWindowsPlatform: windows}, err - } - screenlockType = append(screenlockType, *v) + screenlockType = append(screenlockType, det.ValueString()) } windows.ScreenLockType = &okta.DeviceAssuranceAndroidPlatformAllOfScreenLockType{Include: screenlockType} } @@ -404,31 +396,19 @@ func buildDeviceAssuranceWindowsPolicyRequest(model policyDeviceAssuranceWindows dtc.DeviceEnrollmentDomain = model.TpspDeviceEnrollmentDomain.ValueStringPointer() dtc.DiskEncrypted = model.TpspDiskEncrypted.ValueBoolPointer() if !model.TpspKeyTrustLevel.IsNull() { - v, err := okta.NewKeyTrustLevelBrowserKeyFromValue(model.TpspKeyTrustLevel.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceWindowsPlatform: windows}, err - } - dtc.KeyTrustLevel = v + dtc.KeyTrustLevel = model.TpspKeyTrustLevel.ValueStringPointer() } dtc.OsFirewall = model.TpspOsFirewall.ValueBoolPointer() if !model.TpspOsVersion.IsNull() { dtc.OsVersion = &okta.OSVersionFourComponents{Minimum: model.TpspOsVersion.ValueStringPointer()} } if !model.TpspPasswordProtectionWarningTrigger.IsNull() { - v, err := okta.NewPasswordProtectionWarningTriggerFromValue(model.TpspPasswordProtectionWarningTrigger.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceWindowsPlatform: windows}, err - } - dtc.PasswordProtectionWarningTrigger = v + dtc.PasswordProtectionWarningTrigger = model.TpspPasswordProtectionWarningTrigger.ValueStringPointer() } dtc.RealtimeUrlCheckMode = model.TpspRealtimeURLCheckMode.ValueBoolPointer() if !model.TpspSafeBrowsingProtectionLevel.IsNull() { - v, err := okta.NewSafeBrowsingProtectionLevelFromValue(model.TpspSafeBrowsingProtectionLevel.ValueString()) - if err != nil { - return okta.ListDeviceAssurancePolicies200ResponseInner{DeviceAssuranceWindowsPlatform: windows}, err - } - dtc.SafeBrowsingProtectionLevel = v + dtc.SafeBrowsingProtectionLevel = model.TpspSafeBrowsingProtectionLevel.ValueStringPointer() } dtc.ScreenLockSecured = model.TpspScreenLockSecured.ValueBoolPointer() dtc.SecureBootEnabled = model.TpspSecureBootEnabled.ValueBoolPointer() diff --git a/okta/resource_okta_theme.go b/okta/resource_okta_theme.go index 67fb6933c..bd9684067 100644 --- a/okta/resource_okta_theme.go +++ b/okta/resource_okta_theme.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) func resourceTheme() *schema.Resource { @@ -131,27 +131,23 @@ func resourceThemeUpdate(ctx context.Context, d *schema.ResourceData, m interfac } if val, ok := d.GetOk("sign_in_page_touch_point_variant"); ok { - if siptpv, err := okta.NewSignInPageTouchPointVariantFromValue(val.(string)); err == nil { - theme.SignInPageTouchPointVariant = siptpv - } + siptpv := val.(string) + theme.SignInPageTouchPointVariant = &siptpv } if val, ok := d.GetOk("end_user_dashboard_touch_point_variant"); ok { - if eudtpv, err := okta.NewEndUserDashboardTouchPointVariantFromValue(val.(string)); err == nil { - theme.EndUserDashboardTouchPointVariant = eudtpv - } + eudtpv := val.(string) + theme.EndUserDashboardTouchPointVariant = &eudtpv } if val, ok := d.GetOk("error_page_touch_point_variant"); ok { - if eptpv, err := okta.NewErrorPageTouchPointVariantFromValue(val.(string)); err == nil { - theme.ErrorPageTouchPointVariant = eptpv - } + eptpv := val.(string) + theme.ErrorPageTouchPointVariant = &eptpv } if val, ok := d.GetOk("email_template_touch_point_variant"); ok { - if ettpv, err := okta.NewEmailTemplateTouchPointVariantFromValue(val.(string)); err == nil { - theme.EmailTemplateTouchPointVariant = ettpv - } + ettpv := val.(string) + theme.EmailTemplateTouchPointVariant = &ettpv } themeResp, _, err := getOktaV3ClientFromMetadata(m).CustomizationAPI.ReplaceBrandTheme(ctx, brandID, d.Id()).Theme(theme).Execute() diff --git a/okta/theme.go b/okta/theme.go index a8fccd229..69b31d0c8 100644 --- a/okta/theme.go +++ b/okta/theme.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" ) var themeResourceSchema = map[string]*schema.Schema{ diff --git a/okta/utils.go b/okta/utils.go index 9c02efeeb..df6d9985d 100644 --- a/okta/utils.go +++ b/okta/utils.go @@ -21,7 +21,7 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/okta/okta-sdk-golang/v3/okta" + "github.com/okta/okta-sdk-golang/v4/okta" "github.com/okta/terraform-provider-okta/sdk" )