diff --git a/CHANGELOG.md b/CHANGELOG.md index de2bf525..e0b14c18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,41 +1,4 @@ -## 31.1.1 (Unreleased) -## 30.2.1 (Unreleased) -ENHANCEMENTS: -- Added new resource `avi_controllerportalregistration` [#553](https://github.com/vmware/terraform-provider-avi/pull/553) -- Added new resource `avi_serviceauthprofile` [#553](https://github.com/vmware/terraform-provider-avi/pull/553) -- Added new resource `avi_taskjournal` [#590](https://github.com/vmware/terraform-provider-avi/pull/590) - -BUG FIXES: -- AV-202599 Resource avi_useraccount fails with generic error instead of providing user useful feedback -- Failure to create avi_useraccount resource. https://github.com/vmware/terraform-provider-avi/issues/314 -- AV-187301: Entering wrong credentials on terraform using AVI as provider, while using Plan command breaks statefile -- AV-186452: AVI-provider for Terraform version 22.1.2 and 22.1.4 creates any object in the Admin tenant. -- AV-186737: Changes to certain subresources are not detected as changes by Terraform -- AV-187199: AVI terraform apply the resource object even if it is already exist without showing Error. -- Terraform Provider Avi overwriting existing resources. https://github.com/vmware/terraform-provider-avi/issues/358 -- AV-194160 Terraform Provider crash during avi_serviceenginegroup destroy. https://github.com/vmware/terraform-provider-avi/issues/376 - -## 22.1.6 (March 08, 2024) -NOTE: - -From version 22.1.6, updating system default configurations now requires first importing the existing configuration into the Terraform state. - -Please refer [README.MD](https://github.com/vmware/terraform-provider-avi/tree/22.1.7) - -ENHANCEMENTS: -- Added new resource `avi_systemreport` [#576](https://github.com/vmware/terraform-provider-avi/pull/576/files) -- Updated resources with newly added fields [#576](https://github.com/vmware/terraform-provider-avi/pull/576/files) - -BUG FIXES: -- AV-187199: AVI terraform apply the resource object even if it is already exist without showing Error. -- Terraform Provider Avi overwriting existing resources. https://github.com/vmware/terraform-provider-avi/issues/358 - -## 22.1.5 (October 30, 2023) -BUG FIXES: -- AV-187301: Entering wrong credentials on terraform using AVI as provider, while using Plan command breaks statefile -- AV-186452: AVI-provider for Terraform version 22.1.2 and 22.1.4 creates any object in the Admin tenant. -- AV-186737: Changes to certain subresources are not detected as changes by Terraform - +## 0.3.0 (Unreleased) ## 0.2.3 (June 16, 2020) Features: - Updated Avi Go SDK to latest. diff --git a/avi/data_source_avi_applicationprofile_test.go b/avi/data_source_avi_applicationprofile_test.go index cc3604bf..bb1f11cc 100644 --- a/avi/data_source_avi_applicationprofile_test.go +++ b/avi/data_source_avi_applicationprofile_test.go @@ -115,9 +115,6 @@ resource "avi_applicationprofile" "testApplicationProfile" { use_app_keepalive_timeout = false } preserve_client_port = false - l4_ssl_profile { - ssl_stream_idle_timeout = "3600" - } } data "avi_applicationprofile" "testApplicationProfile" { diff --git a/avi/data_source_avi_customipamdnsprofile_test.go b/avi/data_source_avi_customipamdnsprofile_test.go index ecd7cd3f..a5e398f0 100644 --- a/avi/data_source_avi_customipamdnsprofile_test.go +++ b/avi/data_source_avi_customipamdnsprofile_test.go @@ -26,7 +26,7 @@ func TestAVIDataSourceCustomIpamDnsProfileBasic(t *testing.T) { } -// nolint +//nolint const testAccAVIDSCustomIpamDnsProfileConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/data_source_avi_dnspolicy_test.go b/avi/data_source_avi_dnspolicy_test.go index 1d4800d5..ab54f500 100644 --- a/avi/data_source_avi_dnspolicy_test.go +++ b/avi/data_source_avi_dnspolicy_test.go @@ -26,7 +26,7 @@ func TestAVIDataSourceDnsPolicyBasic(t *testing.T) { } -// nolint +//nolint const testAccAVIDSDnsPolicyConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/data_source_avi_ipaddrgroup_test.go b/avi/data_source_avi_ipaddrgroup_test.go index c3e1901c..d33d34b9 100644 --- a/avi/data_source_avi_ipaddrgroup_test.go +++ b/avi/data_source_avi_ipaddrgroup_test.go @@ -26,7 +26,7 @@ func TestAVIDataSourceIpAddrGroupBasic(t *testing.T) { } -// nolint +//nolint const testAccAVIDSIpAddrGroupConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/data_source_avi_ipamdnsproviderprofile_test.go b/avi/data_source_avi_ipamdnsproviderprofile_test.go index c46e3b5f..34240229 100644 --- a/avi/data_source_avi_ipamdnsproviderprofile_test.go +++ b/avi/data_source_avi_ipamdnsproviderprofile_test.go @@ -28,7 +28,7 @@ func TestAVIDataSourceIpamDnsProviderProfileBasic(t *testing.T) { } -// nolint +//nolint const testAccAVIDSIpamDnsProviderProfileConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/datasource_avi_customipamdnsprofile.go b/avi/datasource_avi_customipamdnsprofile.go index d175a683..ed7cbd66 100644 --- a/avi/datasource_avi_customipamdnsprofile.go +++ b/avi/datasource_avi_customipamdnsprofile.go @@ -5,7 +5,7 @@ package avi import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -// nolint +//nolint func dataSourceAviCustomIpamDnsProfile() *schema.Resource { return &schema.Resource{ Read: ResourceAviCustomIpamDnsProfileRead, diff --git a/avi/datasource_avi_dnspolicy.go b/avi/datasource_avi_dnspolicy.go index 8c59317f..4783b701 100644 --- a/avi/datasource_avi_dnspolicy.go +++ b/avi/datasource_avi_dnspolicy.go @@ -5,7 +5,7 @@ package avi import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -// nolint +//nolint func dataSourceAviDnsPolicy() *schema.Resource { return &schema.Resource{ Read: ResourceAviDnsPolicyRead, diff --git a/avi/datasource_avi_dynamicdnsrecord.go b/avi/datasource_avi_dynamicdnsrecord.go index 22c828a6..153828d7 100644 --- a/avi/datasource_avi_dynamicdnsrecord.go +++ b/avi/datasource_avi_dynamicdnsrecord.go @@ -5,7 +5,7 @@ package avi import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -// nolint +//nolint func dataSourceAviDynamicDnsRecord() *schema.Resource { return &schema.Resource{ Read: ResourceAviDynamicDnsRecordRead, diff --git a/avi/datasource_avi_ipaddrgroup.go b/avi/datasource_avi_ipaddrgroup.go index 523a0f4a..8eace16a 100644 --- a/avi/datasource_avi_ipaddrgroup.go +++ b/avi/datasource_avi_ipaddrgroup.go @@ -5,7 +5,7 @@ package avi import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -// nolint +//nolint func dataSourceAviIpAddrGroup() *schema.Resource { return &schema.Resource{ Read: ResourceAviIpAddrGroupRead, diff --git a/avi/datasource_avi_ipamdnsproviderprofile.go b/avi/datasource_avi_ipamdnsproviderprofile.go index e6e92da9..de9274f1 100644 --- a/avi/datasource_avi_ipamdnsproviderprofile.go +++ b/avi/datasource_avi_ipamdnsproviderprofile.go @@ -5,7 +5,7 @@ package avi import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -// nolint +//nolint func dataSourceAviIpamDnsProviderProfile() *schema.Resource { return &schema.Resource{ Read: ResourceAviIpamDnsProviderProfileRead, diff --git a/avi/resource_avi_actiongroupconfig.go b/avi/resource_avi_actiongroupconfig.go index a74f4084..f8214003 100644 --- a/avi/resource_avi_actiongroupconfig.go +++ b/avi/resource_avi_actiongroupconfig.go @@ -102,7 +102,7 @@ func ResourceAviActionGroupConfigRead(d *schema.ResourceData, meta interface{}) func resourceAviActionGroupConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceActionGroupConfigSchema() - err := APICreate(d, meta, "actiongroupconfig", s) + err := APICreateOrUpdate(d, meta, "actiongroupconfig", s) if err == nil { err = ResourceAviActionGroupConfigRead(d, meta) } @@ -112,7 +112,7 @@ func resourceAviActionGroupConfigCreate(d *schema.ResourceData, meta interface{} func resourceAviActionGroupConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceActionGroupConfigSchema() var err error - err = APIUpdate(d, meta, "actiongroupconfig", s) + err = APICreateOrUpdate(d, meta, "actiongroupconfig", s) if err == nil { err = ResourceAviActionGroupConfigRead(d, meta) } diff --git a/avi/resource_avi_albservicesconfig.go b/avi/resource_avi_albservicesconfig.go index 9b7fde1d..fc18b69f 100644 --- a/avi/resource_avi_albservicesconfig.go +++ b/avi/resource_avi_albservicesconfig.go @@ -154,7 +154,7 @@ func ResourceAviALBServicesConfigRead(d *schema.ResourceData, meta interface{}) func resourceAviALBServicesConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesConfigSchema() - err := APICreate(d, meta, "albservicesconfig", s) + err := APICreateOrUpdate(d, meta, "albservicesconfig", s) if err == nil { err = ResourceAviALBServicesConfigRead(d, meta) } @@ -164,7 +164,7 @@ func resourceAviALBServicesConfigCreate(d *schema.ResourceData, meta interface{} func resourceAviALBServicesConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesConfigSchema() var err error - err = APIUpdate(d, meta, "albservicesconfig", s) + err = APICreateOrUpdate(d, meta, "albservicesconfig", s) if err == nil { err = ResourceAviALBServicesConfigRead(d, meta) } diff --git a/avi/resource_avi_albservicesfiledownload.go b/avi/resource_avi_albservicesfiledownload.go index add589c7..59a36380 100644 --- a/avi/resource_avi_albservicesfiledownload.go +++ b/avi/resource_avi_albservicesfiledownload.go @@ -90,7 +90,7 @@ func ResourceAviALBServicesFileDownloadRead(d *schema.ResourceData, meta interfa func resourceAviALBServicesFileDownloadCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesFileDownloadSchema() - err := APICreate(d, meta, "albservicesfiledownload", s) + err := APICreateOrUpdate(d, meta, "albservicesfiledownload", s) if err == nil { err = ResourceAviALBServicesFileDownloadRead(d, meta) } @@ -100,7 +100,7 @@ func resourceAviALBServicesFileDownloadCreate(d *schema.ResourceData, meta inter func resourceAviALBServicesFileDownloadUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesFileDownloadSchema() var err error - err = APIUpdate(d, meta, "albservicesfiledownload", s) + err = APICreateOrUpdate(d, meta, "albservicesfiledownload", s) if err == nil { err = ResourceAviALBServicesFileDownloadRead(d, meta) } diff --git a/avi/resource_avi_albservicesfileupload.go b/avi/resource_avi_albservicesfileupload.go index c42cd2b9..89c193d1 100644 --- a/avi/resource_avi_albservicesfileupload.go +++ b/avi/resource_avi_albservicesfileupload.go @@ -80,7 +80,7 @@ func ResourceAviALBServicesFileUploadRead(d *schema.ResourceData, meta interface func resourceAviALBServicesFileUploadCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesFileUploadSchema() - err := APICreate(d, meta, "albservicesfileupload", s) + err := APICreateOrUpdate(d, meta, "albservicesfileupload", s) if err == nil { err = ResourceAviALBServicesFileUploadRead(d, meta) } @@ -90,7 +90,7 @@ func resourceAviALBServicesFileUploadCreate(d *schema.ResourceData, meta interfa func resourceAviALBServicesFileUploadUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesFileUploadSchema() var err error - err = APIUpdate(d, meta, "albservicesfileupload", s) + err = APICreateOrUpdate(d, meta, "albservicesfileupload", s) if err == nil { err = ResourceAviALBServicesFileUploadRead(d, meta) } diff --git a/avi/resource_avi_albservicesjob.go b/avi/resource_avi_albservicesjob.go index 2be16301..ddfaad11 100644 --- a/avi/resource_avi_albservicesjob.go +++ b/avi/resource_avi_albservicesjob.go @@ -115,7 +115,7 @@ func ResourceAviALBServicesJobRead(d *schema.ResourceData, meta interface{}) err func resourceAviALBServicesJobCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesJobSchema() - err := APICreate(d, meta, "albservicesjob", s) + err := APICreateOrUpdate(d, meta, "albservicesjob", s) if err == nil { err = ResourceAviALBServicesJobRead(d, meta) } @@ -125,7 +125,7 @@ func resourceAviALBServicesJobCreate(d *schema.ResourceData, meta interface{}) e func resourceAviALBServicesJobUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceALBServicesJobSchema() var err error - err = APIUpdate(d, meta, "albservicesjob", s) + err = APICreateOrUpdate(d, meta, "albservicesjob", s) if err == nil { err = ResourceAviALBServicesJobRead(d, meta) } diff --git a/avi/resource_avi_alertconfig.go b/avi/resource_avi_alertconfig.go index 71ae4e43..6c5aa21e 100644 --- a/avi/resource_avi_alertconfig.go +++ b/avi/resource_avi_alertconfig.go @@ -141,7 +141,7 @@ func ResourceAviAlertConfigRead(d *schema.ResourceData, meta interface{}) error func resourceAviAlertConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertConfigSchema() - err := APICreate(d, meta, "alertconfig", s) + err := APICreateOrUpdate(d, meta, "alertconfig", s) if err == nil { err = ResourceAviAlertConfigRead(d, meta) } @@ -151,7 +151,7 @@ func resourceAviAlertConfigCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviAlertConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertConfigSchema() var err error - err = APIUpdate(d, meta, "alertconfig", s) + err = APICreateOrUpdate(d, meta, "alertconfig", s) if err == nil { err = ResourceAviAlertConfigRead(d, meta) } diff --git a/avi/resource_avi_alertemailconfig.go b/avi/resource_avi_alertemailconfig.go index 4bf4efa0..5abfa703 100644 --- a/avi/resource_avi_alertemailconfig.go +++ b/avi/resource_avi_alertemailconfig.go @@ -76,7 +76,7 @@ func ResourceAviAlertEmailConfigRead(d *schema.ResourceData, meta interface{}) e func resourceAviAlertEmailConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertEmailConfigSchema() - err := APICreate(d, meta, "alertemailconfig", s) + err := APICreateOrUpdate(d, meta, "alertemailconfig", s) if err == nil { err = ResourceAviAlertEmailConfigRead(d, meta) } @@ -86,7 +86,7 @@ func resourceAviAlertEmailConfigCreate(d *schema.ResourceData, meta interface{}) func resourceAviAlertEmailConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertEmailConfigSchema() var err error - err = APIUpdate(d, meta, "alertemailconfig", s) + err = APICreateOrUpdate(d, meta, "alertemailconfig", s) if err == nil { err = ResourceAviAlertEmailConfigRead(d, meta) } diff --git a/avi/resource_avi_alertscriptconfig.go b/avi/resource_avi_alertscriptconfig.go index 871b0904..a1794589 100644 --- a/avi/resource_avi_alertscriptconfig.go +++ b/avi/resource_avi_alertscriptconfig.go @@ -73,7 +73,7 @@ func ResourceAviAlertScriptConfigRead(d *schema.ResourceData, meta interface{}) func resourceAviAlertScriptConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertScriptConfigSchema() - err := APICreate(d, meta, "alertscriptconfig", s) + err := APICreateOrUpdate(d, meta, "alertscriptconfig", s) if err == nil { err = ResourceAviAlertScriptConfigRead(d, meta) } @@ -83,7 +83,7 @@ func resourceAviAlertScriptConfigCreate(d *schema.ResourceData, meta interface{} func resourceAviAlertScriptConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertScriptConfigSchema() var err error - err = APIUpdate(d, meta, "alertscriptconfig", s) + err = APICreateOrUpdate(d, meta, "alertscriptconfig", s) if err == nil { err = ResourceAviAlertScriptConfigRead(d, meta) } diff --git a/avi/resource_avi_alertsyslogconfig.go b/avi/resource_avi_alertsyslogconfig.go index ce6c0ecc..5c379def 100644 --- a/avi/resource_avi_alertsyslogconfig.go +++ b/avi/resource_avi_alertsyslogconfig.go @@ -77,7 +77,7 @@ func ResourceAviAlertSyslogConfigRead(d *schema.ResourceData, meta interface{}) func resourceAviAlertSyslogConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertSyslogConfigSchema() - err := APICreate(d, meta, "alertsyslogconfig", s) + err := APICreateOrUpdate(d, meta, "alertsyslogconfig", s) if err == nil { err = ResourceAviAlertSyslogConfigRead(d, meta) } @@ -87,7 +87,7 @@ func resourceAviAlertSyslogConfigCreate(d *schema.ResourceData, meta interface{} func resourceAviAlertSyslogConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAlertSyslogConfigSchema() var err error - err = APIUpdate(d, meta, "alertsyslogconfig", s) + err = APICreateOrUpdate(d, meta, "alertsyslogconfig", s) if err == nil { err = ResourceAviAlertSyslogConfigRead(d, meta) } diff --git a/avi/resource_avi_analyticsprofile.go b/avi/resource_avi_analyticsprofile.go index 48214838..d95bfa81 100644 --- a/avi/resource_avi_analyticsprofile.go +++ b/avi/resource_avi_analyticsprofile.go @@ -554,7 +554,7 @@ func ResourceAviAnalyticsProfileRead(d *schema.ResourceData, meta interface{}) e func resourceAviAnalyticsProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAnalyticsProfileSchema() - err := APICreate(d, meta, "analyticsprofile", s) + err := APICreateOrUpdate(d, meta, "analyticsprofile", s) if err == nil { err = ResourceAviAnalyticsProfileRead(d, meta) } @@ -564,7 +564,7 @@ func resourceAviAnalyticsProfileCreate(d *schema.ResourceData, meta interface{}) func resourceAviAnalyticsProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAnalyticsProfileSchema() var err error - err = APIUpdate(d, meta, "analyticsprofile", s) + err = APICreateOrUpdate(d, meta, "analyticsprofile", s) if err == nil { err = ResourceAviAnalyticsProfileRead(d, meta) } diff --git a/avi/resource_avi_applicationpersistenceprofile.go b/avi/resource_avi_applicationpersistenceprofile.go index bc553fea..a1a9c8ae 100644 --- a/avi/resource_avi_applicationpersistenceprofile.go +++ b/avi/resource_avi_applicationpersistenceprofile.go @@ -111,7 +111,7 @@ func ResourceAviApplicationPersistenceProfileRead(d *schema.ResourceData, meta i func resourceAviApplicationPersistenceProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceApplicationPersistenceProfileSchema() - err := APICreate(d, meta, "applicationpersistenceprofile", s) + err := APICreateOrUpdate(d, meta, "applicationpersistenceprofile", s) if err == nil { err = ResourceAviApplicationPersistenceProfileRead(d, meta) } @@ -121,7 +121,7 @@ func resourceAviApplicationPersistenceProfileCreate(d *schema.ResourceData, meta func resourceAviApplicationPersistenceProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceApplicationPersistenceProfileSchema() var err error - err = APIUpdate(d, meta, "applicationpersistenceprofile", s) + err = APICreateOrUpdate(d, meta, "applicationpersistenceprofile", s) if err == nil { err = ResourceAviApplicationPersistenceProfileRead(d, meta) } diff --git a/avi/resource_avi_applicationprofile.go b/avi/resource_avi_applicationprofile.go index a7dc62db..66606767 100644 --- a/avi/resource_avi_applicationprofile.go +++ b/avi/resource_avi_applicationprofile.go @@ -145,7 +145,7 @@ func ResourceAviApplicationProfileRead(d *schema.ResourceData, meta interface{}) func resourceAviApplicationProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceApplicationProfileSchema() - err := APICreate(d, meta, "applicationprofile", s) + err := APICreateOrUpdate(d, meta, "applicationprofile", s) if err == nil { err = ResourceAviApplicationProfileRead(d, meta) } @@ -155,7 +155,7 @@ func resourceAviApplicationProfileCreate(d *schema.ResourceData, meta interface{ func resourceAviApplicationProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceApplicationProfileSchema() var err error - err = APIUpdate(d, meta, "applicationprofile", s) + err = APICreateOrUpdate(d, meta, "applicationprofile", s) if err == nil { err = ResourceAviApplicationProfileRead(d, meta) } diff --git a/avi/resource_avi_applicationprofile_test.go b/avi/resource_avi_applicationprofile_test.go index 91d06aac..5856992d 100644 --- a/avi/resource_avi_applicationprofile_test.go +++ b/avi/resource_avi_applicationprofile_test.go @@ -183,9 +183,6 @@ resource "avi_applicationprofile" "testApplicationProfile" { use_app_keepalive_timeout = false } preserve_client_port = false - l4_ssl_profile { - ssl_stream_idle_timeout = "3600" - } } ` @@ -274,8 +271,5 @@ resource "avi_applicationprofile" "testApplicationProfile" { use_app_keepalive_timeout = false } preserve_client_port = false - l4_ssl_profile { - ssl_stream_idle_timeout = "3600" - } } ` diff --git a/avi/resource_avi_authmappingprofile.go b/avi/resource_avi_authmappingprofile.go index bf4a2b53..c1bd3162 100644 --- a/avi/resource_avi_authmappingprofile.go +++ b/avi/resource_avi_authmappingprofile.go @@ -76,7 +76,7 @@ func ResourceAviAuthMappingProfileRead(d *schema.ResourceData, meta interface{}) func resourceAviAuthMappingProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAuthMappingProfileSchema() - err := APICreate(d, meta, "authmappingprofile", s) + err := APICreateOrUpdate(d, meta, "authmappingprofile", s) if err == nil { err = ResourceAviAuthMappingProfileRead(d, meta) } @@ -86,7 +86,7 @@ func resourceAviAuthMappingProfileCreate(d *schema.ResourceData, meta interface{ func resourceAviAuthMappingProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAuthMappingProfileSchema() var err error - err = APIUpdate(d, meta, "authmappingprofile", s) + err = APICreateOrUpdate(d, meta, "authmappingprofile", s) if err == nil { err = ResourceAviAuthMappingProfileRead(d, meta) } diff --git a/avi/resource_avi_authprofile.go b/avi/resource_avi_authprofile.go index 2a4b3859..7644fcf3 100644 --- a/avi/resource_avi_authprofile.go +++ b/avi/resource_avi_authprofile.go @@ -111,7 +111,7 @@ func ResourceAviAuthProfileRead(d *schema.ResourceData, meta interface{}) error func resourceAviAuthProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAuthProfileSchema() - err := APICreate(d, meta, "authprofile", s) + err := APICreateOrUpdate(d, meta, "authprofile", s) if err == nil { err = ResourceAviAuthProfileRead(d, meta) } @@ -121,7 +121,7 @@ func resourceAviAuthProfileCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviAuthProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAuthProfileSchema() var err error - err = APIUpdate(d, meta, "authprofile", s) + err = APICreateOrUpdate(d, meta, "authprofile", s) if err == nil { err = ResourceAviAuthProfileRead(d, meta) } diff --git a/avi/resource_avi_autoscalelaunchconfig.go b/avi/resource_avi_autoscalelaunchconfig.go index bc8e1750..175ce519 100644 --- a/avi/resource_avi_autoscalelaunchconfig.go +++ b/avi/resource_avi_autoscalelaunchconfig.go @@ -95,7 +95,7 @@ func ResourceAviAutoScaleLaunchConfigRead(d *schema.ResourceData, meta interface func resourceAviAutoScaleLaunchConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAutoScaleLaunchConfigSchema() - err := APICreate(d, meta, "autoscalelaunchconfig", s) + err := APICreateOrUpdate(d, meta, "autoscalelaunchconfig", s) if err == nil { err = ResourceAviAutoScaleLaunchConfigRead(d, meta) } @@ -105,7 +105,7 @@ func resourceAviAutoScaleLaunchConfigCreate(d *schema.ResourceData, meta interfa func resourceAviAutoScaleLaunchConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAutoScaleLaunchConfigSchema() var err error - err = APIUpdate(d, meta, "autoscalelaunchconfig", s) + err = APICreateOrUpdate(d, meta, "autoscalelaunchconfig", s) if err == nil { err = ResourceAviAutoScaleLaunchConfigRead(d, meta) } diff --git a/avi/resource_avi_availabilityzone.go b/avi/resource_avi_availabilityzone.go index be2b5482..9cd2c440 100644 --- a/avi/resource_avi_availabilityzone.go +++ b/avi/resource_avi_availabilityzone.go @@ -72,7 +72,7 @@ func ResourceAviAvailabilityZoneRead(d *schema.ResourceData, meta interface{}) e func resourceAviAvailabilityZoneCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceAvailabilityZoneSchema() - err := APICreate(d, meta, "availabilityzone", s) + err := APICreateOrUpdate(d, meta, "availabilityzone", s) if err == nil { err = ResourceAviAvailabilityZoneRead(d, meta) } @@ -82,7 +82,7 @@ func resourceAviAvailabilityZoneCreate(d *schema.ResourceData, meta interface{}) func resourceAviAvailabilityZoneUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceAvailabilityZoneSchema() var err error - err = APIUpdate(d, meta, "availabilityzone", s) + err = APICreateOrUpdate(d, meta, "availabilityzone", s) if err == nil { err = ResourceAviAvailabilityZoneRead(d, meta) } diff --git a/avi/resource_avi_backup.go b/avi/resource_avi_backup.go index 196b21cf..d93575f4 100644 --- a/avi/resource_avi_backup.go +++ b/avi/resource_avi_backup.go @@ -81,7 +81,7 @@ func ResourceAviBackupRead(d *schema.ResourceData, meta interface{}) error { func resourceAviBackupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceBackupSchema() - err := APICreate(d, meta, "backup", s) + err := APICreateOrUpdate(d, meta, "backup", s) if err == nil { err = ResourceAviBackupRead(d, meta) } @@ -91,7 +91,7 @@ func resourceAviBackupCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviBackupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceBackupSchema() var err error - err = APIUpdate(d, meta, "backup", s) + err = APICreateOrUpdate(d, meta, "backup", s) if err == nil { err = ResourceAviBackupRead(d, meta) } diff --git a/avi/resource_avi_backupconfiguration.go b/avi/resource_avi_backupconfiguration.go index 0f9175a6..fecba28c 100644 --- a/avi/resource_avi_backupconfiguration.go +++ b/avi/resource_avi_backupconfiguration.go @@ -147,7 +147,7 @@ func ResourceAviBackupConfigurationRead(d *schema.ResourceData, meta interface{} func resourceAviBackupConfigurationCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceBackupConfigurationSchema() - err := APICreate(d, meta, "backupconfiguration", s) + err := APICreateOrUpdate(d, meta, "backupconfiguration", s) if err == nil { err = ResourceAviBackupConfigurationRead(d, meta) } @@ -157,7 +157,7 @@ func resourceAviBackupConfigurationCreate(d *schema.ResourceData, meta interface func resourceAviBackupConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceBackupConfigurationSchema() var err error - err = APIUpdate(d, meta, "backupconfiguration", s) + err = APICreateOrUpdate(d, meta, "backupconfiguration", s) if err == nil { err = ResourceAviBackupConfigurationRead(d, meta) } diff --git a/avi/resource_avi_botconfigconsolidator.go b/avi/resource_avi_botconfigconsolidator.go index ad714e4d..9b82d9c9 100644 --- a/avi/resource_avi_botconfigconsolidator.go +++ b/avi/resource_avi_botconfigconsolidator.go @@ -66,7 +66,7 @@ func ResourceAviBotConfigConsolidatorRead(d *schema.ResourceData, meta interface func resourceAviBotConfigConsolidatorCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotConfigConsolidatorSchema() - err := APICreate(d, meta, "botconfigconsolidator", s) + err := APICreateOrUpdate(d, meta, "botconfigconsolidator", s) if err == nil { err = ResourceAviBotConfigConsolidatorRead(d, meta) } @@ -76,7 +76,7 @@ func resourceAviBotConfigConsolidatorCreate(d *schema.ResourceData, meta interfa func resourceAviBotConfigConsolidatorUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotConfigConsolidatorSchema() var err error - err = APIUpdate(d, meta, "botconfigconsolidator", s) + err = APICreateOrUpdate(d, meta, "botconfigconsolidator", s) if err == nil { err = ResourceAviBotConfigConsolidatorRead(d, meta) } diff --git a/avi/resource_avi_botdetectionpolicy.go b/avi/resource_avi_botdetectionpolicy.go index 25f7222e..ae62a026 100644 --- a/avi/resource_avi_botdetectionpolicy.go +++ b/avi/resource_avi_botdetectionpolicy.go @@ -108,7 +108,7 @@ func ResourceAviBotDetectionPolicyRead(d *schema.ResourceData, meta interface{}) func resourceAviBotDetectionPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotDetectionPolicySchema() - err := APICreate(d, meta, "botdetectionpolicy", s) + err := APICreateOrUpdate(d, meta, "botdetectionpolicy", s) if err == nil { err = ResourceAviBotDetectionPolicyRead(d, meta) } @@ -118,7 +118,7 @@ func resourceAviBotDetectionPolicyCreate(d *schema.ResourceData, meta interface{ func resourceAviBotDetectionPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotDetectionPolicySchema() var err error - err = APIUpdate(d, meta, "botdetectionpolicy", s) + err = APICreateOrUpdate(d, meta, "botdetectionpolicy", s) if err == nil { err = ResourceAviBotDetectionPolicyRead(d, meta) } diff --git a/avi/resource_avi_botipreputationtypemapping.go b/avi/resource_avi_botipreputationtypemapping.go index 5dedacfc..8e90f11f 100644 --- a/avi/resource_avi_botipreputationtypemapping.go +++ b/avi/resource_avi_botipreputationtypemapping.go @@ -61,7 +61,7 @@ func ResourceAviBotIPReputationTypeMappingRead(d *schema.ResourceData, meta inte func resourceAviBotIPReputationTypeMappingCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotIPReputationTypeMappingSchema() - err := APICreate(d, meta, "botipreputationtypemapping", s) + err := APICreateOrUpdate(d, meta, "botipreputationtypemapping", s) if err == nil { err = ResourceAviBotIPReputationTypeMappingRead(d, meta) } @@ -71,7 +71,7 @@ func resourceAviBotIPReputationTypeMappingCreate(d *schema.ResourceData, meta in func resourceAviBotIPReputationTypeMappingUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotIPReputationTypeMappingSchema() var err error - err = APIUpdate(d, meta, "botipreputationtypemapping", s) + err = APICreateOrUpdate(d, meta, "botipreputationtypemapping", s) if err == nil { err = ResourceAviBotIPReputationTypeMappingRead(d, meta) } diff --git a/avi/resource_avi_botmapping.go b/avi/resource_avi_botmapping.go index bedc5f6d..88c9ace4 100644 --- a/avi/resource_avi_botmapping.go +++ b/avi/resource_avi_botmapping.go @@ -61,7 +61,7 @@ func ResourceAviBotMappingRead(d *schema.ResourceData, meta interface{}) error { func resourceAviBotMappingCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotMappingSchema() - err := APICreate(d, meta, "botmapping", s) + err := APICreateOrUpdate(d, meta, "botmapping", s) if err == nil { err = ResourceAviBotMappingRead(d, meta) } @@ -71,7 +71,7 @@ func resourceAviBotMappingCreate(d *schema.ResourceData, meta interface{}) error func resourceAviBotMappingUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceBotMappingSchema() var err error - err = APIUpdate(d, meta, "botmapping", s) + err = APICreateOrUpdate(d, meta, "botmapping", s) if err == nil { err = ResourceAviBotMappingRead(d, meta) } diff --git a/avi/resource_avi_certificatemanagementprofile.go b/avi/resource_avi_certificatemanagementprofile.go index 66ed9af7..4b72597d 100644 --- a/avi/resource_avi_certificatemanagementprofile.go +++ b/avi/resource_avi_certificatemanagementprofile.go @@ -76,7 +76,7 @@ func ResourceAviCertificateManagementProfileRead(d *schema.ResourceData, meta in func resourceAviCertificateManagementProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceCertificateManagementProfileSchema() - err := APICreate(d, meta, "certificatemanagementprofile", s) + err := APICreateOrUpdate(d, meta, "certificatemanagementprofile", s) if err == nil { err = ResourceAviCertificateManagementProfileRead(d, meta) } @@ -86,7 +86,7 @@ func resourceAviCertificateManagementProfileCreate(d *schema.ResourceData, meta func resourceAviCertificateManagementProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceCertificateManagementProfileSchema() var err error - err = APIUpdate(d, meta, "certificatemanagementprofile", s) + err = APICreateOrUpdate(d, meta, "certificatemanagementprofile", s) if err == nil { err = ResourceAviCertificateManagementProfileRead(d, meta) } diff --git a/avi/resource_avi_cloud.go b/avi/resource_avi_cloud.go index 3945da3c..6cca0fb6 100644 --- a/avi/resource_avi_cloud.go +++ b/avi/resource_avi_cloud.go @@ -353,7 +353,7 @@ func setupVcenterMgmtNetwork(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.AviClient) vcenterConfig, _ := d.GetOk("vcenter_configuration") mgmtNetwork := vcenterConfig.(*schema.Set).List()[0].(map[string]interface{})["management_network"].(string) - if err := APIUpdate(d, meta, "cloud", s); err != nil { + if err := APICreateOrUpdate(d, meta, "cloud", s); err != nil { log.Printf("[Error] Got error for cloud create/update. Error: %s", err.Error()) return err } @@ -367,7 +367,7 @@ func setupVcenterMgmtNetwork(d *schema.ResourceData, meta interface{}) error { if err := waitForCloudState(uuid, "CLOUD_STATE_FAILED", client, maxRetry); err != nil { return err } - if err := APIUpdate(d, meta, "cloud", s); err != nil { + if err := APICreateOrUpdate(d, meta, "cloud", s); err != nil { log.Printf("[Error] Got error for cloud create/update. Error: %s", err.Error()) return err } @@ -385,7 +385,7 @@ func resourceAviCloudCreate(d *schema.ResourceData, meta interface{}) error { _, isVcenterConfig := d.GetOk("vcenter_configuration") if cloudType == "CLOUD_VCENTER" && isVcenterConfig { err = setupVcenterMgmtNetwork(d, meta) - } else if err = APICreate(d, meta, "cloud", s); err == nil { + } else if err = APICreateOrUpdate(d, meta, "cloud", s); err == nil { err = ResourceAviCloudRead(d, meta) } return err @@ -398,7 +398,7 @@ func resourceAviCloudUpdate(d *schema.ResourceData, meta interface{}) error { _, isVcenterConfig := d.GetOk("vcenter_configuration") if cloudType == "CLOUD_VCENTER" && isVcenterConfig { err = setupVcenterMgmtNetwork(d, meta) - } else if err = APIUpdate(d, meta, "cloud", s); err == nil { + } else if err = APICreateOrUpdate(d, meta, "cloud", s); err == nil { err = ResourceAviCloudRead(d, meta) } return err diff --git a/avi/resource_avi_cloudconnectoruser.go b/avi/resource_avi_cloudconnectoruser.go index bb034c7a..598af872 100644 --- a/avi/resource_avi_cloudconnectoruser.go +++ b/avi/resource_avi_cloudconnectoruser.go @@ -123,7 +123,7 @@ func ResourceAviCloudConnectorUserRead(d *schema.ResourceData, meta interface{}) func resourceAviCloudConnectorUserCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceCloudConnectorUserSchema() - err := APICreate(d, meta, "cloudconnectoruser", s) + err := APICreateOrUpdate(d, meta, "cloudconnectoruser", s) if err == nil { err = ResourceAviCloudConnectorUserRead(d, meta) } @@ -133,7 +133,7 @@ func resourceAviCloudConnectorUserCreate(d *schema.ResourceData, meta interface{ func resourceAviCloudConnectorUserUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceCloudConnectorUserSchema() var err error - err = APIUpdate(d, meta, "cloudconnectoruser", s) + err = APICreateOrUpdate(d, meta, "cloudconnectoruser", s) if err == nil { err = ResourceAviCloudConnectorUserRead(d, meta) } diff --git a/avi/resource_avi_cloudproperties.go b/avi/resource_avi_cloudproperties.go index 75fc3c97..5dbfe574 100644 --- a/avi/resource_avi_cloudproperties.go +++ b/avi/resource_avi_cloudproperties.go @@ -74,7 +74,7 @@ func ResourceAviCloudPropertiesRead(d *schema.ResourceData, meta interface{}) er func resourceAviCloudPropertiesCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceCloudPropertiesSchema() - err := APICreate(d, meta, "cloudproperties", s) + err := APICreateOrUpdate(d, meta, "cloudproperties", s) if err == nil { err = ResourceAviCloudPropertiesRead(d, meta) } @@ -84,7 +84,7 @@ func resourceAviCloudPropertiesCreate(d *schema.ResourceData, meta interface{}) func resourceAviCloudPropertiesUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceCloudPropertiesSchema() var err error - err = APIUpdate(d, meta, "cloudproperties", s) + err = APICreateOrUpdate(d, meta, "cloudproperties", s) if err == nil { err = ResourceAviCloudPropertiesRead(d, meta) } diff --git a/avi/resource_avi_cluster.go b/avi/resource_avi_cluster.go index 1333126f..eed86fd8 100644 --- a/avi/resource_avi_cluster.go +++ b/avi/resource_avi_cluster.go @@ -112,7 +112,7 @@ func ResourceAviClusterRead(d *schema.ResourceData, meta interface{}) error { func resourceAviClusterCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceClusterSchema() - err := APICreate(d, meta, "cluster", s) + err := APICreateOrUpdate(d, meta, "cluster", s) // Added wait for cluster initialization process as cluster initialization starts after few seconds. // This is necessary to store correct state of initialized cluster. time.Sleep(90 * time.Second) @@ -125,7 +125,7 @@ func resourceAviClusterCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviClusterUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceClusterSchema() var err error - err = APIUpdate(d, meta, "cluster", s) + err = APICreateOrUpdate(d, meta, "cluster", s) // Added wait for cluster initialization process as cluster initialization starts after few seconds. // This is necessary to store correct state of initialized cluster. time.Sleep(90 * time.Second) diff --git a/avi/resource_avi_clusterclouddetails.go b/avi/resource_avi_clusterclouddetails.go index ed1e0514..d4f87cbf 100644 --- a/avi/resource_avi_clusterclouddetails.go +++ b/avi/resource_avi_clusterclouddetails.go @@ -68,7 +68,7 @@ func ResourceAviClusterCloudDetailsRead(d *schema.ResourceData, meta interface{} func resourceAviClusterCloudDetailsCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceClusterCloudDetailsSchema() - err := APICreate(d, meta, "clusterclouddetails", s) + err := APICreateOrUpdate(d, meta, "clusterclouddetails", s) if err == nil { err = ResourceAviClusterCloudDetailsRead(d, meta) } @@ -78,7 +78,7 @@ func resourceAviClusterCloudDetailsCreate(d *schema.ResourceData, meta interface func resourceAviClusterCloudDetailsUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceClusterCloudDetailsSchema() var err error - err = APIUpdate(d, meta, "clusterclouddetails", s) + err = APICreateOrUpdate(d, meta, "clusterclouddetails", s) if err == nil { err = ResourceAviClusterCloudDetailsRead(d, meta) } diff --git a/avi/resource_avi_controllerportalregistration.go b/avi/resource_avi_controllerportalregistration.go index ccfda9da..97654ae4 100644 --- a/avi/resource_avi_controllerportalregistration.go +++ b/avi/resource_avi_controllerportalregistration.go @@ -68,7 +68,7 @@ func ResourceAviControllerPortalRegistrationRead(d *schema.ResourceData, meta in func resourceAviControllerPortalRegistrationCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceControllerPortalRegistrationSchema() - err := APICreate(d, meta, "controllerportalregistration", s) + err := APICreateOrUpdate(d, meta, "controllerportalregistration", s) if err == nil { err = ResourceAviControllerPortalRegistrationRead(d, meta) } @@ -78,7 +78,7 @@ func resourceAviControllerPortalRegistrationCreate(d *schema.ResourceData, meta func resourceAviControllerPortalRegistrationUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceControllerPortalRegistrationSchema() var err error - err = APIUpdate(d, meta, "controllerportalregistration", s) + err = APICreateOrUpdate(d, meta, "controllerportalregistration", s) if err == nil { err = ResourceAviControllerPortalRegistrationRead(d, meta) } diff --git a/avi/resource_avi_controllerproperties.go b/avi/resource_avi_controllerproperties.go index 02bc13e2..b3170aef 100644 --- a/avi/resource_avi_controllerproperties.go +++ b/avi/resource_avi_controllerproperties.go @@ -4,9 +4,8 @@ package avi import ( - "log" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "log" ) func ResourceControllerPropertiesSchema() map[string]*schema.Schema { @@ -718,7 +717,7 @@ func ResourceAviControllerPropertiesRead(d *schema.ResourceData, meta interface{ func resourceAviControllerPropertiesCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceControllerPropertiesSchema() - err := APICreate(d, meta, "controllerproperties", s) + err := APICreateOrUpdate(d, meta, "controllerproperties", s) if err == nil { err = ResourceAviControllerPropertiesRead(d, meta) } @@ -728,7 +727,7 @@ func resourceAviControllerPropertiesCreate(d *schema.ResourceData, meta interfac func resourceAviControllerPropertiesUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceControllerPropertiesSchema() var err error - err = APIUpdate(d, meta, "controllerproperties", s) + err = APICreateOrUpdate(d, meta, "controllerproperties", s) if err == nil { err = ResourceAviControllerPropertiesRead(d, meta) } diff --git a/avi/resource_avi_controllersite.go b/avi/resource_avi_controllersite.go index 3e42681f..0769ab44 100644 --- a/avi/resource_avi_controllersite.go +++ b/avi/resource_avi_controllersite.go @@ -72,7 +72,7 @@ func ResourceAviControllerSiteRead(d *schema.ResourceData, meta interface{}) err func resourceAviControllerSiteCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceControllerSiteSchema() - err := APICreate(d, meta, "controllersite", s) + err := APICreateOrUpdate(d, meta, "controllersite", s) if err == nil { err = ResourceAviControllerSiteRead(d, meta) } @@ -82,7 +82,7 @@ func resourceAviControllerSiteCreate(d *schema.ResourceData, meta interface{}) e func resourceAviControllerSiteUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceControllerSiteSchema() var err error - err = APIUpdate(d, meta, "controllersite", s) + err = APICreateOrUpdate(d, meta, "controllersite", s) if err == nil { err = ResourceAviControllerSiteRead(d, meta) } diff --git a/avi/resource_avi_csrfpolicy.go b/avi/resource_avi_csrfpolicy.go index d940f0c5..7559a4a2 100644 --- a/avi/resource_avi_csrfpolicy.go +++ b/avi/resource_avi_csrfpolicy.go @@ -83,7 +83,7 @@ func ResourceAviCSRFPolicyRead(d *schema.ResourceData, meta interface{}) error { func resourceAviCSRFPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceCSRFPolicySchema() - err := APICreate(d, meta, "csrfpolicy", s) + err := APICreateOrUpdate(d, meta, "csrfpolicy", s) if err == nil { err = ResourceAviCSRFPolicyRead(d, meta) } @@ -93,7 +93,7 @@ func resourceAviCSRFPolicyCreate(d *schema.ResourceData, meta interface{}) error func resourceAviCSRFPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceCSRFPolicySchema() var err error - err = APIUpdate(d, meta, "csrfpolicy", s) + err = APICreateOrUpdate(d, meta, "csrfpolicy", s) if err == nil { err = ResourceAviCSRFPolicyRead(d, meta) } diff --git a/avi/resource_avi_customipamdnsprofile.go b/avi/resource_avi_customipamdnsprofile.go index 44bad437..9d56c331 100644 --- a/avi/resource_avi_customipamdnsprofile.go +++ b/avi/resource_avi_customipamdnsprofile.go @@ -8,7 +8,7 @@ import ( "log" ) -// nolint +//nolint func ResourceCustomIpamDnsProfileSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "configpb_attributes": { @@ -43,7 +43,7 @@ func ResourceCustomIpamDnsProfileSchema() map[string]*schema.Schema { } } -// nolint +//nolint func resourceAviCustomIpamDnsProfile() *schema.Resource { return &schema.Resource{ Create: resourceAviCustomIpamDnsProfileCreate, @@ -57,13 +57,13 @@ func resourceAviCustomIpamDnsProfile() *schema.Resource { } } -// nolint +//nolint func ResourceCustomIpamDnsProfileImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { s := ResourceCustomIpamDnsProfileSchema() return ResourceImporter(d, m, "customipamdnsprofile", s) } -// nolint +//nolint func ResourceAviCustomIpamDnsProfileRead(d *schema.ResourceData, meta interface{}) error { s := ResourceCustomIpamDnsProfileSchema() err := APIRead(d, meta, "customipamdnsprofile", s) @@ -73,28 +73,28 @@ func ResourceAviCustomIpamDnsProfileRead(d *schema.ResourceData, meta interface{ return err } -// nolint +//nolint func resourceAviCustomIpamDnsProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceCustomIpamDnsProfileSchema() - err := APICreate(d, meta, "customipamdnsprofile", s) + err := APICreateOrUpdate(d, meta, "customipamdnsprofile", s) if err == nil { err = ResourceAviCustomIpamDnsProfileRead(d, meta) } return err } -// nolint +//nolint func resourceAviCustomIpamDnsProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceCustomIpamDnsProfileSchema() var err error - err = APIUpdate(d, meta, "customipamdnsprofile", s) + err = APICreateOrUpdate(d, meta, "customipamdnsprofile", s) if err == nil { err = ResourceAviCustomIpamDnsProfileRead(d, meta) } return err } -// nolint +//nolint func resourceAviCustomIpamDnsProfileDelete(d *schema.ResourceData, meta interface{}) error { var err error if APIDeleteSystemDefaultCheck(d) { diff --git a/avi/resource_avi_customipamdnsprofile_test.go b/avi/resource_avi_customipamdnsprofile_test.go index 3c1acb49..409a14ff 100644 --- a/avi/resource_avi_customipamdnsprofile_test.go +++ b/avi/resource_avi_customipamdnsprofile_test.go @@ -43,7 +43,7 @@ func TestAVICustomIpamDnsProfileBasic(t *testing.T) { } -// nolint +//nolint func testAccCheckAVICustomIpamDnsProfileExists(resourcename string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession @@ -67,7 +67,7 @@ func testAccCheckAVICustomIpamDnsProfileExists(resourcename string) resource.Tes } -// nolint +//nolint func testAccCheckAVICustomIpamDnsProfileDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession var obj interface{} @@ -92,7 +92,7 @@ func testAccCheckAVICustomIpamDnsProfileDestroy(s *terraform.State) error { return nil } -// nolint +//nolint const testAccAVICustomIpamDnsProfileConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" @@ -104,7 +104,7 @@ resource "avi_customipamdnsprofile" "testCustomIpamDnsProfile" { } ` -// nolint +//nolint const testAccAVICustomIpamDnsProfileupdatedConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/resource_avi_dnspolicy.go b/avi/resource_avi_dnspolicy.go index 5c65c2a0..7d1a5815 100644 --- a/avi/resource_avi_dnspolicy.go +++ b/avi/resource_avi_dnspolicy.go @@ -8,7 +8,7 @@ import ( "log" ) -// nolint +//nolint func ResourceDnsPolicySchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "configpb_attributes": { @@ -60,7 +60,7 @@ func ResourceDnsPolicySchema() map[string]*schema.Schema { } } -// nolint +//nolint func resourceAviDnsPolicy() *schema.Resource { return &schema.Resource{ Create: resourceAviDnsPolicyCreate, @@ -74,13 +74,13 @@ func resourceAviDnsPolicy() *schema.Resource { } } -// nolint +//nolint func ResourceDnsPolicyImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { s := ResourceDnsPolicySchema() return ResourceImporter(d, m, "dnspolicy", s) } -// nolint +//nolint func ResourceAviDnsPolicyRead(d *schema.ResourceData, meta interface{}) error { s := ResourceDnsPolicySchema() err := APIRead(d, meta, "dnspolicy", s) @@ -90,28 +90,28 @@ func ResourceAviDnsPolicyRead(d *schema.ResourceData, meta interface{}) error { return err } -// nolint +//nolint func resourceAviDnsPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceDnsPolicySchema() - err := APICreate(d, meta, "dnspolicy", s) + err := APICreateOrUpdate(d, meta, "dnspolicy", s) if err == nil { err = ResourceAviDnsPolicyRead(d, meta) } return err } -// nolint +//nolint func resourceAviDnsPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceDnsPolicySchema() var err error - err = APIUpdate(d, meta, "dnspolicy", s) + err = APICreateOrUpdate(d, meta, "dnspolicy", s) if err == nil { err = ResourceAviDnsPolicyRead(d, meta) } return err } -// nolint +//nolint func resourceAviDnsPolicyDelete(d *schema.ResourceData, meta interface{}) error { var err error if APIDeleteSystemDefaultCheck(d) { diff --git a/avi/resource_avi_dnspolicy_test.go b/avi/resource_avi_dnspolicy_test.go index d070de8d..ca7694dd 100644 --- a/avi/resource_avi_dnspolicy_test.go +++ b/avi/resource_avi_dnspolicy_test.go @@ -43,7 +43,7 @@ func TestAVIDnsPolicyBasic(t *testing.T) { } -// nolint +//nolint func testAccCheckAVIDnsPolicyExists(resourcename string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession @@ -67,7 +67,7 @@ func testAccCheckAVIDnsPolicyExists(resourcename string) resource.TestCheckFunc } -// nolint +//nolint func testAccCheckAVIDnsPolicyDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession var obj interface{} @@ -92,7 +92,7 @@ func testAccCheckAVIDnsPolicyDestroy(s *terraform.State) error { return nil } -// nolint +//nolint const testAccAVIDnsPolicyConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" @@ -104,7 +104,7 @@ resource "avi_dnspolicy" "testDnsPolicy" { } ` -// nolint +//nolint const testAccAVIDnsPolicyupdatedConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/resource_avi_dynamicdnsrecord.go b/avi/resource_avi_dynamicdnsrecord.go index f9ecfca0..306ec328 100644 --- a/avi/resource_avi_dynamicdnsrecord.go +++ b/avi/resource_avi_dynamicdnsrecord.go @@ -8,7 +8,7 @@ import ( "log" ) -// nolint +//nolint func ResourceDynamicDnsRecordSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "algorithm": { @@ -119,7 +119,7 @@ func ResourceDynamicDnsRecordSchema() map[string]*schema.Schema { } } -// nolint +//nolint func resourceAviDynamicDnsRecord() *schema.Resource { return &schema.Resource{ Create: resourceAviDynamicDnsRecordCreate, @@ -133,13 +133,13 @@ func resourceAviDynamicDnsRecord() *schema.Resource { } } -// nolint +//nolint func ResourceDynamicDnsRecordImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { s := ResourceDynamicDnsRecordSchema() return ResourceImporter(d, m, "dynamicdnsrecord", s) } -// nolint +//nolint func ResourceAviDynamicDnsRecordRead(d *schema.ResourceData, meta interface{}) error { s := ResourceDynamicDnsRecordSchema() err := APIRead(d, meta, "dynamicdnsrecord", s) @@ -149,28 +149,28 @@ func ResourceAviDynamicDnsRecordRead(d *schema.ResourceData, meta interface{}) e return err } -// nolint +//nolint func resourceAviDynamicDnsRecordCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceDynamicDnsRecordSchema() - err := APICreate(d, meta, "dynamicdnsrecord", s) + err := APICreateOrUpdate(d, meta, "dynamicdnsrecord", s) if err == nil { err = ResourceAviDynamicDnsRecordRead(d, meta) } return err } -// nolint +//nolint func resourceAviDynamicDnsRecordUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceDynamicDnsRecordSchema() var err error - err = APIUpdate(d, meta, "dynamicdnsrecord", s) + err = APICreateOrUpdate(d, meta, "dynamicdnsrecord", s) if err == nil { err = ResourceAviDynamicDnsRecordRead(d, meta) } return err } -// nolint +//nolint func resourceAviDynamicDnsRecordDelete(d *schema.ResourceData, meta interface{}) error { var err error if APIDeleteSystemDefaultCheck(d) { diff --git a/avi/resource_avi_errorpagebody.go b/avi/resource_avi_errorpagebody.go index 5026bd07..41414608 100644 --- a/avi/resource_avi_errorpagebody.go +++ b/avi/resource_avi_errorpagebody.go @@ -76,7 +76,7 @@ func ResourceAviErrorPageBodyRead(d *schema.ResourceData, meta interface{}) erro func resourceAviErrorPageBodyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceErrorPageBodySchema() - err := APICreate(d, meta, "errorpagebody", s) + err := APICreateOrUpdate(d, meta, "errorpagebody", s) if err == nil { err = ResourceAviErrorPageBodyRead(d, meta) } @@ -86,7 +86,7 @@ func resourceAviErrorPageBodyCreate(d *schema.ResourceData, meta interface{}) er func resourceAviErrorPageBodyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceErrorPageBodySchema() var err error - err = APIUpdate(d, meta, "errorpagebody", s) + err = APICreateOrUpdate(d, meta, "errorpagebody", s) if err == nil { err = ResourceAviErrorPageBodyRead(d, meta) } diff --git a/avi/resource_avi_errorpageprofile.go b/avi/resource_avi_errorpageprofile.go index e8092428..6f1a09d9 100644 --- a/avi/resource_avi_errorpageprofile.go +++ b/avi/resource_avi_errorpageprofile.go @@ -72,7 +72,7 @@ func ResourceAviErrorPageProfileRead(d *schema.ResourceData, meta interface{}) e func resourceAviErrorPageProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceErrorPageProfileSchema() - err := APICreate(d, meta, "errorpageprofile", s) + err := APICreateOrUpdate(d, meta, "errorpageprofile", s) if err == nil { err = ResourceAviErrorPageProfileRead(d, meta) } @@ -82,7 +82,7 @@ func resourceAviErrorPageProfileCreate(d *schema.ResourceData, meta interface{}) func resourceAviErrorPageProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceErrorPageProfileSchema() var err error - err = APIUpdate(d, meta, "errorpageprofile", s) + err = APICreateOrUpdate(d, meta, "errorpageprofile", s) if err == nil { err = ResourceAviErrorPageProfileRead(d, meta) } diff --git a/avi/resource_avi_federationcheckpoint.go b/avi/resource_avi_federationcheckpoint.go index b291e469..242388ff 100644 --- a/avi/resource_avi_federationcheckpoint.go +++ b/avi/resource_avi_federationcheckpoint.go @@ -78,7 +78,7 @@ func ResourceAviFederationCheckpointRead(d *schema.ResourceData, meta interface{ func resourceAviFederationCheckpointCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceFederationCheckpointSchema() - err := APICreate(d, meta, "federationcheckpoint", s) + err := APICreateOrUpdate(d, meta, "federationcheckpoint", s) if err == nil { err = ResourceAviFederationCheckpointRead(d, meta) } @@ -88,7 +88,7 @@ func resourceAviFederationCheckpointCreate(d *schema.ResourceData, meta interfac func resourceAviFederationCheckpointUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceFederationCheckpointSchema() var err error - err = APIUpdate(d, meta, "federationcheckpoint", s) + err = APICreateOrUpdate(d, meta, "federationcheckpoint", s) if err == nil { err = ResourceAviFederationCheckpointRead(d, meta) } diff --git a/avi/resource_avi_fileobject.go b/avi/resource_avi_fileobject.go index 9815805d..3ea807a4 100644 --- a/avi/resource_avi_fileobject.go +++ b/avi/resource_avi_fileobject.go @@ -132,7 +132,7 @@ func ResourceAviFileObjectRead(d *schema.ResourceData, meta interface{}) error { func resourceAviFileObjectCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceFileObjectSchema() - err := APICreate(d, meta, "fileobject", s) + err := APICreateOrUpdate(d, meta, "fileobject", s) if err == nil { err = ResourceAviFileObjectRead(d, meta) } @@ -142,7 +142,7 @@ func resourceAviFileObjectCreate(d *schema.ResourceData, meta interface{}) error func resourceAviFileObjectUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceFileObjectSchema() var err error - err = APIUpdate(d, meta, "fileobject", s) + err = APICreateOrUpdate(d, meta, "fileobject", s) if err == nil { err = ResourceAviFileObjectRead(d, meta) } diff --git a/avi/resource_avi_geodb.go b/avi/resource_avi_geodb.go index d821f595..7e0c2527 100644 --- a/avi/resource_avi_geodb.go +++ b/avi/resource_avi_geodb.go @@ -77,7 +77,7 @@ func ResourceAviGeoDBRead(d *schema.ResourceData, meta interface{}) error { func resourceAviGeoDBCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceGeoDBSchema() - err := APICreate(d, meta, "geodb", s) + err := APICreateOrUpdate(d, meta, "geodb", s) if err == nil { err = ResourceAviGeoDBRead(d, meta) } @@ -87,7 +87,7 @@ func resourceAviGeoDBCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviGeoDBUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceGeoDBSchema() var err error - err = APIUpdate(d, meta, "geodb", s) + err = APICreateOrUpdate(d, meta, "geodb", s) if err == nil { err = ResourceAviGeoDBRead(d, meta) } diff --git a/avi/resource_avi_gslb.go b/avi/resource_avi_gslb.go index 065a5f7c..e7b388e0 100644 --- a/avi/resource_avi_gslb.go +++ b/avi/resource_avi_gslb.go @@ -164,7 +164,7 @@ func ResourceAviGslbRead(d *schema.ResourceData, meta interface{}) error { func resourceAviGslbCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceGslbSchema() - err := APICreate(d, meta, "gslb", s) + err := APICreateOrUpdate(d, meta, "gslb", s) if err == nil { err = ResourceAviGslbRead(d, meta) } @@ -174,7 +174,7 @@ func resourceAviGslbCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviGslbUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceGslbSchema() var err error - err = APIUpdate(d, meta, "gslb", s) + err = APICreateOrUpdate(d, meta, "gslb", s) if err == nil { err = ResourceAviGslbRead(d, meta) } diff --git a/avi/resource_avi_gslbgeodbprofile.go b/avi/resource_avi_gslbgeodbprofile.go index b41646b9..cc8f70a2 100644 --- a/avi/resource_avi_gslbgeodbprofile.go +++ b/avi/resource_avi_gslbgeodbprofile.go @@ -83,7 +83,7 @@ func ResourceAviGslbGeoDbProfileRead(d *schema.ResourceData, meta interface{}) e func resourceAviGslbGeoDbProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceGslbGeoDbProfileSchema() - err := APICreate(d, meta, "gslbgeodbprofile", s) + err := APICreateOrUpdate(d, meta, "gslbgeodbprofile", s) if err == nil { err = ResourceAviGslbGeoDbProfileRead(d, meta) } @@ -93,7 +93,7 @@ func resourceAviGslbGeoDbProfileCreate(d *schema.ResourceData, meta interface{}) func resourceAviGslbGeoDbProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceGslbGeoDbProfileSchema() var err error - err = APIUpdate(d, meta, "gslbgeodbprofile", s) + err = APICreateOrUpdate(d, meta, "gslbgeodbprofile", s) if err == nil { err = ResourceAviGslbGeoDbProfileRead(d, meta) } diff --git a/avi/resource_avi_gslbservice.go b/avi/resource_avi_gslbservice.go index b022426d..d72cb5a4 100644 --- a/avi/resource_avi_gslbservice.go +++ b/avi/resource_avi_gslbservice.go @@ -190,7 +190,7 @@ func ResourceAviGslbServiceRead(d *schema.ResourceData, meta interface{}) error func resourceAviGslbServiceCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceGslbServiceSchema() - err := APICreate(d, meta, "gslbservice", s) + err := APICreateOrUpdate(d, meta, "gslbservice", s) if err == nil { err = ResourceAviGslbServiceRead(d, meta) } @@ -200,7 +200,7 @@ func resourceAviGslbServiceCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviGslbServiceUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceGslbServiceSchema() var err error - err = APIUpdate(d, meta, "gslbservice", s) + err = APICreateOrUpdate(d, meta, "gslbservice", s) if err == nil { err = ResourceAviGslbServiceRead(d, meta) } diff --git a/avi/resource_avi_hardwaresecuritymodulegroup.go b/avi/resource_avi_hardwaresecuritymodulegroup.go index 263c83f8..20c7c63b 100644 --- a/avi/resource_avi_hardwaresecuritymodulegroup.go +++ b/avi/resource_avi_hardwaresecuritymodulegroup.go @@ -72,7 +72,7 @@ func ResourceAviHardwareSecurityModuleGroupRead(d *schema.ResourceData, meta int func resourceAviHardwareSecurityModuleGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceHardwareSecurityModuleGroupSchema() - err := APICreate(d, meta, "hardwaresecuritymodulegroup", s) + err := APICreateOrUpdate(d, meta, "hardwaresecuritymodulegroup", s) if err == nil { err = ResourceAviHardwareSecurityModuleGroupRead(d, meta) } @@ -82,7 +82,7 @@ func resourceAviHardwareSecurityModuleGroupCreate(d *schema.ResourceData, meta i func resourceAviHardwareSecurityModuleGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceHardwareSecurityModuleGroupSchema() var err error - err = APIUpdate(d, meta, "hardwaresecuritymodulegroup", s) + err = APICreateOrUpdate(d, meta, "hardwaresecuritymodulegroup", s) if err == nil { err = ResourceAviHardwareSecurityModuleGroupRead(d, meta) } diff --git a/avi/resource_avi_healthmonitor.go b/avi/resource_avi_healthmonitor.go index ba620796..a5e8b50f 100644 --- a/avi/resource_avi_healthmonitor.go +++ b/avi/resource_avi_healthmonitor.go @@ -244,7 +244,7 @@ func ResourceAviHealthMonitorRead(d *schema.ResourceData, meta interface{}) erro func resourceAviHealthMonitorCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceHealthMonitorSchema() - err := APICreate(d, meta, "healthmonitor", s) + err := APICreateOrUpdate(d, meta, "healthmonitor", s) if err == nil { err = ResourceAviHealthMonitorRead(d, meta) } @@ -254,7 +254,7 @@ func resourceAviHealthMonitorCreate(d *schema.ResourceData, meta interface{}) er func resourceAviHealthMonitorUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceHealthMonitorSchema() var err error - err = APIUpdate(d, meta, "healthmonitor", s) + err = APICreateOrUpdate(d, meta, "healthmonitor", s) if err == nil { err = ResourceAviHealthMonitorRead(d, meta) } diff --git a/avi/resource_avi_httppolicyset.go b/avi/resource_avi_httppolicyset.go index 0fda4192..d5151c2f 100644 --- a/avi/resource_avi_httppolicyset.go +++ b/avi/resource_avi_httppolicyset.go @@ -116,7 +116,7 @@ func ResourceAviHTTPPolicySetRead(d *schema.ResourceData, meta interface{}) erro func resourceAviHTTPPolicySetCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceHTTPPolicySetSchema() - err := APICreate(d, meta, "httppolicyset", s) + err := APICreateOrUpdate(d, meta, "httppolicyset", s) if err == nil { err = ResourceAviHTTPPolicySetRead(d, meta) } @@ -126,7 +126,7 @@ func resourceAviHTTPPolicySetCreate(d *schema.ResourceData, meta interface{}) er func resourceAviHTTPPolicySetUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceHTTPPolicySetSchema() var err error - err = APIUpdate(d, meta, "httppolicyset", s) + err = APICreateOrUpdate(d, meta, "httppolicyset", s) if err == nil { err = ResourceAviHTTPPolicySetRead(d, meta) } diff --git a/avi/resource_avi_icapprofile.go b/avi/resource_avi_icapprofile.go index 2418d323..93424679 100644 --- a/avi/resource_avi_icapprofile.go +++ b/avi/resource_avi_icapprofile.go @@ -137,7 +137,7 @@ func ResourceAviIcapProfileRead(d *schema.ResourceData, meta interface{}) error func resourceAviIcapProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceIcapProfileSchema() - err := APICreate(d, meta, "icapprofile", s) + err := APICreateOrUpdate(d, meta, "icapprofile", s) if err == nil { err = ResourceAviIcapProfileRead(d, meta) } @@ -147,7 +147,7 @@ func resourceAviIcapProfileCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviIcapProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceIcapProfileSchema() var err error - err = APIUpdate(d, meta, "icapprofile", s) + err = APICreateOrUpdate(d, meta, "icapprofile", s) if err == nil { err = ResourceAviIcapProfileRead(d, meta) } diff --git a/avi/resource_avi_image.go b/avi/resource_avi_image.go index f13f2665..c6c97deb 100644 --- a/avi/resource_avi_image.go +++ b/avi/resource_avi_image.go @@ -161,7 +161,7 @@ func ResourceAviImageRead(d *schema.ResourceData, meta interface{}) error { func resourceAviImageCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceImageSchema() - err := APICreate(d, meta, "image", s) + err := APICreateOrUpdate(d, meta, "image", s) if err == nil { err = ResourceAviImageRead(d, meta) } @@ -171,7 +171,7 @@ func resourceAviImageCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviImageUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceImageSchema() var err error - err = APIUpdate(d, meta, "image", s) + err = APICreateOrUpdate(d, meta, "image", s) if err == nil { err = ResourceAviImageRead(d, meta) } diff --git a/avi/resource_avi_inventoryfaultconfig.go b/avi/resource_avi_inventoryfaultconfig.go index 5766e14a..be7cb52b 100644 --- a/avi/resource_avi_inventoryfaultconfig.go +++ b/avi/resource_avi_inventoryfaultconfig.go @@ -81,7 +81,7 @@ func ResourceAviInventoryFaultConfigRead(d *schema.ResourceData, meta interface{ func resourceAviInventoryFaultConfigCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceInventoryFaultConfigSchema() - err := APICreate(d, meta, "inventoryfaultconfig", s) + err := APICreateOrUpdate(d, meta, "inventoryfaultconfig", s) if err == nil { err = ResourceAviInventoryFaultConfigRead(d, meta) } @@ -91,7 +91,7 @@ func resourceAviInventoryFaultConfigCreate(d *schema.ResourceData, meta interfac func resourceAviInventoryFaultConfigUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceInventoryFaultConfigSchema() var err error - err = APIUpdate(d, meta, "inventoryfaultconfig", s) + err = APICreateOrUpdate(d, meta, "inventoryfaultconfig", s) if err == nil { err = ResourceAviInventoryFaultConfigRead(d, meta) } diff --git a/avi/resource_avi_ipaddrgroup.go b/avi/resource_avi_ipaddrgroup.go index ba80c25f..f5429ca7 100644 --- a/avi/resource_avi_ipaddrgroup.go +++ b/avi/resource_avi_ipaddrgroup.go @@ -8,7 +8,7 @@ import ( "log" ) -// nolint +//nolint func ResourceIpAddrGroupSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "addrs": { @@ -80,7 +80,7 @@ func ResourceIpAddrGroupSchema() map[string]*schema.Schema { } } -// nolint +//nolint func resourceAviIpAddrGroup() *schema.Resource { return &schema.Resource{ Create: resourceAviIpAddrGroupCreate, @@ -94,13 +94,13 @@ func resourceAviIpAddrGroup() *schema.Resource { } } -// nolint +//nolint func ResourceIpAddrGroupImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { s := ResourceIpAddrGroupSchema() return ResourceImporter(d, m, "ipaddrgroup", s) } -// nolint +//nolint func ResourceAviIpAddrGroupRead(d *schema.ResourceData, meta interface{}) error { s := ResourceIpAddrGroupSchema() err := APIRead(d, meta, "ipaddrgroup", s) @@ -110,28 +110,28 @@ func ResourceAviIpAddrGroupRead(d *schema.ResourceData, meta interface{}) error return err } -// nolint +//nolint func resourceAviIpAddrGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceIpAddrGroupSchema() - err := APICreate(d, meta, "ipaddrgroup", s) + err := APICreateOrUpdate(d, meta, "ipaddrgroup", s) if err == nil { err = ResourceAviIpAddrGroupRead(d, meta) } return err } -// nolint +//nolint func resourceAviIpAddrGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceIpAddrGroupSchema() var err error - err = APIUpdate(d, meta, "ipaddrgroup", s) + err = APICreateOrUpdate(d, meta, "ipaddrgroup", s) if err == nil { err = ResourceAviIpAddrGroupRead(d, meta) } return err } -// nolint +//nolint func resourceAviIpAddrGroupDelete(d *schema.ResourceData, meta interface{}) error { var err error if APIDeleteSystemDefaultCheck(d) { diff --git a/avi/resource_avi_ipaddrgroup_test.go b/avi/resource_avi_ipaddrgroup_test.go index 3609b932..0d7d99c0 100644 --- a/avi/resource_avi_ipaddrgroup_test.go +++ b/avi/resource_avi_ipaddrgroup_test.go @@ -43,7 +43,7 @@ func TestAVIIpAddrGroupBasic(t *testing.T) { } -// nolint +//nolint func testAccCheckAVIIpAddrGroupExists(resourcename string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession @@ -67,7 +67,7 @@ func testAccCheckAVIIpAddrGroupExists(resourcename string) resource.TestCheckFun } -// nolint +//nolint func testAccCheckAVIIpAddrGroupDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession var obj interface{} @@ -92,7 +92,7 @@ func testAccCheckAVIIpAddrGroupDestroy(s *terraform.State) error { return nil } -// nolint +//nolint const testAccAVIIpAddrGroupConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" @@ -124,7 +124,7 @@ prefixes { } ` -// nolint +//nolint const testAccAVIIpAddrGroupupdatedConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/resource_avi_ipamdnsproviderprofile.go b/avi/resource_avi_ipamdnsproviderprofile.go index c099aea2..ee85e487 100644 --- a/avi/resource_avi_ipamdnsproviderprofile.go +++ b/avi/resource_avi_ipamdnsproviderprofile.go @@ -8,7 +8,7 @@ import ( "log" ) -// nolint +//nolint func ResourceIpamDnsProviderProfileSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "allocate_ip_in_vrf": { @@ -109,7 +109,7 @@ func ResourceIpamDnsProviderProfileSchema() map[string]*schema.Schema { } } -// nolint +//nolint func resourceAviIpamDnsProviderProfile() *schema.Resource { return &schema.Resource{ Create: resourceAviIpamDnsProviderProfileCreate, @@ -123,13 +123,13 @@ func resourceAviIpamDnsProviderProfile() *schema.Resource { } } -// nolint +//nolint func ResourceIpamDnsProviderProfileImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { s := ResourceIpamDnsProviderProfileSchema() return ResourceImporter(d, m, "ipamdnsproviderprofile", s) } -// nolint +//nolint func ResourceAviIpamDnsProviderProfileRead(d *schema.ResourceData, meta interface{}) error { s := ResourceIpamDnsProviderProfileSchema() err := APIRead(d, meta, "ipamdnsproviderprofile", s) @@ -139,28 +139,28 @@ func ResourceAviIpamDnsProviderProfileRead(d *schema.ResourceData, meta interfac return err } -// nolint +//nolint func resourceAviIpamDnsProviderProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceIpamDnsProviderProfileSchema() - err := APICreate(d, meta, "ipamdnsproviderprofile", s) + err := APICreateOrUpdate(d, meta, "ipamdnsproviderprofile", s) if err == nil { err = ResourceAviIpamDnsProviderProfileRead(d, meta) } return err } -// nolint +//nolint func resourceAviIpamDnsProviderProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceIpamDnsProviderProfileSchema() var err error - err = APIUpdate(d, meta, "ipamdnsproviderprofile", s) + err = APICreateOrUpdate(d, meta, "ipamdnsproviderprofile", s) if err == nil { err = ResourceAviIpamDnsProviderProfileRead(d, meta) } return err } -// nolint +//nolint func resourceAviIpamDnsProviderProfileDelete(d *schema.ResourceData, meta interface{}) error { var err error if APIDeleteSystemDefaultCheck(d) { diff --git a/avi/resource_avi_ipamdnsproviderprofile_test.go b/avi/resource_avi_ipamdnsproviderprofile_test.go index b4230a33..6008064a 100644 --- a/avi/resource_avi_ipamdnsproviderprofile_test.go +++ b/avi/resource_avi_ipamdnsproviderprofile_test.go @@ -47,7 +47,7 @@ func TestAVIIpamDnsProviderProfileBasic(t *testing.T) { } -// nolint +//nolint func testAccCheckAVIIpamDnsProviderProfileExists(resourcename string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession @@ -71,7 +71,7 @@ func testAccCheckAVIIpamDnsProviderProfileExists(resourcename string) resource.T } -// nolint +//nolint func testAccCheckAVIIpamDnsProviderProfileDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*clients.AviClient).AviSession var obj interface{} @@ -96,7 +96,7 @@ func testAccCheckAVIIpamDnsProviderProfileDestroy(s *terraform.State) error { return nil } -// nolint +//nolint const testAccAVIIpamDnsProviderProfileConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" @@ -112,7 +112,7 @@ resource "avi_ipamdnsproviderprofile" "testIpamDnsProviderProfile" { } ` -// nolint +//nolint const testAccAVIIpamDnsProviderProfileupdatedConfig = ` data "avi_tenant" "default_tenant"{ name= "admin" diff --git a/avi/resource_avi_ipreputationdb.go b/avi/resource_avi_ipreputationdb.go index 40a909a1..fa370a3c 100644 --- a/avi/resource_avi_ipreputationdb.go +++ b/avi/resource_avi_ipreputationdb.go @@ -97,7 +97,7 @@ func ResourceAviIPReputationDBRead(d *schema.ResourceData, meta interface{}) err func resourceAviIPReputationDBCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceIPReputationDBSchema() - err := APICreate(d, meta, "ipreputationdb", s) + err := APICreateOrUpdate(d, meta, "ipreputationdb", s) if err == nil { err = ResourceAviIPReputationDBRead(d, meta) } @@ -107,7 +107,7 @@ func resourceAviIPReputationDBCreate(d *schema.ResourceData, meta interface{}) e func resourceAviIPReputationDBUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceIPReputationDBSchema() var err error - err = APIUpdate(d, meta, "ipreputationdb", s) + err = APICreateOrUpdate(d, meta, "ipreputationdb", s) if err == nil { err = ResourceAviIPReputationDBRead(d, meta) } diff --git a/avi/resource_avi_jwtserverprofile.go b/avi/resource_avi_jwtserverprofile.go index eb7dc0b4..834953aa 100644 --- a/avi/resource_avi_jwtserverprofile.go +++ b/avi/resource_avi_jwtserverprofile.go @@ -89,7 +89,7 @@ func ResourceAviJWTServerProfileRead(d *schema.ResourceData, meta interface{}) e func resourceAviJWTServerProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceJWTServerProfileSchema() - err := APICreate(d, meta, "jwtserverprofile", s) + err := APICreateOrUpdate(d, meta, "jwtserverprofile", s) if err == nil { err = ResourceAviJWTServerProfileRead(d, meta) } @@ -99,7 +99,7 @@ func resourceAviJWTServerProfileCreate(d *schema.ResourceData, meta interface{}) func resourceAviJWTServerProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceJWTServerProfileSchema() var err error - err = APIUpdate(d, meta, "jwtserverprofile", s) + err = APICreateOrUpdate(d, meta, "jwtserverprofile", s) if err == nil { err = ResourceAviJWTServerProfileRead(d, meta) } diff --git a/avi/resource_avi_l4policyset.go b/avi/resource_avi_l4policyset.go index befea648..d4eba735 100644 --- a/avi/resource_avi_l4policyset.go +++ b/avi/resource_avi_l4policyset.go @@ -89,7 +89,7 @@ func ResourceAviL4PolicySetRead(d *schema.ResourceData, meta interface{}) error func resourceAviL4PolicySetCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceL4PolicySetSchema() - err := APICreate(d, meta, "l4policyset", s) + err := APICreateOrUpdate(d, meta, "l4policyset", s) if err == nil { err = ResourceAviL4PolicySetRead(d, meta) } @@ -99,7 +99,7 @@ func resourceAviL4PolicySetCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviL4PolicySetUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceL4PolicySetSchema() var err error - err = APIUpdate(d, meta, "l4policyset", s) + err = APICreateOrUpdate(d, meta, "l4policyset", s) if err == nil { err = ResourceAviL4PolicySetRead(d, meta) } diff --git a/avi/resource_avi_labelgroup.go b/avi/resource_avi_labelgroup.go index 680b3217..b7aec83c 100644 --- a/avi/resource_avi_labelgroup.go +++ b/avi/resource_avi_labelgroup.go @@ -62,7 +62,7 @@ func ResourceAviLabelGroupRead(d *schema.ResourceData, meta interface{}) error { func resourceAviLabelGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceLabelGroupSchema() - err := APICreate(d, meta, "labelgroup", s) + err := APICreateOrUpdate(d, meta, "labelgroup", s) if err == nil { err = ResourceAviLabelGroupRead(d, meta) } @@ -72,7 +72,7 @@ func resourceAviLabelGroupCreate(d *schema.ResourceData, meta interface{}) error func resourceAviLabelGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceLabelGroupSchema() var err error - err = APIUpdate(d, meta, "labelgroup", s) + err = APICreateOrUpdate(d, meta, "labelgroup", s) if err == nil { err = ResourceAviLabelGroupRead(d, meta) } diff --git a/avi/resource_avi_licenseledgerdetails.go b/avi/resource_avi_licenseledgerdetails.go index bfe79fa6..f7ad1fdc 100644 --- a/avi/resource_avi_licenseledgerdetails.go +++ b/avi/resource_avi_licenseledgerdetails.go @@ -62,7 +62,7 @@ func ResourceAviLicenseLedgerDetailsRead(d *schema.ResourceData, meta interface{ func resourceAviLicenseLedgerDetailsCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceLicenseLedgerDetailsSchema() - err := APICreate(d, meta, "licenseledgerdetails", s) + err := APICreateOrUpdate(d, meta, "licenseledgerdetails", s) if err == nil { err = ResourceAviLicenseLedgerDetailsRead(d, meta) } @@ -72,7 +72,7 @@ func resourceAviLicenseLedgerDetailsCreate(d *schema.ResourceData, meta interfac func resourceAviLicenseLedgerDetailsUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceLicenseLedgerDetailsSchema() var err error - err = APIUpdate(d, meta, "licenseledgerdetails", s) + err = APICreateOrUpdate(d, meta, "licenseledgerdetails", s) if err == nil { err = ResourceAviLicenseLedgerDetailsRead(d, meta) } diff --git a/avi/resource_avi_licensestatus.go b/avi/resource_avi_licensestatus.go index ad225785..57050786 100644 --- a/avi/resource_avi_licensestatus.go +++ b/avi/resource_avi_licensestatus.go @@ -70,7 +70,7 @@ func ResourceAviLicenseStatusRead(d *schema.ResourceData, meta interface{}) erro func resourceAviLicenseStatusCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceLicenseStatusSchema() - err := APICreate(d, meta, "licensestatus", s) + err := APICreateOrUpdate(d, meta, "licensestatus", s) if err == nil { err = ResourceAviLicenseStatusRead(d, meta) } @@ -80,7 +80,7 @@ func resourceAviLicenseStatusCreate(d *schema.ResourceData, meta interface{}) er func resourceAviLicenseStatusUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceLicenseStatusSchema() var err error - err = APIUpdate(d, meta, "licensestatus", s) + err = APICreateOrUpdate(d, meta, "licensestatus", s) if err == nil { err = ResourceAviLicenseStatusRead(d, meta) } diff --git a/avi/resource_avi_memorybalancerrequest.go b/avi/resource_avi_memorybalancerrequest.go index d01fbf94..38af403d 100644 --- a/avi/resource_avi_memorybalancerrequest.go +++ b/avi/resource_avi_memorybalancerrequest.go @@ -89,7 +89,7 @@ func ResourceAviMemoryBalancerRequestRead(d *schema.ResourceData, meta interface func resourceAviMemoryBalancerRequestCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceMemoryBalancerRequestSchema() - err := APICreate(d, meta, "memorybalancerrequest", s) + err := APICreateOrUpdate(d, meta, "memorybalancerrequest", s) if err == nil { err = ResourceAviMemoryBalancerRequestRead(d, meta) } @@ -99,7 +99,7 @@ func resourceAviMemoryBalancerRequestCreate(d *schema.ResourceData, meta interfa func resourceAviMemoryBalancerRequestUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceMemoryBalancerRequestSchema() var err error - err = APIUpdate(d, meta, "memorybalancerrequest", s) + err = APICreateOrUpdate(d, meta, "memorybalancerrequest", s) if err == nil { err = ResourceAviMemoryBalancerRequestRead(d, meta) } diff --git a/avi/resource_avi_microservicegroup.go b/avi/resource_avi_microservicegroup.go index ec12ecf6..f3b14e56 100644 --- a/avi/resource_avi_microservicegroup.go +++ b/avi/resource_avi_microservicegroup.go @@ -77,7 +77,7 @@ func ResourceAviMicroServiceGroupRead(d *schema.ResourceData, meta interface{}) func resourceAviMicroServiceGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceMicroServiceGroupSchema() - err := APICreate(d, meta, "microservicegroup", s) + err := APICreateOrUpdate(d, meta, "microservicegroup", s) if err == nil { err = ResourceAviMicroServiceGroupRead(d, meta) } @@ -87,7 +87,7 @@ func resourceAviMicroServiceGroupCreate(d *schema.ResourceData, meta interface{} func resourceAviMicroServiceGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceMicroServiceGroupSchema() var err error - err = APIUpdate(d, meta, "microservicegroup", s) + err = APICreateOrUpdate(d, meta, "microservicegroup", s) if err == nil { err = ResourceAviMicroServiceGroupRead(d, meta) } diff --git a/avi/resource_avi_natpolicy.go b/avi/resource_avi_natpolicy.go index aa4f3136..7b5154f2 100644 --- a/avi/resource_avi_natpolicy.go +++ b/avi/resource_avi_natpolicy.go @@ -83,7 +83,7 @@ func ResourceAviNatPolicyRead(d *schema.ResourceData, meta interface{}) error { func resourceAviNatPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceNatPolicySchema() - err := APICreate(d, meta, "natpolicy", s) + err := APICreateOrUpdate(d, meta, "natpolicy", s) if err == nil { err = ResourceAviNatPolicyRead(d, meta) } @@ -93,7 +93,7 @@ func resourceAviNatPolicyCreate(d *schema.ResourceData, meta interface{}) error func resourceAviNatPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceNatPolicySchema() var err error - err = APIUpdate(d, meta, "natpolicy", s) + err = APICreateOrUpdate(d, meta, "natpolicy", s) if err == nil { err = ResourceAviNatPolicyRead(d, meta) } diff --git a/avi/resource_avi_network.go b/avi/resource_avi_network.go index 6903f14e..bc3e9c6e 100644 --- a/avi/resource_avi_network.go +++ b/avi/resource_avi_network.go @@ -122,7 +122,7 @@ func ResourceAviNetworkRead(d *schema.ResourceData, meta interface{}) error { func resourceAviNetworkCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkSchema() - err := APICreate(d, meta, "network", s) + err := APICreateOrUpdate(d, meta, "network", s) if err == nil { err = ResourceAviNetworkRead(d, meta) } @@ -132,7 +132,7 @@ func resourceAviNetworkCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviNetworkUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkSchema() var err error - err = APIUpdate(d, meta, "network", s) + err = APICreateOrUpdate(d, meta, "network", s) if err == nil { err = ResourceAviNetworkRead(d, meta) } diff --git a/avi/resource_avi_networkprofile.go b/avi/resource_avi_networkprofile.go index ad02c0a4..31628e46 100644 --- a/avi/resource_avi_networkprofile.go +++ b/avi/resource_avi_networkprofile.go @@ -83,7 +83,7 @@ func ResourceAviNetworkProfileRead(d *schema.ResourceData, meta interface{}) err func resourceAviNetworkProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkProfileSchema() - err := APICreate(d, meta, "networkprofile", s) + err := APICreateOrUpdate(d, meta, "networkprofile", s) if err == nil { err = ResourceAviNetworkProfileRead(d, meta) } @@ -93,7 +93,7 @@ func resourceAviNetworkProfileCreate(d *schema.ResourceData, meta interface{}) e func resourceAviNetworkProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkProfileSchema() var err error - err = APIUpdate(d, meta, "networkprofile", s) + err = APICreateOrUpdate(d, meta, "networkprofile", s) if err == nil { err = ResourceAviNetworkProfileRead(d, meta) } diff --git a/avi/resource_avi_networksecuritypolicy.go b/avi/resource_avi_networksecuritypolicy.go index b7d4767f..1b3d091d 100644 --- a/avi/resource_avi_networksecuritypolicy.go +++ b/avi/resource_avi_networksecuritypolicy.go @@ -104,7 +104,7 @@ func ResourceAviNetworkSecurityPolicyRead(d *schema.ResourceData, meta interface func resourceAviNetworkSecurityPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkSecurityPolicySchema() - err := APICreate(d, meta, "networksecuritypolicy", s) + err := APICreateOrUpdate(d, meta, "networksecuritypolicy", s) if err == nil { err = ResourceAviNetworkSecurityPolicyRead(d, meta) } @@ -114,7 +114,7 @@ func resourceAviNetworkSecurityPolicyCreate(d *schema.ResourceData, meta interfa func resourceAviNetworkSecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkSecurityPolicySchema() var err error - err = APIUpdate(d, meta, "networksecuritypolicy", s) + err = APICreateOrUpdate(d, meta, "networksecuritypolicy", s) if err == nil { err = ResourceAviNetworkSecurityPolicyRead(d, meta) } diff --git a/avi/resource_avi_networkservice.go b/avi/resource_avi_networkservice.go index f8a4b858..b7e18fe3 100644 --- a/avi/resource_avi_networkservice.go +++ b/avi/resource_avi_networkservice.go @@ -90,7 +90,7 @@ func ResourceAviNetworkServiceRead(d *schema.ResourceData, meta interface{}) err func resourceAviNetworkServiceCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkServiceSchema() - err := APICreate(d, meta, "networkservice", s) + err := APICreateOrUpdate(d, meta, "networkservice", s) if err == nil { err = ResourceAviNetworkServiceRead(d, meta) } @@ -100,7 +100,7 @@ func resourceAviNetworkServiceCreate(d *schema.ResourceData, meta interface{}) e func resourceAviNetworkServiceUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceNetworkServiceSchema() var err error - err = APIUpdate(d, meta, "networkservice", s) + err = APICreateOrUpdate(d, meta, "networkservice", s) if err == nil { err = ResourceAviNetworkServiceRead(d, meta) } diff --git a/avi/resource_avi_nsxtsegmentruntime.go b/avi/resource_avi_nsxtsegmentruntime.go index e6fd2407..a1da6f94 100644 --- a/avi/resource_avi_nsxtsegmentruntime.go +++ b/avi/resource_avi_nsxtsegmentruntime.go @@ -149,7 +149,7 @@ func ResourceAviNsxtSegmentRuntimeRead(d *schema.ResourceData, meta interface{}) func resourceAviNsxtSegmentRuntimeCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceNsxtSegmentRuntimeSchema() - err := APICreate(d, meta, "nsxtsegmentruntime", s) + err := APICreateOrUpdate(d, meta, "nsxtsegmentruntime", s) if err == nil { err = ResourceAviNsxtSegmentRuntimeRead(d, meta) } @@ -159,7 +159,7 @@ func resourceAviNsxtSegmentRuntimeCreate(d *schema.ResourceData, meta interface{ func resourceAviNsxtSegmentRuntimeUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceNsxtSegmentRuntimeSchema() var err error - err = APIUpdate(d, meta, "nsxtsegmentruntime", s) + err = APICreateOrUpdate(d, meta, "nsxtsegmentruntime", s) if err == nil { err = ResourceAviNsxtSegmentRuntimeRead(d, meta) } diff --git a/avi/resource_avi_pkiprofile.go b/avi/resource_avi_pkiprofile.go index b1fe968f..f53c81b5 100644 --- a/avi/resource_avi_pkiprofile.go +++ b/avi/resource_avi_pkiprofile.go @@ -111,7 +111,7 @@ func ResourceAviPKIProfileRead(d *schema.ResourceData, meta interface{}) error { func resourceAviPKIProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourcePKIProfileSchema() - err := APICreate(d, meta, "pkiprofile", s) + err := APICreateOrUpdate(d, meta, "pkiprofile", s) if err == nil { err = ResourceAviPKIProfileRead(d, meta) } @@ -121,7 +121,7 @@ func resourceAviPKIProfileCreate(d *schema.ResourceData, meta interface{}) error func resourceAviPKIProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourcePKIProfileSchema() var err error - err = APIUpdate(d, meta, "pkiprofile", s) + err = APICreateOrUpdate(d, meta, "pkiprofile", s) if err == nil { err = ResourceAviPKIProfileRead(d, meta) } diff --git a/avi/resource_avi_pool.go b/avi/resource_avi_pool.go index 413e14bb..8e0755e3 100644 --- a/avi/resource_avi_pool.go +++ b/avi/resource_avi_pool.go @@ -472,7 +472,7 @@ func resourceAviPoolCreate(d *schema.ResourceData, meta interface{}) error { } ignoreServers = true } - err := APICreate(d, meta, "pool", s) + err := APICreateOrUpdate(d, meta, "pool", s) if err == nil { err = ResourceAviPoolRead(d, meta) } @@ -496,14 +496,14 @@ func resourceAviPoolUpdate(d *schema.ResourceData, meta interface{}) error { err = errors.New("Error Invalid Plan. cannot set ignore_servers and servers together") return err } - err = APIUpdate(d, meta, "pool", s, true) + err = APICreateOrUpdate(d, meta, "pool", s, true) if err == nil { err = ResourceAviPoolRead(d, meta) } d.Set("servers", nil) d.Set("ignore_servers", true) } else { - err = APIUpdate(d, meta, "pool", s) + err = APICreateOrUpdate(d, meta, "pool", s) if err == nil { err = ResourceAviPoolRead(d, meta) } diff --git a/avi/resource_avi_poolgroup.go b/avi/resource_avi_poolgroup.go index 09b192ad..d9528f8e 100644 --- a/avi/resource_avi_poolgroup.go +++ b/avi/resource_avi_poolgroup.go @@ -131,7 +131,7 @@ func ResourceAviPoolGroupRead(d *schema.ResourceData, meta interface{}) error { func resourceAviPoolGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourcePoolGroupSchema() - err := APICreate(d, meta, "poolgroup", s) + err := APICreateOrUpdate(d, meta, "poolgroup", s) if err == nil { err = ResourceAviPoolGroupRead(d, meta) } @@ -141,7 +141,7 @@ func resourceAviPoolGroupCreate(d *schema.ResourceData, meta interface{}) error func resourceAviPoolGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourcePoolGroupSchema() var err error - err = APIUpdate(d, meta, "poolgroup", s) + err = APICreateOrUpdate(d, meta, "poolgroup", s) if err == nil { err = ResourceAviPoolGroupRead(d, meta) } diff --git a/avi/resource_avi_poolgroupdeploymentpolicy.go b/avi/resource_avi_poolgroupdeploymentpolicy.go index 79073d98..412e1d3e 100644 --- a/avi/resource_avi_poolgroupdeploymentpolicy.go +++ b/avi/resource_avi_poolgroupdeploymentpolicy.go @@ -111,7 +111,7 @@ func ResourceAviPoolGroupDeploymentPolicyRead(d *schema.ResourceData, meta inter func resourceAviPoolGroupDeploymentPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourcePoolGroupDeploymentPolicySchema() - err := APICreate(d, meta, "poolgroupdeploymentpolicy", s) + err := APICreateOrUpdate(d, meta, "poolgroupdeploymentpolicy", s) if err == nil { err = ResourceAviPoolGroupDeploymentPolicyRead(d, meta) } @@ -121,7 +121,7 @@ func resourceAviPoolGroupDeploymentPolicyCreate(d *schema.ResourceData, meta int func resourceAviPoolGroupDeploymentPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourcePoolGroupDeploymentPolicySchema() var err error - err = APIUpdate(d, meta, "poolgroupdeploymentpolicy", s) + err = APICreateOrUpdate(d, meta, "poolgroupdeploymentpolicy", s) if err == nil { err = ResourceAviPoolGroupDeploymentPolicyRead(d, meta) } diff --git a/avi/resource_avi_prioritylabels.go b/avi/resource_avi_prioritylabels.go index 5c3c26d1..f2519f9b 100644 --- a/avi/resource_avi_prioritylabels.go +++ b/avi/resource_avi_prioritylabels.go @@ -82,7 +82,7 @@ func ResourceAviPriorityLabelsRead(d *schema.ResourceData, meta interface{}) err func resourceAviPriorityLabelsCreate(d *schema.ResourceData, meta interface{}) error { s := ResourcePriorityLabelsSchema() - err := APICreate(d, meta, "prioritylabels", s) + err := APICreateOrUpdate(d, meta, "prioritylabels", s) if err == nil { err = ResourceAviPriorityLabelsRead(d, meta) } @@ -92,7 +92,7 @@ func resourceAviPriorityLabelsCreate(d *schema.ResourceData, meta interface{}) e func resourceAviPriorityLabelsUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourcePriorityLabelsSchema() var err error - err = APIUpdate(d, meta, "prioritylabels", s) + err = APICreateOrUpdate(d, meta, "prioritylabels", s) if err == nil { err = ResourceAviPriorityLabelsRead(d, meta) } diff --git a/avi/resource_avi_protocolparser.go b/avi/resource_avi_protocolparser.go index 237f50b9..9c131bcb 100644 --- a/avi/resource_avi_protocolparser.go +++ b/avi/resource_avi_protocolparser.go @@ -76,7 +76,7 @@ func ResourceAviProtocolParserRead(d *schema.ResourceData, meta interface{}) err func resourceAviProtocolParserCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceProtocolParserSchema() - err := APICreate(d, meta, "protocolparser", s) + err := APICreateOrUpdate(d, meta, "protocolparser", s) if err == nil { err = ResourceAviProtocolParserRead(d, meta) } @@ -86,7 +86,7 @@ func resourceAviProtocolParserCreate(d *schema.ResourceData, meta interface{}) e func resourceAviProtocolParserUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceProtocolParserSchema() var err error - err = APIUpdate(d, meta, "protocolparser", s) + err = APICreateOrUpdate(d, meta, "protocolparser", s) if err == nil { err = ResourceAviProtocolParserRead(d, meta) } diff --git a/avi/resource_avi_rmcloudopsproto.go b/avi/resource_avi_rmcloudopsproto.go index 016f9357..96c965f0 100644 --- a/avi/resource_avi_rmcloudopsproto.go +++ b/avi/resource_avi_rmcloudopsproto.go @@ -70,7 +70,7 @@ func ResourceAviRmCloudOpsProtoRead(d *schema.ResourceData, meta interface{}) er func resourceAviRmCloudOpsProtoCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceRmCloudOpsProtoSchema() - err := APICreate(d, meta, "rmcloudopsproto", s) + err := APICreateOrUpdate(d, meta, "rmcloudopsproto", s) if err == nil { err = ResourceAviRmCloudOpsProtoRead(d, meta) } @@ -80,7 +80,7 @@ func resourceAviRmCloudOpsProtoCreate(d *schema.ResourceData, meta interface{}) func resourceAviRmCloudOpsProtoUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceRmCloudOpsProtoSchema() var err error - err = APIUpdate(d, meta, "rmcloudopsproto", s) + err = APICreateOrUpdate(d, meta, "rmcloudopsproto", s) if err == nil { err = ResourceAviRmCloudOpsProtoRead(d, meta) } diff --git a/avi/resource_avi_role.go b/avi/resource_avi_role.go index ac9cc554..1940c350 100644 --- a/avi/resource_avi_role.go +++ b/avi/resource_avi_role.go @@ -78,7 +78,7 @@ func ResourceAviRoleRead(d *schema.ResourceData, meta interface{}) error { func resourceAviRoleCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceRoleSchema() - err := APICreate(d, meta, "role", s) + err := APICreateOrUpdate(d, meta, "role", s) if err == nil { err = ResourceAviRoleRead(d, meta) } @@ -88,7 +88,7 @@ func resourceAviRoleCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviRoleUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceRoleSchema() var err error - err = APIUpdate(d, meta, "role", s) + err = APICreateOrUpdate(d, meta, "role", s) if err == nil { err = ResourceAviRoleRead(d, meta) } diff --git a/avi/resource_avi_scheduler.go b/avi/resource_avi_scheduler.go index 68c4d083..38f70ef2 100644 --- a/avi/resource_avi_scheduler.go +++ b/avi/resource_avi_scheduler.go @@ -109,7 +109,7 @@ func ResourceAviSchedulerRead(d *schema.ResourceData, meta interface{}) error { func resourceAviSchedulerCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSchedulerSchema() - err := APICreate(d, meta, "scheduler", s) + err := APICreateOrUpdate(d, meta, "scheduler", s) if err == nil { err = ResourceAviSchedulerRead(d, meta) } @@ -119,7 +119,7 @@ func resourceAviSchedulerCreate(d *schema.ResourceData, meta interface{}) error func resourceAviSchedulerUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSchedulerSchema() var err error - err = APIUpdate(d, meta, "scheduler", s) + err = APICreateOrUpdate(d, meta, "scheduler", s) if err == nil { err = ResourceAviSchedulerRead(d, meta) } diff --git a/avi/resource_avi_securitymanagerdata.go b/avi/resource_avi_securitymanagerdata.go index b434f76c..889ac9a2 100644 --- a/avi/resource_avi_securitymanagerdata.go +++ b/avi/resource_avi_securitymanagerdata.go @@ -61,7 +61,7 @@ func ResourceAviSecurityManagerDataRead(d *schema.ResourceData, meta interface{} func resourceAviSecurityManagerDataCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSecurityManagerDataSchema() - err := APICreate(d, meta, "securitymanagerdata", s) + err := APICreateOrUpdate(d, meta, "securitymanagerdata", s) if err == nil { err = ResourceAviSecurityManagerDataRead(d, meta) } @@ -71,7 +71,7 @@ func resourceAviSecurityManagerDataCreate(d *schema.ResourceData, meta interface func resourceAviSecurityManagerDataUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSecurityManagerDataSchema() var err error - err = APIUpdate(d, meta, "securitymanagerdata", s) + err = APICreateOrUpdate(d, meta, "securitymanagerdata", s) if err == nil { err = ResourceAviSecurityManagerDataRead(d, meta) } diff --git a/avi/resource_avi_securitypolicy.go b/avi/resource_avi_securitypolicy.go index 0981caf3..0fc63f67 100644 --- a/avi/resource_avi_securitypolicy.go +++ b/avi/resource_avi_securitypolicy.go @@ -113,7 +113,7 @@ func ResourceAviSecurityPolicyRead(d *schema.ResourceData, meta interface{}) err func resourceAviSecurityPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSecurityPolicySchema() - err := APICreate(d, meta, "securitypolicy", s) + err := APICreateOrUpdate(d, meta, "securitypolicy", s) if err == nil { err = ResourceAviSecurityPolicyRead(d, meta) } @@ -123,7 +123,7 @@ func resourceAviSecurityPolicyCreate(d *schema.ResourceData, meta interface{}) e func resourceAviSecurityPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSecurityPolicySchema() var err error - err = APIUpdate(d, meta, "securitypolicy", s) + err = APICreateOrUpdate(d, meta, "securitypolicy", s) if err == nil { err = ResourceAviSecurityPolicyRead(d, meta) } diff --git a/avi/resource_avi_seproperties.go b/avi/resource_avi_seproperties.go index f09962ca..48ebaf3a 100644 --- a/avi/resource_avi_seproperties.go +++ b/avi/resource_avi_seproperties.go @@ -71,7 +71,7 @@ func ResourceAviSePropertiesRead(d *schema.ResourceData, meta interface{}) error func resourceAviSePropertiesCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSePropertiesSchema() - err := APICreate(d, meta, "seproperties", s) + err := APICreateOrUpdate(d, meta, "seproperties", s) if err == nil { err = ResourceAviSePropertiesRead(d, meta) } @@ -81,7 +81,7 @@ func resourceAviSePropertiesCreate(d *schema.ResourceData, meta interface{}) err func resourceAviSePropertiesUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSePropertiesSchema() var err error - err = APIUpdate(d, meta, "seproperties", s) + err = APICreateOrUpdate(d, meta, "seproperties", s) if err == nil { err = ResourceAviSePropertiesRead(d, meta) } diff --git a/avi/resource_avi_serverautoscalepolicy.go b/avi/resource_avi_serverautoscalepolicy.go index 51cb0ece..defc6a46 100644 --- a/avi/resource_avi_serverautoscalepolicy.go +++ b/avi/resource_avi_serverautoscalepolicy.go @@ -153,7 +153,7 @@ func ResourceAviServerAutoScalePolicyRead(d *schema.ResourceData, meta interface func resourceAviServerAutoScalePolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceServerAutoScalePolicySchema() - err := APICreate(d, meta, "serverautoscalepolicy", s) + err := APICreateOrUpdate(d, meta, "serverautoscalepolicy", s) if err == nil { err = ResourceAviServerAutoScalePolicyRead(d, meta) } @@ -163,7 +163,7 @@ func resourceAviServerAutoScalePolicyCreate(d *schema.ResourceData, meta interfa func resourceAviServerAutoScalePolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceServerAutoScalePolicySchema() var err error - err = APIUpdate(d, meta, "serverautoscalepolicy", s) + err = APICreateOrUpdate(d, meta, "serverautoscalepolicy", s) if err == nil { err = ResourceAviServerAutoScalePolicyRead(d, meta) } diff --git a/avi/resource_avi_serviceauthprofile.go b/avi/resource_avi_serviceauthprofile.go index 037753a4..6d4b4dc7 100644 --- a/avi/resource_avi_serviceauthprofile.go +++ b/avi/resource_avi_serviceauthprofile.go @@ -77,7 +77,7 @@ func ResourceAviServiceAuthProfileRead(d *schema.ResourceData, meta interface{}) func resourceAviServiceAuthProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceServiceAuthProfileSchema() - err := APICreate(d, meta, "serviceauthprofile", s) + err := APICreateOrUpdate(d, meta, "serviceauthprofile", s) if err == nil { err = ResourceAviServiceAuthProfileRead(d, meta) } @@ -87,7 +87,7 @@ func resourceAviServiceAuthProfileCreate(d *schema.ResourceData, meta interface{ func resourceAviServiceAuthProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceServiceAuthProfileSchema() var err error - err = APIUpdate(d, meta, "serviceauthprofile", s) + err = APICreateOrUpdate(d, meta, "serviceauthprofile", s) if err == nil { err = ResourceAviServiceAuthProfileRead(d, meta) } diff --git a/avi/resource_avi_serviceengine.go b/avi/resource_avi_serviceengine.go index 218669b4..1a152b2a 100644 --- a/avi/resource_avi_serviceengine.go +++ b/avi/resource_avi_serviceengine.go @@ -137,7 +137,7 @@ func ResourceAviServiceEngineRead(d *schema.ResourceData, meta interface{}) erro func resourceAviServiceEngineCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceServiceEngineSchema() - err := APICreate(d, meta, "serviceengine", s) + err := APICreateOrUpdate(d, meta, "serviceengine", s) if err == nil { err = ResourceAviServiceEngineRead(d, meta) } @@ -147,7 +147,7 @@ func resourceAviServiceEngineCreate(d *schema.ResourceData, meta interface{}) er func resourceAviServiceEngineUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceServiceEngineSchema() var err error - err = APIUpdate(d, meta, "serviceengine", s) + err = APICreateOrUpdate(d, meta, "serviceengine", s) if err == nil { err = ResourceAviServiceEngineRead(d, meta) } diff --git a/avi/resource_avi_serviceenginegroup.go b/avi/resource_avi_serviceenginegroup.go index 6f1eba7e..f1323e3c 100644 --- a/avi/resource_avi_serviceenginegroup.go +++ b/avi/resource_avi_serviceenginegroup.go @@ -4,13 +4,12 @@ package avi import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/vmware/alb-sdk/go/clients" "log" "strconv" "strings" "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/vmware/alb-sdk/go/clients" ) func ResourceServiceEngineGroupSchema() map[string]*schema.Schema { @@ -1731,7 +1730,7 @@ func ResourceAviServiceEngineGroupRead(d *schema.ResourceData, meta interface{}) func resourceAviServiceEngineGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceServiceEngineGroupSchema() - err := APICreate(d, meta, "serviceenginegroup", s) + err := APICreateOrUpdate(d, meta, "serviceenginegroup", s) if err == nil { err = ResourceAviServiceEngineGroupRead(d, meta) } @@ -1741,7 +1740,7 @@ func resourceAviServiceEngineGroupCreate(d *schema.ResourceData, meta interface{ func resourceAviServiceEngineGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceServiceEngineGroupSchema() var err error - err = APIUpdate(d, meta, "serviceenginegroup", s) + err = APICreateOrUpdate(d, meta, "serviceenginegroup", s) if err == nil { err = ResourceAviServiceEngineGroupRead(d, meta) } diff --git a/avi/resource_avi_siteversion.go b/avi/resource_avi_siteversion.go index 2ac9615a..ebac059c 100644 --- a/avi/resource_avi_siteversion.go +++ b/avi/resource_avi_siteversion.go @@ -104,7 +104,7 @@ func ResourceAviSiteVersionRead(d *schema.ResourceData, meta interface{}) error func resourceAviSiteVersionCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSiteVersionSchema() - err := APICreate(d, meta, "siteversion", s) + err := APICreateOrUpdate(d, meta, "siteversion", s) if err == nil { err = ResourceAviSiteVersionRead(d, meta) } @@ -114,7 +114,7 @@ func resourceAviSiteVersionCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviSiteVersionUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSiteVersionSchema() var err error - err = APIUpdate(d, meta, "siteversion", s) + err = APICreateOrUpdate(d, meta, "siteversion", s) if err == nil { err = ResourceAviSiteVersionRead(d, meta) } diff --git a/avi/resource_avi_snmptrapprofile.go b/avi/resource_avi_snmptrapprofile.go index 4d403f8b..d8c34a50 100644 --- a/avi/resource_avi_snmptrapprofile.go +++ b/avi/resource_avi_snmptrapprofile.go @@ -67,7 +67,7 @@ func ResourceAviSnmpTrapProfileRead(d *schema.ResourceData, meta interface{}) er func resourceAviSnmpTrapProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSnmpTrapProfileSchema() - err := APICreate(d, meta, "snmptrapprofile", s) + err := APICreateOrUpdate(d, meta, "snmptrapprofile", s) if err == nil { err = ResourceAviSnmpTrapProfileRead(d, meta) } @@ -77,7 +77,7 @@ func resourceAviSnmpTrapProfileCreate(d *schema.ResourceData, meta interface{}) func resourceAviSnmpTrapProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSnmpTrapProfileSchema() var err error - err = APIUpdate(d, meta, "snmptrapprofile", s) + err = APICreateOrUpdate(d, meta, "snmptrapprofile", s) if err == nil { err = ResourceAviSnmpTrapProfileRead(d, meta) } diff --git a/avi/resource_avi_sslkeyandcertificate.go b/avi/resource_avi_sslkeyandcertificate.go index 3bb2def7..4e35c947 100644 --- a/avi/resource_avi_sslkeyandcertificate.go +++ b/avi/resource_avi_sslkeyandcertificate.go @@ -194,7 +194,7 @@ func ResourceAviSSLKeyAndCertificateRead(d *schema.ResourceData, meta interface{ func resourceAviSSLKeyAndCertificateCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSSLKeyAndCertificateSchema() - err := APICreate(d, meta, "sslkeyandcertificate", s) + err := APICreateOrUpdate(d, meta, "sslkeyandcertificate", s) if err == nil { err = ResourceAviSSLKeyAndCertificateRead(d, meta) } @@ -204,7 +204,7 @@ func resourceAviSSLKeyAndCertificateCreate(d *schema.ResourceData, meta interfac func resourceAviSSLKeyAndCertificateUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSSLKeyAndCertificateSchema() var err error - err = APIUpdate(d, meta, "sslkeyandcertificate", s) + err = APICreateOrUpdate(d, meta, "sslkeyandcertificate", s) if err == nil { err = ResourceAviSSLKeyAndCertificateRead(d, meta) } diff --git a/avi/resource_avi_sslprofile.go b/avi/resource_avi_sslprofile.go index 3beae09e..755e155e 100644 --- a/avi/resource_avi_sslprofile.go +++ b/avi/resource_avi_sslprofile.go @@ -159,7 +159,7 @@ func ResourceAviSSLProfileRead(d *schema.ResourceData, meta interface{}) error { func resourceAviSSLProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSSLProfileSchema() - err := APICreate(d, meta, "sslprofile", s) + err := APICreateOrUpdate(d, meta, "sslprofile", s) if err == nil { err = ResourceAviSSLProfileRead(d, meta) } @@ -169,7 +169,7 @@ func resourceAviSSLProfileCreate(d *schema.ResourceData, meta interface{}) error func resourceAviSSLProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSSLProfileSchema() var err error - err = APIUpdate(d, meta, "sslprofile", s) + err = APICreateOrUpdate(d, meta, "sslprofile", s) if err == nil { err = ResourceAviSSLProfileRead(d, meta) } diff --git a/avi/resource_avi_ssopolicy.go b/avi/resource_avi_ssopolicy.go index 620ef36b..dfb45752 100644 --- a/avi/resource_avi_ssopolicy.go +++ b/avi/resource_avi_ssopolicy.go @@ -84,7 +84,7 @@ func ResourceAviSSOPolicyRead(d *schema.ResourceData, meta interface{}) error { func resourceAviSSOPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSSOPolicySchema() - err := APICreate(d, meta, "ssopolicy", s) + err := APICreateOrUpdate(d, meta, "ssopolicy", s) if err == nil { err = ResourceAviSSOPolicyRead(d, meta) } @@ -94,7 +94,7 @@ func resourceAviSSOPolicyCreate(d *schema.ResourceData, meta interface{}) error func resourceAviSSOPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSSOPolicySchema() var err error - err = APIUpdate(d, meta, "ssopolicy", s) + err = APICreateOrUpdate(d, meta, "ssopolicy", s) if err == nil { err = ResourceAviSSOPolicyRead(d, meta) } diff --git a/avi/resource_avi_statediffoperation.go b/avi/resource_avi_statediffoperation.go index c3cbba74..c5e8fa04 100644 --- a/avi/resource_avi_statediffoperation.go +++ b/avi/resource_avi_statediffoperation.go @@ -82,7 +82,7 @@ func ResourceAviStatediffOperationRead(d *schema.ResourceData, meta interface{}) func resourceAviStatediffOperationCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceStatediffOperationSchema() - err := APICreate(d, meta, "statediffoperation", s) + err := APICreateOrUpdate(d, meta, "statediffoperation", s) if err == nil { err = ResourceAviStatediffOperationRead(d, meta) } @@ -92,7 +92,7 @@ func resourceAviStatediffOperationCreate(d *schema.ResourceData, meta interface{ func resourceAviStatediffOperationUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceStatediffOperationSchema() var err error - err = APIUpdate(d, meta, "statediffoperation", s) + err = APICreateOrUpdate(d, meta, "statediffoperation", s) if err == nil { err = ResourceAviStatediffOperationRead(d, meta) } diff --git a/avi/resource_avi_statediffsnapshot.go b/avi/resource_avi_statediffsnapshot.go index bf93f790..2fc303fd 100644 --- a/avi/resource_avi_statediffsnapshot.go +++ b/avi/resource_avi_statediffsnapshot.go @@ -129,7 +129,7 @@ func ResourceAviStatediffSnapshotRead(d *schema.ResourceData, meta interface{}) func resourceAviStatediffSnapshotCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceStatediffSnapshotSchema() - err := APICreate(d, meta, "statediffsnapshot", s) + err := APICreateOrUpdate(d, meta, "statediffsnapshot", s) if err == nil { err = ResourceAviStatediffSnapshotRead(d, meta) } @@ -139,7 +139,7 @@ func resourceAviStatediffSnapshotCreate(d *schema.ResourceData, meta interface{} func resourceAviStatediffSnapshotUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceStatediffSnapshotSchema() var err error - err = APIUpdate(d, meta, "statediffsnapshot", s) + err = APICreateOrUpdate(d, meta, "statediffsnapshot", s) if err == nil { err = ResourceAviStatediffSnapshotRead(d, meta) } diff --git a/avi/resource_avi_stringgroup.go b/avi/resource_avi_stringgroup.go index e1221269..6f674513 100644 --- a/avi/resource_avi_stringgroup.go +++ b/avi/resource_avi_stringgroup.go @@ -87,7 +87,7 @@ func ResourceAviStringGroupRead(d *schema.ResourceData, meta interface{}) error func resourceAviStringGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceStringGroupSchema() - err := APICreate(d, meta, "stringgroup", s) + err := APICreateOrUpdate(d, meta, "stringgroup", s) if err == nil { err = ResourceAviStringGroupRead(d, meta) } @@ -97,7 +97,7 @@ func resourceAviStringGroupCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviStringGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceStringGroupSchema() var err error - err = APIUpdate(d, meta, "stringgroup", s) + err = APICreateOrUpdate(d, meta, "stringgroup", s) if err == nil { err = ResourceAviStringGroupRead(d, meta) } diff --git a/avi/resource_avi_systemconfiguration.go b/avi/resource_avi_systemconfiguration.go index 23c9c643..c9e1532a 100644 --- a/avi/resource_avi_systemconfiguration.go +++ b/avi/resource_avi_systemconfiguration.go @@ -195,7 +195,7 @@ func ResourceAviSystemConfigurationRead(d *schema.ResourceData, meta interface{} func resourceAviSystemConfigurationCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSystemConfigurationSchema() - err := APICreate(d, meta, "systemconfiguration", s) + err := APICreateOrUpdate(d, meta, "systemconfiguration", s) if err == nil { err = ResourceAviSystemConfigurationRead(d, meta) } @@ -205,7 +205,7 @@ func resourceAviSystemConfigurationCreate(d *schema.ResourceData, meta interface func resourceAviSystemConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSystemConfigurationSchema() var err error - err = APIUpdate(d, meta, "systemconfiguration", s) + err = APICreateOrUpdate(d, meta, "systemconfiguration", s) if err == nil { err = ResourceAviSystemConfigurationRead(d, meta) } diff --git a/avi/resource_avi_systemlimits.go b/avi/resource_avi_systemlimits.go index 25f1e7d7..b8c96bdc 100644 --- a/avi/resource_avi_systemlimits.go +++ b/avi/resource_avi_systemlimits.go @@ -70,7 +70,7 @@ func ResourceAviSystemLimitsRead(d *schema.ResourceData, meta interface{}) error func resourceAviSystemLimitsCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSystemLimitsSchema() - err := APICreate(d, meta, "systemlimits", s) + err := APICreateOrUpdate(d, meta, "systemlimits", s) if err == nil { err = ResourceAviSystemLimitsRead(d, meta) } @@ -80,7 +80,7 @@ func resourceAviSystemLimitsCreate(d *schema.ResourceData, meta interface{}) err func resourceAviSystemLimitsUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSystemLimitsSchema() var err error - err = APIUpdate(d, meta, "systemlimits", s) + err = APICreateOrUpdate(d, meta, "systemlimits", s) if err == nil { err = ResourceAviSystemLimitsRead(d, meta) } diff --git a/avi/resource_avi_systemreport.go b/avi/resource_avi_systemreport.go index 3268f738..8fb96ab7 100644 --- a/avi/resource_avi_systemreport.go +++ b/avi/resource_avi_systemreport.go @@ -110,7 +110,7 @@ func ResourceAviSystemReportRead(d *schema.ResourceData, meta interface{}) error func resourceAviSystemReportCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceSystemReportSchema() - err := APICreate(d, meta, "systemreport", s) + err := APICreateOrUpdate(d, meta, "systemreport", s) if err == nil { err = ResourceAviSystemReportRead(d, meta) } @@ -120,7 +120,7 @@ func resourceAviSystemReportCreate(d *schema.ResourceData, meta interface{}) err func resourceAviSystemReportUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceSystemReportSchema() var err error - err = APIUpdate(d, meta, "systemreport", s) + err = APICreateOrUpdate(d, meta, "systemreport", s) if err == nil { err = ResourceAviSystemReportRead(d, meta) } diff --git a/avi/resource_avi_taskjournal.go b/avi/resource_avi_taskjournal.go index 8ce975e9..b831158b 100644 --- a/avi/resource_avi_taskjournal.go +++ b/avi/resource_avi_taskjournal.go @@ -93,7 +93,7 @@ func ResourceAviTaskJournalRead(d *schema.ResourceData, meta interface{}) error func resourceAviTaskJournalCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceTaskJournalSchema() - err := APICreate(d, meta, "taskjournal", s) + err := APICreateOrUpdate(d, meta, "taskjournal", s) if err == nil { err = ResourceAviTaskJournalRead(d, meta) } @@ -103,7 +103,7 @@ func resourceAviTaskJournalCreate(d *schema.ResourceData, meta interface{}) erro func resourceAviTaskJournalUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceTaskJournalSchema() var err error - err = APIUpdate(d, meta, "taskjournal", s) + err = APICreateOrUpdate(d, meta, "taskjournal", s) if err == nil { err = ResourceAviTaskJournalRead(d, meta) } diff --git a/avi/resource_avi_tenant.go b/avi/resource_avi_tenant.go index 41a27325..54d5a5a6 100644 --- a/avi/resource_avi_tenant.go +++ b/avi/resource_avi_tenant.go @@ -95,7 +95,7 @@ func ResourceAviTenantRead(d *schema.ResourceData, meta interface{}) error { func resourceAviTenantCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceTenantSchema() - err := APICreate(d, meta, "tenant", s) + err := APICreateOrUpdate(d, meta, "tenant", s) if err == nil { err = ResourceAviTenantRead(d, meta) } @@ -105,7 +105,7 @@ func resourceAviTenantCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviTenantUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceTenantSchema() var err error - err = APIUpdate(d, meta, "tenant", s) + err = APICreateOrUpdate(d, meta, "tenant", s) if err == nil { err = ResourceAviTenantRead(d, meta) } diff --git a/avi/resource_avi_tenantsystemconfiguration.go b/avi/resource_avi_tenantsystemconfiguration.go index 5a02598e..99c14cbc 100644 --- a/avi/resource_avi_tenantsystemconfiguration.go +++ b/avi/resource_avi_tenantsystemconfiguration.go @@ -67,7 +67,7 @@ func ResourceAviTenantSystemConfigurationRead(d *schema.ResourceData, meta inter func resourceAviTenantSystemConfigurationCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceTenantSystemConfigurationSchema() - err := APICreate(d, meta, "tenantsystemconfiguration", s) + err := APICreateOrUpdate(d, meta, "tenantsystemconfiguration", s) if err == nil { err = ResourceAviTenantSystemConfigurationRead(d, meta) } @@ -77,7 +77,7 @@ func resourceAviTenantSystemConfigurationCreate(d *schema.ResourceData, meta int func resourceAviTenantSystemConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceTenantSystemConfigurationSchema() var err error - err = APIUpdate(d, meta, "tenantsystemconfiguration", s) + err = APICreateOrUpdate(d, meta, "tenantsystemconfiguration", s) if err == nil { err = ResourceAviTenantSystemConfigurationRead(d, meta) } diff --git a/avi/resource_avi_testsedatastorelevel1.go b/avi/resource_avi_testsedatastorelevel1.go index 00c2fcce..d720cc68 100644 --- a/avi/resource_avi_testsedatastorelevel1.go +++ b/avi/resource_avi_testsedatastorelevel1.go @@ -67,7 +67,7 @@ func ResourceAviTestSeDatastoreLevel1Read(d *schema.ResourceData, meta interface func resourceAviTestSeDatastoreLevel1Create(d *schema.ResourceData, meta interface{}) error { s := ResourceTestSeDatastoreLevel1Schema() - err := APICreate(d, meta, "testsedatastorelevel1", s) + err := APICreateOrUpdate(d, meta, "testsedatastorelevel1", s) if err == nil { err = ResourceAviTestSeDatastoreLevel1Read(d, meta) } @@ -77,7 +77,7 @@ func resourceAviTestSeDatastoreLevel1Create(d *schema.ResourceData, meta interfa func resourceAviTestSeDatastoreLevel1Update(d *schema.ResourceData, meta interface{}) error { s := ResourceTestSeDatastoreLevel1Schema() var err error - err = APIUpdate(d, meta, "testsedatastorelevel1", s) + err = APICreateOrUpdate(d, meta, "testsedatastorelevel1", s) if err == nil { err = ResourceAviTestSeDatastoreLevel1Read(d, meta) } diff --git a/avi/resource_avi_testsedatastorelevel2.go b/avi/resource_avi_testsedatastorelevel2.go index fabcba42..d17067fd 100644 --- a/avi/resource_avi_testsedatastorelevel2.go +++ b/avi/resource_avi_testsedatastorelevel2.go @@ -67,7 +67,7 @@ func ResourceAviTestSeDatastoreLevel2Read(d *schema.ResourceData, meta interface func resourceAviTestSeDatastoreLevel2Create(d *schema.ResourceData, meta interface{}) error { s := ResourceTestSeDatastoreLevel2Schema() - err := APICreate(d, meta, "testsedatastorelevel2", s) + err := APICreateOrUpdate(d, meta, "testsedatastorelevel2", s) if err == nil { err = ResourceAviTestSeDatastoreLevel2Read(d, meta) } @@ -77,7 +77,7 @@ func resourceAviTestSeDatastoreLevel2Create(d *schema.ResourceData, meta interfa func resourceAviTestSeDatastoreLevel2Update(d *schema.ResourceData, meta interface{}) error { s := ResourceTestSeDatastoreLevel2Schema() var err error - err = APIUpdate(d, meta, "testsedatastorelevel2", s) + err = APICreateOrUpdate(d, meta, "testsedatastorelevel2", s) if err == nil { err = ResourceAviTestSeDatastoreLevel2Read(d, meta) } diff --git a/avi/resource_avi_testsedatastorelevel3.go b/avi/resource_avi_testsedatastorelevel3.go index acc878d4..7a4127d1 100644 --- a/avi/resource_avi_testsedatastorelevel3.go +++ b/avi/resource_avi_testsedatastorelevel3.go @@ -62,7 +62,7 @@ func ResourceAviTestSeDatastoreLevel3Read(d *schema.ResourceData, meta interface func resourceAviTestSeDatastoreLevel3Create(d *schema.ResourceData, meta interface{}) error { s := ResourceTestSeDatastoreLevel3Schema() - err := APICreate(d, meta, "testsedatastorelevel3", s) + err := APICreateOrUpdate(d, meta, "testsedatastorelevel3", s) if err == nil { err = ResourceAviTestSeDatastoreLevel3Read(d, meta) } @@ -72,7 +72,7 @@ func resourceAviTestSeDatastoreLevel3Create(d *schema.ResourceData, meta interfa func resourceAviTestSeDatastoreLevel3Update(d *schema.ResourceData, meta interface{}) error { s := ResourceTestSeDatastoreLevel3Schema() var err error - err = APIUpdate(d, meta, "testsedatastorelevel3", s) + err = APICreateOrUpdate(d, meta, "testsedatastorelevel3", s) if err == nil { err = ResourceAviTestSeDatastoreLevel3Read(d, meta) } diff --git a/avi/resource_avi_trafficcloneprofile.go b/avi/resource_avi_trafficcloneprofile.go index 44f23cff..718fa7e4 100644 --- a/avi/resource_avi_trafficcloneprofile.go +++ b/avi/resource_avi_trafficcloneprofile.go @@ -83,7 +83,7 @@ func ResourceAviTrafficCloneProfileRead(d *schema.ResourceData, meta interface{} func resourceAviTrafficCloneProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceTrafficCloneProfileSchema() - err := APICreate(d, meta, "trafficcloneprofile", s) + err := APICreateOrUpdate(d, meta, "trafficcloneprofile", s) if err == nil { err = ResourceAviTrafficCloneProfileRead(d, meta) } @@ -93,7 +93,7 @@ func resourceAviTrafficCloneProfileCreate(d *schema.ResourceData, meta interface func resourceAviTrafficCloneProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceTrafficCloneProfileSchema() var err error - err = APIUpdate(d, meta, "trafficcloneprofile", s) + err = APICreateOrUpdate(d, meta, "trafficcloneprofile", s) if err == nil { err = ResourceAviTrafficCloneProfileRead(d, meta) } diff --git a/avi/resource_avi_upgradestatusinfo.go b/avi/resource_avi_upgradestatusinfo.go index 1b9a4c9f..7c22f5a5 100644 --- a/avi/resource_avi_upgradestatusinfo.go +++ b/avi/resource_avi_upgradestatusinfo.go @@ -307,7 +307,7 @@ func ResourceAviUpgradeStatusInfoRead(d *schema.ResourceData, meta interface{}) func resourceAviUpgradeStatusInfoCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceUpgradeStatusInfoSchema() - err := APICreate(d, meta, "upgradestatusinfo", s) + err := APICreateOrUpdate(d, meta, "upgradestatusinfo", s) if err == nil { err = ResourceAviUpgradeStatusInfoRead(d, meta) } @@ -317,7 +317,7 @@ func resourceAviUpgradeStatusInfoCreate(d *schema.ResourceData, meta interface{} func resourceAviUpgradeStatusInfoUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceUpgradeStatusInfoSchema() var err error - err = APIUpdate(d, meta, "upgradestatusinfo", s) + err = APICreateOrUpdate(d, meta, "upgradestatusinfo", s) if err == nil { err = ResourceAviUpgradeStatusInfoRead(d, meta) } diff --git a/avi/resource_avi_upgradestatussummary.go b/avi/resource_avi_upgradestatussummary.go index 7c81f899..a32eea8d 100644 --- a/avi/resource_avi_upgradestatussummary.go +++ b/avi/resource_avi_upgradestatussummary.go @@ -127,7 +127,7 @@ func ResourceAviUpgradeStatusSummaryRead(d *schema.ResourceData, meta interface{ func resourceAviUpgradeStatusSummaryCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceUpgradeStatusSummarySchema() - err := APICreate(d, meta, "upgradestatussummary", s) + err := APICreateOrUpdate(d, meta, "upgradestatussummary", s) if err == nil { err = ResourceAviUpgradeStatusSummaryRead(d, meta) } @@ -137,7 +137,7 @@ func resourceAviUpgradeStatusSummaryCreate(d *schema.ResourceData, meta interfac func resourceAviUpgradeStatusSummaryUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceUpgradeStatusSummarySchema() var err error - err = APIUpdate(d, meta, "upgradestatussummary", s) + err = APICreateOrUpdate(d, meta, "upgradestatussummary", s) if err == nil { err = ResourceAviUpgradeStatusSummaryRead(d, meta) } diff --git a/avi/resource_avi_user.go b/avi/resource_avi_user.go index bd583015..8983e692 100644 --- a/avi/resource_avi_user.go +++ b/avi/resource_avi_user.go @@ -173,7 +173,7 @@ func ResourceAviUserRead(d *schema.ResourceData, meta interface{}) error { func resourceAviUserCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceUserSchema() - err := APICreate(d, meta, "user", s) + err := APICreateOrUpdate(d, meta, "user", s) if err == nil { err = ResourceAviUserRead(d, meta) } @@ -183,7 +183,7 @@ func resourceAviUserCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviUserUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceUserSchema() var err error - err = APIUpdate(d, meta, "user", s) + err = APICreateOrUpdate(d, meta, "user", s) if err == nil { err = ResourceAviUserRead(d, meta) } diff --git a/avi/resource_avi_useraccount.go b/avi/resource_avi_useraccount.go index e78c592a..470364a9 100644 --- a/avi/resource_avi_useraccount.go +++ b/avi/resource_avi_useraccount.go @@ -23,7 +23,7 @@ func ResourceUserAccountSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "username": { Type: schema.TypeString, - Required: true, + Optional: true, }, "old_password": { Type: schema.TypeString, @@ -68,7 +68,6 @@ func ResourceAviUserAccountRead(d *schema.ResourceData, meta interface{}) error func resourceAviUserAccountCreate(d *schema.ResourceData, meta interface{}) error { if strings.Compare(d.Get("old_password").(string), d.Get("password").(string)) == 0 { - d.SetId(d.Get("username").(string)) return nil } err := resourceAviUserAccountUpdate(d, meta) @@ -92,7 +91,6 @@ func resourceAviUserAccountUpdate(d *schema.ResourceData, meta interface{}) erro err = client.AviSession.Put(path, data, &robj) if err != nil { log.Printf("[ERROR] in updating the object %v\n", err) - return err } else { // we dont get UUID because of nil response and username is unique in useraccount d.SetId(username.(string)) diff --git a/avi/resource_avi_useraccountprofile.go b/avi/resource_avi_useraccountprofile.go index 7b7624d1..3b4cb2e6 100644 --- a/avi/resource_avi_useraccountprofile.go +++ b/avi/resource_avi_useraccountprofile.go @@ -93,7 +93,7 @@ func ResourceAviUserAccountProfileRead(d *schema.ResourceData, meta interface{}) func resourceAviUserAccountProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceUserAccountProfileSchema() - err := APICreate(d, meta, "useraccountprofile", s) + err := APICreateOrUpdate(d, meta, "useraccountprofile", s) if err == nil { err = ResourceAviUserAccountProfileRead(d, meta) } @@ -103,7 +103,7 @@ func resourceAviUserAccountProfileCreate(d *schema.ResourceData, meta interface{ func resourceAviUserAccountProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceUserAccountProfileSchema() var err error - err = APIUpdate(d, meta, "useraccountprofile", s) + err = APICreateOrUpdate(d, meta, "useraccountprofile", s) if err == nil { err = ResourceAviUserAccountProfileRead(d, meta) } diff --git a/avi/resource_avi_vcenterserver.go b/avi/resource_avi_vcenterserver.go index 49f1b9a9..30afc3bb 100644 --- a/avi/resource_avi_vcenterserver.go +++ b/avi/resource_avi_vcenterserver.go @@ -83,7 +83,7 @@ func ResourceAviVCenterServerRead(d *schema.ResourceData, meta interface{}) erro func resourceAviVCenterServerCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceVCenterServerSchema() - err := APICreate(d, meta, "vcenterserver", s) + err := APICreateOrUpdate(d, meta, "vcenterserver", s) if err == nil { err = ResourceAviVCenterServerRead(d, meta) } @@ -93,7 +93,7 @@ func resourceAviVCenterServerCreate(d *schema.ResourceData, meta interface{}) er func resourceAviVCenterServerUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceVCenterServerSchema() var err error - err = APIUpdate(d, meta, "vcenterserver", s) + err = APICreateOrUpdate(d, meta, "vcenterserver", s) if err == nil { err = ResourceAviVCenterServerRead(d, meta) } diff --git a/avi/resource_avi_virtualservice.go b/avi/resource_avi_virtualservice.go index 4c5326c5..379e7ea6 100644 --- a/avi/resource_avi_virtualservice.go +++ b/avi/resource_avi_virtualservice.go @@ -557,7 +557,7 @@ func ResourceAviVirtualServiceRead(d *schema.ResourceData, meta interface{}) err func resourceAviVirtualServiceCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceVirtualServiceSchema() - err := APICreate(d, meta, "virtualservice", s) + err := APICreateOrUpdate(d, meta, "virtualservice", s) if err == nil { err = ResourceAviVirtualServiceRead(d, meta) } @@ -567,7 +567,7 @@ func resourceAviVirtualServiceCreate(d *schema.ResourceData, meta interface{}) e func resourceAviVirtualServiceUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceVirtualServiceSchema() var err error - err = APIUpdate(d, meta, "virtualservice", s) + err = APICreateOrUpdate(d, meta, "virtualservice", s) if err == nil { err = ResourceAviVirtualServiceRead(d, meta) } diff --git a/avi/resource_avi_vrfcontext.go b/avi/resource_avi_vrfcontext.go index 0b5718d6..69a188c9 100644 --- a/avi/resource_avi_vrfcontext.go +++ b/avi/resource_avi_vrfcontext.go @@ -128,7 +128,7 @@ func ResourceAviVrfContextRead(d *schema.ResourceData, meta interface{}) error { func resourceAviVrfContextCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceVrfContextSchema() - err := APICreate(d, meta, "vrfcontext", s) + err := APICreateOrUpdate(d, meta, "vrfcontext", s) if err == nil { err = ResourceAviVrfContextRead(d, meta) } @@ -138,7 +138,7 @@ func resourceAviVrfContextCreate(d *schema.ResourceData, meta interface{}) error func resourceAviVrfContextUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceVrfContextSchema() var err error - err = APIUpdate(d, meta, "vrfcontext", s) + err = APICreateOrUpdate(d, meta, "vrfcontext", s) if err == nil { err = ResourceAviVrfContextRead(d, meta) } diff --git a/avi/resource_avi_vsdatascriptset.go b/avi/resource_avi_vsdatascriptset.go index 7d504628..c5194f04 100644 --- a/avi/resource_avi_vsdatascriptset.go +++ b/avi/resource_avi_vsdatascriptset.go @@ -137,7 +137,7 @@ func ResourceAviVSDataScriptSetRead(d *schema.ResourceData, meta interface{}) er func resourceAviVSDataScriptSetCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceVSDataScriptSetSchema() - err := APICreate(d, meta, "vsdatascriptset", s) + err := APICreateOrUpdate(d, meta, "vsdatascriptset", s) if err == nil { err = ResourceAviVSDataScriptSetRead(d, meta) } @@ -147,7 +147,7 @@ func resourceAviVSDataScriptSetCreate(d *schema.ResourceData, meta interface{}) func resourceAviVSDataScriptSetUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceVSDataScriptSetSchema() var err error - err = APIUpdate(d, meta, "vsdatascriptset", s) + err = APICreateOrUpdate(d, meta, "vsdatascriptset", s) if err == nil { err = ResourceAviVSDataScriptSetRead(d, meta) } diff --git a/avi/resource_avi_vsgs.go b/avi/resource_avi_vsgs.go index 6658f662..24c4f543 100644 --- a/avi/resource_avi_vsgs.go +++ b/avi/resource_avi_vsgs.go @@ -88,7 +88,7 @@ func ResourceAviVsGsRead(d *schema.ResourceData, meta interface{}) error { func resourceAviVsGsCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceVsGsSchema() - err := APICreate(d, meta, "vsgs", s) + err := APICreateOrUpdate(d, meta, "vsgs", s) if err == nil { err = ResourceAviVsGsRead(d, meta) } @@ -98,7 +98,7 @@ func resourceAviVsGsCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviVsGsUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceVsGsSchema() var err error - err = APIUpdate(d, meta, "vsgs", s) + err = APICreateOrUpdate(d, meta, "vsgs", s) if err == nil { err = ResourceAviVsGsRead(d, meta) } diff --git a/avi/resource_avi_vsvip.go b/avi/resource_avi_vsvip.go index 50f0cc86..0312f07a 100644 --- a/avi/resource_avi_vsvip.go +++ b/avi/resource_avi_vsvip.go @@ -133,7 +133,7 @@ func ResourceAviVsVipRead(d *schema.ResourceData, meta interface{}) error { func resourceAviVsVipCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceVsVipSchema() - err := APICreate(d, meta, "vsvip", s) + err := APICreateOrUpdate(d, meta, "vsvip", s) if err == nil { err = ResourceAviVsVipRead(d, meta) } @@ -184,7 +184,7 @@ func resourceAviVsVipUpdate(d *schema.ResourceData, meta interface{}) error { } else { log.Printf("[ERROR] resourceAviVsVipUpdate in GET: %v\n", err) } - err = APIUpdate(d, meta, "vsvip", s) + err = APICreateOrUpdate(d, meta, "vsvip", s) if err == nil { err = ResourceAviVsVipRead(d, meta) } diff --git a/avi/resource_avi_wafapplicationsignatureprovider.go b/avi/resource_avi_wafapplicationsignatureprovider.go index 5e7b44eb..593b3ead 100644 --- a/avi/resource_avi_wafapplicationsignatureprovider.go +++ b/avi/resource_avi_wafapplicationsignatureprovider.go @@ -90,7 +90,7 @@ func ResourceAviWafApplicationSignatureProviderRead(d *schema.ResourceData, meta func resourceAviWafApplicationSignatureProviderCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafApplicationSignatureProviderSchema() - err := APICreate(d, meta, "wafapplicationsignatureprovider", s) + err := APICreateOrUpdate(d, meta, "wafapplicationsignatureprovider", s) if err == nil { err = ResourceAviWafApplicationSignatureProviderRead(d, meta) } @@ -100,7 +100,7 @@ func resourceAviWafApplicationSignatureProviderCreate(d *schema.ResourceData, me func resourceAviWafApplicationSignatureProviderUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafApplicationSignatureProviderSchema() var err error - err = APIUpdate(d, meta, "wafapplicationsignatureprovider", s) + err = APICreateOrUpdate(d, meta, "wafapplicationsignatureprovider", s) if err == nil { err = ResourceAviWafApplicationSignatureProviderRead(d, meta) } diff --git a/avi/resource_avi_wafcrs.go b/avi/resource_avi_wafcrs.go index 9159c33a..b1d31aad 100644 --- a/avi/resource_avi_wafcrs.go +++ b/avi/resource_avi_wafcrs.go @@ -113,7 +113,7 @@ func ResourceAviWafCRSRead(d *schema.ResourceData, meta interface{}) error { func resourceAviWafCRSCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafCRSSchema() - err := APICreate(d, meta, "wafcrs", s) + err := APICreateOrUpdate(d, meta, "wafcrs", s) if err == nil { err = ResourceAviWafCRSRead(d, meta) } @@ -123,7 +123,7 @@ func resourceAviWafCRSCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviWafCRSUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafCRSSchema() var err error - err = APIUpdate(d, meta, "wafcrs", s) + err = APICreateOrUpdate(d, meta, "wafcrs", s) if err == nil { err = ResourceAviWafCRSRead(d, meta) } diff --git a/avi/resource_avi_wafpolicy.go b/avi/resource_avi_wafpolicy.go index a3b7c80b..8a472a9b 100644 --- a/avi/resource_avi_wafpolicy.go +++ b/avi/resource_avi_wafpolicy.go @@ -203,7 +203,7 @@ func ResourceAviWafPolicyRead(d *schema.ResourceData, meta interface{}) error { func resourceAviWafPolicyCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafPolicySchema() - err := APICreate(d, meta, "wafpolicy", s) + err := APICreateOrUpdate(d, meta, "wafpolicy", s) if err == nil { err = ResourceAviWafPolicyRead(d, meta) } @@ -213,7 +213,7 @@ func resourceAviWafPolicyCreate(d *schema.ResourceData, meta interface{}) error func resourceAviWafPolicyUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafPolicySchema() var err error - err = APIUpdate(d, meta, "wafpolicy", s) + err = APICreateOrUpdate(d, meta, "wafpolicy", s) if err == nil { err = ResourceAviWafPolicyRead(d, meta) } diff --git a/avi/resource_avi_wafpolicypsmgroup.go b/avi/resource_avi_wafpolicypsmgroup.go index 56e08c3a..3b866d49 100644 --- a/avi/resource_avi_wafpolicypsmgroup.go +++ b/avi/resource_avi_wafpolicypsmgroup.go @@ -99,7 +99,7 @@ func ResourceAviWafPolicyPSMGroupRead(d *schema.ResourceData, meta interface{}) func resourceAviWafPolicyPSMGroupCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafPolicyPSMGroupSchema() - err := APICreate(d, meta, "wafpolicypsmgroup", s) + err := APICreateOrUpdate(d, meta, "wafpolicypsmgroup", s) if err == nil { err = ResourceAviWafPolicyPSMGroupRead(d, meta) } @@ -109,7 +109,7 @@ func resourceAviWafPolicyPSMGroupCreate(d *schema.ResourceData, meta interface{} func resourceAviWafPolicyPSMGroupUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafPolicyPSMGroupSchema() var err error - err = APIUpdate(d, meta, "wafpolicypsmgroup", s) + err = APICreateOrUpdate(d, meta, "wafpolicypsmgroup", s) if err == nil { err = ResourceAviWafPolicyPSMGroupRead(d, meta) } diff --git a/avi/resource_avi_wafprofile.go b/avi/resource_avi_wafprofile.go index e816792f..294d93e0 100644 --- a/avi/resource_avi_wafprofile.go +++ b/avi/resource_avi_wafprofile.go @@ -82,7 +82,7 @@ func ResourceAviWafProfileRead(d *schema.ResourceData, meta interface{}) error { func resourceAviWafProfileCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafProfileSchema() - err := APICreate(d, meta, "wafprofile", s) + err := APICreateOrUpdate(d, meta, "wafprofile", s) if err == nil { err = ResourceAviWafProfileRead(d, meta) } @@ -92,7 +92,7 @@ func resourceAviWafProfileCreate(d *schema.ResourceData, meta interface{}) error func resourceAviWafProfileUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWafProfileSchema() var err error - err = APIUpdate(d, meta, "wafprofile", s) + err = APICreateOrUpdate(d, meta, "wafprofile", s) if err == nil { err = ResourceAviWafProfileRead(d, meta) } diff --git a/avi/resource_avi_webapput.go b/avi/resource_avi_webapput.go index 79bf94fa..407b9ad6 100644 --- a/avi/resource_avi_webapput.go +++ b/avi/resource_avi_webapput.go @@ -136,7 +136,7 @@ func ResourceAviWebappUTRead(d *schema.ResourceData, meta interface{}) error { func resourceAviWebappUTCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWebappUTSchema() - err := APICreate(d, meta, "webapput", s) + err := APICreateOrUpdate(d, meta, "webapput", s) if err == nil { err = ResourceAviWebappUTRead(d, meta) } @@ -146,7 +146,7 @@ func resourceAviWebappUTCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviWebappUTUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWebappUTSchema() var err error - err = APIUpdate(d, meta, "webapput", s) + err = APICreateOrUpdate(d, meta, "webapput", s) if err == nil { err = ResourceAviWebappUTRead(d, meta) } diff --git a/avi/resource_avi_webhook.go b/avi/resource_avi_webhook.go index ce4c02d3..6117a977 100644 --- a/avi/resource_avi_webhook.go +++ b/avi/resource_avi_webhook.go @@ -82,7 +82,7 @@ func ResourceAviWebhookRead(d *schema.ResourceData, meta interface{}) error { func resourceAviWebhookCreate(d *schema.ResourceData, meta interface{}) error { s := ResourceWebhookSchema() - err := APICreate(d, meta, "webhook", s) + err := APICreateOrUpdate(d, meta, "webhook", s) if err == nil { err = ResourceAviWebhookRead(d, meta) } @@ -92,7 +92,7 @@ func resourceAviWebhookCreate(d *schema.ResourceData, meta interface{}) error { func resourceAviWebhookUpdate(d *schema.ResourceData, meta interface{}) error { s := ResourceWebhookSchema() var err error - err = APIUpdate(d, meta, "webhook", s) + err = APICreateOrUpdate(d, meta, "webhook", s) if err == nil { err = ResourceAviWebhookRead(d, meta) } diff --git a/avi/utils.go b/avi/utils.go index 6c5940fe..187f8011 100644 --- a/avi/utils.go +++ b/avi/utils.go @@ -276,57 +276,10 @@ func SetIDFromObj(d *schema.ResourceData, robj interface{}) { } } -// It is a API to create any Avi REST resource. It handles special situations with cloud -// and tenant filters as objects may already be present. -func APICreate(d *schema.ResourceData, meta interface{}, objType string, s map[string]*schema.Schema, - opts ...bool) error { - client := meta.(*clients.AviClient) - var robj interface{} - obj := d - - if data, err := SchemaToAviData(obj, s); err == nil { - path := "api/" + objType - specialobj := IsPostNotAllowed(objType) - var obj interface{} - tenantName := "" - if tenantRef, ok := d.GetOk("tenant_ref"); ok && strings.Contains(tenantRef.(string), - "api/tenant/") { - tenantUUID := strings.SplitN(tenantRef.(string), "/", 4)[3] - err := client.AviSession.Get(tenantUUID, &obj) - if err != nil { - log.Printf("[ERROR] APICreateOrUpdate tenant with uuid %v not found err %v\n", tenantUUID, err) - return err - } - tenantName = obj.(map[string]interface{})["name"].(string) - log.Printf("[INFO] APICreateOrUpdate Tenant ref found %v", tenantName) - } - if specialobj { - err = client.AviSession.Put(path, data, &robj) - if err != nil { - log.Printf("[ERROR] APICreateOrUpdate: PUT on %v Error %v path %v id %v\n", objType, err, path, - d.Id()) - } else { - SetIDFromObj(d, robj) - } - } else { - log.Printf("[INFO] APICreateOrUpdate: Creating obj %v schema %v data %v\n", objType, d, data) - err = client.AviSession.Post(path, data, &robj, session.SetOptTenant(tenantName)) - if err != nil { - log.Printf("[ERROR] APICreateOrUpdate creation failed %v\n", err) - } else { - SetIDFromObj(d, robj) - } - } - return err - } else { // nolint - log.Printf("[ERROR] APICreate: Error %v", err) - return err - } -} - -// It is a API to update any Avi REST resource. It handles special situations with cloud -// and tenant filters as objects may already be present. -func APIUpdate(d *schema.ResourceData, meta interface{}, objType string, s map[string]*schema.Schema, +// It is generic API to create and update any Avi REST resource. It handles special situations with cloud +// and tenant filters as objects may already be present. If the resource does not exist it will try to +// create it. In case, it is present then automatically converts to PUT semantics. +func APICreateOrUpdate(d *schema.ResourceData, meta interface{}, objType string, s map[string]*schema.Schema, opts ...bool) error { client := meta.(*clients.AviClient) var robj interface{} @@ -354,6 +307,7 @@ func APIUpdate(d *schema.ResourceData, meta interface{}, objType string, s map[s log.Printf("[INFO] APICreateOrUpdate Tenant ref found %v", tenantName) } if specialobj { + path = path + "?skip_default=true" err = client.AviSession.Put(path, data, &robj) if err != nil { log.Printf("[ERROR] APICreateOrUpdate: PUT on %v Error %v path %v id %v\n", objType, err, path, @@ -362,7 +316,7 @@ func APIUpdate(d *schema.ResourceData, meta interface{}, objType string, s map[s SetIDFromObj(d, robj) } } else if uuid, ok := d.GetOk("uuid"); ok { - path = path + "/" + uuid.(string) + path = path + "/" + uuid.(string) + "?skip_default=true" if !usePatchForUpdate { err = client.AviSession.Put(path, data, &robj, session.SetOptTenant(tenantName)) } else { @@ -371,10 +325,70 @@ func APIUpdate(d *schema.ResourceData, meta interface{}, objType string, s map[s if err != nil { log.Printf("[ERROR] APICreateOrUpdate: PUT Error %v path %v id %v\n", err, path, d.Id()) } + } else { + if name, ok := d.GetOk("name"); ok { + var existingObj interface{} + if cloudRef, ok := d.GetOk("cloud_ref"); ok && strings.Contains(cloudRef.(string), + "api/cloud/") { + cloudUUID := strings.SplitN(cloudRef.(string), "api/cloud/", 2)[1] + // strip the # if it exists + cloudUUID = strings.Split(cloudUUID, "#")[0] + log.Printf("[INFO] APICreateOrUpdate: using cloud %v for obj %v name %s \n", + cloudUUID, objType, name) + err = client.AviSession.GetObject(objType, session.SetName(name.(string)), + session.SetResult(&existingObj), session.SetCloudUUID(cloudUUID), + session.SetSkipDefault(true), session.SetOptTenant(tenantName)) + if err != nil { + log.Printf("[ERROR] APICreateOrUpdate: GET Error %v path %v id %v\n", err, path, d.Id()) + } + } else { + log.Printf("[INFO] APICreateOrUpdate: reading obj %v name %s \n", + objType, name) + err = client.AviSession.GetObject(objType, session.SetName(name.(string)), + session.SetResult(&existingObj), session.SetSkipDefault(true), session.SetOptTenant(tenantName)) + if err != nil { + log.Printf("[ERROR] APICreateOrUpdate: GET Error %v path %v id %v\n", err, path, d.Id()) + } + } + + if existingObj == nil { + // object not found + log.Printf("[INFO] APICreateOrUpdate: Creating obj type %v schema %v data %v\n", objType, d, + data) + err = client.AviSession.Post(path, data, &robj, session.SetOptTenant(tenantName)) + if err == nil && robj != nil { + SetIDFromObj(d, robj) + } else { + log.Printf("[ERROR] APICreateOrUpdate creation failed %v object with name %v\n", err, + name) + } + } else { + // found existing object. + SetIDFromObj(d, existingObj) + uuid = existingObj.(map[string]interface{})["uuid"].(string) + path = path + "/" + uuid.(string) + "?skip_default=true" + if !usePatchForUpdate { + err = client.AviSession.Put(path, data, &robj) + } else { + err = client.AviSession.Patch(path, data, "replace", &robj, session.SetOptTenant(tenantName)) + } + if err != nil { + log.Printf("[ERROR] APICreateOrUpdate: PUT Error %v path %v id %v\n", err, path, d.Id()) + } + } + } else { + log.Printf("[INFO] APICreateOrUpdate: Creating obj %v schema %v data %v\n", objType, d, data) + err = client.AviSession.Post(path, data, &robj, session.SetOptTenant(tenantName)) + if err != nil { + log.Printf("[ERROR] APICreateOrUpdate creation failed %v\n", err) + } else { + SetIDFromObj(d, robj) + } + } } return err - } else { // nolint - log.Printf("[ERROR] APIUpdate: Error %v", err) + } else { //nolint + log.Printf("[ERROR] APICreateOrUpdate: Error %v", err) return err } } @@ -414,7 +428,7 @@ func APIRead(d *schema.ResourceData, meta interface{}, objType string, s map[str if specialobj { path = "api/" + objType } else { - path = "api/" + objType + "/" + uuid + path = "api/" + objType + "/" + uuid + "?skip_default=true" } log.Printf("[DEBUG] APIRead reading object with id %v path %v\n", uuid, path) err := client.AviSession.Get(path, &obj, session.SetOptTenant(tenantName)) @@ -456,7 +470,15 @@ func APIRead(d *schema.ResourceData, meta interface{}, objType string, s map[str log.Printf("[ERROR] APIRead not found %v\n", d.Get("uuid")) return nil } - if modAPIRes, err := PreprocessAPIRes(obj, s); err == nil { + if localData, err := SchemaToAviData(d, s); err == nil { + modAPIRes, err := SetDefaultsInAPIRes(obj, localData, s) + if err != nil { + log.Printf("[ERROR] APIRead in modifying api response object %v\n", err) + } + modAPIRes, err = PreprocessAPIRes(modAPIRes, s) + if err != nil { + log.Printf("[ERROR] APIRead in modifying api response object for conversion %v\n", err) + } if _, err := APIDataToSchema(modAPIRes, d, s); err == nil { if modAPIRes.(map[string]interface{})["uuid"] != nil { uuid = modAPIRes.(map[string]interface{})["uuid"].(string) @@ -475,40 +497,10 @@ func APIRead(d *schema.ResourceData, meta interface{}, objType string, s map[str } else { log.Printf("[ERROR] APIRead in setting read object %v\n", err) } + log.Printf("[DEBUG] type: %v localData : %v", objType, localData) log.Printf("[DEBUG] type: %v modAPIRes: %v", objType, modAPIRes) - } else { - log.Printf("[ERROR] APIRead in modifying api response object for conversion %v\n", err) } - // if localData, err := SchemaToAviData(d, s); err == nil { - // // modAPIRes, err := SetDefaultsInAPIRes(obj, localData, s) - // if err != nil { - // log.Printf("[ERROR] APIRead in modifying api response object %v\n", err) - // } - // modAPIRes, err := PreprocessAPIRes(obj, s) - // if err != nil { - // log.Printf("[ERROR] APIRead in modifying api response object for conversion %v\n", err) - // } - // if _, err := APIDataToSchema(modAPIRes, d, s); err == nil { - // if modAPIRes.(map[string]interface{})["uuid"] != nil { - // uuid = modAPIRes.(map[string]interface{})["uuid"].(string) - // } - // if modAPIRes.(map[string]interface{})["url"] != nil { - // url = modAPIRes.(map[string]interface{})["url"].(string) - // } - // //url = strings.SplitN(url, "#", 2)[0] - // if url != "" { - // d.SetId(url) - // log.Printf("[DEBUG] APIRead read object with id %v\n", url) - // } else { - // d.SetId(uuid) - // log.Printf("[DEBUG] APIRead read object with id %v\n", uuid) - // } - // } else { - // log.Printf("[ERROR] APIRead in setting read object %v\n", err) - // } - // log.Printf("[DEBUG] type: %v localData : %v", objType, localData) - // log.Printf("[DEBUG] type: %v modAPIRes: %v", objType, modAPIRes) - // } + return nil } @@ -548,7 +540,7 @@ func ResourceImporter(d *schema.ResourceData, meta interface{}, objType string, } var data interface{} client := meta.(*clients.AviClient) - path := "api/" + objType + path := "api/" + objType + "?skip_default=true" err := client.AviSession.Get(path, &data) if err != nil { log.Printf("[ERROR] ResourceImporter %v in GET of path %v\n", err, path) diff --git a/go.mod b/go.mod index 90cad9b0..82ee28cc 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.16 require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0 - github.com/vmware/alb-sdk v0.0.0-20240506071759-27da9b298b96 + github.com/vmware/alb-sdk v0.0.0-20240530080103-cb11cb46c579 golang.org/x/net v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index d2029ace..7a0a8f9f 100644 --- a/go.sum +++ b/go.sum @@ -243,6 +243,10 @@ github.com/vmware/alb-sdk v0.0.0-20240502042605-947bfcf176dd h1:90FBuhMMWHNCDwRS github.com/vmware/alb-sdk v0.0.0-20240502042605-947bfcf176dd/go.mod h1:fuRb4saDY/xy/UMeMvyKYmcplNknEL9ysaqYSw7reNE= github.com/vmware/alb-sdk v0.0.0-20240506071759-27da9b298b96 h1:yY5O0FmL82oBLNcTB38MoZABz3GSDAoPN6NkbF4RxKw= github.com/vmware/alb-sdk v0.0.0-20240506071759-27da9b298b96/go.mod h1:fuRb4saDY/xy/UMeMvyKYmcplNknEL9ysaqYSw7reNE= +github.com/vmware/alb-sdk v0.0.0-20240508104949-e395e65a3dec h1:IC3e4KjYgOLHmTxyNSz/lFCDU7fmM3SJjZ47Sru0fQA= +github.com/vmware/alb-sdk v0.0.0-20240508104949-e395e65a3dec/go.mod h1:fuRb4saDY/xy/UMeMvyKYmcplNknEL9ysaqYSw7reNE= +github.com/vmware/alb-sdk v0.0.0-20240530080103-cb11cb46c579 h1:9vXkySix8eybjZLjFKp+a+gRkjuhvwJQ4w6ugquxpZk= +github.com/vmware/alb-sdk v0.0.0-20240530080103-cb11cb46c579/go.mod h1:fuRb4saDY/xy/UMeMvyKYmcplNknEL9ysaqYSw7reNE= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=