diff --git a/CHANGELOG.md b/CHANGELOG.md index fa2ea250..de198b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ +FEATURES: +## 0.2.0-beta (March 01, 2022) + +* **New Resource:** `resource_tag_membership` +* **New Resource:** `resource_path_trace` +* **New Resource:** `resource_golden_image` +* **New Resource:** `resource_swim_image_file` +* **New Resource:** `resource_global_credential_cli` +* **New Resource:** `resource_global_credential_http_read` +* **New Resource:** `resource_global_credential_http_write` +* **New Resource:** `resource_global_credential_netconf` +* **New Resource:** `resource_global_credential_snmpv2_read` +* **New Resource:** `resource_global_credential_snmpv2_write` +* **New Resource:** `resource_global_credential_snmpv3` +* **New Resource:** `resource_site` +* **New Resource:** `resource_service_provider` + +IMPROVEMENTS: +* dnacenter/resource_wireless_enterprise_ssid: Add trigger for update passphrase +* dnacenter/resource_network_device: Add trigger for update role of a device +* dnacenter/resource_configuration_template: Add trigger for new versio released + +BUG FIXES: +* Remove `use_api_gateway` and `use_csrf_token` configuration parameters from `provider` + ## 0.1.0-beta.2 (February 08, 2022) NOTES: diff --git a/Makefile b/Makefile index 177f6061..909c5ecc 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ HOSTNAME=hashicorp.com NAMESPACE=edu NAME=dnacenter BINARY=terraform-provider-${NAME} -VERSION=0.1.0-beta.2 +VERSION=0.2.0-beta OS_ARCH=darwin_arm64 GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) WEBSITE_REPO=github.com/hashicorp/terraform-website diff --git a/README.md b/README.md index 57a8064e..f4bffc06 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Other versions of this collection have support for previous Cisco DNA Center ver | Cisco DNA Center version | Terraform "dnacenter" provider version | |--------------------------|----------------------------------------| | 2.1.1 | 0.0.4 | -| 2.2.3.3 | 0.1.0-beta.2 | +| 2.2.3.3 | 0.2.0-beta | ## Using the provider @@ -38,7 +38,7 @@ terraform { required_providers { dnacenter = { source = "cisco-en-programmability/dnacenter" - version = "0.1.0-beta.2" + version = "0.2.0-beta" } } } @@ -76,7 +76,7 @@ terraform { required_providers { dnacenter = { source = "hashicorp.com/edu/dnacenter" - version = "0.1.0-beta.2" + version = "0.2.0-beta" } } } diff --git a/dnacenter/data_source_global_credential.go b/dnacenter/data_source_global_credential.go index b827b9f9..7591bd2c 100644 --- a/dnacenter/data_source_global_credential.go +++ b/dnacenter/data_source_global_credential.go @@ -99,6 +99,43 @@ func dataSourceGlobalCredential() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "netconf_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "read_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "write_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, }, }, }, @@ -205,11 +242,42 @@ func flattenDiscoveryGetGlobalCredentialsItems(items *[]dnacentersdkgo.ResponseD respItem["id"] = item.ID respItem["instance_tenant_id"] = item.InstanceTenantID respItem["instance_uuid"] = item.InstanceUUID + respItem["password"] = item.Password + respItem["port"] = item.Port + respItem["secure"] = boolPtrToString(item.Secure) + respItem["username"] = item.Username + respItem["netconf_port"] = item.NetconfPort + respItem["read_community"] = item.ReadCommunity + respItem["write_community"] = item.WriteCommunity respItems = append(respItems, respItem) } return respItems } +func flattenDiscoveryGetGlobalCredentialsItem(item *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse) []map[string]interface{} { + if item == nil { + return nil + } + + respItem := make(map[string]interface{}) + respItem["comments"] = item.Comments + respItem["credential_type"] = item.CredentialType + respItem["description"] = item.Description + respItem["id"] = item.ID + respItem["instance_tenant_id"] = item.InstanceTenantID + respItem["instance_uuid"] = item.InstanceUUID + respItem["password"] = item.Password + respItem["port"] = item.Port + respItem["secure"] = boolPtrToString(item.Secure) + respItem["username"] = item.Username + respItem["netconf_port"] = item.NetconfPort + respItem["read_community"] = item.ReadCommunity + respItem["write_community"] = item.WriteCommunity + return []map[string]interface{}{ + respItem, + } +} + func flattenDiscoveryGetCredentialSubTypeByCredentialIDItem(item *dnacentersdkgo.ResponseDiscoveryGetCredentialSubTypeByCredentialID) []map[string]interface{} { if item == nil { return nil diff --git a/dnacenter/data_source_license_smart_account_details.go b/dnacenter/data_source_license_smart_account_details.go index 46a98408..70e44dff 100644 --- a/dnacenter/data_source_license_smart_account_details.go +++ b/dnacenter/data_source_license_smart_account_details.go @@ -114,3 +114,19 @@ func flattenLicensesSmartAccountDetailsItems(items *[]dnacentersdkgo.ResponseLic } return respItems } + +func flattenLicensesSmartAccountDetailsItem(item *dnacentersdkgo.ResponseLicensesSmartAccountDetailsResponse) []map[string]interface{} { + if item == nil { + return nil + } + + respItem := make(map[string]interface{}) + respItem["name"] = item.Name + respItem["id"] = item.ID + respItem["domain"] = item.Domain + respItem["is_active_smart_account"] = boolPtrToString(item.IsActiveSmartAccount) + + return []map[string]interface{}{ + respItem, + } +} diff --git a/dnacenter/data_source_sensor.go b/dnacenter/data_source_sensor.go index 123aa43d..3a8d32dc 100644 --- a/dnacenter/data_source_sensor.go +++ b/dnacenter/data_source_sensor.go @@ -212,6 +212,30 @@ func flattenSensorsSensorsItems(items *[]dnacentersdkgo.ResponseSensorsSensorsRe return respItems } +func flattenSensorsSensorsItem(item *dnacentersdkgo.ResponseSensorsSensorsResponse) []map[string]interface{} { + if item == nil { + return nil + } + + respItem := make(map[string]interface{}) + respItem["name"] = item.Name + respItem["status"] = item.Status + respItem["radio_mac_address"] = item.RadioMacAddress + respItem["ethernet_mac_address"] = item.EthernetMacAddress + respItem["location"] = item.Location + respItem["backhaul_type"] = item.BackhaulType + respItem["serial_number"] = item.SerialNumber + respItem["ip_address"] = item.IPAddress + respItem["version"] = item.Version + respItem["last_seen"] = item.LastSeen + respItem["type"] = item.Type + respItem["ssh_config"] = flattenSensorsSensorsItemsSSHConfig(item.SSHConfig) + respItem["is_led_enabled"] = boolPtrToString(item.IsLEDEnabled) + return []map[string]interface{}{ + respItem, + } +} + func flattenSensorsSensorsItemsSSHConfig(item *dnacentersdkgo.ResponseSensorsSensorsResponseSSHConfig) []map[string]interface{} { if item == nil { return nil diff --git a/dnacenter/data_source_service_provider.go b/dnacenter/data_source_service_provider.go index 43a4fef9..34d8c7e2 100644 --- a/dnacenter/data_source_service_provider.go +++ b/dnacenter/data_source_service_provider.go @@ -104,7 +104,7 @@ func dataSourceServiceProvider() *schema.Resource { "version": &schema.Schema{ Description: `Version`, - Type: schema.TypeString, + Type: schema.TypeInt, Computed: true, }, }, @@ -173,6 +173,28 @@ func flattenNetworkSettingsGetServiceProviderDetailsItems(items *[]dnacentersdkg return respItems } +func flattenNetworkSettingsGetServiceProviderDetailsItem(item *dnacentersdkgo.ResponseNetworkSettingsGetServiceProviderDetailsResponse) []map[string]interface{} { + if item == nil { + return nil + } + + respItem := make(map[string]interface{}) + respItem["instance_type"] = item.InstanceType + respItem["instance_uuid"] = item.InstanceUUID + respItem["namespace"] = item.Namespace + respItem["type"] = item.Type + respItem["key"] = item.Key + respItem["version"] = item.Version + respItem["value"] = flattenNetworkSettingsGetServiceProviderDetailsItemsValue(item.Value) + respItem["group_uuid"] = item.GroupUUID + respItem["inherited_group_uuid"] = item.InheritedGroupUUID + respItem["inherited_group_name"] = item.InheritedGroupName + + return []map[string]interface{}{ + respItem, + } +} + func flattenNetworkSettingsGetServiceProviderDetailsItemsValue(items *[]dnacentersdkgo.ResponseNetworkSettingsGetServiceProviderDetailsResponseValue) []map[string]interface{} { if items == nil { return nil diff --git a/dnacenter/data_source_site.go b/dnacenter/data_source_site.go index 065a5ac5..917e76e5 100644 --- a/dnacenter/data_source_site.go +++ b/dnacenter/data_source_site.go @@ -61,8 +61,102 @@ func dataSourceSite() *schema.Resource { Description: `Additional Info`, Type: schema.TypeList, Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "attributes": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "address": &schema.Schema{ + Description: `address`, + Type: schema.TypeString, + Computed: true, + }, + + "address_inherited_from": &schema.Schema{ + Description: `addressInheritedFrom`, + Type: schema.TypeString, + Computed: true, + }, + + "country": &schema.Schema{ + Description: `country`, + Type: schema.TypeString, + Computed: true, + }, + + "floor_index": &schema.Schema{ + Description: `floorIndex`, + Type: schema.TypeString, + Computed: true, + }, + + "height": &schema.Schema{ + Description: `height`, + Type: schema.TypeString, + Computed: true, + }, + + "latitude": &schema.Schema{ + Description: `latitude`, + Type: schema.TypeString, + Computed: true, + }, + + "length": &schema.Schema{ + Description: `length`, + Type: schema.TypeString, + Computed: true, + }, + + "longitude": &schema.Schema{ + Description: `longitude`, + Type: schema.TypeString, + Computed: true, + }, + + "offset_x": &schema.Schema{ + Description: `offsetX`, + Type: schema.TypeString, + Computed: true, + }, + + "offset_y": &schema.Schema{ + Description: `offsetY`, + Type: schema.TypeString, + Computed: true, + }, + + "rf_model": &schema.Schema{ + Description: `rfModel`, + Type: schema.TypeString, + Computed: true, + }, + + "type": &schema.Schema{ + Description: `type`, + Type: schema.TypeString, + Computed: true, + }, + + "width": &schema.Schema{ + Description: `width`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "namespace": &schema.Schema{ + Description: `namespace`, + Type: schema.TypeString, + Computed: true, + }, + }, }, }, @@ -176,7 +270,7 @@ func flattenSitesGetSiteItems(items *[]dnacentersdkgo.ResponseSitesGetSiteRespon respItem := make(map[string]interface{}) respItem["parent_id"] = item.ParentID respItem["name"] = item.Name - respItem["additional_info"] = item.AdditionalInfo + respItem["additional_info"] = flattenSitesGetSiteItemsAdditionalInfo(&item.AdditionalInfo) respItem["site_hierarchy"] = item.SiteHierarchy respItem["site_name_hierarchy"] = item.SiteNameHierarchy respItem["instance_tenant_id"] = item.InstanceTenantID @@ -185,3 +279,42 @@ func flattenSitesGetSiteItems(items *[]dnacentersdkgo.ResponseSitesGetSiteRespon } return respItems } + +func flattenSitesGetSiteItemsAdditionalInfo(items *[]dnacentersdkgo.ResponseSitesGetSiteResponseAdditionalInfo) []map[string]interface{} { + if items == nil { + return nil + } + var respItems []map[string]interface{} + for _, item := range *items { + respItem := make(map[string]interface{}) + respItem["namespace"] = item.Namespace + respItem["attributes"] = flattenSitesGetSiteItemsAdditionalInfoAttributes(&item.Attributes) + respItems = append(respItems, respItem) + } + return respItems +} + +func flattenSitesGetSiteItemsAdditionalInfoAttributes(item *dnacentersdkgo.ResponseSitesGetSiteResponseAdditionalInfoAttributes) []map[string]interface{} { + if item == nil { + return nil + } + respItem := make(map[string]interface{}) + respItem["country"] = item.Country + respItem["address"] = item.Address + respItem["latitude"] = item.Latitude + respItem["address_inherited_from"] = item.AddressInheritedFrom + respItem["type"] = item.Type + respItem["longitude"] = item.Longitude + respItem["offset_x"] = item.OffsetX + respItem["offset_y"] = item.OffsetY + respItem["length"] = item.Length + respItem["width"] = item.Width + respItem["height"] = item.Height + respItem["rf_model"] = item.RfModel + respItem["floor_index"] = item.FloorIndex + + return []map[string]interface{}{ + respItem, + } + +} diff --git a/dnacenter/data_source_swim_image_details.go b/dnacenter/data_source_swim_image_details.go index 37309ab4..e75a262c 100644 --- a/dnacenter/data_source_swim_image_details.go +++ b/dnacenter/data_source_swim_image_details.go @@ -454,7 +454,39 @@ func flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItems(items *[]dna } return respItems } +func flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItem(item *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse) []map[string]interface{} { + if item == nil { + return nil + } + respItem := make(map[string]interface{}) + respItem["applicable_devices_for_image"] = flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItemsApplicableDevicesForImage(item.ApplicableDevicesForImage) + respItem["application_type"] = item.ApplicationType + respItem["created_time"] = item.CreatedTime + respItem["extended_attributes"] = flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItemsExtendedAttributes(item.ExtendedAttributes) + respItem["family"] = item.Family + respItem["feature"] = item.Feature + respItem["file_service_id"] = item.FileServiceID + respItem["file_size"] = item.FileSize + respItem["image_integrity_status"] = item.ImageIntegrityStatus + respItem["image_name"] = item.ImageName + respItem["image_series"] = item.ImageSeries + respItem["image_source"] = item.ImageSource + respItem["image_type"] = item.ImageType + respItem["image_uuid"] = item.ImageUUID + respItem["import_source_type"] = item.ImportSourceType + respItem["is_tagged_golden"] = boolPtrToString(item.IsTaggedGolden) + respItem["md5_checksum"] = item.Md5Checksum + respItem["name"] = item.Name + respItem["profile_info"] = flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItemsProfileInfo(item.ProfileInfo) + respItem["sha_check_sum"] = item.ShaCheckSum + respItem["vendor"] = item.Vendor + respItem["version"] = item.Version + + return []map[string]interface{}{ + respItem, + } +} func flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItemsApplicableDevicesForImage(items *[]dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponseApplicableDevicesForImage) []map[string]interface{} { if items == nil { return nil diff --git a/dnacenter/provider.go b/dnacenter/provider.go index d1f8a04b..f8b31a7d 100644 --- a/dnacenter/provider.go +++ b/dnacenter/provider.go @@ -49,65 +49,67 @@ func Provider() *schema.Provider { ValidateFunc: validateStringHasValueFunc([]string{"true", "false"}), Description: "Flag to enable or disable SSL certificate verification. If not set, it uses the DNAC_SSL_VERIFY environment variable; defaults to `true`.", }, - "use_api_gateway": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("DNAC_USE_API_GATEWAY", "false"), - ValidateFunc: validateStringHasValueFunc([]string{"true", "false"}), - Description: "Flag to enable or disable the usage of the DNAC's API Gateway. If not set, it uses the DNAC_USE_API_GATEWAY environment variable; defaults to `false`.", - }, - "use_csrf_token": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("DNAC_USE_CSRF_TOKEN", "false"), - ValidateFunc: validateStringHasValueFunc([]string{"true", "false"}), - Description: "Flag to enable or disable the usage of the X-CSRF-Token header. If not set, it uses the DNAC_USE_CSRF_TOKEN environment varible; defaults to `false`.", - }, }, ResourcesMap: map[string]*schema.Resource{ - "dnacenter_reserve_ip_subpool": resourceReserveIPSubpool(), - "dnacenter_wireless_rf_profile": resourceWirelessRfProfile(), - "dnacenter_wireless_profile": resourceWirelessProfile(), - "dnacenter_configuration_template_project": resourceConfigurationTemplateProject(), - "dnacenter_tag": resourceTag(), - "dnacenter_snmp_properties": resourceSNMPProperties(), - "dnacenter_pnp_global_settings": resourcePnpGlobalSettings(), - "dnacenter_site_design_floormap": resourceSiteDesignFloormap(), - "dnacenter_nfv_profile": resourceNfvProfile(), - "dnacenter_network_device_list": resourceNetworkDeviceList(), - "dnacenter_network_device": resourceNetworkDevice(), - "dnacenter_global_pool": resourceGlobalPool(), - "dnacenter_event_subscription_syslog": resourceEventSubscriptionSyslog(), - "dnacenter_event_subscription_rest": resourceEventSubscriptionRest(), - "dnacenter_event_subscription_email": resourceEventSubscriptionEmail(), - "dnacenter_event_subscription": resourceEventSubscription(), - "dnacenter_wireless_dynamic_interface": resourceWirelessDynamicInterface(), - "dnacenter_wireless_enterprise_ssid": resourceWirelessEnterpriseSSID(), - "dnacenter_discovery": resourceDiscovery(), - "dnacenter_device_replacement": resourceDeviceReplacement(), - "dnacenter_reports": resourceReports(), - "dnacenter_sda_multicast": resourceSdaMulticast(), - "dnacenter_sda_virtual_network_v2": resourceSdaVirtualNetworkV2(), - "dnacenter_sda_provision_device": resourceSdaProvisionDevice(), - "dnacenter_sda_virtual_network_ip_pool": resourceSdaVirtualNetworkIPPool(), - "dnacenter_sda_virtual_network": resourceSdaVirtualNetwork(), - "dnacenter_sda_port_assignment_for_user_device": resourceSdaPortAssignmentForUserDevice(), - "dnacenter_sda_port_assignment_for_access_point": resourceSdaPortAssignmentForAccessPoint(), - "dnacenter_sda_fabric_site": resourceSdaFabricSite(), - "dnacenter_sda_fabric": resourceSdaFabric(), - "dnacenter_sda_fabric_edge_device": resourceSdaFabricEdgeDevice(), - "dnacenter_sda_fabric_control_plane_device": resourceSdaFabricControlPlaneDevice(), - "dnacenter_sda_fabric_border_device": resourceSdaFabricBorderDevice(), - "dnacenter_sda_fabric_authentication_profile": resourceSdaFabricAuthenticationProfile(), - "dnacenter_applications": resourceApplications(), - "dnacenter_application_sets": resourceApplicationSets(), - "dnacenter_pnp_workflow": resourcePnpWorkflow(), - "dnacenter_pnp_device": resourcePnpDevice(), - "dnacenter_configuration_template": resourceConfigurationTemplate(), - "dnacenter_app_policy_queuing_profile": resourceAppPolicyQueuingProfile(), - "dnacenter_business_sda_hostonboarding_ssid_ippool": resourceBusinessSdaHostonboardingSSIDIPpool(), - "dnacenter_endpoint_analytics_profiling_rules": resourceEndpointAnalyticsProfilingRules(), - "dnacenter_qos_device_interface": resourceQosDeviceInterface(), + "dnacenter_reserve_ip_subpool": resourceReserveIPSubpool(), + "dnacenter_wireless_rf_profile": resourceWirelessRfProfile(), + "dnacenter_wireless_profile": resourceWirelessProfile(), + "dnacenter_configuration_template_project": resourceConfigurationTemplateProject(), + "dnacenter_tag": resourceTag(), + "dnacenter_tag_membership": resourceTagMembership(), + "dnacenter_snmp_properties": resourceSNMPProperties(), + "dnacenter_pnp_global_settings": resourcePnpGlobalSettings(), + "dnacenter_site_design_floormap": resourceSiteDesignFloormap(), + "dnacenter_nfv_profile": resourceNfvProfile(), + "dnacenter_network_device_list": resourceNetworkDeviceList(), + "dnacenter_network_device": resourceNetworkDevice(), + "dnacenter_global_pool": resourceGlobalPool(), + "dnacenter_event_subscription_syslog": resourceEventSubscriptionSyslog(), + "dnacenter_event_subscription_rest": resourceEventSubscriptionRest(), + "dnacenter_event_subscription_email": resourceEventSubscriptionEmail(), + "dnacenter_event_subscription": resourceEventSubscription(), + "dnacenter_wireless_dynamic_interface": resourceWirelessDynamicInterface(), + "dnacenter_wireless_enterprise_ssid": resourceWirelessEnterpriseSSID(), + "dnacenter_discovery": resourceDiscovery(), + "dnacenter_device_replacement": resourceDeviceReplacement(), + "dnacenter_reports": resourceReports(), + "dnacenter_sda_multicast": resourceSdaMulticast(), + "dnacenter_sda_virtual_network_v2": resourceSdaVirtualNetworkV2(), + "dnacenter_sda_provision_device": resourceSdaProvisionDevice(), + "dnacenter_sda_virtual_network_ip_pool": resourceSdaVirtualNetworkIPPool(), + "dnacenter_sda_virtual_network": resourceSdaVirtualNetwork(), + "dnacenter_sda_port_assignment_for_user_device": resourceSdaPortAssignmentForUserDevice(), + "dnacenter_sda_port_assignment_for_access_point": resourceSdaPortAssignmentForAccessPoint(), + "dnacenter_sda_fabric_site": resourceSdaFabricSite(), + "dnacenter_sda_fabric": resourceSdaFabric(), + "dnacenter_sda_fabric_edge_device": resourceSdaFabricEdgeDevice(), + "dnacenter_sda_fabric_control_plane_device": resourceSdaFabricControlPlaneDevice(), + "dnacenter_sda_fabric_border_device": resourceSdaFabricBorderDevice(), + "dnacenter_sda_fabric_authentication_profile": resourceSdaFabricAuthenticationProfile(), + "dnacenter_applications": resourceApplications(), + "dnacenter_application_sets": resourceApplicationSets(), + "dnacenter_pnp_workflow": resourcePnpWorkflow(), + "dnacenter_pnp_device": resourcePnpDevice(), + "dnacenter_configuration_template": resourceConfigurationTemplate(), + "dnacenter_app_policy_queuing_profile": resourceAppPolicyQueuingProfile(), + "dnacenter_business_sda_hostonboarding_ssid_ippool": resourceBusinessSdaHostonboardingSSIDIPpool(), + "dnacenter_endpoint_analytics_profiling_rules": resourceEndpointAnalyticsProfilingRules(), + "dnacenter_qos_device_interface": resourceQosDeviceInterface(), + "dnacenter_path_trace": resourcePathTrace(), + "dnacenter_global_credential_cli": resourceGlobalCredentialCli(), + "dnacenter_global_credential_http_read": resourceGlobalCredentialHTTPRead(), + "dnacenter_global_credential_http_write": resourceGlobalCredentialHTTPWrite(), + "dnacenter_global_credential_netconf": resourceGlobalCredentialNetconf(), + "dnacenter_global_credential_snmpv2_read_community": resourceGlobalCredentialSNMPv2ReadCommunity(), + "dnacenter_global_credential_snmpv2_write_community": resourceGlobalCredentialSNMPv2WriteCommunity(), + "dnacenter_global_credential_snmpv3": resourceGlobalCredentialSNMPv3(), + "dnacenter_golden_image": resourceGoldenImage(), + "dnacenter_license_device": resourceLicenseDevice(), + "dnacenter_nfv_provision_detail": resourceNfvProvisionDetail(), + "dnacenter_sensor": resourceSensor(), + "dnacenter_service_provider": resourceServiceProvider(), + "dnacenter_site": resourceSite(), + "dnacenter_swim_image_file": resourceSwimImageFile(), }, DataSourcesMap: map[string]*schema.Resource{ "dnacenter_reserve_ip_subpool": dataSourceReserveIPSubpool(), diff --git a/dnacenter/resource_app_policy_queuing_profile.go b/dnacenter/resource_app_policy_queuing_profile.go index 2ff35093..61d3677c 100644 --- a/dnacenter/resource_app_policy_queuing_profile.go +++ b/dnacenter/resource_app_policy_queuing_profile.go @@ -844,9 +844,6 @@ func resourceAppPolicyQueuingProfileDelete(ctx context.Context, d *schema.Resour queryParams1.Name = vName item, err := searchApplicationPolicyGetApplicationPolicyQueuingProfile(m, queryParams1) if err != nil || item == nil { - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetApplicationPolicyQueuingProfile", err, - "Failure at GetApplicationPolicyQueuingProfile, unexpected response", "")) return diags } diff --git a/dnacenter/resource_applications.go b/dnacenter/resource_applications.go index 556d7b06..6a9ffc28 100644 --- a/dnacenter/resource_applications.go +++ b/dnacenter/resource_applications.go @@ -550,7 +550,7 @@ func resourceApplicationsCreate(ctx context.Context, d *schema.ResourceData, m i if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) diags = append(diags, diagError( - "Failure when executing CreateApplicationSet", err)) + "Failure when executing CreateApplication", err)) return diags } } diff --git a/dnacenter/resource_business_sda_hostonboarding_ssid_ippool.go b/dnacenter/resource_business_sda_hostonboarding_ssid_ippool.go index 72bafddb..3280f1f4 100644 --- a/dnacenter/resource_business_sda_hostonboarding_ssid_ippool.go +++ b/dnacenter/resource_business_sda_hostonboarding_ssid_ippool.go @@ -322,7 +322,7 @@ func resourceBusinessSdaHostonboardingSSIDIPpoolUpdate(ctx context.Context, d *s bapiError := response2.BapiError diags = append(diags, diagErrorWithAlt( "Failure when executing AddSSIDToIPPoolMapping", err, - "Failure at AddSSIDToIPPoolMapping execution", bapiError)) + "Failure at UpdateSSIDToIPPoolMapping execution", bapiError)) return diags } } diff --git a/dnacenter/resource_compliance.go b/dnacenter/resource_compliance.go new file mode 100644 index 00000000..5f95ef35 --- /dev/null +++ b/dnacenter/resource_compliance.go @@ -0,0 +1,355 @@ +package dnacenter + +import ( + "context" + "log" + "reflect" + "time" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceCompliance() *schema.Resource { + return &schema.Resource{ + Description: ` +`, + + CreateContext: resourceComplianceCreate, + ReadContext: resourceComplianceRead, + UpdateContext: resourceComplianceUpdate, + DeleteContext: resourceComplianceDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ap_manager_interface_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "associated_wlc_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "boot_date_time": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "collection_interval": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "collection_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "error_code": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "error_description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "family": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "hostname": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_count": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "inventory_status_detail": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "last_update_time": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "line_card_count": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "line_card_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "location_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "mac_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "management_ip_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "memory_size": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "platform_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "reachability_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "reachability_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "role": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "role_source": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "serial_number": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "series": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "snmp_contact": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "snmp_location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "software_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "software_version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "tag_count": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "tunnel_udp_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "up_time": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "waas_device_mode": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "categories": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "device_uuids": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "trigger_full": &schema.Schema{ + + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceComplianceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + vDeviceUuids := resourceItem["device_uuids"] + vvDeviceUuids := interfaceToSliceString(vDeviceUuids) + request1 := expandRequestComplianceCheckRunRunCompliance(ctx, "parameters.0", d) + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + response1, restyResp1, err := client.Compliance.RunCompliance(request1) + if err != nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing RunCompliance", err, + "Failure at RunCompliance, unexpected response", "")) + return diags + } + if response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing AddWLCToFabricDomain", err, + "Failure at AddWLCToFabricDomain, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing RunCompliance", err)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["device_uuids"] = vvDeviceUuids[0] + d.SetId(joinResourceID(resourceMap)) + return resourceComplianceRead(ctx, d, m) +} + +func resourceComplianceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["device_uuids"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetDeviceByID") + vvID := vID + + response1, restyResp1, err := client.Devices.GetDeviceByID(vvID) + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + vItem1 := flattenDevicesGetDeviceByIDItem(response1.Response) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetDeviceByID response", + err)) + return diags + } + return diags + + } + return diags +} + +func resourceComplianceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourceComplianceRead(ctx, d, m) +} + +func resourceComplianceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete BusinessSdaWireless on Dna Center + // Returning empty diags to delete it on Terraform + return diags +} + +func expandRequestComplianceCheckRunRunCompliance(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestComplianceRunCompliance { + request := dnacentersdkgo.RequestComplianceRunCompliance{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".trigger_full")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".trigger_full")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".trigger_full")))) { + request.TriggerFull = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".categories")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".categories")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".categories")))) { + request.Categories = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_uuids")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_uuids")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_uuids")))) { + request.DeviceUUIDs = interfaceToSliceString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} diff --git a/dnacenter/resource_configuration_template.go b/dnacenter/resource_configuration_template.go index 015a969d..1656f70a 100644 --- a/dnacenter/resource_configuration_template.go +++ b/dnacenter/resource_configuration_template.go @@ -14,9 +14,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +//Falta el trigger /version/ + func resourceConfigurationTemplate() *schema.Resource { return &schema.Resource{ - Description: `It manages read, update and delete operations on Configuration Templates. + Description: `It manages create, read, update and delete operations on Configuration Templates. + +- API to create a template by project id. - API to update a template. @@ -1650,7 +1654,7 @@ func resourceConfigurationTemplate() *schema.Resource { Description: `Project UUID `, Type: schema.TypeString, - Optional: true, + Required: true, }, "project_name": &schema.Schema{ Description: `Project name @@ -1892,7 +1896,7 @@ func resourceConfigurationTemplate() *schema.Resource { Description: `templateId path parameter. templateId(UUID) of template to be deleted `, Type: schema.TypeString, - Required: true, + Optional: true, }, "template_params": &schema.Schema{ Type: schema.TypeList, @@ -2113,6 +2117,12 @@ func resourceConfigurationTemplate() *schema.Resource { }, }, }, + "comments": &schema.Schema{ + Description: `Template version comments + `, + Type: schema.TypeString, + Optional: true, + }, "version": &schema.Schema{ Description: `Current version of template `, @@ -2127,15 +2137,66 @@ func resourceConfigurationTemplate() *schema.Resource { } func resourceConfigurationTemplateCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + var diags diag.Diagnostics + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestConfigurationTemplateCreateTemplate(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + + vTemplateID, okTemplateID := resourceItem["template_id"] + vvTemplateID := interfaceToString(vTemplateID) + vProjectID := resourceItem["project_id"] + vvProjectID := interfaceToString(vProjectID) + if okTemplateID && vvTemplateID != "" { + getResponse2, _, err := client.ConfigurationTemplates.GetsDetailsOfAGivenTemplate(vvTemplateID, nil) + if err == nil && getResponse2 != nil { + resourceMap := make(map[string]string) + resourceMap["template_id"] = vvTemplateID + resourceMap["project_id"] = vvProjectID + d.SetId(joinResourceID(resourceMap)) + return resourceConfigurationTemplateRead(ctx, d, m) + } + } + resp1, restyResp1, err := client.ConfigurationTemplates.CreateTemplate(vvProjectID, request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateTemplate", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateTemplate", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateTemplate", err)) + return diags + } + vvTemplateID = response2.Response.Data + } resourceMap := make(map[string]string) - // TODO: Add the path params to `item` schema - // & return it individually - resourceMap["id"] = interfaceToString(resourceItem["id"]) - resourceMap["name"] = interfaceToString(resourceItem["name"]) + resourceMap["template_id"] = vvTemplateID + resourceMap["project_id"] = vvProjectID d.SetId(joinResourceID(resourceMap)) - return diags + return resourceConfigurationTemplateRead(ctx, d, m) } func resourceConfigurationTemplateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -2145,16 +2206,20 @@ func resourceConfigurationTemplateRead(ctx context.Context, d *schema.ResourceDa resourceID := d.Id() resourceMap := separateResourceID(resourceID) - vTemplateID := resourceMap["id"] - vTemplateName := resourceMap["name"] + vTemplateID := resourceMap["template_id"] + //vProjectID := resourceMap["project_id"] + //vTemplateName := resourceMap["name"] - if vTemplateName != "" { + /*if vTemplateName != "" { log.Printf("[DEBUG] Selected method 1: GetsTheTemplatesAvailable") queryParams1 := dnacentersdkgo.GetsTheTemplatesAvailableQueryParams{} - + queryParams1.ProjectID = vProjectID response1, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParams1, vTemplateName) if err != nil || response1 == nil { + if err != nil { + log.Printf("[DEBUG] Error when search => %s", err.Error()) + } d.SetId("") return diags } @@ -2168,9 +2233,7 @@ func resourceConfigurationTemplateRead(ctx context.Context, d *schema.ResourceDa if restyResp2 != nil { log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) } - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetsDetailsOfAGivenTemplate", err, - "Failure at GetsDetailsOfAGivenTemplate, unexpected response", "")) + d.SetId("") return diags } vItems1 := flattenConfigurationTemplatesGetsDetailsOfAGivenTemplateItem(response2) @@ -2181,7 +2244,8 @@ func resourceConfigurationTemplateRead(ctx context.Context, d *schema.ResourceDa return diags } return diags - } else if vTemplateID != "" { + } else*/ + if vTemplateID != "" { log.Printf("[DEBUG] Selected method 2: GetsDetailsOfAGivenTemplate") vvTemplateID := vTemplateID queryParams2 := dnacentersdkgo.GetsDetailsOfAGivenTemplateQueryParams{} @@ -2217,8 +2281,9 @@ func resourceConfigurationTemplateUpdate(ctx context.Context, d *schema.Resource resourceID := d.Id() resourceMap := separateResourceID(resourceID) - vTemplateID := resourceMap["id"] - vTemplateName := resourceMap["name"] + vTemplateID := resourceMap["template_id"] + //vProjectID := resourceMap["project_id"] + //vTemplateName := resourceMap["name"] var vvTemplateID string // NOTE: Consider adding getAllItems and search function to get missing params if vTemplateID != "" { @@ -2232,9 +2297,9 @@ func resourceConfigurationTemplateUpdate(ctx context.Context, d *schema.Resource "Failure at GetsDetailsOfAGivenTemplate, unexpected response", "")) return diags } - } else if vTemplateName != "" { + } /*else if vTemplateName != "" { queryParams1 := dnacentersdkgo.GetsTheTemplatesAvailableQueryParams{} - + queryParams1.ProjectID = vProjectID response1, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParams1, vTemplateName) if err != nil || response1 == nil { @@ -2245,16 +2310,62 @@ func resourceConfigurationTemplateUpdate(ctx context.Context, d *schema.Resource } vvTemplateID = response1.TemplateID } - + */ if d.HasChange("parameters") { - log.Printf("[DEBUG] Name used for update operation %s", vTemplateName) + log.Printf("[DEBUG] ID used for update operation %s", vTemplateID) request1 := expandRequestConfigurationTemplateUpdateTemplate(ctx, "parameters.0", d) if request1 != nil { log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) } - if request1 != nil && request1.ID == "" { - request1.ID = vvTemplateID + request1.ID = vvTemplateID + if d.HasChange("parameters.0.comments") { + request2 := expandRequestConfigurationTemplateVersionCreateVersionTemplate(ctx, "parameters.0", d) + if request2 != nil { + log.Printf("[DEBUG] request2 sent => %v", responseInterfaceToString(*request2)) + } + request2.TemplateID = vTemplateID + response2, restyResp2, err := client.ConfigurationTemplates.VersionTemplate(request2) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp2.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing VersionTemplate", err, restyResp2.String(), + "Failure at VersionTemplate, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing VersionTemplate", err, + "Failure at VersionTemplate, unexpected response", "")) + return diags + } + if response2.Response == nil { + diags = append(diags, diagError( + "Failure when executing VersionTemplate", err)) + return diags + } + taskId := response2.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing VersionTemplate", err)) + return diags + } + } } + response1, restyResp1, err := client.ConfigurationTemplates.UpdateTemplate(request1) if err != nil || response1 == nil { if restyResp1 != nil { @@ -2291,7 +2402,7 @@ func resourceConfigurationTemplateUpdate(ctx context.Context, d *schema.Resource if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) diags = append(diags, diagError( - "Failure when executing CreateApplicationSet", err)) + "Failure when executing UpdateTemplate", err)) return diags } } @@ -2308,8 +2419,9 @@ func resourceConfigurationTemplateDelete(ctx context.Context, d *schema.Resource resourceID := d.Id() resourceMap := separateResourceID(resourceID) - vTemplateID := resourceMap["id"] - vTemplateName := resourceMap["name"] + vTemplateID := resourceMap["template_id"] + //vProjectID := resourceMap["project_id"] + //vTemplateName := resourceMap["name"] var vvTemplateID string // REVIEW: Add getAllItems and search function to get missing params @@ -2322,16 +2434,18 @@ func resourceConfigurationTemplateDelete(ctx context.Context, d *schema.Resource return diags } } - if vTemplateName != "" { - queryParams1 := dnacentersdkgo.GetsTheTemplatesAvailableQueryParams{} + /* + if vTemplateName != "" { + queryParams1 := dnacentersdkgo.GetsTheTemplatesAvailableQueryParams{} + queryParams1.ProjectID = vProjectID + response1, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParams1, vTemplateName) - response1, err := searchConfigurationTemplatesGetsTheTemplatesAvailable(m, queryParams1, vTemplateName) - - if err != nil || response1 == nil { - return diags + if err != nil || response1 == nil { + return diags + } + vvTemplateID = response1.TemplateID } - vvTemplateID = response1.TemplateID - } + */ response1, restyResp1, err := client.ConfigurationTemplates.DeletesTheTemplate(vvTemplateID) if err != nil || response1 == nil { if restyResp1 != nil { @@ -2353,10 +2467,10 @@ func resourceConfigurationTemplateDelete(ctx context.Context, d *schema.Resource return diags } -func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplate { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplate{} +func expandRequestConfigurationTemplateCreateTemplate(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplate { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplate{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".tags")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".tags")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".tags")))) { - request.Tags = expandRequestConfigurationTemplateUpdateTemplateTagsArray(ctx, key+".tags", d) + request.Tags = expandRequestConfigurationTemplateCreateTemplateTagsArray(ctx, key+".tags", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".author")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".author")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".author")))) { request.Author = interfaceToString(v) @@ -2365,7 +2479,7 @@ func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key s request.Composite = interfaceToBoolPtr(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".containing_templates")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".containing_templates")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".containing_templates")))) { - request.ContainingTemplates = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesArray(ctx, key+".containing_templates", d) + request.ContainingTemplates = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesArray(ctx, key+".containing_templates", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".create_time")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".create_time")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".create_time")))) { request.CreateTime = interfaceToIntPtr(v) @@ -2377,7 +2491,7 @@ func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key s request.Description = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_types")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_types")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_types")))) { - request.DeviceTypes = expandRequestConfigurationTemplateUpdateTemplateDeviceTypesArray(ctx, key+".device_types", d) + request.DeviceTypes = expandRequestConfigurationTemplateCreateTemplateDeviceTypesArray(ctx, key+".device_types", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".failure_policy")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".failure_policy")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".failure_policy")))) { request.FailurePolicy = interfaceToString(v) @@ -2410,7 +2524,7 @@ func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key s request.RollbackTemplateContent = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_params")))) { - request.RollbackTemplateParams = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsArray(ctx, key+".rollback_template_params", d) + request.RollbackTemplateParams = expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsArray(ctx, key+".rollback_template_params", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".software_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".software_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".software_type")))) { request.SoftwareType = interfaceToString(v) @@ -2425,10 +2539,10 @@ func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key s request.TemplateContent = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_params")))) { - request.TemplateParams = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsArray(ctx, key+".template_params", d) + request.TemplateParams = expandRequestConfigurationTemplateCreateTemplateTemplateParamsArray(ctx, key+".template_params", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".validation_errors")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".validation_errors")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".validation_errors")))) { - request.ValidationErrors = expandRequestConfigurationTemplateUpdateTemplateValidationErrors(ctx, key+".validation_errors.0", d) + request.ValidationErrors = expandRequestConfigurationTemplateCreateTemplateValidationErrors(ctx, key+".validation_errors.0", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".version")))) { request.Version = interfaceToString(v) @@ -2440,8 +2554,8 @@ func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key s return &request } -func expandRequestConfigurationTemplateUpdateTemplateTagsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags{} +func expandRequestConfigurationTemplateCreateTemplateTagsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTags { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTags{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2451,8 +2565,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTagsArray(ctx context.Conte if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateTags(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateTags(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2464,8 +2578,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTagsArray(ctx context.Conte return &request } -func expandRequestConfigurationTemplateUpdateTemplateTags(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags{} +func expandRequestConfigurationTemplateCreateTemplateTags(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTags { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTags{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) } @@ -2479,8 +2593,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTags(ctx context.Context, k return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplates { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplates{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2490,8 +2604,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesArray(ct if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplates(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2503,10 +2617,10 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesArray(ct return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplates(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplates { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplates{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".tags")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".tags")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".tags")))) { - request.Tags = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTagsArray(ctx, key+".tags", d) + request.Tags = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTagsArray(ctx, key+".tags", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".composite")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".composite")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".composite")))) { request.Composite = interfaceToBoolPtr(v) @@ -2515,7 +2629,7 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx con request.Description = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_types")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_types")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_types")))) { - request.DeviceTypes = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypesArray(ctx, key+".device_types", d) + request.DeviceTypes = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesDeviceTypesArray(ctx, key+".device_types", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) @@ -2530,13 +2644,13 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx con request.ProjectName = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_params")))) { - request.RollbackTemplateParams = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsArray(ctx, key+".rollback_template_params", d) + request.RollbackTemplateParams = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsArray(ctx, key+".rollback_template_params", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_content")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_content")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_content")))) { request.TemplateContent = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_params")))) { - request.TemplateParams = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsArray(ctx, key+".template_params", d) + request.TemplateParams = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsArray(ctx, key+".template_params", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".version")))) { request.Version = interfaceToString(v) @@ -2548,8 +2662,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx con return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTagsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTagsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTags { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTags{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2559,8 +2673,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTagsArra if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTags(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTags(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2572,8 +2686,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTagsArra return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTags(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTags(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTags { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTags{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) } @@ -2587,8 +2701,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTags(ctx return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesDeviceTypesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesDeviceTypes { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesDeviceTypes{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2598,8 +2712,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTy if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypes(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplatesDeviceTypes(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2611,8 +2725,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTy return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypes(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesDeviceTypes(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesDeviceTypes { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesDeviceTypes{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_family")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_family")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_family")))) { request.ProductFamily = interfaceToString(v) } @@ -2629,8 +2743,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTy return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParams{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2640,8 +2754,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2653,8 +2767,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParams{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { request.Binding = interfaceToString(v) } @@ -2701,13 +2815,13 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback request.Provider = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { - request.Range = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRangeArray(ctx, key+".range", d) + request.Range = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsRangeArray(ctx, key+".range", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { request.Required = interfaceToBoolPtr(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { - request.Selection = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection(ctx, key+".selection.0", d) + request.Selection = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsSelection(ctx, key+".selection.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -2716,8 +2830,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsRange{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2727,8 +2841,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2740,8 +2854,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsRange{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) } @@ -2758,8 +2872,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsSelection{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { request.DefaultSelectedValues = interfaceToSliceString(v) } @@ -2770,7 +2884,7 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback request.SelectionType = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { - request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + request.SelectionValues = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -2779,8 +2893,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues { - var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues request = d.Get(fixKeyAccess(key)) if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -2789,8 +2903,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollback return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParams{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2800,8 +2914,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2813,8 +2927,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParams{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { request.Binding = interfaceToString(v) } @@ -2861,13 +2975,13 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate request.Provider = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { - request.Range = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRangeArray(ctx, key+".range", d) + request.Range = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsRangeArray(ctx, key+".range", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { request.Required = interfaceToBoolPtr(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { - request.Selection = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelection(ctx, key+".selection.0", d) + request.Selection = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsSelection(ctx, key+".selection.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -2876,8 +2990,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsRange{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2887,8 +3001,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2900,8 +3014,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsRange{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) } @@ -2918,8 +3032,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelection { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelection{} +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsSelection{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { request.DefaultSelectedValues = interfaceToSliceString(v) } @@ -2930,7 +3044,7 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate request.SelectionType = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { - request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + request.SelectionValues = expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -2939,8 +3053,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate return &request } -func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues { - var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues +func expandRequestConfigurationTemplateCreateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues request = d.Get(fixKeyAccess(key)) if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -2949,8 +3063,8 @@ func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplate return &request } -func expandRequestConfigurationTemplateUpdateTemplateDeviceTypesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes{} +func expandRequestConfigurationTemplateCreateTemplateDeviceTypesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateDeviceTypes { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateDeviceTypes{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -2960,8 +3074,8 @@ func expandRequestConfigurationTemplateUpdateTemplateDeviceTypesArray(ctx contex if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateDeviceTypes(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateDeviceTypes(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -2973,8 +3087,8 @@ func expandRequestConfigurationTemplateUpdateTemplateDeviceTypesArray(ctx contex return &request } -func expandRequestConfigurationTemplateUpdateTemplateDeviceTypes(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes{} +func expandRequestConfigurationTemplateCreateTemplateDeviceTypes(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateDeviceTypes { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateDeviceTypes{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_family")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_family")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_family")))) { request.ProductFamily = interfaceToString(v) } @@ -2991,8 +3105,8 @@ func expandRequestConfigurationTemplateUpdateTemplateDeviceTypes(ctx context.Con return &request } -func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParams{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -3002,8 +3116,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsArray if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -3015,8 +3129,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsArray return &request } -func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParams{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { request.Binding = interfaceToString(v) } @@ -3063,13 +3177,13 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParams(ctx request.Provider = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { - request.Range = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRangeArray(ctx, key+".range", d) + request.Range = expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsRangeArray(ctx, key+".range", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { request.Required = interfaceToBoolPtr(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { - request.Selection = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelection(ctx, key+".selection.0", d) + request.Selection = expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsSelection(ctx, key+".selection.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3078,8 +3192,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParams(ctx return &request } -func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsRange{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -3089,8 +3203,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -3102,8 +3216,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange return &request } -func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsRange{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) } @@ -3120,8 +3234,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange return &request } -func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelection { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelection{} +func expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsSelection{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { request.DefaultSelectedValues = interfaceToSliceString(v) } @@ -3132,7 +3246,7 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelec request.SelectionType = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { - request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + request.SelectionValues = expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3141,8 +3255,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelec return &request } -func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelectionSelectionValues { - var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelectionSelectionValues +func expandRequestConfigurationTemplateCreateTemplateRollbackTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateRollbackTemplateParamsSelectionSelectionValues request = d.Get(fixKeyAccess(key)) if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3151,8 +3265,8 @@ func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelec return &request } -func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParams{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -3162,8 +3276,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsArray(ctx con if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -3175,8 +3289,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsArray(ctx con return &request } -func expandRequestConfigurationTemplateUpdateTemplateTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams{} +func expandRequestConfigurationTemplateCreateTemplateTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParams{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { request.Binding = interfaceToString(v) } @@ -3223,13 +3337,13 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParams(ctx context. request.Provider = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { - request.Range = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRangeArray(ctx, key+".range", d) + request.Range = expandRequestConfigurationTemplateCreateTemplateTemplateParamsRangeArray(ctx, key+".range", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { request.Required = interfaceToBoolPtr(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { - request.Selection = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelection(ctx, key+".selection.0", d) + request.Selection = expandRequestConfigurationTemplateCreateTemplateTemplateParamsSelection(ctx, key+".selection.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3238,8 +3352,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParams(ctx context. return &request } -func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsRange{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -3249,8 +3363,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRangeArray(ct if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -3262,8 +3376,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRangeArray(ct return &request } -func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange{} +func expandRequestConfigurationTemplateCreateTemplateTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsRange{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { request.ID = interfaceToString(v) } @@ -3280,8 +3394,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRange(ctx con return &request } -func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelection { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelection{} +func expandRequestConfigurationTemplateCreateTemplateTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsSelection{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { request.DefaultSelectedValues = interfaceToSliceString(v) } @@ -3292,7 +3406,7 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelection(ctx request.SelectionType = interfaceToString(v) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { - request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + request.SelectionValues = expandRequestConfigurationTemplateCreateTemplateTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) } if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3301,8 +3415,8 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelection(ctx return &request } -func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelectionSelectionValues { - var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelectionSelectionValues +func expandRequestConfigurationTemplateCreateTemplateTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateTemplateParamsSelectionSelectionValues request = d.Get(fixKeyAccess(key)) if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3311,13 +3425,13 @@ func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelectionSele return &request } -func expandRequestConfigurationTemplateUpdateTemplateValidationErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrors { - request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrors{} +func expandRequestConfigurationTemplateCreateTemplateValidationErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrors { + request := dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrors{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_errors")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_errors")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_errors")))) { - request.RollbackTemplateErrors = expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrorsArray(ctx, key+".rollback_template_errors", d) + request.RollbackTemplateErrors = expandRequestConfigurationTemplateCreateTemplateValidationErrorsRollbackTemplateErrorsArray(ctx, key+".rollback_template_errors", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_errors")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_errors")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_errors")))) { - request.TemplateErrors = expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrorsArray(ctx, key+".template_errors", d) + request.TemplateErrors = expandRequestConfigurationTemplateCreateTemplateValidationErrorsTemplateErrorsArray(ctx, key+".template_errors", d) } if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_id")))) { request.TemplateID = interfaceToString(v) @@ -3332,8 +3446,8 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrors(ctx contex return &request } -func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrorsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors{} +func expandRequestConfigurationTemplateCreateTemplateValidationErrorsRollbackTemplateErrorsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsRollbackTemplateErrors { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsRollbackTemplateErrors{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -3343,8 +3457,8 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTem if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrors(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateValidationErrorsRollbackTemplateErrors(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -3356,8 +3470,8 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTem return &request } -func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors { - var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors +func expandRequestConfigurationTemplateCreateTemplateValidationErrorsRollbackTemplateErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsRollbackTemplateErrors { + var request dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsRollbackTemplateErrors request = d.Get(fixKeyAccess(key)) if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3366,8 +3480,8 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTem return &request } -func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrorsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors { - request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors{} +func expandRequestConfigurationTemplateCreateTemplateValidationErrorsTemplateErrorsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsTemplateErrors { + request := []dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsTemplateErrors{} key = fixKeyAccess(key) o := d.Get(key) if o == nil { @@ -3377,8 +3491,8 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErr if len(objs) == 0 { return nil } - for item_no := range objs { - i := expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrors(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateCreateTemplateValidationErrorsTemplateErrors(ctx, fmt.Sprintf("%s.%d", key, item_no), d) if i != nil { request = append(request, *i) } @@ -3390,8 +3504,8 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErr return &request } -func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors { - var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors +func expandRequestConfigurationTemplateCreateTemplateValidationErrorsTemplateErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsTemplateErrors { + var request dnacentersdkgo.RequestConfigurationTemplatesCreateTemplateValidationErrorsTemplateErrors request = d.Get(fixKeyAccess(key)) if isEmptyValue(reflect.ValueOf(request)) { return nil @@ -3400,17 +3514,1080 @@ func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErr return &request } -func searchConfigurationTemplatesGetsTheTemplatesAvailable(m interface{}, queryParams dnacentersdkgo.GetsTheTemplatesAvailableQueryParams, vName string) (*dnacentersdkgo.ResponseItemConfigurationTemplatesGetsTheTemplatesAvailable, error) { - client := m.(*dnacentersdkgo.Client) - var err error - var foundItem *dnacentersdkgo.ResponseItemConfigurationTemplatesGetsTheTemplatesAvailable - nResponse, _, err := client.ConfigurationTemplates.GetsTheTemplatesAvailable(nil) - - if err != nil { - return foundItem, err +func expandRequestConfigurationTemplateVersionCreateVersionTemplate(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesVersionTemplate { + request := dnacentersdkgo.RequestConfigurationTemplatesVersionTemplate{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) } - //maxPageSize := 10 + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_id")))) { + request.TemplateID = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} +func expandRequestConfigurationTemplateUpdateTemplate(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplate { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplate{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".tags")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".tags")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".tags")))) { + request.Tags = expandRequestConfigurationTemplateUpdateTemplateTagsArray(ctx, key+".tags", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".author")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".author")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".author")))) { + request.Author = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".composite")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".composite")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".composite")))) { + request.Composite = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".containing_templates")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".containing_templates")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".containing_templates")))) { + request.ContainingTemplates = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesArray(ctx, key+".containing_templates", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".create_time")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".create_time")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".create_time")))) { + request.CreateTime = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".custom_params_order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".custom_params_order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".custom_params_order")))) { + request.CustomParamsOrder = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_types")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_types")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_types")))) { + request.DeviceTypes = expandRequestConfigurationTemplateUpdateTemplateDeviceTypesArray(ctx, key+".device_types", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".failure_policy")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".failure_policy")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".failure_policy")))) { + request.FailurePolicy = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".language")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".language")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".language")))) { + request.Language = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".last_update_time")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".last_update_time")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".last_update_time")))) { + request.LastUpdateTime = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".latest_version_time")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".latest_version_time")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".latest_version_time")))) { + request.LatestVersionTime = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parent_template_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parent_template_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parent_template_id")))) { + request.ParentTemplateID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".project_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".project_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".project_id")))) { + request.ProjectID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".project_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".project_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".project_name")))) { + request.ProjectName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_content")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_content")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_content")))) { + request.RollbackTemplateContent = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_params")))) { + request.RollbackTemplateParams = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsArray(ctx, key+".rollback_template_params", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".software_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".software_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".software_type")))) { + request.SoftwareType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".software_variant")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".software_variant")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".software_variant")))) { + request.SoftwareVariant = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".software_version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".software_version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".software_version")))) { + request.SoftwareVersion = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_content")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_content")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_content")))) { + request.TemplateContent = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_params")))) { + request.TemplateParams = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsArray(ctx, key+".template_params", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".validation_errors")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".validation_errors")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".validation_errors")))) { + request.ValidationErrors = expandRequestConfigurationTemplateUpdateTemplateValidationErrors(ctx, key+".validation_errors.0", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".version")))) { + request.Version = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTagsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateTags(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTags(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTags{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplates(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplates{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".tags")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".tags")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".tags")))) { + request.Tags = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTagsArray(ctx, key+".tags", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".composite")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".composite")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".composite")))) { + request.Composite = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_types")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_types")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_types")))) { + request.DeviceTypes = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypesArray(ctx, key+".device_types", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".language")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".language")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".language")))) { + request.Language = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".project_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".project_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".project_name")))) { + request.ProjectName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_params")))) { + request.RollbackTemplateParams = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsArray(ctx, key+".rollback_template_params", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_content")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_content")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_content")))) { + request.TemplateContent = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_params")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_params")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_params")))) { + request.TemplateParams = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsArray(ctx, key+".template_params", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".version")))) { + request.Version = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTagsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTags(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTags(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTags{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypes(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesDeviceTypes(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesDeviceTypes{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_family")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_family")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_family")))) { + request.ProductFamily = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_series")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_series")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_series")))) { + request.ProductSeries = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_type")))) { + request.ProductType = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParams{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { + request.Binding = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".custom_order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".custom_order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".custom_order")))) { + request.CustomOrder = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".data_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".data_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".data_type")))) { + request.DataType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_value")))) { + request.DefaultValue = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".display_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".display_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".display_name")))) { + request.DisplayName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".group")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".group")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".group")))) { + request.Group = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instruction_text")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instruction_text")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instruction_text")))) { + request.InstructionText = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".key")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".key")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".key")))) { + request.Key = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".not_param")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".not_param")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".not_param")))) { + request.NotParam = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".order")))) { + request.Order = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".param_array")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".param_array")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".param_array")))) { + request.ParamArray = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parameter_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parameter_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parameter_name")))) { + request.ParameterName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".provider")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".provider")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".provider")))) { + request.Provider = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { + request.Range = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRangeArray(ctx, key+".range", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { + request.Required = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { + request.Selection = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection(ctx, key+".selection.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsRange{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".max_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".max_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".max_value")))) { + request.MaxValue = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".min_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".min_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".min_value")))) { + request.MinValue = interfaceToIntPtr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelection{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { + request.DefaultSelectedValues = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_type")))) { + request.SelectionType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { + request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesRollbackTemplateParamsSelectionSelectionValues + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParams{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { + request.Binding = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".custom_order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".custom_order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".custom_order")))) { + request.CustomOrder = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".data_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".data_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".data_type")))) { + request.DataType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_value")))) { + request.DefaultValue = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".display_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".display_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".display_name")))) { + request.DisplayName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".group")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".group")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".group")))) { + request.Group = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instruction_text")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instruction_text")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instruction_text")))) { + request.InstructionText = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".key")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".key")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".key")))) { + request.Key = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".not_param")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".not_param")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".not_param")))) { + request.NotParam = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".order")))) { + request.Order = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".param_array")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".param_array")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".param_array")))) { + request.ParamArray = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parameter_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parameter_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parameter_name")))) { + request.ParameterName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".provider")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".provider")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".provider")))) { + request.Provider = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { + request.Range = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRangeArray(ctx, key+".range", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { + request.Required = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { + request.Selection = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelection(ctx, key+".selection.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsRange{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".max_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".max_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".max_value")))) { + request.MaxValue = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".min_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".min_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".min_value")))) { + request.MinValue = interfaceToIntPtr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelection{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { + request.DefaultSelectedValues = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_type")))) { + request.SelectionType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { + request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateContainingTemplatesTemplateParamsSelectionSelectionValues + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateDeviceTypesArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateDeviceTypes(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateDeviceTypes(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateDeviceTypes{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_family")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_family")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_family")))) { + request.ProductFamily = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_series")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_series")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_series")))) { + request.ProductSeries = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".product_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".product_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".product_type")))) { + request.ProductType = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParams{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { + request.Binding = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".custom_order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".custom_order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".custom_order")))) { + request.CustomOrder = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".data_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".data_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".data_type")))) { + request.DataType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_value")))) { + request.DefaultValue = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".display_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".display_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".display_name")))) { + request.DisplayName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".group")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".group")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".group")))) { + request.Group = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instruction_text")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instruction_text")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instruction_text")))) { + request.InstructionText = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".key")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".key")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".key")))) { + request.Key = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".not_param")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".not_param")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".not_param")))) { + request.NotParam = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".order")))) { + request.Order = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".param_array")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".param_array")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".param_array")))) { + request.ParamArray = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parameter_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parameter_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parameter_name")))) { + request.ParameterName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".provider")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".provider")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".provider")))) { + request.Provider = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { + request.Range = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRangeArray(ctx, key+".range", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { + request.Required = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { + request.Selection = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelection(ctx, key+".selection.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsRange{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".max_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".max_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".max_value")))) { + request.MaxValue = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".min_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".min_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".min_value")))) { + request.MinValue = interfaceToIntPtr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelection{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { + request.DefaultSelectedValues = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_type")))) { + request.SelectionType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { + request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateRollbackTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateRollbackTemplateParamsSelectionSelectionValues + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateTemplateParams(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTemplateParams(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParams{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".binding")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".binding")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".binding")))) { + request.Binding = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".custom_order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".custom_order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".custom_order")))) { + request.CustomOrder = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".data_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".data_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".data_type")))) { + request.DataType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_value")))) { + request.DefaultValue = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".display_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".display_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".display_name")))) { + request.DisplayName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".group")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".group")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".group")))) { + request.Group = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instruction_text")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instruction_text")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instruction_text")))) { + request.InstructionText = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".key")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".key")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".key")))) { + request.Key = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".not_param")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".not_param")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".not_param")))) { + request.NotParam = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".order")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".order")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".order")))) { + request.Order = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".param_array")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".param_array")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".param_array")))) { + request.ParamArray = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parameter_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parameter_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parameter_name")))) { + request.ParameterName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".provider")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".provider")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".provider")))) { + request.Provider = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".range")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".range")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".range")))) { + request.Range = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRangeArray(ctx, key+".range", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".required")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".required")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".required")))) { + request.Required = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection")))) { + request.Selection = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelection(ctx, key+".selection.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRangeArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRange(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsRange(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsRange{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".max_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".max_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".max_value")))) { + request.MaxValue = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".min_value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".min_value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".min_value")))) { + request.MinValue = interfaceToIntPtr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelection(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelection { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelection{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".default_selected_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".default_selected_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".default_selected_values")))) { + request.DefaultSelectedValues = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_type")))) { + request.SelectionType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selection_values")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selection_values")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selection_values")))) { + request.SelectionValues = expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelectionSelectionValues(ctx, key+".selection_values.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateTemplateParamsSelectionSelectionValues(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelectionSelectionValues { + var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateTemplateParamsSelectionSelectionValues + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateValidationErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrors { + request := dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrors{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rollback_template_errors")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rollback_template_errors")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rollback_template_errors")))) { + request.RollbackTemplateErrors = expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrorsArray(ctx, key+".rollback_template_errors", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_errors")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_errors")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_errors")))) { + request.TemplateErrors = expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrorsArray(ctx, key+".template_errors", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_id")))) { + request.TemplateID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".template_version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".template_version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".template_version")))) { + request.TemplateVersion = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrorsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrors(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsRollbackTemplateErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors { + var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsRollbackTemplateErrors + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrorsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors { + request := []dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrors(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestConfigurationTemplateUpdateTemplateValidationErrorsTemplateErrors(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors { + var request dnacentersdkgo.RequestConfigurationTemplatesUpdateTemplateValidationErrorsTemplateErrors + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchConfigurationTemplatesGetsTheTemplatesAvailable(m interface{}, queryParams dnacentersdkgo.GetsTheTemplatesAvailableQueryParams, vName string) (*dnacentersdkgo.ResponseItemConfigurationTemplatesGetsTheTemplatesAvailable, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseItemConfigurationTemplatesGetsTheTemplatesAvailable + nResponse, _, err := client.ConfigurationTemplates.GetsTheTemplatesAvailable(nil) + + if err != nil { + log.Printf("[DEBUG] Error when search => %s", err.Error()) + return foundItem, err + } + //maxPageSize := 10 + log.Printf("[DEBUG] Start to find a concidence") for _, item := range *nResponse { if vName == item.Name { foundItem = &item diff --git a/dnacenter/resource_discovery.go b/dnacenter/resource_discovery.go index a48b7a4a..b01af254 100644 --- a/dnacenter/resource_discovery.go +++ b/dnacenter/resource_discovery.go @@ -724,7 +724,7 @@ func resourceDiscoveryCreate(ctx context.Context, d *schema.ResourceData, m inte if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) diags = append(diags, diagError( - "Failure when executing CreateDiscovery", err)) + "Failure when executing StartDiscovery", err)) return diags } } @@ -770,9 +770,7 @@ func resourceDiscoveryRead(ctx context.Context, d *schema.ResourceData, m interf } return diags - } - - if vName != "" { + } else if vName != "" { response1, err := searchDiscovery(m, vName) if err != nil || response1 == nil { d.SetId("") @@ -879,7 +877,7 @@ func resourceDiscoveryUpdate(ctx context.Context, d *schema.ResourceData, m inte if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) diags = append(diags, diagError( - "Failure when executing UpdateDiscovery", err)) + "Failure when executing UpdatesAnExistingDiscoveryBySpecifiedID", err)) return diags } } diff --git a/dnacenter/resource_global_credential_cli.go b/dnacenter/resource_global_credential_cli.go new file mode 100644 index 00000000..749f257f --- /dev/null +++ b/dnacenter/resource_global_credential_cli.go @@ -0,0 +1,474 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialCli() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and update operations on Discovery. + +- Updates global CLI credentials + +- Adds global CLI credential + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialCliCreate, + ReadContext: resourceGlobalCredentialCliRead, + UpdateContext: resourceGlobalCredentialCliUpdate, + DeleteContext: resourceGlobalCredentialCliDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestDiscoveryCreateCLICredentials`, + Type: schema.TypeList, + MaxItems: 1, + MinItems: 1, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "enable_password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Sensitive: true, + }, + "username": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialCliCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGlobalCredentialCliCreateCliCredentials(ctx, "parameters", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + vUsername := resourceItem["username"] + vvUsername := interfaceToString(vUsername) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "CLI" + item, err := searchDiscoveryGetGlobalCredentialsCli(m, queryParams1, vvUsername, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialCliRead(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateCliCredentials(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateCliCredentials", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateCliCredentials", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateCliCredentials", err)) + return diags + } + } + + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialCliRead(ctx, d, m) +} + +func resourceGlobalCredentialCliRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "CLI" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsCli(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialCliUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "CLI" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + queryParams1.CredentialSubType = vCredentialSubType + response1, err := searchDiscoveryGetGlobalCredentialsCli(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + + //selectedMethod := 1 + //var vvID string + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestGlobalCredentialCliUpdateCliCredentials(ctx, "parameters.0", d) + request1.ID = response1.ID + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateCliCredentials(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateCliCredentials", err, restyResp1.String(), + "Failure at UpdateCliCredentials, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateCliCredentials", err, + "Failure at UpdateCliCredentials, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateCliCredentials", err)) + return diags + } + } + } + + return resourceGlobalCredentialCliRead(ctx, d, m) +} + +func resourceGlobalCredentialCliDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete GlobalCredentialSNMPv2ReadCommunity on Dna Center + // Returning empty diags to delete it on Terraform + // DeleteGlobalCredentialsByID + client := m.(*dnacentersdkgo.Client) + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + vUsername := resourceMap["username"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "CLI" + item, err := searchDiscoveryGetGlobalCredentialsCli(m, queryParams1, vUsername, vID) + if item == nil && err != nil { + return resourceGlobalCredentialCliRead(ctx, d, m) + } + if vID != item.ID { + vID = item.ID + } + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} +func expandRequestGlobalCredentialCliCreateCliCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateCliCredentials { + request := dnacentersdkgo.RequestDiscoveryCreateCliCredentials{} + if v := expandRequestGlobalCredentialCliCreateCliCredentialsItemArray(ctx, key, d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialCliCreateCliCredentialsItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateCliCredentials { + request := []dnacentersdkgo.RequestItemDiscoveryCreateCliCredentials{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestGlobalCredentialCliCreateCliCredentialsItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialCliCreateCliCredentialsItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateCliCredentials { + request := dnacentersdkgo.RequestItemDiscoveryCreateCliCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".enable_password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".enable_password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".enable_password")))) { + request.EnablePassword = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".password")))) { + request.Password = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialCliUpdateCliCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateCliCredentials { + request := dnacentersdkgo.RequestDiscoveryUpdateCliCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".enable_password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".enable_password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".enable_password")))) { + request.EnablePassword = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".password")))) { + request.Password = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsCli(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vUsername string, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "CLI" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID || item.Username == vUsername { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_credential_http_read.go b/dnacenter/resource_global_credential_http_read.go new file mode 100644 index 00000000..f22dfcdf --- /dev/null +++ b/dnacenter/resource_global_credential_http_read.go @@ -0,0 +1,506 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialHTTPRead() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and update operations on Discovery. + +- Adds HTTP read credentials + +- Updates global HTTP Read credential + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialHTTPReadCreate, + ReadContext: resourceGlobalCredentialHTTPReadRead, + UpdateContext: resourceGlobalCredentialHTTPReadUpdate, + DeleteContext: resourceGlobalCredentialHTTPReadDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestDiscoveryCreateHTTPReadCredentials`, + Type: schema.TypeList, + MaxItems: 1, + MinItems: 1, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Sensitive: true, + }, + "port": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + "username": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialHTTPReadCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGlobalCredentialHTTPReadCreateHTTPReadCredentials(ctx, "parameters", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + vUsername := resourceItem["username"] + vvUsername := interfaceToString(vUsername) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "HTTP_READ" + item, err := searchDiscoveryGetGlobalCredentialsHttpRead(m, queryParams1, vvUsername, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialHTTPReadRead(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateHTTPReadCredentials(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateHTTPReadCredentials", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateHTTPReadCredentials", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateHTTPReadCredentials", err)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialHTTPReadRead(ctx, d, m) +} + +func resourceGlobalCredentialHTTPReadRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "HTTP_READ" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsHttpRead(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialHTTPReadUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "HTTP_READ" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + queryParams1.CredentialSubType = vCredentialSubType + response1, err := searchDiscoveryGetGlobalCredentialsHttpRead(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestGlobalCredentialHTTPReadUpdateHTTPReadCredential(ctx, "parameters.0", d) + request1.ID = response1.ID + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateHTTPReadCredential(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateHTTPReadCredential", err, restyResp1.String(), + "Failure at UpdateHTTPReadCredential, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateHTTPReadCredential", err, + "Failure at UpdateHTTPReadCredential, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateHTTPReadCredential", err)) + return diags + } + } + + } + + return resourceGlobalCredentialHTTPReadRead(ctx, d, m) +} + +func resourceGlobalCredentialHTTPReadDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete GlobalCredentialSNMPv2ReadCommunity on Dna Center + // Returning empty diags to delete it on Terraform + // DeleteGlobalCredentialsByID + client := m.(*dnacentersdkgo.Client) + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + vUsername := resourceMap["username"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "HTTP_READ" + item, err := searchDiscoveryGetGlobalCredentialsHttpRead(m, queryParams1, vUsername, vID) + if item == nil && err != nil { + return resourceGlobalCredentialHTTPReadRead(ctx, d, m) + } + if vID != item.ID { + vID = item.ID + } + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} +func expandRequestGlobalCredentialHTTPReadCreateHTTPReadCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateHTTPReadCredentials { + request := dnacentersdkgo.RequestDiscoveryCreateHTTPReadCredentials{} + if v := expandRequestGlobalCredentialHTTPReadCreateHTTPReadCredentialsItemArray(ctx, key+".", d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialHTTPReadCreateHTTPReadCredentialsItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateHTTPReadCredentials { + request := []dnacentersdkgo.RequestItemDiscoveryCreateHTTPReadCredentials{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestGlobalCredentialHTTPReadCreateHTTPReadCredentialsItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialHTTPReadCreateHTTPReadCredentialsItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateHTTPReadCredentials { + request := dnacentersdkgo.RequestItemDiscoveryCreateHTTPReadCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".password")))) { + request.Password = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".port")))) { + request.Port = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".secure")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".secure")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".secure")))) { + request.Secure = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialHTTPReadUpdateHTTPReadCredential(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateHTTPReadCredential { + request := dnacentersdkgo.RequestDiscoveryUpdateHTTPReadCredential{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".password")))) { + request.Password = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".port")))) { + request.Port = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".secure")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".secure")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".secure")))) { + request.Secure = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsHttpRead(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vUsername string, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "HTTP_READ" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID || item.Username == vUsername { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_credential_http_write.go b/dnacenter/resource_global_credential_http_write.go new file mode 100644 index 00000000..508a4c3c --- /dev/null +++ b/dnacenter/resource_global_credential_http_write.go @@ -0,0 +1,506 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialHTTPWrite() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read, update and delete operations on Discovery. +- Adds global HTTP write credentials + +- Updates global HTTP write credentials + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialHTTPWriteCreate, + ReadContext: resourceGlobalCredentialHTTPWriteRead, + UpdateContext: resourceGlobalCredentialHTTPWriteUpdate, + DeleteContext: resourceGlobalCredentialHTTPWriteDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `HttpWriteCredentials`, + Type: schema.TypeList, + MaxItems: 1, + MinItems: 1, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Sensitive: true, + }, + "port": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "secure": &schema.Schema{ + + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + "username": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialHTTPWriteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestHTTPWriteCredentialCreateCreateHTTPWriteCredentials(ctx, "parameters", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + vUsername := resourceItem["username"] + vvUsername := interfaceToString(vUsername) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "HTTP_WRITE" + item, err := searchDiscoveryGetGlobalCredentialsHttpWrite(m, queryParams1, vvUsername, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialHTTPWriteRead(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateHTTPWriteCredentials(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateHTTPWriteCredentials", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateHTTPWriteCredentials", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateHTTPWriteCredentials", err)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialHTTPWriteRead(ctx, d, m) +} + +func resourceGlobalCredentialHTTPWriteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "HTTP_WRITE" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsHttpWrite(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialHTTPWriteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "HTTP_WRITE" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + queryParams1.CredentialSubType = vCredentialSubType + response1, err := searchDiscoveryGetGlobalCredentialsHttpWrite(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestHTTPWriteCredentialUpdateUpdateHTTPWriteCredentials(ctx, "parameters.0", d) + request1.ID = response1.ID + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateHTTPWriteCredentials(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateHTTPWriteCredentials", err, restyResp1.String(), + "Failure at UpdateHTTPWriteCredentials, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateHTTPWriteCredentials", err, + "Failure at UpdateHTTPWriteCredentials, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateHTTPWriteCredentials", err)) + return diags + } + } + + } + + return resourceGlobalCredentialHTTPReadRead(ctx, d, m) +} + +func resourceGlobalCredentialHTTPWriteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete GlobalCredentialSNMPv2ReadCommunity on Dna Center + // Returning empty diags to delete it on Terraform + // DeleteGlobalCredentialsByID + client := m.(*dnacentersdkgo.Client) + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + vUsername := resourceMap["username"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "HTTP_WRITE" + item, err := searchDiscoveryGetGlobalCredentialsHttpWrite(m, queryParams1, vUsername, vID) + if item == nil && err != nil { + return resourceGlobalCredentialHTTPWriteRead(ctx, d, m) + } + if vID != item.ID { + vID = item.ID + } + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} + +func expandRequestHTTPWriteCredentialCreateCreateHTTPWriteCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateHTTPWriteCredentials { + request := dnacentersdkgo.RequestDiscoveryCreateHTTPWriteCredentials{} + if v := expandRequestHTTPWriteCredentialCreateCreateHTTPWriteCredentialsItemArray(ctx, key, d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestHTTPWriteCredentialCreateCreateHTTPWriteCredentialsItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateHTTPWriteCredentials { + request := []dnacentersdkgo.RequestItemDiscoveryCreateHTTPWriteCredentials{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no := range objs { + i := expandRequestHTTPWriteCredentialCreateCreateHTTPWriteCredentialsItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestHTTPWriteCredentialCreateCreateHTTPWriteCredentialsItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateHTTPWriteCredentials { + request := dnacentersdkgo.RequestItemDiscoveryCreateHTTPWriteCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".password")))) { + request.Password = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".port")))) { + request.Port = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".secure")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".secure")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".secure")))) { + request.Secure = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestHTTPWriteCredentialUpdateUpdateHTTPWriteCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateHTTPWriteCredentials { + request := dnacentersdkgo.RequestDiscoveryUpdateHTTPWriteCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".password")))) { + request.Password = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".port")))) { + request.Port = interfaceToIntPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".secure")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".secure")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".secure")))) { + request.Secure = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsHttpWrite(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vUsername string, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "HTTP_WRITE" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID || item.Username == vUsername { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_credential_netconf.go b/dnacenter/resource_global_credential_netconf.go new file mode 100644 index 00000000..ea03b5a5 --- /dev/null +++ b/dnacenter/resource_global_credential_netconf.go @@ -0,0 +1,477 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialNetconf() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and update operations on Discovery. + +- Updates global netconf credentials + +- Adds global netconf credentials + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialNetconfCreate, + ReadContext: resourceGlobalCredentialNetconfRead, + UpdateContext: resourceGlobalCredentialNetconfUpdate, + DeleteContext: resourceGlobalCredentialNetconfDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "netconf_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestDiscoveryCreateNetconfCredentials`, + Type: schema.TypeList, + MaxItems: 1, + MinItems: 1, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "netconf_port": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialNetconfCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGlobalCredentialNetconfCreateNetconfCredentials(ctx, "parameters", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + vNetconfPort := resourceItem["netconf_port"] + vvNetconfPort := interfaceToString(vNetconfPort) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "NETCONF" + item, err := searchDiscoveryGetGlobalCredentialsNetConf(m, queryParams1, vvNetconfPort, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["netconf_port"] = vvNetconfPort + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialNetconfRead(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateNetconfCredentials(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateNetconfCredentials", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateNetconfCredentials", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateNetconfCredentials", err)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["netconf_port"] = vvNetconfPort + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialNetconfRead(ctx, d, m) +} + +func resourceGlobalCredentialNetconfRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "NETCONF" + vNetconfPort := resourceMap["netconf_port"] + vID := resourceMap["id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsNetConf(m, queryParams1, vNetconfPort, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialNetconfUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vNetconfPort := resourceMap["netconf_port"] + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "NETCONF" + item, err := searchDiscoveryGetGlobalCredentialsNetConf(m, queryParams1, vNetconfPort, vID) + if err != nil || item == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestGlobalCredentialNetconfUpdateNetconfCredentials(ctx, "parameters.0", d) + request1.ID = item.ID + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateNetconfCredentials(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateNetconfCredentials", err, restyResp1.String(), + "Failure at UpdateNetconfCredentials, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateNetconfCredentials", err, + "Failure at UpdateNetconfCredentials, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateNetconfCredentials", err)) + return diags + } + } + + } + + return resourceGlobalCredentialNetconfRead(ctx, d, m) +} + +func resourceGlobalCredentialNetconfDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete GlobalCredentialSNMPv2ReadCommunity on Dna Center + // Returning empty diags to delete it on Terraform + // DeleteGlobalCredentialsByID + client := m.(*dnacentersdkgo.Client) + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + vNetconfPort := resourceMap["netconf_port"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "NETCONF" + item, err := searchDiscoveryGetGlobalCredentialsNetConf(m, queryParams1, vNetconfPort, vID) + if item == nil && err != nil { + return resourceGlobalCredentialNetconfRead(ctx, d, m) + } + + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} +func expandRequestGlobalCredentialNetconfCreateNetconfCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateNetconfCredentials { + request := dnacentersdkgo.RequestDiscoveryCreateNetconfCredentials{} + if v := expandRequestGlobalCredentialNetconfCreateNetconfCredentialsItemArray(ctx, key, d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialNetconfCreateNetconfCredentialsItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateNetconfCredentials { + request := []dnacentersdkgo.RequestItemDiscoveryCreateNetconfCredentials{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestGlobalCredentialNetconfCreateNetconfCredentialsItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialNetconfCreateNetconfCredentialsItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateNetconfCredentials { + request := dnacentersdkgo.RequestItemDiscoveryCreateNetconfCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".netconf_port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".netconf_port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".netconf_port")))) { + request.NetconfPort = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialNetconfUpdateNetconfCredentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateNetconfCredentials { + request := dnacentersdkgo.RequestDiscoveryUpdateNetconfCredentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".netconf_port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".netconf_port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".netconf_port")))) { + request.NetconfPort = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsNetConf(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vNetconfPort string, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "NETCONF" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID || item.NetconfPort == vNetconfPort { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_credential_snmpv2_read_community.go b/dnacenter/resource_global_credential_snmpv2_read_community.go new file mode 100644 index 00000000..03000463 --- /dev/null +++ b/dnacenter/resource_global_credential_snmpv2_read_community.go @@ -0,0 +1,482 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialSNMPv2ReadCommunity() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and update operations on Discovery. + +- Updates global SNMP read community + +- Adds global SNMP read community + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialSNMPv2ReadCommunityCreate, + ReadContext: resourceGlobalCredentialSNMPv2ReadCommunityRead, + UpdateContext: resourceGlobalCredentialSNMPv2ReadCommunityUpdate, + DeleteContext: resourceGlobalCredentialSNMPv2ReadCommunityDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "netconf_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "read_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "write_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestDiscoveryCreateSNMPReadCommunity`, + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "comments": &schema.Schema{ + Description: `Comments to identify the credential +`, + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Description: `Credential type to identify the application that uses the credential +`, + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Description: `Name/Description of the credential +`, + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "read_community": &schema.Schema{ + Description: `SNMP read community +`, + Type: schema.TypeString, + Optional: true, + // ForceNew: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialSNMPv2ReadCommunityCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGlobalCredentialSNMPv2ReadCommunityCreateSNMPReadCommunity(ctx, "parameters", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + + vReadCommunity := resourceItem["read_community"] + vvReadCommunity := interfaceToString(vReadCommunity) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + // resourceID := d.Id() + // if resourceID != "" { + // log.Printf("[DEBUG] ResourceID => %s", resourceID) + // resourceMap := separateResourceID(resourceID) + // vvID = resourceMap["id"] + // } + + queryParams1.CredentialSubType = "SNMPV2_READ_COMMUNITY" + item, err := searchDiscoveryGetGlobalCredentialsSmpv2Read(m, queryParams1, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["read_community"] = vvReadCommunity + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialSNMPv2ReadCommunityRead(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateSNMPReadCommunity(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateSNMPReadCommunity", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateSNMPReadCommunity", err)) + return diags + } + + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateSNMPReadCommunity", err)) + return diags + } + vvID = response2.Response.Progress + } + resourceMap := make(map[string]string) + resourceMap["read_community"] = vvReadCommunity + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialSNMPv2ReadCommunityRead(ctx, d, m) +} + +func resourceGlobalCredentialSNMPv2ReadCommunityRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "SNMPV2_READ_COMMUNITY" + vID := resourceMap["id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsSmpv2Read(m, queryParams1, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialSNMPv2ReadCommunityUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "SNMPV2_READ_COMMUNITY" + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + queryParams1.CredentialSubType = vCredentialSubType + item, err := searchDiscoveryGetGlobalCredentialsSmpv2Read(m, queryParams1, vID) + if err != nil || item == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + log.Printf("[DEBUG] ReadCommunity=> %s", item.ReadCommunity) + + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestGlobalCredentialSNMPv2ReadCommunityUpdateSNMPReadCommunity(ctx, "parameters.0", d) + request1.InstanceUUID = item.InstanceUUID + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateSNMPReadCommunity(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateSNMPReadCommunity", err, restyResp1.String(), + "Failure at UpdateSNMPReadCommunity, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSNMPReadCommunity", err, + "Failure at UpdateSNMPReadCommunity, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateSNMPReadCommunity", err)) + return diags + } + } + } + + return resourceGlobalCredentialSNMPv2ReadCommunityRead(ctx, d, m) +} + +func resourceGlobalCredentialSNMPv2ReadCommunityDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete GlobalCredentialSNMPv2ReadCommunity on Dna Center + // Returning empty diags to delete it on Terraform + // DeleteGlobalCredentialsByID + client := m.(*dnacentersdkgo.Client) + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "SNMPV2_READ_COMMUNITY" + item, err := searchDiscoveryGetGlobalCredentialsSmpv2Write(m, queryParams1, vID) + if item == nil && err != nil { + return resourceGlobalCredentialSNMPv2ReadCommunityRead(ctx, d, m) + } + + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} +func expandRequestGlobalCredentialSNMPv2ReadCommunityCreateSNMPReadCommunity(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateSNMPReadCommunity { + request := dnacentersdkgo.RequestDiscoveryCreateSNMPReadCommunity{} + if v := expandRequestGlobalCredentialSNMPv2ReadCommunityCreateSNMPReadCommunityItemArray(ctx, key+".", d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv2ReadCommunityCreateSNMPReadCommunityItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateSNMPReadCommunity { + request := []dnacentersdkgo.RequestItemDiscoveryCreateSNMPReadCommunity{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestGlobalCredentialSNMPv2ReadCommunityCreateSNMPReadCommunityItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv2ReadCommunityCreateSNMPReadCommunityItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateSNMPReadCommunity { + request := dnacentersdkgo.RequestItemDiscoveryCreateSNMPReadCommunity{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".read_community")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".read_community")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".read_community")))) { + request.ReadCommunity = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv2ReadCommunityUpdateSNMPReadCommunity(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateSNMPReadCommunity { + request := dnacentersdkgo.RequestDiscoveryUpdateSNMPReadCommunity{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".read_community")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".read_community")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".read_community")))) { + request.ReadCommunity = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsSmpv2Read(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "SNMPV2_READ_COMMUNITY" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_credential_snmpv2_write_community.go b/dnacenter/resource_global_credential_snmpv2_write_community.go new file mode 100644 index 00000000..dccb554d --- /dev/null +++ b/dnacenter/resource_global_credential_snmpv2_write_community.go @@ -0,0 +1,478 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialSNMPv2WriteCommunity() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and update operations on Discovery. + +- Adds global SNMP write community + +- Updates global SNMP write community + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialSNMPv2WriteCommunityCreate, + ReadContext: resourceGlobalCredentialSNMPv2WriteCommunityRead, + UpdateContext: resourceGlobalCredentialSNMPv2WriteCommunityUpdate, + DeleteContext: resourceGlobalCredentialSNMPv2WriteCommunityDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "netconf_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "read_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "write_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestDiscoveryCreateSNMPWriteCommunity`, + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "comments": &schema.Schema{ + Description: `Comments to identify the credential +`, + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Description: `Credential type to identify the application that uses the credential +`, + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Description: `Name/Description of the credential +`, + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "write_community": &schema.Schema{ + Description: `SNMP write community +`, + Type: schema.TypeString, + Optional: true, + // ForceNew: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialSNMPv2WriteCommunityCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGlobalCredentialSNMPv2WriteCommunityCreateSNMPWriteCommunity(ctx, "parameters", d) + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + vWriteCommunity := resourceItem["write_community"] + vvWriteCommunity := interfaceToString(vWriteCommunity) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "SNMPV2_WRITE_COMMUNITY" + item, err := searchDiscoveryGetGlobalCredentialsSmpv2Write(m, queryParams1, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["write_community"] = vvWriteCommunity + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialSNMPv2WriteCommunityRead(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateSNMPWriteCommunity(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateSNMPWriteCommunity", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateSNMPWriteCommunity", err)) + return diags + } + + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateSNMPWriteCommunity", err)) + return diags + } + vvID = response2.Response.Progress + } + + resourceMap := make(map[string]string) + resourceMap["write_community"] = vvWriteCommunity + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialSNMPv2WriteCommunityRead(ctx, d, m) +} + +func resourceGlobalCredentialSNMPv2WriteCommunityRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "SNMPV2_WRITE_COMMUNITY" + vID := resourceMap["id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsSmpv2Write(m, queryParams1, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialSNMPv2WriteCommunityUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "SNMPV2_WRITE_COMMUNITY" + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + queryParams1.CredentialSubType = vCredentialSubType + item, err := searchDiscoveryGetGlobalCredentialsSmpv2Write(m, queryParams1, vID) + if err != nil || item == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestGlobalCredentialSNMPv2WriteCommunityUpdateSNMPWriteCommunity(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateSNMPWriteCommunity(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateSNMPWriteCommunity", err, restyResp1.String(), + "Failure at UpdateSNMPWriteCommunity, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSNMPWriteCommunity", err, + "Failure at UpdateSNMPWriteCommunity, unexpected response", "")) + return diags + } + + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateSNMPWriteCommunity", err)) + return diags + } + } + } + + return resourceGlobalCredentialSNMPv2WriteCommunityRead(ctx, d, m) +} + +func resourceGlobalCredentialSNMPv2WriteCommunityDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + // NOTE: Unable to delete GlobalCredentialSNMPv2WriteCommunity on Dna Center + // Returning empty diags to delete it on Terraform + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "SNMPV2_WRITE_COMMUNITY" + item, err := searchDiscoveryGetGlobalCredentialsSmpv2Write(m, queryParams1, vID) + if item == nil && err != nil { + return resourceGlobalCredentialSNMPv2WriteCommunityRead(ctx, d, m) + } + + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} +func expandRequestGlobalCredentialSNMPv2WriteCommunityCreateSNMPWriteCommunity(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateSNMPWriteCommunity { + request := dnacentersdkgo.RequestDiscoveryCreateSNMPWriteCommunity{} + if v := expandRequestGlobalCredentialSNMPv2WriteCommunityCreateSNMPWriteCommunityItemArray(ctx, key+".", d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv2WriteCommunityCreateSNMPWriteCommunityItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateSNMPWriteCommunity { + request := []dnacentersdkgo.RequestItemDiscoveryCreateSNMPWriteCommunity{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestGlobalCredentialSNMPv2WriteCommunityCreateSNMPWriteCommunityItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv2WriteCommunityCreateSNMPWriteCommunityItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateSNMPWriteCommunity { + request := dnacentersdkgo.RequestItemDiscoveryCreateSNMPWriteCommunity{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".write_community")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".write_community")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".write_community")))) { + request.WriteCommunity = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv2WriteCommunityUpdateSNMPWriteCommunity(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateSNMPWriteCommunity { + request := dnacentersdkgo.RequestDiscoveryUpdateSNMPWriteCommunity{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".write_community")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".write_community")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".write_community")))) { + request.WriteCommunity = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsSmpv2Write(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "SNMPV2_WRITE_COMMUNITY" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_credential_snmpv3.go b/dnacenter/resource_global_credential_snmpv3.go new file mode 100644 index 00000000..deff86fa --- /dev/null +++ b/dnacenter/resource_global_credential_snmpv3.go @@ -0,0 +1,539 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGlobalCredentialSNMPv3() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and update operations on Discovery. + +- Updates global SNMPv3 credential + +- Adds global SNMPv3 credentials + +- Deletes global credential for the given ID +`, + + CreateContext: resourceGlobalCredentialSNMPv3Create, + ReadContext: resourceGlobalCredentialSNMPv3Read, + UpdateContext: resourceGlobalCredentialSNMPv3Update, + DeleteContext: resourceGlobalCredentialSNMPv3Delete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "comments": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "netconf_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "password": &schema.Schema{ + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + + "port": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "read_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "secure": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + + "username": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "write_community": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestDiscoveryCreateSNMPv3Credentials`, + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "auth_password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "auth_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "comments": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "credential_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_tenant_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "privacy_password": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "privacy_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "snmp_mode": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "username": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceGlobalCredentialSNMPv3Create(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGlobalCredentialSNMPv3CreateSNMPv3Credentials(ctx, "parameters", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + vUsername := resourceItem["username"] + vvUsername := interfaceToString(vUsername) + vID := resourceItem["id"] + vvID := interfaceToString(vID) + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "SNMPV3" + item, err := searchDiscoveryGetGlobalCredentialsSmpv3(m, queryParams1, vvUsername, vvID) + if item != nil || err != nil { + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialSNMPv3Read(ctx, d, m) + } + resp1, restyResp1, err := client.Discovery.CreateSNMPv3Credentials(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateSNMPv3Credentials", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateSNMPv3Credentials", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateSNMPv3Credentials", err)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["username"] = vvUsername + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourceGlobalCredentialSNMPv3Read(ctx, d, m) +} + +func resourceGlobalCredentialSNMPv3Read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "SNMPV3" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGlobalCredentials") + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = vCredentialSubType + + response1, err := searchDiscoveryGetGlobalCredentialsSmpv3(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenDiscoveryGetGlobalCredentialsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGlobalCredentials search response", + err)) + return diags + } + + } + return diags +} + +func resourceGlobalCredentialSNMPv3Update(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vCredentialSubType := "SNMPV3" + vUsername := resourceMap["username"] + vID := resourceMap["id"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + queryParams1.CredentialSubType = vCredentialSubType + response1, err := searchDiscoveryGetGlobalCredentialsSmpv3(m, queryParams1, vUsername, vID) + if err != nil || response1 == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + + var vvName string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vvName) + request1 := expandRequestGlobalCredentialSNMPv3UpdateSNMPv3Credentials(ctx, "parameters.0", d) + request1.ID = response1.ID + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Discovery.UpdateSNMPv3Credentials(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateSNMPv3Credentials", err, restyResp1.String(), + "Failure at UpdateSNMPv3Credentials, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSNMPv3Credentials", err, + "Failure at UpdateSNMPv3Credentials, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateSNMPv3Credentials", err)) + return diags + } + } + } + + return resourceGlobalCredentialSNMPv3Read(ctx, d, m) +} + +func resourceGlobalCredentialSNMPv3Delete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete GlobalCredentialSNMPv2ReadCommunity on Dna Center + // Returning empty diags to delete it on Terraform + // DeleteGlobalCredentialsByID + client := m.(*dnacentersdkgo.Client) + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + vUsername := resourceMap["username"] + + queryParams1 := dnacentersdkgo.GetGlobalCredentialsQueryParams{} + + queryParams1.CredentialSubType = "SNMPV3" + item, err := searchDiscoveryGetGlobalCredentialsSmpv3(m, queryParams1, vUsername, vID) + if item == nil && err != nil { + return resourceGlobalCredentialSNMPv3Read(ctx, d, m) + } + if vID != item.ID { + vID = item.ID + } + + if vID != "" { + response1, restyResp1, err := client.Discovery.DeleteGlobalCredentialsByID(vID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteGlobalCredentialsByID", err, + "Failure at DeleteGlobalCredentialsByID, unexpected response", "")) + return diags + } + } + return diags +} +func expandRequestGlobalCredentialSNMPv3CreateSNMPv3Credentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryCreateSNMPv3Credentials { + request := dnacentersdkgo.RequestDiscoveryCreateSNMPv3Credentials{} + if v := expandRequestGlobalCredentialSNMPv3CreateSNMPv3CredentialsItemArray(ctx, key, d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv3CreateSNMPv3CredentialsItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemDiscoveryCreateSNMPv3Credentials { + request := []dnacentersdkgo.RequestItemDiscoveryCreateSNMPv3Credentials{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestGlobalCredentialSNMPv3CreateSNMPv3CredentialsItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv3CreateSNMPv3CredentialsItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemDiscoveryCreateSNMPv3Credentials { + request := dnacentersdkgo.RequestItemDiscoveryCreateSNMPv3Credentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".auth_password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".auth_password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".auth_password")))) { + request.AuthPassword = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".auth_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".auth_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".auth_type")))) { + request.AuthType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".privacy_password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".privacy_password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".privacy_password")))) { + request.PrivacyPassword = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".privacy_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".privacy_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".privacy_type")))) { + request.PrivacyType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".snmp_mode")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".snmp_mode")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".snmp_mode")))) { + request.SNMPMode = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestGlobalCredentialSNMPv3UpdateSNMPv3Credentials(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDiscoveryUpdateSNMPv3Credentials { + request := dnacentersdkgo.RequestDiscoveryUpdateSNMPv3Credentials{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".auth_password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".auth_password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".auth_password")))) { + request.AuthPassword = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".auth_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".auth_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".auth_type")))) { + request.AuthType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".comments")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".comments")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".comments")))) { + request.Comments = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".credential_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".credential_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".credential_type")))) { + request.CredentialType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".description")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".description")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".description")))) { + request.Description = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_tenant_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_tenant_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_tenant_id")))) { + request.InstanceTenantID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".instance_uuid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".instance_uuid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".instance_uuid")))) { + request.InstanceUUID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".privacy_password")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".privacy_password")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".privacy_password")))) { + request.PrivacyPassword = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".privacy_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".privacy_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".privacy_type")))) { + request.PrivacyType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".snmp_mode")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".snmp_mode")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".snmp_mode")))) { + request.SNMPMode = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".username")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".username")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".username")))) { + request.Username = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchDiscoveryGetGlobalCredentialsSmpv3(m interface{}, queryParams dnacentersdkgo.GetGlobalCredentialsQueryParams, vUsername string, vID string) (*dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + var ite *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentials + queryParams.CredentialSubType = "SNMPV3" + ite, _, err = client.Discovery.GetGlobalCredentials(&queryParams) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range *itemsCopy.Response { + // Call get by _ method and set value to foundItem and return + if item.ID == vID || item.Username == vUsername { + var getItem *dnacentersdkgo.ResponseDiscoveryGetGlobalCredentialsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_global_pool.go b/dnacenter/resource_global_pool.go index 4fef4c35..39dbaf99 100644 --- a/dnacenter/resource_global_pool.go +++ b/dnacenter/resource_global_pool.go @@ -511,9 +511,6 @@ func resourceGlobalPoolDelete(ctx context.Context, d *schema.ResourceData, m int queryParams1 := dnacentersdkgo.GetGlobalPoolQueryParams{} item, err := searchNetworkSettingsGetGlobalPool(m, queryParams1, vID, vIpPoolName) if err != nil { - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetGlobalPool", err, - "Failure at GetGlobalPool, unexpected response", "")) return diags } if item == nil || len(*item) == 0 { @@ -568,7 +565,7 @@ func resourceGlobalPoolDelete(ctx context.Context, d *schema.ResourceData, m int bapiError := response2.BapiError diags = append(diags, diagErrorWithAlt( "Failure when executing UpdateGlobalPool", err, - "Failure at UpdateGlobalPool execution", bapiError)) + "Failure at DeleteGlobalIPPool execution", bapiError)) return diags } } diff --git a/dnacenter/resource_golden_image.go b/dnacenter/resource_golden_image.go new file mode 100644 index 00000000..40998dae --- /dev/null +++ b/dnacenter/resource_golden_image.go @@ -0,0 +1,295 @@ +package dnacenter + +import ( + "context" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceGoldenImage() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and delete operations on Software Image Management (SWIM). + +- Golden Tag image. Set siteId as -1 for Global site. + +- Remove golden tag. Set siteId as -1 for Global site. +`, + + CreateContext: resourceGoldenImageCreate, + ReadContext: resourceGoldenImageRead, + UpdateContext: resourceGoldenImageUpdate, + DeleteContext: resourceGoldenImageDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "device_role": &schema.Schema{ + Description: `Device Role. Possible Values : ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION and CORE. +`, + Type: schema.TypeString, + Computed: true, + }, + "inherited_site_id": &schema.Schema{ + Description: `Inherited Site Id. If the Golden Tag is not tagged for the current site but is inherited from a higher enclosing site, it will contain the uuid of the site from where the tag is inherited. In case the golden tag is inherited from the Global site the value will be "-1". +`, + Type: schema.TypeString, + Computed: true, + }, + "inherited_site_name": &schema.Schema{ + Description: `Inherited Site Name. If the Golden Tag is not tagged for the current site but is inherited from a higher enclosing site, it will contain the name of the site from where the tag is inherited. +`, + Type: schema.TypeString, + Computed: true, + }, + "tagged_golden": &schema.Schema{ + Description: `Tagged Golden. +`, + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "device_family_identifier": &schema.Schema{ + Description: `Device Family Identifier e.g. : 277696480-283933147, 277696480 +`, + Type: schema.TypeString, + Optional: true, + }, + "device_role": &schema.Schema{ + Description: `Device Role. Permissible Values : ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION and CORE. +`, + Type: schema.TypeString, + Optional: true, + }, + "image_id": &schema.Schema{ + Description: `imageId in uuid format. +`, + Type: schema.TypeString, + Optional: true, + }, + "site_id": &schema.Schema{ + Description: `SiteId in uuid format. For Global Site "-1" to be used. +`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceGoldenImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestGoldenImageTagAsGoldenImage(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + + vSiteID, okSiteID := resourceItem["site_id"] + vvSiteID := interfaceToString(vSiteID) + vDeviceFamilyIDentifier, okDeviceFamilyIDentifier := resourceItem["device_family_identifier"] + vvDeviceFamilyIDentifier := interfaceToString(vDeviceFamilyIDentifier) + vDeviceRole, okDeviceRole := resourceItem["device_role"] + vvDeviceRole := interfaceToString(vDeviceRole) + vImageID, okImageID := resourceItem["image_id"] + vvImageID := interfaceToString(vImageID) + if okSiteID && vvSiteID != "" && okDeviceFamilyIDentifier && vvDeviceFamilyIDentifier != "" && okDeviceRole && vvDeviceRole != "" && okImageID && vvImageID != "" { + getResponse1, _, err := client.SoftwareImageManagementSwim.GetGoldenTagStatusOfAnImage(vvSiteID, vvDeviceFamilyIDentifier, vvDeviceRole, vvImageID) + if err == nil && getResponse1 != nil && getResponse1.Response != nil && getResponse1.Response.TaggedGolden != nil { + if *getResponse1.Response.TaggedGolden { + resourceMap := make(map[string]string) + resourceMap["site_id"] = vvSiteID + resourceMap["device_family_identifier"] = vvDeviceFamilyIDentifier + resourceMap["device_role"] = vvDeviceRole + resourceMap["image_id"] = vvImageID + d.SetId(joinResourceID(resourceMap)) + return resourceGoldenImageRead(ctx, d, m) + } + } + } + resp1, restyResp1, err := client.SoftwareImageManagementSwim.TagAsGoldenImage(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing TagAsGoldenImage", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing TagAsGoldenImage", err)) + return diags + } + resourceMap := make(map[string]string) + resourceMap["site_id"] = vvSiteID + resourceMap["device_family_identifier"] = vvDeviceFamilyIDentifier + resourceMap["device_role"] = vvDeviceRole + resourceMap["image_id"] = vvImageID + d.SetId(joinResourceID(resourceMap)) + return resourceGoldenImageRead(ctx, d, m) +} + +func resourceGoldenImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vSiteID := resourceMap["site_id"] + vDeviceFamilyIDentifier := resourceMap["device_family_identifier"] + vDeviceRole := resourceMap["device_role"] + vImageID := resourceMap["image_id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetGoldenTagStatusOfAnImage") + vvSiteID := vSiteID + vvDeviceFamilyIDentifier := vDeviceFamilyIDentifier + vvDeviceRole := vDeviceRole + vvImageID := vImageID + + response1, restyResp1, err := client.SoftwareImageManagementSwim.GetGoldenTagStatusOfAnImage(vvSiteID, vvDeviceFamilyIDentifier, vvDeviceRole, vvImageID) + + if !d.IsNewResource() && err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + vItem1 := flattenSoftwareImageManagementSwimGetGoldenTagStatusOfAnImageItem(response1.Response) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetGoldenTagStatusOfAnImage response", + err)) + return diags + } + return diags + + } + return diags +} + +func resourceGoldenImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourceGoldenImageRead(ctx, d, m) +} + +func resourceGoldenImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vSiteID := resourceMap["site_id"] + vDeviceFamilyIDentifier := resourceMap["device_family_identifier"] + vDeviceRole := resourceMap["device_role"] + vImageID := resourceMap["image_id"] + + selectedMethod := 1 + //var vvID string + //var vvName string + if selectedMethod == 1 { + //vvID = vID + getResp, _, err := client.SoftwareImageManagementSwim.GetGoldenTagStatusOfAnImage(vSiteID, vDeviceFamilyIDentifier, vDeviceRole, vImageID) + if err != nil || getResp == nil { + // Assume that element it is already gone + return diags + } + } + response1, restyResp1, err := client.SoftwareImageManagementSwim.RemoveGoldenTagForImage(vSiteID, vDeviceFamilyIDentifier, vDeviceRole, vImageID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for delete operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing RemoveGoldenTagForImage", err, restyResp1.String(), + "Failure at RemoveGoldenTagForImage, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing RemoveGoldenTagForImage", err, + "Failure at RemoveGoldenTagForImage, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing CreateConfigurationTemplateProject", err)) + return diags + } + } + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + + return diags +} +func expandRequestGoldenImageTagAsGoldenImage(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSoftwareImageManagementSwimTagAsGoldenImage { + request := dnacentersdkgo.RequestSoftwareImageManagementSwimTagAsGoldenImage{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".image_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".image_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".image_id")))) { + request.ImageID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".site_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".site_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".site_id")))) { + request.SiteID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_role")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_role")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_role")))) { + request.DeviceRole = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_family_identifier")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_family_identifier")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_family_identifier")))) { + request.DeviceFamilyIDentifier = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} diff --git a/dnacenter/resource_license_device.go b/dnacenter/resource_license_device.go new file mode 100644 index 00000000..8cbceaba --- /dev/null +++ b/dnacenter/resource_license_device.go @@ -0,0 +1,377 @@ +package dnacenter + +import ( + "context" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceLicenseDevice() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and delete operations on Licenses. + +`, + + CreateContext: resourceLicenseDeviceCreate, + ReadContext: resourceLicenseDeviceRead, + UpdateContext: resourceLicenseDeviceUpdate, + DeleteContext: resourceLicenseDeviceDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "domain": &schema.Schema{ + Description: `Domain of smart account +`, + Type: schema.TypeString, + Computed: true, + }, + + "id": &schema.Schema{ + Description: `Id of smart account +`, + Type: schema.TypeString, + Computed: true, + }, + + "is_active_smart_account": &schema.Schema{ + Description: `Is active smart account +`, + + Type: schema.TypeString, + Computed: true, + }, + + "name": &schema.Schema{ + Description: `Name of smart account +`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "smart_account_id": &schema.Schema{ + Description: `smart_account_id path parameter. Id of smart account + `, + Type: schema.TypeString, + Required: true, + }, + "virtual_account_name": &schema.Schema{ + Description: `virtual_account_name path parameter. Name of target virtual account + `, + Type: schema.TypeString, + Required: true, + }, + "device_uuids": &schema.Schema{ + Description: `Comma separated device ids + `, + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + } +} + +func resourceLicenseDeviceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*dnacentersdkgo.Client) + resourceItem := *getResourceItem(d.Get("parameters")) + vSmartAccountID := resourceItem["smart_account_id"] + vvSmartAccountID := interfaceToString(vSmartAccountID) + vVirtualAccountName := resourceItem["virtual_account_name"] + vvVirtualAccountName := interfaceToString(vVirtualAccountName) + request1 := expandRequestLicenseVirtualAccountChangeChangeVirtualAccount(ctx, "parameters.0", d) + response1, err := searchLicensesSmartAccountDetails(m, vvVirtualAccountName, vvSmartAccountID) + + if err != nil || response1 != nil { + resourceMap := make(map[string]string) + resourceMap["smart_account_id"] = interfaceToString(resourceItem["smart_account_id"]) + resourceMap["virtual_account_name"] = interfaceToString(resourceItem["virtual_account_name"]) + d.SetId(joinResourceID(resourceMap)) + return resourceLicenseDeviceRead(ctx, d, m) + } + + response2, restyResp1, err := client.Licenses.ChangeVirtualAccount(vvSmartAccountID, vvVirtualAccountName, request1) + + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + if err != nil || response2 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing ChangeVirtualAccount", err, + "Failure at ChangeVirtualAccount, unexpected response", "")) + return diags + } + + taskId := response2.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response3, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response3 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response3.Response != nil && response3.Response.IsError != nil && *response3.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response3.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing ChangeVirtualAccount", err)) + return diags + } + } + + resourceMap := make(map[string]string) + resourceMap["smart_account_id"] = interfaceToString(resourceItem["smart_account_id"]) + resourceMap["virtual_account_name"] = interfaceToString(resourceItem["virtual_account_name"]) + d.SetId(joinResourceID(resourceMap)) + return resourceLicenseDeviceRead(ctx, d, m) +} + +func resourceLicenseDeviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + + vSmartAccountID := resourceMap["smart_account_id"] + vVirtualAccountName := resourceMap["virtual_account_name"] + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: SmartAccountDetails") + + response1, err := searchLicensesSmartAccountDetails(m, vVirtualAccountName, vSmartAccountID) + + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenLicensesSmartAccountDetailsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting SmartAccountDetails search response", + err)) + return diags + } + + } + return diags +} + +func resourceLicenseDeviceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vSmartAccountID := resourceMap["smart_account_id"] + vVirtualAccountName := resourceMap["virtual_account_name"] + + item, err := searchLicensesSmartAccountDetails(m, vVirtualAccountName, vSmartAccountID) + + if err != nil || item == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetGlobalCredentials", err, + "Failure at GetGlobalCredentials, unexpected response", "")) + return diags + } + + if d.HasChange("parameters") { + request1 := expandRequestLicenseDeviceRegistrationDeviceRegistration(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.Licenses.DeviceRegistration(vVirtualAccountName, request1) + + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeviceRegistration", err, + "Failure at DeviceRegistration, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing DeviceRegistration", err)) + return diags + } + } + } + + return resourceLicenseDeviceRead(ctx, d, m) +} + +func resourceLicenseDeviceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + client := m.(*dnacentersdkgo.Client) + // NOTE: Unable to delete LicenseDevice on Dna Center + // Returning empty diags to delete it on Terraform + log.Printf("[DEBUG] Selected method 1: DeviceDeregistration") + request1 := expandRequestLicenseDeviceDeregistrationDeviceDeregistration(ctx, "parameters.0", d) + + response1, restyResp1, err := client.Licenses.DeviceDeregistration(request1) + + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeviceDeregistration", err, + "Failure at DeviceDeregistration, unexpected response", "")) + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing DeviceDeregistration", err)) + return diags + } + } + d.SetId("") + return diags +} + +func expandRequestLicenseVirtualAccountChangeChangeVirtualAccount(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestLicensesChangeVirtualAccount { + request := dnacentersdkgo.RequestLicensesChangeVirtualAccount{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_uuids")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_uuids")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_uuids")))) { + request.DeviceUUIDs = interfaceToSliceString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestLicenseDeviceRegistrationDeviceRegistration(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestLicensesDeviceRegistration { + request := dnacentersdkgo.RequestLicensesDeviceRegistration{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_uuids")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_uuids")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_uuids")))) { + request.DeviceUUIDs = interfaceToSliceString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} +func expandRequestLicenseDeviceDeregistrationDeviceDeregistration(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestLicensesDeviceDeregistration { + request := dnacentersdkgo.RequestLicensesDeviceDeregistration{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_uuids")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_uuids")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_uuids")))) { + request.DeviceUUIDs = interfaceToSliceString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchLicensesSmartAccountDetails(m interface{}, vName string, vID string) (*dnacentersdkgo.ResponseLicensesSmartAccountDetailsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseLicensesSmartAccountDetailsResponse + var ite *dnacentersdkgo.ResponseLicensesSmartAccountDetails + ite, _, err = client.Licenses.SmartAccountDetails() + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items.Response + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.Name == vName && item.ID == vID { + var getItem *dnacentersdkgo.ResponseLicensesSmartAccountDetailsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return nil, err +} diff --git a/dnacenter/resource_network_device.go b/dnacenter/resource_network_device.go index 3f6562e5..9b1c54b3 100644 --- a/dnacenter/resource_network_device.go +++ b/dnacenter/resource_network_device.go @@ -218,14 +218,11 @@ func resourceNetworkDevice() *schema.Resource { } func resourceNetworkDeviceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var diags diag.Diagnostics resourceItem := *getResourceItem(d.Get("parameters")) resourceMap := make(map[string]string) - // TODO: Add the path params to `item` schema - // & return it individually resourceMap["id"] = interfaceToString(resourceItem["id"]) d.SetId(joinResourceID(resourceMap)) - return diags + return resourceNetworkDeviceRead(ctx, d, m) } func resourceNetworkDeviceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/dnacenter/resource_network_device_list.go b/dnacenter/resource_network_device_list.go index 6c7852a5..187d5879 100644 --- a/dnacenter/resource_network_device_list.go +++ b/dnacenter/resource_network_device_list.go @@ -457,6 +457,14 @@ func resourceNetworkDeviceList() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "role": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "role_source": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, }, }, }, @@ -613,12 +621,63 @@ func resourceNetworkDeviceListUpdate(ctx context.Context, d *schema.ResourceData queryParams1.ManagementIPAddress = vIPAddress item, err := searchDevicesGetDeviceList(m, queryParams1) if err != nil || item == nil { - d.SetId("") + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetDeviceList", err, + "Failure at GetDeviceList, unexpected response", "")) return diags } // NOTE: Consider adding getAllItems and search function to get missing params if d.HasChange("parameters") { + if d.HasChange("parameters.0.role") || d.HasChange("parameters.0.role_source") { + request2 := expandRequestNetworkDeviceUpdateRoleUpdateDeviceRole(ctx, "parameters.0", d) + if request2 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request2)) + } + if request2 != nil && item != nil && request2.ID == "" { + request2.ID = item.ID + } + response2, restyResp2, err := client.Devices.UpdateDeviceRole(request2) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp2.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateDeviceRole", err, restyResp2.String(), + "Failure at UpdateDeviceRole, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateDeviceRole", err, + "Failure at UpdateDeviceRole, unexpected response", "")) + return diags + } + if response2.Response == nil { + diags = append(diags, diagError( + "Failure when executing UpdateDeviceRole", err)) + return diags + } + taskId := response2.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdateDeviceRole", err)) + return diags + } + } + } log.Printf("[DEBUG] Name used for update operation %s", vSerialNumber) request1 := expandRequestNetworkDeviceListSyncDevices2(ctx, "parameters.0", d) if request1 != nil { @@ -807,6 +866,24 @@ func expandRequestNetworkDeviceListAddDevice2UpdateMgmtIPaddressList(ctx context return &request } +func expandRequestNetworkDeviceUpdateRoleUpdateDeviceRole(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDevicesUpdateDeviceRole { + request := dnacentersdkgo.RequestDevicesUpdateDeviceRole{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".id")))) { + request.ID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".role")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".role")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".role")))) { + request.Role = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".role_source")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".role_source")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".role_source")))) { + request.RoleSource = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + func expandRequestNetworkDeviceListSyncDevices2(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDevicesSyncDevices2 { request := dnacentersdkgo.RequestDevicesSyncDevices2{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".cli_transport")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".cli_transport")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".cli_transport")))) { diff --git a/dnacenter/resource_nfv_profile.go b/dnacenter/resource_nfv_profile.go index 31bcf872..832ea1fc 100644 --- a/dnacenter/resource_nfv_profile.go +++ b/dnacenter/resource_nfv_profile.go @@ -725,9 +725,6 @@ func resourceNfvProfileDelete(ctx context.Context, d *schema.ResourceData, m int queryParams1.Name = vName item, err := searchSiteDesignGetNfvProfile(m, queryParams1, &vID) if err != nil || item == nil { - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetNFVProfile", err, - "Failure at GetNFVProfile, unexpected response", "")) return diags } if vID == "" { diff --git a/dnacenter/resource_nfv_provision_detail.go b/dnacenter/resource_nfv_provision_detail.go new file mode 100644 index 00000000..429827a5 --- /dev/null +++ b/dnacenter/resource_nfv_provision_detail.go @@ -0,0 +1,140 @@ +package dnacenter + +import ( + "context" + "reflect" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceNfvProvisionDetail() *schema.Resource { + return &schema.Resource{ + Description: `It manages create and read operations on Site Design. + +- Checks the provisioning detail of an ENCS device including log information. +`, + + CreateContext: resourceNfvProvisionDetailCreate, + ReadContext: resourceNfvProvisionDetailRead, + UpdateContext: resourceNfvProvisionDetailUpdate, + DeleteContext: resourceNfvProvisionDetailDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "device_ip": &schema.Schema{ + Description: `Device Ip`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceNfvProvisionDetailCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + //var diags diag.Diagnostics + + //resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestNfvProvisionDetailNfvProvisioningDetail(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + + /*resp1, restyResp1, err := client.SiteDesign.NfvProvisioningDetail(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing NfvProvisioningDetail", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing NfvProvisioningDetail", err)) + return diags + }*/ + resourceMap := make(map[string]string) + d.SetId(joinResourceID(resourceMap)) + return resourceNfvProvisionDetailRead(ctx, d, m) +} + +func resourceNfvProvisionDetailRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vDeviceIP := resourceMap["device_ip"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetDeviceDetailsByIP") + queryParams1 := dnacentersdkgo.GetDeviceDetailsByIPQueryParams{} + + queryParams1.DeviceIP = vDeviceIP + + response1, restyResp1, err := client.SiteDesign.GetDeviceDetailsByIP(&queryParams1) + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + vItem1 := flattenSiteDesignGetDeviceDetailsByIPItem(response1.ProvisionDetails) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetDeviceDetailsByIP response", + err)) + return diags + } + return diags + + } + return diags +} + +func resourceNfvProvisionDetailUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourceNfvProvisionDetailRead(ctx, d, m) +} + +func resourceNfvProvisionDetailDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete NfvProvisionDetail on Dna Center + // Returning empty diags to delete it on Terraform + return diags +} +func expandRequestNfvProvisionDetailNfvProvisioningDetail(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSiteDesignNfvProvisioningDetail { + request := dnacentersdkgo.RequestSiteDesignNfvProvisioningDetail{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_ip")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_ip")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_ip")))) { + request.DeviceIP = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} diff --git a/dnacenter/resource_path_trace.go b/dnacenter/resource_path_trace.go new file mode 100644 index 00000000..1f207ec1 --- /dev/null +++ b/dnacenter/resource_path_trace.go @@ -0,0 +1,3458 @@ +package dnacenter + +import ( + "context" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourcePathTrace() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and delete operations on Path Trace. + +- Initiates a new flow analysis with periodic refresh and stat collection options. Returns a request id and a task id to +get results and follow progress. + +- Deletes a flow analysis request by its id +`, + + CreateContext: resourcePathTraceCreate, + ReadContext: resourcePathTraceRead, + UpdateContext: resourcePathTraceUpdate, + DeleteContext: resourcePathTraceDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "detailed_status": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_trace_calculation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "acl_trace_calculation_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "last_update": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "network_elements": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "accuracy_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "percent": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "detailed_status": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_trace_calculation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "acl_trace_calculation_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "device_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "cpu_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "five_min_usage_in_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "five_secs_usage_in_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "one_min_usage_in_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "memory_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "memory_usage": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "total_memory": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "device_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "device_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "egress_physical_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "egress_virtual_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "flex_connect": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "authentication": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_switching": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "egress_acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "ingress_acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "wireless_lan_controller_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "wireless_lan_controller_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ingress_physical_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "ingress_virtual_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "link_information_source": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "perf_mon_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "perf_mon_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "perf_mon_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "byte_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "dest_ip_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_interface": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ipv4_dsc_p": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ipv4_ttl": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_interface": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "packet_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "packet_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "packet_loss": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "packet_loss_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "rtp_jitter_max": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "rtp_jitter_mean": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "rtp_jitter_min": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "source_ip_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "role": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ssid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "tunnels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "wlan_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "network_elements_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "accuracy_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "percent": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "detailed_status": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_trace_calculation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "acl_trace_calculation_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "device_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "cpu_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "five_min_usage_in_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "five_secs_usage_in_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "one_min_usage_in_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "memory_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "memory_usage": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "total_memory": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "device_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "device_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "egress_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "physical_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "virtual_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "flex_connect": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "authentication": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_switching": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "egress_acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "ingress_acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "wireless_lan_controller_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "wireless_lan_controller_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ingress_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "physical_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "virtual_interface": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_analysis": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "acl_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_aces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ace": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "matching_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dest_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "source_ports": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "result": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "admin_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_flushes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_queue_max_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "input_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "operational_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "output_drop": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_ratebps": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "interface_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "interface_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "path_overlay_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_plane": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "data_packet_encapsulation": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vxlan_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "dscp": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vnid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "qos_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "class_map_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "drop_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "num_packets": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "offered_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_bandwidthbps": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "queue_depth": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_no_buffer_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "queue_total_drops": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "qos_stats_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "qos_stats_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "used_vlan": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "vrf_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "link_information_source": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "perf_mon_collection": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "perf_mon_collection_failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "perf_monitor_statistics": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "byte_rate": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "dest_ip_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "input_interface": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ipv4_dsc_p": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ipv4_ttl": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "output_interface": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "packet_bytes": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "packet_count": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "packet_loss": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "packet_loss_percentage": &schema.Schema{ + Type: schema.TypeFloat, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "refreshed_at": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "rtp_jitter_max": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "rtp_jitter_mean": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "rtp_jitter_min": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "source_ip_address": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "role": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "ssid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "tunnels": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "wlan_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "properties": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "request": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_path": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + "create_time": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "failure_reason": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "inclusions": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "last_update_time": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + "periodic_refresh": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + Computed: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "control_path": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + "dest_ip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "dest_port": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "flow_analysis_id": &schema.Schema{ + Description: `flowAnalysisId path parameter. Flow analysis request id +`, + Type: schema.TypeString, + Optional: true, + }, + "inclusions": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "periodic_refresh": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + "protocol": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "source_ip": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "source_port": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourcePathTraceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestPathTraceInitiateANewPathtrace(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + + vFlowAnalysisID := resourceItem["flow_analysis_id"] + vvFlowAnalysisID := interfaceToString(vFlowAnalysisID) + + if vvFlowAnalysisID != "" { + getResponse2, _, err := client.PathTrace.RetrievesPreviousPathtrace(vvFlowAnalysisID) + if err == nil && getResponse2 != nil { + resourceMap := make(map[string]string) + resourceMap["flow_analysis_id"] = vvFlowAnalysisID + d.SetId(joinResourceID(resourceMap)) + return resourcePathTraceRead(ctx, d, m) + } + } + + resp1, restyResp1, err := client.PathTrace.InitiateANewPathtrace(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing InitiateANewPathtrace", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing InitiateANewPathtrace", err)) + return diags + } + if resp1.Response == nil { + diags = append(diags, diagError( + "Failure when executing InitiateANewPathtrace", err)) + return diags + } + taskId := resp1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing InitiateANewPathtrace", err)) + return diags + } + } + + vvFlowAnalysisID = resp1.Response.FlowAnalysisID + + resourceMap := make(map[string]string) + resourceMap["flow_analysis_id"] = vvFlowAnalysisID + d.SetId(joinResourceID(resourceMap)) + return resourcePathTraceRead(ctx, d, m) +} + +func resourcePathTraceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vFlowAnalysisID := resourceMap["flow_analysis_id"] + + selectedMethod := 2 + if selectedMethod == 2 { + log.Printf("[DEBUG] Selected method 2: RetrievesPreviousPathtrace") + vvFlowAnalysisID := vFlowAnalysisID + + response2, restyResp2, err := client.PathTrace.RetrievesPreviousPathtrace(vvFlowAnalysisID) + + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response2)) + + vItem2 := flattenPathTraceRetrievesPreviousPathtraceItem(response2.Response) + if err := d.Set("item", vItem2); err != nil { + diags = append(diags, diagError( + "Failure when setting RetrievesPreviousPathtrace response", + err)) + return diags + } + return diags + + } + return diags +} + +func resourcePathTraceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourcePathTraceRead(ctx, d, m) +} + +func resourcePathTraceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vFlowAnalysisID := resourceMap["flow_analysis_id"] + + if vFlowAnalysisID != "" { + getResponse2, _, err := client.PathTrace.RetrievesPreviousPathtrace(vFlowAnalysisID) + if err == nil && getResponse2 == nil { + d.SetId("") + return diags + } + } else { + return diags + } + + //var vvID string + //var vvName string + // REVIEW: Add getAllItems and search function to get missing params + + response1, restyResp1, err := client.PathTrace.DeletesPathtraceByID(vFlowAnalysisID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for delete operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing DeletesPathtraceByID", err, restyResp1.String(), + "Failure at DeletesPathtraceByID, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeletesPathtraceByID", err, + "Failure at DeletesPathtraceByID, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing DeletesPathtraceByID", err)) + return diags + } + } + + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + + return diags +} +func expandRequestPathTraceInitiateANewPathtrace(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestPathTraceInitiateANewPathtrace { + request := dnacentersdkgo.RequestPathTraceInitiateANewPathtrace{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".control_path")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".control_path")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".control_path")))) { + request.ControlPath = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".dest_ip")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".dest_ip")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".dest_ip")))) { + request.DestIP = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".dest_port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".dest_port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".dest_port")))) { + request.DestPort = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".inclusions")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".inclusions")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".inclusions")))) { + request.Inclusions = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".periodic_refresh")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".periodic_refresh")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".periodic_refresh")))) { + request.PeriodicRefresh = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".protocol")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".protocol")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".protocol")))) { + request.Protocol = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".source_ip")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".source_ip")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".source_ip")))) { + request.SourceIP = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".source_port")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".source_port")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".source_port")))) { + request.SourcePort = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} diff --git a/dnacenter/resource_pnp_device_claim.go b/dnacenter/resource_pnp_device_claim.go new file mode 100644 index 00000000..e77f0e9d --- /dev/null +++ b/dnacenter/resource_pnp_device_claim.go @@ -0,0 +1,1908 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourcePnpDeviceClaim() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read, update and delete operations on Device Onboarding (PnP). + +- Claim a device to the PnP database. + +- Unclaim specified device from PnP database +`, + + CreateContext: resourcePnpDeviceClaimCreate, + ReadContext: resourcePnpDeviceClaimRead, + UpdateContext: resourcePnpDeviceClaimUpdate, + DeleteContext: resourcePnpDeviceClaimDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "id": &schema.Schema{ + Description: `Id`, + Type: schema.TypeString, + Computed: true, + }, + "day_zero_config": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "config": &schema.Schema{ + Description: `Config`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "day_zero_config_preview": &schema.Schema{ + Description: `Day Zero Config Preview`, + Type: schema.TypeString, + Computed: true, + }, + "device_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "aaa_credentials": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "password": &schema.Schema{ + Description: `Password`, + Type: schema.TypeString, + Sensitive: true, + Computed: true, + }, + "username": &schema.Schema{ + Description: `Username`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "added_on": &schema.Schema{ + Description: `Added On`, + Type: schema.TypeFloat, + Computed: true, + }, + "addn_mac_addrs": &schema.Schema{ + Description: `Addn Mac Addrs`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "agent_type": &schema.Schema{ + Description: `Agent Type`, + Type: schema.TypeString, + Computed: true, + }, + "auth_status": &schema.Schema{ + Description: `Auth Status`, + Type: schema.TypeString, + Computed: true, + }, + "authenticated_mic_number": &schema.Schema{ + Description: `Authenticated Mic Number`, + Type: schema.TypeString, + Computed: true, + }, + "authenticated_sudi_serial_no": &schema.Schema{ + Description: `Authenticated Sudi Serial No`, + Type: schema.TypeString, + Computed: true, + }, + "capabilities_supported": &schema.Schema{ + Description: `Capabilities Supported`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cm_state": &schema.Schema{ + Description: `Cm State`, + Type: schema.TypeString, + Computed: true, + }, + "description": &schema.Schema{ + Description: `Description`, + Type: schema.TypeString, + Computed: true, + }, + "device_sudi_serial_nos": &schema.Schema{ + Description: `Device Sudi Serial Nos`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "device_type": &schema.Schema{ + Description: `Device Type`, + Type: schema.TypeString, + Computed: true, + }, + "features_supported": &schema.Schema{ + Description: `Features Supported`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "file_system_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "freespace": &schema.Schema{ + Description: `Freespace`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "readable": &schema.Schema{ + Description: `Readable`, + + Type: schema.TypeString, + Computed: true, + }, + "size": &schema.Schema{ + Description: `Size`, + Type: schema.TypeFloat, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "writeable": &schema.Schema{ + Description: `Writeable`, + + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "first_contact": &schema.Schema{ + Description: `First Contact`, + Type: schema.TypeFloat, + Computed: true, + }, + "hostname": &schema.Schema{ + Description: `Hostname`, + Type: schema.TypeString, + Computed: true, + }, + "http_headers": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "key": &schema.Schema{ + Description: `Key`, + Type: schema.TypeString, + Computed: true, + }, + "value": &schema.Schema{ + Description: `Value`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "image_file": &schema.Schema{ + Description: `Image File`, + Type: schema.TypeString, + Computed: true, + }, + "image_version": &schema.Schema{ + Description: `Image Version`, + Type: schema.TypeString, + Computed: true, + }, + "ip_interfaces": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ipv4_address": &schema.Schema{ + Description: `Ipv4 Address`, + Type: schema.TypeString, + Computed: true, + }, + "ipv6_address_list": &schema.Schema{ + Description: `Ipv6 Address List`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "mac_address": &schema.Schema{ + Description: `Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "status": &schema.Schema{ + Description: `Status`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "last_contact": &schema.Schema{ + Description: `Last Contact`, + Type: schema.TypeFloat, + Computed: true, + }, + "last_sync_time": &schema.Schema{ + Description: `Last Sync Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "last_update_on": &schema.Schema{ + Description: `Last Update On`, + Type: schema.TypeFloat, + Computed: true, + }, + "location": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "address": &schema.Schema{ + Description: `Address`, + Type: schema.TypeString, + Computed: true, + }, + "altitude": &schema.Schema{ + Description: `Altitude`, + Type: schema.TypeString, + Computed: true, + }, + "latitude": &schema.Schema{ + Description: `Latitude`, + Type: schema.TypeString, + Computed: true, + }, + "longitude": &schema.Schema{ + Description: `Longitude`, + Type: schema.TypeString, + Computed: true, + }, + "site_id": &schema.Schema{ + Description: `Site Id`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "mac_address": &schema.Schema{ + Description: `Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + "mode": &schema.Schema{ + Description: `Mode`, + Type: schema.TypeString, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "neighbor_links": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "local_interface_name": &schema.Schema{ + Description: `Local Interface Name`, + Type: schema.TypeString, + Computed: true, + }, + "local_mac_address": &schema.Schema{ + Description: `Local Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + "local_short_interface_name": &schema.Schema{ + Description: `Local Short Interface Name`, + Type: schema.TypeString, + Computed: true, + }, + "remote_device_name": &schema.Schema{ + Description: `Remote Device Name`, + Type: schema.TypeString, + Computed: true, + }, + "remote_interface_name": &schema.Schema{ + Description: `Remote Interface Name`, + Type: schema.TypeString, + Computed: true, + }, + "remote_mac_address": &schema.Schema{ + Description: `Remote Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + "remote_platform": &schema.Schema{ + Description: `Remote Platform`, + Type: schema.TypeString, + Computed: true, + }, + "remote_short_interface_name": &schema.Schema{ + Description: `Remote Short Interface Name`, + Type: schema.TypeString, + Computed: true, + }, + "remote_version": &schema.Schema{ + Description: `Remote Version`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "onb_state": &schema.Schema{ + Description: `Onb State`, + Type: schema.TypeString, + Computed: true, + }, + "pid": &schema.Schema{ + Description: `Pid`, + Type: schema.TypeString, + Computed: true, + }, + "pnp_profile_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "created_by": &schema.Schema{ + Description: `Created By`, + Type: schema.TypeString, + Computed: true, + }, + "discovery_created": &schema.Schema{ + Description: `Discovery Created`, + + Type: schema.TypeString, + Computed: true, + }, + "primary_endpoint": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "certificate": &schema.Schema{ + Description: `Certificate`, + Type: schema.TypeString, + Computed: true, + }, + "fqdn": &schema.Schema{ + Description: `Fqdn`, + Type: schema.TypeString, + Computed: true, + }, + "ipv4_address": &schema.Schema{ + Description: `Ipv4 Address`, + Type: schema.TypeString, + Computed: true, + }, + "ipv6_address": &schema.Schema{ + Description: `Ipv6 Address`, + Type: schema.TypeString, + Computed: true, + }, + "port": &schema.Schema{ + Description: `Port`, + Type: schema.TypeFloat, + Computed: true, + }, + "protocol": &schema.Schema{ + Description: `Protocol`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "profile_name": &schema.Schema{ + Description: `Profile Name`, + Type: schema.TypeString, + Computed: true, + }, + "secondary_endpoint": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "certificate": &schema.Schema{ + Description: `Certificate`, + Type: schema.TypeString, + Computed: true, + }, + "fqdn": &schema.Schema{ + Description: `Fqdn`, + Type: schema.TypeString, + Computed: true, + }, + "ipv4_address": &schema.Schema{ + Description: `Ipv4 Address`, + Type: schema.TypeString, + Computed: true, + }, + "ipv6_address": &schema.Schema{ + Description: `Ipv6 Address`, + Type: schema.TypeString, + Computed: true, + }, + "port": &schema.Schema{ + Description: `Port`, + Type: schema.TypeFloat, + Computed: true, + }, + "protocol": &schema.Schema{ + Description: `Protocol`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "populate_inventory": &schema.Schema{ + Description: `Populate Inventory`, + + Type: schema.TypeString, + Computed: true, + }, + "pre_workflow_cli_ouputs": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "cli": &schema.Schema{ + Description: `Cli`, + Type: schema.TypeString, + Computed: true, + }, + "cli_output": &schema.Schema{ + Description: `Cli Output`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "project_id": &schema.Schema{ + Description: `Project Id`, + Type: schema.TypeString, + Computed: true, + }, + "project_name": &schema.Schema{ + Description: `Project Name`, + Type: schema.TypeString, + Computed: true, + }, + "reload_requested": &schema.Schema{ + Description: `Reload Requested`, + + Type: schema.TypeString, + Computed: true, + }, + "serial_number": &schema.Schema{ + Description: `Serial Number`, + Type: schema.TypeString, + Computed: true, + }, + "site_id": &schema.Schema{ + Description: `Site Id`, + Type: schema.TypeString, + Computed: true, + }, + "site_name": &schema.Schema{ + Description: `Site Name`, + Type: schema.TypeString, + Computed: true, + }, + "smart_account_id": &schema.Schema{ + Description: `Smart Account Id`, + Type: schema.TypeString, + Computed: true, + }, + "source": &schema.Schema{ + Description: `Source`, + Type: schema.TypeString, + Computed: true, + }, + "stack": &schema.Schema{ + Description: `Stack`, + + Type: schema.TypeString, + Computed: true, + }, + "stack_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "is_full_ring": &schema.Schema{ + Description: `Is Full Ring`, + + Type: schema.TypeString, + Computed: true, + }, + "stack_member_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "hardware_version": &schema.Schema{ + Description: `Hardware Version`, + Type: schema.TypeString, + Computed: true, + }, + "license_level": &schema.Schema{ + Description: `License Level`, + Type: schema.TypeString, + Computed: true, + }, + "license_type": &schema.Schema{ + Description: `License Type`, + Type: schema.TypeString, + Computed: true, + }, + "mac_address": &schema.Schema{ + Description: `Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + "pid": &schema.Schema{ + Description: `Pid`, + Type: schema.TypeString, + Computed: true, + }, + "priority": &schema.Schema{ + Description: `Priority`, + Type: schema.TypeFloat, + Computed: true, + }, + "role": &schema.Schema{ + Description: `Role`, + Type: schema.TypeString, + Computed: true, + }, + "serial_number": &schema.Schema{ + Description: `Serial Number`, + Type: schema.TypeString, + Computed: true, + }, + "software_version": &schema.Schema{ + Description: `Software Version`, + Type: schema.TypeString, + Computed: true, + }, + "stack_number": &schema.Schema{ + Description: `Stack Number`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "sudi_serial_number": &schema.Schema{ + Description: `Sudi Serial Number`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "stack_ring_protocol": &schema.Schema{ + Description: `Stack Ring Protocol`, + Type: schema.TypeString, + Computed: true, + }, + "supports_stack_workflows": &schema.Schema{ + Description: `Supports Stack Workflows`, + + Type: schema.TypeString, + Computed: true, + }, + "total_member_count": &schema.Schema{ + Description: `Total Member Count`, + Type: schema.TypeFloat, + Computed: true, + }, + "valid_license_levels": &schema.Schema{ + Description: `Valid License Levels`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "sudi_required": &schema.Schema{ + Description: `Sudi Required`, + + Type: schema.TypeString, + Computed: true, + }, + "tags": &schema.Schema{ + Description: `Tags`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "user_mic_numbers": &schema.Schema{ + Description: `User Mic Numbers`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "user_sudi_serial_nos": &schema.Schema{ + Description: `User Sudi Serial Nos`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "virtual_account_id": &schema.Schema{ + Description: `Virtual Account Id`, + Type: schema.TypeString, + Computed: true, + }, + "workflow_id": &schema.Schema{ + Description: `Workflow Id`, + Type: schema.TypeString, + Computed: true, + }, + "workflow_name": &schema.Schema{ + Description: `Workflow Name`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "run_summary_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "details": &schema.Schema{ + Description: `Details`, + Type: schema.TypeString, + Computed: true, + }, + "error_flag": &schema.Schema{ + Description: `Error Flag`, + + Type: schema.TypeString, + Computed: true, + }, + "history_task_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "addn_details": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "key": &schema.Schema{ + Description: `Key`, + Type: schema.TypeString, + Computed: true, + }, + "value": &schema.Schema{ + Description: `Value`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "work_item_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "command": &schema.Schema{ + Description: `Command`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "output_str": &schema.Schema{ + Description: `Output Str`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "timestamp": &schema.Schema{ + Description: `Timestamp`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + "system_reset_workflow": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "id": &schema.Schema{ + Description: `Id`, + Type: schema.TypeString, + Computed: true, + }, + "add_to_inventory": &schema.Schema{ + Description: `Add To Inventory`, + + Type: schema.TypeString, + Computed: true, + }, + "added_on": &schema.Schema{ + Description: `Added On`, + Type: schema.TypeFloat, + Computed: true, + }, + "config_id": &schema.Schema{ + Description: `Config Id`, + Type: schema.TypeString, + Computed: true, + }, + "curr_task_idx": &schema.Schema{ + Description: `Curr Task Idx`, + Type: schema.TypeFloat, + Computed: true, + }, + "description": &schema.Schema{ + Description: `Description`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "exec_time": &schema.Schema{ + Description: `Exec Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "image_id": &schema.Schema{ + Description: `Image Id`, + Type: schema.TypeString, + Computed: true, + }, + "instance_type": &schema.Schema{ + Description: `Instance Type`, + Type: schema.TypeString, + Computed: true, + }, + "lastupdate_on": &schema.Schema{ + Description: `Lastupdate On`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "tasks": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "curr_work_item_idx": &schema.Schema{ + Description: `Curr Work Item Idx`, + Type: schema.TypeFloat, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "task_seq_no": &schema.Schema{ + Description: `Task Seq No`, + Type: schema.TypeFloat, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "work_item_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "command": &schema.Schema{ + Description: `Command`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "output_str": &schema.Schema{ + Description: `Output Str`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "tenant_id": &schema.Schema{ + Description: `Tenant Id`, + Type: schema.TypeString, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "use_state": &schema.Schema{ + Description: `Use State`, + Type: schema.TypeString, + Computed: true, + }, + "version": &schema.Schema{ + Description: `Version`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + "system_workflow": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "id": &schema.Schema{ + Description: `Id`, + Type: schema.TypeString, + Computed: true, + }, + "add_to_inventory": &schema.Schema{ + Description: `Add To Inventory`, + + Type: schema.TypeString, + Computed: true, + }, + "added_on": &schema.Schema{ + Description: `Added On`, + Type: schema.TypeFloat, + Computed: true, + }, + "config_id": &schema.Schema{ + Description: `Config Id`, + Type: schema.TypeString, + Computed: true, + }, + "curr_task_idx": &schema.Schema{ + Description: `Curr Task Idx`, + Type: schema.TypeFloat, + Computed: true, + }, + "description": &schema.Schema{ + Description: `Description`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "exec_time": &schema.Schema{ + Description: `Exec Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "image_id": &schema.Schema{ + Description: `Image Id`, + Type: schema.TypeString, + Computed: true, + }, + "instance_type": &schema.Schema{ + Description: `Instance Type`, + Type: schema.TypeString, + Computed: true, + }, + "lastupdate_on": &schema.Schema{ + Description: `Lastupdate On`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "tasks": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "curr_work_item_idx": &schema.Schema{ + Description: `Curr Work Item Idx`, + Type: schema.TypeFloat, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "task_seq_no": &schema.Schema{ + Description: `Task Seq No`, + Type: schema.TypeFloat, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "work_item_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "command": &schema.Schema{ + Description: `Command`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "output_str": &schema.Schema{ + Description: `Output Str`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "tenant_id": &schema.Schema{ + Description: `Tenant Id`, + Type: schema.TypeString, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "use_state": &schema.Schema{ + Description: `Use State`, + Type: schema.TypeString, + Computed: true, + }, + "version": &schema.Schema{ + Description: `Version`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + "tenant_id": &schema.Schema{ + Description: `Tenant Id`, + Type: schema.TypeString, + Computed: true, + }, + "version": &schema.Schema{ + Description: `Version`, + Type: schema.TypeFloat, + Computed: true, + }, + "workflow": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "id": &schema.Schema{ + Description: `Id`, + Type: schema.TypeString, + Computed: true, + }, + "add_to_inventory": &schema.Schema{ + Description: `Add To Inventory`, + + Type: schema.TypeString, + Computed: true, + }, + "added_on": &schema.Schema{ + Description: `Added On`, + Type: schema.TypeFloat, + Computed: true, + }, + "config_id": &schema.Schema{ + Description: `Config Id`, + Type: schema.TypeString, + Computed: true, + }, + "curr_task_idx": &schema.Schema{ + Description: `Curr Task Idx`, + Type: schema.TypeFloat, + Computed: true, + }, + "description": &schema.Schema{ + Description: `Description`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "exec_time": &schema.Schema{ + Description: `Exec Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "image_id": &schema.Schema{ + Description: `Image Id`, + Type: schema.TypeString, + Computed: true, + }, + "instance_type": &schema.Schema{ + Description: `Instance Type`, + Type: schema.TypeString, + Computed: true, + }, + "lastupdate_on": &schema.Schema{ + Description: `Lastupdate On`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "tasks": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "curr_work_item_idx": &schema.Schema{ + Description: `Curr Work Item Idx`, + Type: schema.TypeFloat, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "task_seq_no": &schema.Schema{ + Description: `Task Seq No`, + Type: schema.TypeFloat, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "work_item_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "command": &schema.Schema{ + Description: `Command`, + Type: schema.TypeString, + Computed: true, + }, + "end_time": &schema.Schema{ + Description: `End Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "output_str": &schema.Schema{ + Description: `Output Str`, + Type: schema.TypeString, + Computed: true, + }, + "start_time": &schema.Schema{ + Description: `Start Time`, + Type: schema.TypeFloat, + Computed: true, + }, + "state": &schema.Schema{ + Description: `State`, + Type: schema.TypeString, + Computed: true, + }, + "time_taken": &schema.Schema{ + Description: `Time Taken`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "tenant_id": &schema.Schema{ + Description: `Tenant Id`, + Type: schema.TypeString, + Computed: true, + }, + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + "use_state": &schema.Schema{ + Description: `Use State`, + Type: schema.TypeString, + Computed: true, + }, + "version": &schema.Schema{ + Description: `Version`, + Type: schema.TypeFloat, + Computed: true, + }, + }, + }, + }, + "workflow_parameters": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "config_list": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "config_id": &schema.Schema{ + Description: `Config Id`, + Type: schema.TypeString, + Computed: true, + }, + "config_parameters": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "key": &schema.Schema{ + Description: `Key`, + Type: schema.TypeString, + Computed: true, + }, + "value": &schema.Schema{ + Description: `Value`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "license_level": &schema.Schema{ + Description: `License Level`, + Type: schema.TypeString, + Computed: true, + }, + "license_type": &schema.Schema{ + Description: `License Type`, + Type: schema.TypeString, + Computed: true, + }, + "top_of_stack_serial_number": &schema.Schema{ + Description: `Top Of Stack Serial Number`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config_file_url": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "config_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "device_claim_list": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "config_list": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "config_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "config_parameters": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "key": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "value": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + "device_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "license_level": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "license_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "top_of_stack_serial_number": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "file_service_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "image_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "image_url": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "populate_inventory": &schema.Schema{ + + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + "project_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "workflow_id": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourcePnpDeviceClaimCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + //resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestPnpDeviceClaimClaimDevice(ctx, "parameters.0", d) + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + vDeviceID := "" + if _, ok := d.GetOk("parameters.0"); ok { + if _, ok := d.GetOk("parameters.0.device_claim_list"); ok { + if _, ok := d.GetOk("parameters.0.device_claim_list.0"); ok { + if v, ok := d.GetOk("parameters.0.device_claim_list.0.device_id"); ok { + vDeviceID = interfaceToString(v) + } + } + } + } + + vvID := interfaceToString(vDeviceID) + if vvID != "" { + getResponse2, _, err := client.DeviceOnboardingPnp.GetDeviceByID(vvID) + if err == nil && getResponse2 != nil && getResponse2.DeviceInfo != nil && getResponse2.DeviceInfo.State == "Claimed" { + resourceMap := make(map[string]string) + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourcePnpDeviceClaimRead(ctx, d, m) + } + } + resp1, restyResp1, err := client.DeviceOnboardingPnp.ClaimDevice(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing ClaimDevice", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing ClaimDevice", err)) + return diags + } + resourceMap := make(map[string]string) + resourceMap["id"] = vvID + d.SetId(joinResourceID(resourceMap)) + return resourcePnpDeviceClaimRead(ctx, d, m) +} + +func resourcePnpDeviceClaimRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + if vID != "" { + log.Printf("[DEBUG] Selected method 2: GetDeviceByID") + vvID := vID + + response2, restyResp2, err := client.DeviceOnboardingPnp.GetDeviceByID(vvID) + + if err != nil || response2 == nil || response2.DeviceInfo != nil && response2.DeviceInfo.State == "Unclaimed" { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response2)) + + vItemID2 := flattenDeviceOnboardingPnpGetDeviceByIDItem(response2) + if err := d.Set("item", vItemID2); err != nil { + diags = append(diags, diagError( + "Failure when setting GetDeviceByID response", + err)) + return diags + } + return diags + + } + return diags +} + +func resourcePnpDeviceClaimUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourcePnpDeviceClaimRead(ctx, d, m) +} + +func resourcePnpDeviceClaimDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["id"] + + if vID != "" { + getResponse2, _, err := client.DeviceOnboardingPnp.GetDeviceByID(vID) + if err == nil && getResponse2 == nil && getResponse2.DeviceInfo != nil && getResponse2.DeviceInfo.State == "Unclaimed" { + d.SetId("") + return diags + } + } else { + return diags + } + + //var vvID string + //var vvName string + // REVIEW: Add getAllItems and search function to get missing params + request1 := dnacentersdkgo.RequestDeviceOnboardingPnpUnClaimDevice{} + request1.DeviceIDList = append(request1.DeviceIDList, vID) + response1, restyResp1, err := client.DeviceOnboardingPnp.UnClaimDevice(&request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for delete operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UnClaimDevice", err, restyResp1.String(), + "Failure at UnClaimDevice, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UnClaimDevice", err, + "Failure at UnClaimDevice, unexpected response", "")) + return diags + } + + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + return diags +} +func expandRequestPnpDeviceClaimClaimDevice(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDeviceOnboardingPnpClaimDevice { + request := dnacentersdkgo.RequestDeviceOnboardingPnpClaimDevice{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_file_url")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_file_url")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_file_url")))) { + request.ConfigFileURL = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_id")))) { + request.ConfigID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_claim_list")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_claim_list")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_claim_list")))) { + request.DeviceClaimList = expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListArray(ctx, key+".device_claim_list", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".file_service_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".file_service_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".file_service_id")))) { + request.FileServiceID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".image_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".image_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".image_id")))) { + request.ImageID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".image_url")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".image_url")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".image_url")))) { + request.ImageURL = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".populate_inventory")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".populate_inventory")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".populate_inventory")))) { + request.PopulateInventory = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".project_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".project_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".project_id")))) { + request.ProjectID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".workflow_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".workflow_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".workflow_id")))) { + request.WorkflowID = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimList { + request := []dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimList{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no := range objs { + i := expandRequestPnpDeviceClaimClaimDeviceDeviceClaimList(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestPnpDeviceClaimClaimDeviceDeviceClaimList(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimList { + request := dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimList{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_list")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_list")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_list")))) { + request.ConfigList = expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigListArray(ctx, key+".config_list", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".device_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".device_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".device_id")))) { + request.DeviceID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".license_level")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".license_level")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".license_level")))) { + request.LicenseLevel = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".license_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".license_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".license_type")))) { + request.LicenseType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".top_of_stack_serial_number")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".top_of_stack_serial_number")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".top_of_stack_serial_number")))) { + request.TopOfStackSerialNumber = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigListArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigList { + request := []dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigList{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no := range objs { + i := expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigList(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigList(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigList { + request := dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigList{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_id")))) { + request.ConfigID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".config_parameters")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config_parameters")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config_parameters")))) { + request.ConfigParameters = expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigListConfigParametersArray(ctx, key+".config_parameters", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigListConfigParametersArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigListConfigParameters { + request := []dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigListConfigParameters{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no := range objs { + i := expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigListConfigParameters(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestPnpDeviceClaimClaimDeviceDeviceClaimListConfigListConfigParameters(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigListConfigParameters { + request := dnacentersdkgo.RequestDeviceOnboardingPnpClaimDeviceDeviceClaimListConfigListConfigParameters{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".key")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".key")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".key")))) { + request.Key = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".value")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".value")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".value")))) { + request.Value = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} +func searchDeviceOnboardingPnpGetDeviceClaimList2(m interface{}, queryParams dnacentersdkgo.GetDeviceList2QueryParams, vName string) (*dnacentersdkgo.ResponseItemDeviceOnboardingPnpGetDeviceList2, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseItemDeviceOnboardingPnpGetDeviceList2 + nResponse, _, err := client.DeviceOnboardingPnp.GetDeviceList2(nil) + if nResponse == nil || err != nil { + return foundItem, err + } + maxPageSize := len(*nResponse) + for _, item := range *nResponse { + if item.DeviceInfo != nil && vName == item.DeviceInfo.Name { + foundItem = &item + return foundItem, err + } + } + queryParams.Limit = maxPageSize + queryParams.Offset = maxPageSize + nResponse, _, err = client.DeviceOnboardingPnp.GetDeviceList2(&queryParams) + return foundItem, err +} + +//ISSUE Pnp Device- ISSUE waiting for : [{}] we have: {} diff --git a/dnacenter/resource_pnp_workflow.go b/dnacenter/resource_pnp_workflow.go index 2f442c30..af9b3fe0 100644 --- a/dnacenter/resource_pnp_workflow.go +++ b/dnacenter/resource_pnp_workflow.go @@ -476,9 +476,7 @@ func resourcePnpWorkflowRead(ctx context.Context, d *schema.ResourceData, m inte if restyResp2 != nil { log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) } - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetWorkflowByID", err, - "Failure at GetWorkflowByID, unexpected response", "")) + d.SetId("") return diags } diff --git a/dnacenter/resource_sda_fabric_site.go b/dnacenter/resource_sda_fabric_site.go index e7ee1adf..e6330406 100644 --- a/dnacenter/resource_sda_fabric_site.go +++ b/dnacenter/resource_sda_fabric_site.go @@ -233,7 +233,9 @@ func resourceSdaFabricSiteDelete(ctx context.Context, d *schema.ResourceData, m if restyResp1 != nil { log.Printf("[DEBUG] resty response for delete operation => %v", restyResp1.String()) } - d.SetId("") + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteSiteFromSdaFabric", err, + "Failure at DeleteSiteFromSdaFabric, unexpected response", "")) return diags } diff --git a/dnacenter/resource_sensor.go b/dnacenter/resource_sensor.go new file mode 100644 index 00000000..eb4e5e24 --- /dev/null +++ b/dnacenter/resource_sensor.go @@ -0,0 +1,645 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceSensor() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and delete operations on Sensors. + +- Intent API to create a SENSOR test template with a new SSID, existing SSID, or both new and existing SSID + +- Intent API to delete an existing SENSOR test template +`, + + CreateContext: resourceSensorCreate, + ReadContext: resourceSensorRead, + UpdateContext: resourceSensorUpdate, + DeleteContext: resourceSensorDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "backhaul_type": &schema.Schema{ + Description: `Backhaul Type`, + Type: schema.TypeString, + Computed: true, + }, + + "ethernet_mac_address": &schema.Schema{ + Description: `Ethernet Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + + "ip_address": &schema.Schema{ + Description: `Ip Address`, + Type: schema.TypeString, + Computed: true, + }, + + "is_led_enabled": &schema.Schema{ + Description: `Is L E D Enabled`, + + Type: schema.TypeString, + Computed: true, + }, + + "last_seen": &schema.Schema{ + Description: `Last Seen`, + Type: schema.TypeInt, + Computed: true, + }, + + "location": &schema.Schema{ + Description: `Location`, + Type: schema.TypeString, + Computed: true, + }, + + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + + "radio_mac_address": &schema.Schema{ + Description: `Radio Mac Address`, + Type: schema.TypeString, + Computed: true, + }, + + "serial_number": &schema.Schema{ + Description: `Serial Number`, + Type: schema.TypeString, + Computed: true, + }, + + "ssh_config": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "enable_password": &schema.Schema{ + Description: `Enable Password`, + Type: schema.TypeString, + Computed: true, + }, + + "ssh_password": &schema.Schema{ + Description: `Ssh Password`, + Type: schema.TypeString, + Computed: true, + }, + + "ssh_state": &schema.Schema{ + Description: `Ssh State`, + Type: schema.TypeString, + Computed: true, + }, + + "ssh_user_name": &schema.Schema{ + Description: `Ssh User Name`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "status": &schema.Schema{ + Description: `Status`, + Type: schema.TypeString, + Computed: true, + }, + + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + + "version": &schema.Schema{ + Description: `Version`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "ap_coverage": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "bands": &schema.Schema{ + Description: `Bands`, + Type: schema.TypeString, + Optional: true, + }, + "number_of_aps_to_test": &schema.Schema{ + Description: `Number Of Aps To Test`, + Type: schema.TypeString, + Optional: true, + }, + "rssi_threshold": &schema.Schema{ + Description: `Rssi Threshold`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "connection": &schema.Schema{ + Description: `Connection`, + Type: schema.TypeString, + Optional: true, + }, + "model_version": &schema.Schema{ + Description: `Model Version`, + Type: schema.TypeInt, + Optional: true, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Optional: true, + }, + "ssids": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "auth_type": &schema.Schema{ + Description: `Auth Type`, + Type: schema.TypeString, + Optional: true, + }, + "categories": &schema.Schema{ + Description: `Categories`, + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "profile_name": &schema.Schema{ + Description: `Profile Name`, + Type: schema.TypeString, + Optional: true, + }, + "psk": &schema.Schema{ + Description: `Psk`, + Type: schema.TypeString, + Optional: true, + }, + "qos_policy": &schema.Schema{ + Description: `Qos Policy`, + Type: schema.TypeString, + Optional: true, + }, + "ssid": &schema.Schema{ + Description: `Ssid`, + Type: schema.TypeString, + Optional: true, + }, + "tests": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "config": &schema.Schema{ + Description: `Config`, + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "third_party": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "selected": &schema.Schema{ + Description: `Selected`, + // Type: schema.TypeBool, + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func resourceSensorCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestSensorCreateSensorTestTemplate(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + vName := resourceItem["name"] + vvName := interfaceToString(vName) + item, err := searchSensorsSensors(m, vvName) + if err != nil || item == nil { + resourceMap := make(map[string]string) + resourceMap["name"] = vvName + d.SetId(joinResourceID(resourceMap)) + return resourceSensorRead(ctx, d, m) + } + resp1, restyResp1, err := client.Sensors.CreateSensorTestTemplate(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateSensorTestTemplate", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateSensorTestTemplate", err)) + return diags + } + //Falta verificar por medio de EXECUTION ID, no pude porque el esquema de respuesta esta mal. + + resourceMap := make(map[string]string) + resourceMap["name"] = vvName + d.SetId(joinResourceID(resourceMap)) + return resourceSensorRead(ctx, d, m) +} + +func resourceSensorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vName := resourceMap["name"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: Sensors") + //queryParams1 := dnacentersdkgo.SensorsQueryParams{} + + response1, err := searchSensorsSensors(m, vName) + + if err != nil || response1 == nil { + /*if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + }*/ + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenSensorsSensorsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting Sensors search response", + err)) + return diags + } + + } + return diags +} + +func resourceSensorUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourceSensorRead(ctx, d, m) +} + +func resourceSensorDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vName := resourceMap["name"] + + item, err := searchSensorsSensors(m, vName) + if err != nil || item == nil { + d.SetId("") + return diags + } + + //selectedMethod := 1 + //var vvID string + //var vvName string + // REVIEW: Add getAllItems and search function to get missing params + + queryParams := dnacentersdkgo.DeleteSensorTestQueryParams{ + TemplateName: vName, + } + response1, restyResp1, err := client.Sensors.DeleteSensorTest(&queryParams) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for delete operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing DeleteSensorTest", err, restyResp1.String(), + "Failure at DeleteSensorTest, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteSensorTest", err, + "Failure at DeleteSensorTest, unexpected response", "")) + return diags + } + + //Falta verificar por medio de EXECUTION ID, no pude porque el esquema de respuesta esta mal. + + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + + return diags +} +func expandRequestSensorCreateSensorTestTemplate(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSensorsCreateSensorTestTemplate { + request := dnacentersdkgo.RequestSensorsCreateSensorTestTemplate{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".ssids")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".ssids")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".ssids")))) { + request.SSIDs = expandRequestSensorCreateSensorTestTemplateSSIDsArray(ctx, key+".ssids", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".connection")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".connection")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".connection")))) { + request.Connection = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".ap_coverage")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".ap_coverage")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".ap_coverage")))) { + request.ApCoverage = expandRequestSensorCreateSensorTestTemplateApCoverageArray(ctx, key+".ap_coverage", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".model_version")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".model_version")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".model_version")))) { + request.ModelVersion = interfaceToIntPtr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDs { + request := []dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDs{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestSensorCreateSensorTestTemplateSSIDs(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDs(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDs { + request := dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDs{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".ssid")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".ssid")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".ssid")))) { + request.SSID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".profile_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".profile_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".profile_name")))) { + request.ProfileName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".auth_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".auth_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".auth_type")))) { + request.AuthType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".third_party")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".third_party")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".third_party")))) { + request.ThirdParty = expandRequestSensorCreateSensorTestTemplateSSIDsThirdParty(ctx, key+".third_party.0", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".psk")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".psk")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".psk")))) { + request.Psk = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".tests")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".tests")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".tests")))) { + request.Tests = expandRequestSensorCreateSensorTestTemplateSSIDsTestsArray(ctx, key+".tests", d) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".categories")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".categories")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".categories")))) { + request.Categories = interfaceToSliceString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".qos_policy")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".qos_policy")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".qos_policy")))) { + request.QosPolicy = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDsThirdParty(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsThirdParty { + request := dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsThirdParty{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".selected")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".selected")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".selected")))) { + request.Selected = interfaceToBoolPtr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDsTestsArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTests { + request := []dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTests{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestSensorCreateSensorTestTemplateSSIDsTests(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDsTests(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTests { + request := dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTests{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".config")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".config")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".config")))) { + request.Config = expandRequestSensorCreateSensorTestTemplateSSIDsTestsConfigArray(ctx, key+".config", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDsTestsConfigArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTestsConfig { + request := []dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTestsConfig{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestSensorCreateSensorTestTemplateSSIDsTestsConfig(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateSSIDsTestsConfig(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTestsConfig { + var request dnacentersdkgo.RequestSensorsCreateSensorTestTemplateSSIDsTestsConfig + request = d.Get(fixKeyAccess(key)) + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateApCoverageArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestSensorsCreateSensorTestTemplateApCoverage { + request := []dnacentersdkgo.RequestSensorsCreateSensorTestTemplateApCoverage{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestSensorCreateSensorTestTemplateApCoverage(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSensorCreateSensorTestTemplateApCoverage(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSensorsCreateSensorTestTemplateApCoverage { + request := dnacentersdkgo.RequestSensorsCreateSensorTestTemplateApCoverage{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".bands")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".bands")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".bands")))) { + request.Bands = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".number_of_aps_to_test")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".number_of_aps_to_test")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".number_of_aps_to_test")))) { + request.NumberOfApsToTest = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rssi_threshold")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rssi_threshold")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rssi_threshold")))) { + request.RssiThreshold = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchSensorsSensors(m interface{}, vName string) (*dnacentersdkgo.ResponseSensorsSensorsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseSensorsSensorsResponse + var ite *dnacentersdkgo.ResponseSensorsSensors + ite, _, err = client.Sensors.Sensors(nil) + if err != nil { + return foundItem, err + } + items := ite + if items == nil { + return foundItem, err + } + itemsCopy := *items.Response + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.Name == vName { + var getItem *dnacentersdkgo.ResponseSensorsSensorsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_service_provider.go b/dnacenter/resource_service_provider.go new file mode 100644 index 00000000..9afc8347 --- /dev/null +++ b/dnacenter/resource_service_provider.go @@ -0,0 +1,605 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceServiceProvider() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read, update and delete operations on Network Settings. + +- API to create service provider profile(QOS). + +- API to update SP profile. + +- API to delete Service Provider profile (QoS). +`, + + CreateContext: resourceServiceProviderCreate, + ReadContext: resourceServiceProviderRead, + UpdateContext: resourceServiceProviderUpdate, + DeleteContext: resourceServiceProviderDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "group_uuid": &schema.Schema{ + Description: `Group Uuid`, + Type: schema.TypeString, + Computed: true, + }, + + "inherited_group_name": &schema.Schema{ + Description: `Inherited Group Name`, + Type: schema.TypeString, + Computed: true, + }, + + "inherited_group_uuid": &schema.Schema{ + Description: `Inherited Group Uuid`, + Type: schema.TypeString, + Computed: true, + }, + + "instance_type": &schema.Schema{ + Description: `Instance Type`, + Type: schema.TypeString, + Computed: true, + }, + + "instance_uuid": &schema.Schema{ + Description: `Instance Uuid`, + Type: schema.TypeString, + Computed: true, + }, + + "key": &schema.Schema{ + Description: `Key`, + Type: schema.TypeString, + Computed: true, + }, + + "namespace": &schema.Schema{ + Description: `Namespace`, + Type: schema.TypeString, + Computed: true, + }, + + "type": &schema.Schema{ + Description: `Type`, + Type: schema.TypeString, + Computed: true, + }, + + "value": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "sla_profile_name": &schema.Schema{ + Description: `Sla Profile Name`, + Type: schema.TypeString, + Computed: true, + }, + + "sp_profile_name": &schema.Schema{ + Description: `Sp Profile Name`, + Type: schema.TypeString, + Computed: true, + }, + + "wan_provider": &schema.Schema{ + Description: `Wan Provider`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "version": &schema.Schema{ + Description: `Version`, + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "settings": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "qos": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "model": &schema.Schema{ + Description: `Model`, + Type: schema.TypeString, + Optional: true, + }, + "profile_name": &schema.Schema{ + Description: `Profile Name`, + Type: schema.TypeString, + Optional: true, + }, + "wan_provider": &schema.Schema{ + Description: `Wan Provider`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func resourceServiceProviderCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + //resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestServiceProviderCreateSpProfile(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + + vvSpProfileName := "" + if _, ok := d.GetOk("parameters.0"); ok { + if _, ok := d.GetOk("parameters.0.settings"); ok { + if _, ok := d.GetOk("parameters.0.settings.0"); ok { + if _, ok := d.GetOk("parameters.0.settings.0.qos"); ok { + if v, ok := d.GetOk("parameters.0.settings.0.qos.0.profile_name"); ok { + vvSpProfileName = interfaceToString(v) + } + } + } + } + } + + item, err := searchNetworkSettingsGetServiceProviderDetails(m, vvSpProfileName) + if err == nil && item != nil { + resourceMap := make(map[string]string) + resourceMap["profile_name"] = vvSpProfileName + d.SetId(joinResourceID(resourceMap)) + return resourceServiceProviderRead(ctx, d, m) + } + + resp1, restyResp1, err := client.NetworkSettings.CreateSpProfile(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateSpProfile", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateSpProfile", err)) + return diags + } + + executionId := resp1.ExecutionID + log.Printf("[DEBUG] ExecutionID => %s", executionId) + if executionId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetBusinessAPIExecutionDetails", err, + "Failure at GetBusinessAPIExecutionDetails, unexpected response", "")) + return diags + } + for response2.Status == "IN_PROGRESS" { + time.Sleep(10 * time.Second) + response2, restyResp1, err = client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetExecutionByID", err, + "Failure at GetExecutionByID, unexpected response", "")) + return diags + } + } + if response2.Status == "FAILURE" { + bapiError := response2.BapiError + diags = append(diags, diagErrorWithAlt( + "Failure when executing CreateSpProfile", err, + "Failure at CreateSpProfile execution", bapiError)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["profile_name"] = vvSpProfileName + d.SetId(joinResourceID(resourceMap)) + return resourceServiceProviderRead(ctx, d, m) +} + +func resourceServiceProviderRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vSPProfleName := resourceMap["profile_name"] + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetServiceProviderDetails") + + response1, err := searchNetworkSettingsGetServiceProviderDetails(m, vSPProfleName) + + if err != nil || response1 == nil { + if err != nil { + log.Printf("[DEBUG] Error => %s", err.Error()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + + vItem1 := flattenNetworkSettingsGetServiceProviderDetailsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetServiceProviderDetails search response", + err)) + return diags + } + + } + return diags +} + +func resourceServiceProviderUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + isProfileNameChange := false + newProfileName := "" + vSpProfileName := resourceMap["profile_name"] + item, err := searchNetworkSettingsGetServiceProviderDetails(m, vSpProfileName) + if err != nil || item == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetServiceProviderDetails", err, + "Failure at yGetApplications, unexpected response", "")) + return diags + } + if d.HasChange("parameters") { + log.Printf("[DEBUG] Name used for update operation %s", vSpProfileName) + request1 := expandRequestServiceProviderUpdateSpProfile(ctx, "parameters.0", d) + newQos := *request1.Settings.Qos + if d.HasChange("parameters.0.settings.0.qos.0.profile_name") { + old, _ := d.GetChange("parameters.0.settings.0.qos.0.profile_name") + isProfileNameChange = true + newQos[0].OldProfileName = interfaceToString(old) + request1.Settings.Qos = &newQos + newProfileName = newQos[0].ProfileName + } + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + response1, restyResp1, err := client.NetworkSettings.UpdateSpProfile(request1) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateSpProfile", err, restyResp1.String(), + "Failure at UpdateSpProfile, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSpProfile", err, + "Failure at UpdateSpProfile, unexpected response", "")) + return diags + } + executionId := response1.ExecutionID + log.Printf("[DEBUG] ExecutionID => %s", executionId) + if executionId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetBusinessAPIExecutionDetails", err, + "Failure at GetBusinessAPIExecutionDetails, unexpected response", "")) + return diags + } + for response2.Status == "IN_PROGRESS" { + time.Sleep(10 * time.Second) + response2, restyResp1, err = client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetExecutionByID", err, + "Failure at GetExecutionByID, unexpected response", "")) + return diags + } + } + if response2.Status == "FAILURE" { + bapiError := response2.BapiError + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSpProfile", err, + "Failure at UpdateSpProfile execution", bapiError)) + return diags + } + } + } + if isProfileNameChange { + resourceMap := make(map[string]string) + resourceMap["profile_name"] = newProfileName + d.SetId(joinResourceID(resourceMap)) + } + return resourceServiceProviderRead(ctx, d, m) +} + +func resourceServiceProviderDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vSpProfileName := resourceMap["profile_name"] + item, err := searchNetworkSettingsGetServiceProviderDetails(m, vSpProfileName) + if err != nil || item == nil { + d.SetId("") + return diags + } + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: DeleteSpProfile") + + response1, restyResp1, err := client.NetworkSettings.DeleteSpProfile(vSpProfileName) + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteSpProfile", err, + "Failure at DeleteSpProfile, unexpected response", "")) + return diags + } + + executionId := response1.ExecutionID + log.Printf("[DEBUG] ExecutionID => %s", executionId) + if executionId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetBusinessAPIExecutionDetails", err, + "Failure at GetBusinessAPIExecutionDetails, unexpected response", "")) + return diags + } + for response2.Status == "IN_PROGRESS" { + time.Sleep(10 * time.Second) + response2, restyResp1, err = client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetExecutionByID", err, + "Failure at GetExecutionByID, unexpected response", "")) + return diags + } + } + if response2.Status == "FAILURE" { + bapiError := response2.BapiError + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteSpProfile", err, + "Failure at DeleteSpProfile execution", bapiError)) + return diags + } + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + d.SetId("") + return diags + + } + return diags +} +func expandRequestServiceProviderCreateSpProfile(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestNetworkSettingsCreateSpProfile { + request := dnacentersdkgo.RequestNetworkSettingsCreateSpProfile{} + request.Settings = expandRequestServiceProviderCreateSpProfileSettings(ctx, key+".settings.0", d) + + return &request +} + +func expandRequestServiceProviderCreateSpProfileSettings(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestNetworkSettingsCreateSpProfileSettings { + request := dnacentersdkgo.RequestNetworkSettingsCreateSpProfileSettings{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".qos")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".qos")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".qos")))) { + request.Qos = expandRequestServiceProviderCreateSpProfileSettingsQosArray(ctx, key+".qos", d) + } + + return &request +} + +func expandRequestServiceProviderCreateSpProfileSettingsQosArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestNetworkSettingsCreateSpProfileSettingsQos { + request := []dnacentersdkgo.RequestNetworkSettingsCreateSpProfileSettingsQos{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestServiceProviderCreateSpProfileSettingsQos(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + + return &request +} + +func expandRequestServiceProviderCreateSpProfileSettingsQos(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestNetworkSettingsCreateSpProfileSettingsQos { + request := dnacentersdkgo.RequestNetworkSettingsCreateSpProfileSettingsQos{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".profile_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".profile_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".profile_name")))) { + request.ProfileName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".model")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".model")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".model")))) { + request.Model = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".wan_provider")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".wan_provider")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".wan_provider")))) { + request.WanProvider = interfaceToString(v) + } + + return &request +} + +func expandRequestServiceProviderUpdateSpProfile(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestNetworkSettingsUpdateSpProfile { + request := dnacentersdkgo.RequestNetworkSettingsUpdateSpProfile{} + request.Settings = expandRequestServiceProviderUpdateSpProfileSettings(ctx, key+".settings.0", d) + + return &request +} + +func expandRequestServiceProviderUpdateSpProfileSettings(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestNetworkSettingsUpdateSpProfileSettings { + request := dnacentersdkgo.RequestNetworkSettingsUpdateSpProfileSettings{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".qos")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".qos")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".qos")))) { + request.Qos = expandRequestServiceProviderUpdateSpProfileSettingsQosArray(ctx, key+".qos", d) + } + + return &request +} + +func expandRequestServiceProviderUpdateSpProfileSettingsQosArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestNetworkSettingsUpdateSpProfileSettingsQos { + request := []dnacentersdkgo.RequestNetworkSettingsUpdateSpProfileSettingsQos{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestServiceProviderUpdateSpProfileSettingsQos(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + + return &request +} + +func expandRequestServiceProviderUpdateSpProfileSettingsQos(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestNetworkSettingsUpdateSpProfileSettingsQos { + request := dnacentersdkgo.RequestNetworkSettingsUpdateSpProfileSettingsQos{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".profile_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".profile_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".profile_name")))) { + request.ProfileName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".model")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".model")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".model")))) { + request.Model = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".wan_provider")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".wan_provider")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".wan_provider")))) { + request.WanProvider = interfaceToString(v) + } + + return &request +} + +func searchNetworkSettingsGetServiceProviderDetails(m interface{}, vSProfileName string) (*dnacentersdkgo.ResponseNetworkSettingsGetServiceProviderDetailsResponse, error) { + log.Printf("[DEBUG] Search") + log.Printf("[DEBUG] Search sp profile name =>%s", vSProfileName) + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseNetworkSettingsGetServiceProviderDetailsResponse + var ite *dnacentersdkgo.ResponseNetworkSettingsGetServiceProviderDetails + ite, resty, err := client.NetworkSettings.GetServiceProviderDetails() + log.Printf("[DEBUG] Load data") + if resty != nil { + log.Printf("Failure when sarch => %s", resty.String()) + } + log.Printf("[DEBUG] Load data1") + if err != nil { + return foundItem, err + } + log.Printf("[DEBUG] Load data2") + items := ite + if items == nil { + return foundItem, err + } + log.Printf("[DEBUG] Load data3") + if items.Response == nil { + return foundItem, err + } + itemsCopy := *items.Response + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.Value != nil { + for _, item2 := range *item.Value { + if item2.SpProfileName == vSProfileName { + log.Printf("[DEBUG] Search finded item") + var getItem *dnacentersdkgo.ResponseNetworkSettingsGetServiceProviderDetailsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + } + } + log.Printf("[DEBUG] Search final") + return foundItem, err +} diff --git a/dnacenter/resource_site.go b/dnacenter/resource_site.go new file mode 100644 index 00000000..c6a772b1 --- /dev/null +++ b/dnacenter/resource_site.go @@ -0,0 +1,888 @@ +package dnacenter + +import ( + "context" + "reflect" + "strconv" + "strings" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceSite() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read, update and delete operations on Sites. + +- Creates site with area/building/floor with specified hierarchy. + +- Update site area/building/floor with specified hierarchy and new values + +- Delete site with area/building/floor by siteId. +`, + + CreateContext: resourceSiteCreate, + ReadContext: resourceSiteRead, + UpdateContext: resourceSiteUpdate, + DeleteContext: resourceSiteDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "additional_info": &schema.Schema{ + Description: `Additional Info`, + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "attributes": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "address": &schema.Schema{ + Description: `address`, + Type: schema.TypeString, + Computed: true, + }, + + "address_inherited_from": &schema.Schema{ + Description: `addressInheritedFrom`, + Type: schema.TypeString, + Computed: true, + }, + + "country": &schema.Schema{ + Description: `country`, + Type: schema.TypeString, + Computed: true, + }, + + "floor_index": &schema.Schema{ + Description: `floorIndex`, + Type: schema.TypeString, + Computed: true, + }, + + "height": &schema.Schema{ + Description: `height`, + Type: schema.TypeString, + Computed: true, + }, + + "latitude": &schema.Schema{ + Description: `latitude`, + Type: schema.TypeString, + Computed: true, + }, + + "length": &schema.Schema{ + Description: `length`, + Type: schema.TypeString, + Computed: true, + }, + + "longitude": &schema.Schema{ + Description: `longitude`, + Type: schema.TypeString, + Computed: true, + }, + + "offset_x": &schema.Schema{ + Description: `offsetX`, + Type: schema.TypeString, + Computed: true, + }, + + "offset_y": &schema.Schema{ + Description: `offsetY`, + Type: schema.TypeString, + Computed: true, + }, + + "rf_model": &schema.Schema{ + Description: `rfModel`, + Type: schema.TypeString, + Computed: true, + }, + + "type": &schema.Schema{ + Description: `type`, + Type: schema.TypeString, + Computed: true, + }, + + "width": &schema.Schema{ + Description: `width`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "namespace": &schema.Schema{ + Description: `namespace`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "id": &schema.Schema{ + Description: `Id`, + Type: schema.TypeString, + Computed: true, + }, + + "instance_tenant_id": &schema.Schema{ + Description: `Instance Tenant Id`, + Type: schema.TypeString, + Computed: true, + }, + + "name": &schema.Schema{ + Description: `Name`, + Type: schema.TypeString, + Computed: true, + }, + + "parent_id": &schema.Schema{ + Description: `Parent Id`, + Type: schema.TypeString, + Computed: true, + }, + + "site_hierarchy": &schema.Schema{ + Description: `Site Hierarchy`, + Type: schema.TypeString, + Computed: true, + }, + + "site_name_hierarchy": &schema.Schema{ + Description: `Site Name Hierarchy`, + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "site": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "area": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "name": &schema.Schema{ + Description: `Name of the area (eg: Area1) +`, + Type: schema.TypeString, + Optional: true, + }, + "parent_name": &schema.Schema{ + Description: `Parent name of the area to be created +`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "building": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "address": &schema.Schema{ + Description: `Address of the building to be created +`, + Type: schema.TypeString, + Optional: true, + }, + "latitude": &schema.Schema{ + Description: `Latitude coordinate of the building (eg:37.338) +`, + Type: schema.TypeFloat, + Optional: true, + }, + "longitude": &schema.Schema{ + Description: `Longitude coordinate of the building (eg:-121.832) +`, + Type: schema.TypeFloat, + Optional: true, + }, + "name": &schema.Schema{ + Description: `Name of the building (eg: building1) +`, + Type: schema.TypeString, + Optional: true, + }, + "parent_name": &schema.Schema{ + Description: `Parent name of building to be created +`, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "floor": &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "height": &schema.Schema{ + Description: `Height of the floor (eg: 15) +`, + Type: schema.TypeFloat, + Optional: true, + }, + "length": &schema.Schema{ + Description: `Length of the floor (eg: 100) +`, + Type: schema.TypeFloat, + Optional: true, + }, + "name": &schema.Schema{ + Description: `Name of the floor (eg:floor-1) +`, + Type: schema.TypeString, + Optional: true, + }, + "parent_name": &schema.Schema{ + Description: `Parent name of the floor to be created +`, + Type: schema.TypeString, + Optional: true, + }, + "rf_model": &schema.Schema{ + Description: `Type of floor. Allowed values are 'Cubes And Walled Offices', 'Drywall Office Only', 'Indoor High Ceiling', 'Outdoor Open Space'. +`, + Type: schema.TypeString, + Optional: true, + }, + "width": &schema.Schema{ + Description: `Width of the floor (eg:100) +`, + Type: schema.TypeFloat, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + "site_id": &schema.Schema{ + Description: `siteId path parameter. Site id to which site details to be updated. +`, + Type: schema.TypeString, + Optional: true, + }, + "type": &schema.Schema{ + Description: `Type of site to create (eg: area, building, floor) +`, + Type: schema.TypeString, + Required: true, + }, + /*"runsync": &schema.Schema{ + Description: `HeaderParam + `, + Type: schema.TypeString, + Required: true, + }, + "timeout": &schema.Schema{ + Description: `HeaderParam + `, + Type: schema.TypeString, + Optional: true, + }, + "persistbapioutput": &schema.Schema{ + Description: `HeaderParam + `, + Type: schema.TypeString, + Required: true, + },*/ + }, + }, + }, + }, + } +} + +func resourceSiteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestSiteCreateSite(ctx, "parameters.0", d) + + vSiteID := resourceItem["site_id"] + vvSiteID := interfaceToString(vSiteID) + vType := resourceItem["type"] + vvType := interfaceToString(vType) + /*vTimeout, okTimeout := resourceItem["timeout"] + vvTimeout := interfaceToString(vTimeout) + vRunsync := resourceItem["runsync"] + vvRunsync := interfaceToString(vRunsync) + vPersistbapioutput := resourceItem["persistbapioutput"] + vvPersistbapioutput := interfaceToString(vPersistbapioutput)*/ + + vvName := "" + vvParentName := "" + if _, ok := d.GetOk("parameters.0"); ok { + if _, ok := d.GetOk("parameters.0.site"); ok { + if _, ok := d.GetOk("parameters.0.site.0"); ok { + if _, ok := d.GetOk("parameters.0.site.0." + vvType); ok { + if v, ok := d.GetOk("parameters.0.site.0." + vvType + ".0.name"); ok { + vvName = interfaceToString(v) + } + if v2, ok := d.GetOk("parameters.0.site.0." + vvType + ".0.parent_name"); ok { + vvParentName = interfaceToString(v2) + } + } + } + } + } + + pathName := []string{vvParentName, vvName} + newName := strings.Join(pathName, "/") + if !strings.Contains(newName, "Global/") { + newPathName := []string{"Global", newName} + newName = strings.Join(newPathName, "/") + } + queryParams1 := dnacentersdkgo.GetSiteQueryParams{} + queryParams1.Name = newName + log.Printf("[DEBUG] newName => %s", newName) + item, err := searchSitesGetSite(m, queryParams1) + if err == nil || item != nil { + resourceMap := make(map[string]string) + resourceMap["site_id"] = item.ID + //resourceMap["type"] = item.AdditionalInfo + resourceMap["name"] = item.SiteNameHierarchy + /*resourceMap["runsync"] = vvRunsync + resourceMap["persistbapioutput"] = vvPersistbapioutput + resourceMap["timeout"] = vvTimeout*/ + d.SetId(joinResourceID(resourceMap)) + return resourceSiteRead(ctx, d, m) + } + headers := dnacentersdkgo.CreateSiteHeaderParams{} + headers.Persistbapioutput = "false" + headers.Runsync = "false" + /*if okTimeout { + headers.Timeout = vvTimeout + }*/ + resp1, restyResp1, err := client.Sites.CreateSite(request1, &headers) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing CreateSite", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing CreateSite", err)) + return diags + } + + executionId := resp1.ExecutionID + log.Printf("[DEBUG] ExecutionID => %s", executionId) + if executionId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response1 %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetBusinessAPIExecutionDetails", err, + "Failure at GetBusinessAPIExecutionDetails, unexpected response", "")) + return diags + } + for response2.Status == "IN_PROGRESS" { + time.Sleep(10 * time.Second) + response2, restyResp1, err = client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response2 %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetExecutionByID", err, + "Failure at GetExecutionByID, unexpected response", "")) + return diags + } + } + if response2.Status == "FAILURE" { + bapiError := response2.BapiError + diags = append(diags, diagErrorWithAlt( + "Failure when executing CreateSite", err, + "Failure at CreateSite execution", bapiError)) + return diags + } + } + resourceMap := make(map[string]string) + resourceMap["site_id"] = vvSiteID + //resourceMap["type"] = vvType + resourceMap["name"] = newName + //resourceMap["parent_name"] = vvParentName + /*resourceMap["runsync"] = vvRunsync + resourceMap["persistbapioutput"] = vvPersistbapioutput + resourceMap["timeout"] = vvTimeout*/ + d.SetId(joinResourceID(resourceMap)) + return resourceSiteRead(ctx, d, m) +} + +func resourceSiteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vName := resourceMap["name"] + log.Printf("[DEBUG] Read SiteNameHierarchy => %s", vName) + //vSiteID := resourceMap["site_id"] + //vParentName := resourceMap["parent_name"] + + selectedMethod := 1 + if selectedMethod == 1 { + //pathName := []string{vParentName, vName} + //newName := strings.Join(pathName, "/") + //log.Printf("[DEBUG] Selected method 1: GetSite") + queryParams1 := dnacentersdkgo.GetSiteQueryParams{} + queryParams1.Name = vName + //queryParams1.SiteID = vSiteID + log.Printf("[DEBUG] Read name => %s", queryParams1.Name) + log.Printf("[DEBUG] Read site => %s", queryParams1.SiteID) + response1, restyResp1, err := client.Sites.GetSite(&queryParams1) + + if err != nil || response1 == nil { + log.Printf("[DEBUG] Error => %s", err.Error()) + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response3 %s", restyResp1.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + vItem1 := flattenSitesGetSiteItems(response1.Response) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetSite search response", + err)) + return diags + } + + } + return diags +} + +func resourceSiteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vName := resourceMap["name"] + vSiteID := resourceMap["site_id"] + //vParentName := resourceMap["parent_name"] + /*vRunsync := resourceMap["runsync"] + vPersistbapioutput := resourceMap["persistbapioutput"] + vTimeout := resourceMap["timeout"]*/ + //pathName := []string{vParentName, vName} + //newName := strings.Join(pathName, "/") + queryParams1 := dnacentersdkgo.GetSiteQueryParams{} + queryParams1.Name = vName + item, err := searchSitesGetSite(m, queryParams1) + if err != nil || item == nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetSite", err, + "Failure at GetSite, unexpected response", "")) + return diags + } + if vSiteID != item.ID { + vSiteID = item.ID + } + var vvID string + // NOTE: Consider adding getAllItems and search function to get missing params + // if selectedMethod == 1 { } + if d.HasChange("parameters") { + log.Printf("[DEBUG] ID used for update operation %s", vvID) + request1 := expandRequestSiteUpdateSite(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + headers := dnacentersdkgo.UpdateSiteHeaderParams{} + headers.Persistbapioutput = "false" + headers.Runsync = "false" + /*if vTimeout != "" { + headers.Timeout = vTimeout + }*/ + + response1, restyResp1, err := client.Sites.UpdateSite(vSiteID, request1, &headers) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing UpdateSite", err, restyResp1.String(), + "Failure at UpdateSite, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSite", err, + "Failure at UpdateSite, unexpected response", "")) + return diags + } + if response1.Response != nil { + errorResult, _ := strconv.ParseBool(response1.Response.IsError) + if errorResult { + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdateSite", err, + "Failure at UpdateSite, unexpected response", "")) + return diags + } + } + } + + return resourceSiteRead(ctx, d, m) +} + +func resourceSiteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vName := resourceMap["name"] + vSiteID := resourceMap["site_id"] + + queryParams1 := dnacentersdkgo.GetSiteQueryParams{} + queryParams1.Name = vName + item, err := searchSitesGetSite(m, queryParams1) + if err != nil || item == nil { + d.SetId("") + return diags + } + + if vSiteID != item.ID { + vSiteID = item.ID + } + + response1, restyResp1, err := client.Sites.DeleteSite(vSiteID) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] resty response for delete operation => %v", restyResp1.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing DeleteSite", err, restyResp1.String(), + "Failure at DeleteSite, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteSite", err, + "Failure at DeleteSite, unexpected response", "")) + return diags + } + + if response1.Status == "FAILURE" { + diags = append(diags, diagErrorWithAlt( + "Failure when executing DeleteSite", err, + "Failure at DeleteSite, unexpected response", "")) + return diags + } + + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + + return diags +} +func expandRequestSiteCreateSite(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesCreateSite { + request := dnacentersdkgo.RequestSitesCreateSite{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".type")))) { + request.Type = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".site")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".site")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".site")))) { + request.Site = expandRequestSiteCreateSiteSite(ctx, key+".site.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteCreateSiteSite(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesCreateSiteSite { + request := dnacentersdkgo.RequestSitesCreateSiteSite{} + var typeStr string + if typeS, ok := d.GetOkExists(fixKeyAccess("parameters.0.type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess("parameters.0.type")))) && (ok || !reflect.DeepEqual(typeS, d.Get(fixKeyAccess("parameters.0.type")))) { + typeStr = interfaceToString(typeS) + } else { + return nil + } + + if v, ok := d.GetOkExists(fixKeyAccess(key + ".area")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".area")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".area")))) { + if typeStr == "area" { + request.Area = expandRequestSiteCreateSiteSiteArea(ctx, key+".area.0", d) + } + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".building")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".building")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".building")))) { + if typeStr == "building" { + request.Building = expandRequestSiteCreateSiteSiteBuilding(ctx, key+".building.0", d) + } + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".floor")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".floor")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".floor")))) { + if typeStr == "floor" { + request.Floor = expandRequestSiteCreateSiteSiteFloor(ctx, key+".floor.0", d) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteCreateSiteSiteArea(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesCreateSiteSiteArea { + request := dnacentersdkgo.RequestSitesCreateSiteSiteArea{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parent_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parent_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parent_name")))) { + request.ParentName = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteCreateSiteSiteBuilding(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesCreateSiteSiteBuilding { + request := dnacentersdkgo.RequestSitesCreateSiteSiteBuilding{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".address")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".address")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".address")))) { + request.Address = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parent_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parent_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parent_name")))) { + request.ParentName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".latitude")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".latitude")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".latitude")))) { + request.Latitude = interfaceToFloat64Ptr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".longitude")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".longitude")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".longitude")))) { + request.Longitude = interfaceToFloat64Ptr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteCreateSiteSiteFloor(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesCreateSiteSiteFloor { + request := dnacentersdkgo.RequestSitesCreateSiteSiteFloor{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parent_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parent_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parent_name")))) { + request.ParentName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rf_model")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rf_model")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rf_model")))) { + request.RfModel = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".width")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".width")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".width")))) { + request.Width = interfaceToFloat64Ptr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".length")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".length")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".length")))) { + request.Length = interfaceToFloat64Ptr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".height")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".height")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".height")))) { + request.Height = interfaceToFloat64Ptr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteUpdateSite(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesUpdateSite { + request := dnacentersdkgo.RequestSitesUpdateSite{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".type")))) { + request.Type = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".site")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".site")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".site")))) { + request.Site = expandRequestSiteUpdateSiteSite(ctx, key+".site.0", d) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteUpdateSiteSite(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesUpdateSiteSite { + request := dnacentersdkgo.RequestSitesUpdateSiteSite{} + var typeStr string + if typeS, ok := d.GetOkExists(fixKeyAccess("parameters.0.type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess("parameters.0.type")))) && (ok || !reflect.DeepEqual(typeS, d.Get(fixKeyAccess("parameters.0.type")))) { + typeStr = interfaceToString(typeS) + } else { + return nil + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".area")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".area")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".area")))) { + if typeStr == "area" { + request.Area = expandRequestSiteUpdateSiteSiteArea(ctx, key+".area.0", d) + } + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".building")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".building")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".building")))) { + if typeStr == "building" { + request.Building = expandRequestSiteUpdateSiteSiteBuilding(ctx, key+".building.0", d) + } + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".floor")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".floor")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".floor")))) { + if typeStr == "floor" { + request.Floor = expandRequestSiteUpdateSiteSiteFloor(ctx, key+".floor.0", d) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteUpdateSiteSiteArea(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesUpdateSiteSiteArea { + request := dnacentersdkgo.RequestSitesUpdateSiteSiteArea{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parent_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parent_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parent_name")))) { + request.ParentName = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteUpdateSiteSiteBuilding(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesUpdateSiteSiteBuilding { + request := dnacentersdkgo.RequestSitesUpdateSiteSiteBuilding{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".address")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".address")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".address")))) { + request.Address = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".parent_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".parent_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".parent_name")))) { + request.ParentName = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".latitude")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".latitude")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".latitude")))) { + request.Latitude = interfaceToFloat64Ptr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".longitude")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".longitude")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".longitude")))) { + request.Longitude = interfaceToFloat64Ptr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSiteUpdateSiteSiteFloor(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSitesUpdateSiteSiteFloor { + request := dnacentersdkgo.RequestSitesUpdateSiteSiteFloor{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { + request.Name = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".rf_model")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".rf_model")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".rf_model")))) { + request.RfModel = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".width")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".width")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".width")))) { + request.Width = interfaceToFloat64Ptr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".length")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".length")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".length")))) { + request.Length = interfaceToFloat64Ptr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".height")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".height")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".height")))) { + request.Height = interfaceToFloat64Ptr(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchSitesGetSite(m interface{}, queryParams dnacentersdkgo.GetSiteQueryParams) (*dnacentersdkgo.ResponseSitesGetSiteResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseSitesGetSiteResponse + var ite *dnacentersdkgo.ResponseSitesGetSite + ite, restyResp1, err := client.Sites.GetSite(&queryParams) + if err != nil { + if restyResp1 != nil { + log.Printf("[DEBUG] restyResp1 => %v", restyResp1.String()) + } + log.Printf("[DEBUG] Error =>%s", err.Error()) + return foundItem, err + } + items := ite.Response + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.SiteNameHierarchy == queryParams.Name { + var getItem *dnacentersdkgo.ResponseSitesGetSiteResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_swim_image_file.go b/dnacenter/resource_swim_image_file.go new file mode 100644 index 00000000..34ff4272 --- /dev/null +++ b/dnacenter/resource_swim_image_file.go @@ -0,0 +1,459 @@ +package dnacenter + +import ( + "context" + "io" + "os" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceSwimImageFile() *schema.Resource { + return &schema.Resource{ + Description: `It manages create and read operations on Software Image Management (SWIM). + +- Fetches a software image from local file system and uploads to DNA Center. Supported software image files extensions +are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. +Upload the file to the **file** form data field +`, + + CreateContext: resourceSwimImageFileCreate, + ReadContext: resourceSwimImageFileRead, + UpdateContext: resourceSwimImageFileUpdate, + DeleteContext: resourceSwimImageFileDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "applicable_devices_for_image": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "mdf_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "product_id": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + + "product_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "application_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "created_time": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "extended_attributes": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "family": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "feature": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "file_service_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "file_size": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "image_integrity_status": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "image_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "image_series": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + + "image_source": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "image_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "image_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "import_source_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "is_tagged_golden": &schema.Schema{ + + Type: schema.TypeString, + Computed: true, + }, + + "md5_checksum": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "profile_info": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "extended_attributes": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "memory": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "product_type": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "profile_name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "shares": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + + "v_cpu": &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + }, + }, + }, + }, + + "sha_check_sum": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "vendor": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + + "version": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "file_name": &schema.Schema{ + Description: `File name.`, + Type: schema.TypeString, + Required: true, + }, + "file_path": &schema.Schema{ + Description: `File absolute path.`, + Type: schema.TypeString, + Required: true, + }, + "is_third_party": &schema.Schema{ + Description: `isThirdParty query parameter. Third party Image check + `, + Type: schema.TypeBool, + Optional: true, + }, + "third_party_application_type": &schema.Schema{ + Description: `thirdPartyApplicationType query parameter. Third Party Application Type + `, + Type: schema.TypeString, + Optional: true, + }, + "third_party_image_family": &schema.Schema{ + Description: `thirdPartyImageFamily query parameter. Third Party image family + `, + Type: schema.TypeString, + Optional: true, + }, + "third_party_vendor": &schema.Schema{ + Description: `thirdPartyVendor query parameter. Third Party Vendor + `, + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceSwimImageFileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceItem := *getResourceItem(d.Get("parameters")) + vIsThirdParty, okIsThirdParty := resourceItem["is_third_party"] + vThirdPartyVendor, okThirdPartyVendor := resourceItem["third_party_vendor"] + vThirdPartyImageFamily, okThirdPartyImageFamily := resourceItem["third_party_image_family"] + vThirdPartyApplicationType, okThirdPartyApplicationType := resourceItem["third_party_application_type"] + vFileName := resourceItem["file_name"] + vFilePath := resourceItem["file_path"] + + if vFileName.(string) != "" { + query := dnacentersdkgo.GetSoftwareImageDetailsQueryParams{ + Name: vFileName.(string), + } + item, err := searchSoftwareImageManagementSwimGetSoftwareImageDetailsFile(m, query) + + if item != nil && err == nil { + resourceMap := make(map[string]string) + resourceMap["file_name"] = vFileName.(string) + resourceMap["file_path"] = vFilePath.(string) + d.SetId(joinResourceID(resourceMap)) + return resourceSwimImageFileRead(ctx, d, m) + } + } + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: ImportLocalSoftwareImage") + queryParams1 := dnacentersdkgo.ImportLocalSoftwareImageQueryParams{} + + if okIsThirdParty { + queryParams1.IsThirdParty = vIsThirdParty.(bool) + } + if okThirdPartyVendor { + queryParams1.ThirdPartyVendor = vThirdPartyVendor.(string) + } + if okThirdPartyImageFamily { + queryParams1.ThirdPartyImageFamily = vThirdPartyImageFamily.(string) + } + if okThirdPartyApplicationType { + queryParams1.ThirdPartyApplicationType = vThirdPartyApplicationType.(string) + } + + isDir, err := IsDirectory(vFilePath.(string)) + if err != nil || isDir { + diags = append(diags, diagErrorWithAlt( + "Failure when executing File", err, + "Failure at File, Path is a directory", "")) + return diags + } + f, err := os.Open(vFilePath.(string)) + if err != nil { + diags = append(diags, diagErrorWithAlt( + "Failure when executing ImportLocalSoftwareImage", err, + "Failure at ImportLocalSoftwareImage, unexpected response", "")) + return diags + } + defer func() { + if err = f.Close(); err != nil { + log.Printf("File close error %s", err.Error()) + } + }() + + var r io.Reader + r = f + + response1, restyResp1, err := client.SoftwareImageManagementSwim.ImportLocalSoftwareImage( + &queryParams1, + &dnacentersdkgo.ImportLocalSoftwareImageMultipartFields{ + File: r, + FileName: vFileName.(string), + }, + ) + log.Printf("[DEBUG] File name => %s", vFileName.(string)) + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + if err != nil { + log.Printf("[DEBUG] Error response => %s", err.Error()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing ImportLocalSoftwareImage", err, + "Failure at ImportLocalSoftwareImage, unexpected response", "")) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing ImportLocalSoftwareImage", err)) + return diags + } + } + } + resourceMap := make(map[string]string) + resourceMap["file_name"] = vFileName.(string) + resourceMap["file_path"] = vFilePath.(string) + d.SetId(joinResourceID(resourceMap)) + return resourceSwimImageFileRead(ctx, d, m) +} + +func resourceSwimImageFileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vName := resourceMap["file_name"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetSoftwareImageDetails") + queryParams1 := dnacentersdkgo.GetSoftwareImageDetailsQueryParams{ + Name: vName, + } + + response1, err := searchSoftwareImageManagementSwimGetSoftwareImageDetailsFile(m, queryParams1) + + if err != nil || response1 == nil { + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + vItem1 := flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItem(response1) + if err := d.Set("item", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetSoftwareImageDetails search response", + err)) + return diags + } + + } + return diags +} + +func resourceSwimImageFileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourceSwimImageFileRead(ctx, d, m) +} + +func resourceSwimImageFileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete SwimImageFile on Dna Center + // Returning empty diags to delete it on Terraform + return diags +} + +func searchSoftwareImageManagementSwimGetSoftwareImageDetailsFile(m interface{}, queryParams dnacentersdkgo.GetSoftwareImageDetailsQueryParams) (*dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse + var ite *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetails + ite, _, err = client.SoftwareImageManagementSwim.GetSoftwareImageDetails(&queryParams) + if err != nil { + return foundItem, err + } + items := ite.Response + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.Name == queryParams.Name { + var getItem *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_swim_image_url.go b/dnacenter/resource_swim_image_url.go new file mode 100644 index 00000000..3ce904a5 --- /dev/null +++ b/dnacenter/resource_swim_image_url.go @@ -0,0 +1,250 @@ +package dnacenter + +import ( + "context" + "fmt" + "reflect" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceSwimImageURL() *schema.Resource { + return &schema.Resource{ + Description: `It manages create and read operations on Software Image Management (SWIM). + +- Fetches a software image from remote file system (using URL for HTTP/FTP) and uploads to DNA Center. Supported image +files extensions are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2 +`, + + CreateContext: resourceSwimImageURLCreate, + ReadContext: resourceSwimImageURLRead, + UpdateContext: resourceSwimImageURLUpdate, + DeleteContext: resourceSwimImageURLDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestSoftwareImageManagementSwimImportSoftwareImageViaURL`, + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "application_type": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "image_family": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "source_url": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "third_party": &schema.Schema{ + // Type: schema.TypeBool, + Type: schema.TypeString, + ValidateFunc: validateStringHasValueFunc([]string{"", "true", "false"}), + Optional: true, + }, + "vendor": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func resourceSwimImageURLCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + //client := m.(*dnacentersdkgo.Client) + + //var diags diag.Diagnostics + + //resourceItem := *getResourceItem(d.Get("parameters")) + request1 := expandRequestSwimImageURLImportSoftwareImageViaURL(ctx, "parameters.0", d) + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + /* + resp1, restyResp1, err := client.SoftwareImageManagementSwim.ImportSoftwareImageViaURL(request1) + if err != nil || resp1 == nil { + if restyResp1 != nil { + diags = append(diags, diagErrorWithResponse( + "Failure when executing ImportSoftwareImageViaURL", err, restyResp1.String())) + return diags + } + diags = append(diags, diagError( + "Failure when executing ImportSoftwareImageViaURL", err)) + return diags + }*/ + resourceMap := make(map[string]string) + d.SetId(joinResourceID(resourceMap)) + return resourceSwimImageURLRead(ctx, d, m) +} + +func resourceSwimImageURLRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + /* + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vImageUUID := resourceMap["image_uuid"] + vName := resourceMap["name"] + vFamily := resourceMap["family"] + vApplicationType := resourceMap["application_type"] + vImageIntegrityStatus := resourceMap["image_integrity_status"] + vVersion := resourceMap["version"] + vImageSeries := resourceMap["image_series"] + vImageName := resourceMap["image_name"] + vIsTaggedGolden := resourceMap["is_tagged_golden"] + vIsCCORecommended := resourceMap["is_cco_recommended"] + vIsCCOLatest := resourceMap["is_cco_latest"] + vCreatedTime := resourceMap["created_time"] + vImageSizeGreaterThan := resourceMap["image_size_greater_than"] + vImageSizeLesserThan := resourceMap["image_size_lesser_than"] + vSortBy := resourceMap["sort_by"] + vSortOrder := resourceMap["sort_order"] + vLimit := resourceMap["limit"] + vOffset := resourceMap["offset"] + */ + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetSoftwareImageDetails") + queryParams1 := dnacentersdkgo.GetSoftwareImageDetailsQueryParams{} + + response1, restyResp1, err := client.SoftwareImageManagementSwim.GetSoftwareImageDetails(&queryParams1) + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + //TODO FOR DNAC + /* + vItem1 := flattenSoftwareImageManagementSwimGetSoftwareImageDetailsItems(response1) + if err := d.Set("parameters", vItem1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetSoftwareImageDetails search response", + err)) + return diags + } + */ + + } + return diags +} + +func resourceSwimImageURLUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + return resourceSwimImageURLRead(ctx, d, m) +} + +func resourceSwimImageURLDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + // NOTE: Unable to delete SwimImageURL on Dna Center + // Returning empty diags to delete it on Terraform + return diags +} +func expandRequestSwimImageURLImportSoftwareImageViaURL(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestSoftwareImageManagementSwimImportSoftwareImageViaURL { + request := dnacentersdkgo.RequestSoftwareImageManagementSwimImportSoftwareImageViaURL{} + if v := expandRequestSwimImageURLImportSoftwareImageViaURLItemArray(ctx, key+".", d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSwimImageURLImportSoftwareImageViaURLItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemSoftwareImageManagementSwimImportSoftwareImageViaURL { + request := []dnacentersdkgo.RequestItemSoftwareImageManagementSwimImportSoftwareImageViaURL{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no, _ := range objs { + i := expandRequestSwimImageURLImportSoftwareImageViaURLItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestSwimImageURLImportSoftwareImageViaURLItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemSoftwareImageManagementSwimImportSoftwareImageViaURL { + request := dnacentersdkgo.RequestItemSoftwareImageManagementSwimImportSoftwareImageViaURL{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".application_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".application_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".application_type")))) { + request.ApplicationType = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".image_family")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".image_family")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".image_family")))) { + request.ImageFamily = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".source_url")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".source_url")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".source_url")))) { + request.SourceURL = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".third_party")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".third_party")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".third_party")))) { + request.ThirdParty = interfaceToBoolPtr(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".vendor")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".vendor")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".vendor")))) { + request.Vendor = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchSoftwareImageManagementSwimGetSoftwareImageDetailsURL(m interface{}, queryParams dnacentersdkgo.GetSoftwareImageDetailsQueryParams) (*dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse + var ite *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetails + ite, _, err = client.SoftwareImageManagementSwim.GetSoftwareImageDetails(&queryParams) + if err != nil { + return foundItem, err + } + items := ite.Response + if items == nil { + return foundItem, err + } + itemsCopy := *items + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.Name == queryParams.Name { + var getItem *dnacentersdkgo.ResponseSoftwareImageManagementSwimGetSoftwareImageDetailsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_tag.go b/dnacenter/resource_tag.go index b02c4fd4..d3fcf2c1 100644 --- a/dnacenter/resource_tag.go +++ b/dnacenter/resource_tag.go @@ -328,9 +328,7 @@ func resourceTagRead(ctx context.Context, d *schema.ResourceData, m interface{}) if restyResp2 != nil { log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) } - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetTagByID", err, - "Failure at GetTagByID, unexpected response", "")) + d.SetId("") return diags } @@ -353,9 +351,7 @@ func resourceTagRead(ctx context.Context, d *schema.ResourceData, m interface{}) if restyResp2 != nil { log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) } - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetTagByID", err, - "Failure at GetTagByID, unexpected response", "")) + d.SetId("") return diags } diff --git a/dnacenter/resource_tag_membership.go b/dnacenter/resource_tag_membership.go new file mode 100644 index 00000000..c2a0147d --- /dev/null +++ b/dnacenter/resource_tag_membership.go @@ -0,0 +1,365 @@ +package dnacenter + +import ( + "context" + "reflect" + "time" + + "log" + + dnacentersdkgo "github.com/cisco-en-programmability/dnacenter-go-sdk/v3/sdk" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceTagMembership() *schema.Resource { + return &schema.Resource{ + Description: `It manages create, read and delete operations on Tag member. + + • Adds members to the tag specified by id + • Removes Tag member from the tag specified by id +`, + + CreateContext: resourceTagMembershipCreate, + ReadContext: resourceTagMembershipRead, + UpdateContext: resourceTagMembershipUpdate, + DeleteContext: resourceTagMembershipDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "last_updated": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "item": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + + "instance_uuid": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parameters": &schema.Schema{ + Description: `Array of RequestApplicationPolicyCreateApplicationSet`, + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tag_id": &schema.Schema{ + Description: `id path parameter. Tag ID + `, + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "member_type": &schema.Schema{ + Description: ``, + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "member_id": &schema.Schema{ + Description: `memberId path parameter. TagMember id to be removed from tag + `, + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + }, + }, + }, + } +} + +func resourceTagMembershipCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + log.Printf("[DEBUG] Beginning ApplicationSets Create") + client := m.(*dnacentersdkgo.Client) + + resourceItem := *getResourceItem(d.Get("parameters")) + vID := resourceItem["tag_id"] + vvID := vID.(string) + vMemberId := resourceItem["member_id"] + vvMemberId := vMemberId.(string) + vMemberType := resourceItem["member_type"] + vvMemberType := vMemberType.(string) + var diags diag.Diagnostics + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: AddMembersToTheTag") + + request1 := expandRequestTagMemberCreateAddMembersToTheTag(ctx, "parameters.0", d) + + response1, restyResp1, err := client.Tag.AddMembersToTheTag(vvID, request1) + + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing AddMembersToTheTag", err, + "Failure at AddMembersToTheTag, unexpected response", "")) + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + if response1.Response == nil { + diags = append(diags, diagError( + "Failure when executing CreateApplicationPolicyQueuingProfile", err)) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing AddMembersToTheTag", err)) + return diags + } + } + + } + resourceMap := make(map[string]string) + resourceMap["tag_id"] = vvID + resourceMap["member_type"] = vvMemberType + resourceMap["member_id"] = vvMemberId + d.SetId(joinResourceID(resourceMap)) + return resourceTagMembershipRead(ctx, d, m) +} + +func resourceTagMembershipRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["tag_id"] + vMemberType := resourceMap["member_type"] + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: GetTagMembersByID") + queryParams1 := dnacentersdkgo.GetTagMembersByIDQueryParams{} + queryParams1.MemberType = vMemberType + response1, restyResp1, err := client.Tag.GetTagMembersByID(vID, &queryParams1) + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + d.SetId("") + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + + vItems1 := flattenTagGetTagMembersByIDItems(response1.Response) + if err := d.Set("item", vItems1); err != nil { + diags = append(diags, diagError( + "Failure when setting GetTagMembersByID response", + err)) + return diags + } + return diags + } + return diags +} + +func resourceTagMembershipUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: UpdatesTagMembership") + request1 := expandRequestTagMembershipUpdatesTagMembership(ctx, "parameters.0", d) + + response1, restyResp1, err := client.Tag.UpdatesTagMembership(request1) + + if request1 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request1)) + } + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing UpdatesTagMembership", err, + "Failure at UpdatesTagMembership, unexpected response", "")) + return diags + } + if response1.Response == nil { + diags = append(diags, diagError( + "Failure when executing CreateApplicationPolicyQueuingProfile", err)) + return diags + } + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing UpdatesTagMembership", err)) + return diags + } + } + } + return resourceTagMembershipRead(ctx, d, m) +} + +func resourceTagMembershipDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*dnacentersdkgo.Client) + + var diags diag.Diagnostics + resourceID := d.Id() + resourceMap := separateResourceID(resourceID) + vID := resourceMap["tag_id"] + vMemberID := resourceMap["member_id"] + + selectedMethod := 1 + if selectedMethod == 1 { + log.Printf("[DEBUG] Selected method 1: RemoveTagMember") + + response1, restyResp1, err := client.Tag.RemoveTagMember(vID, vMemberID) + + if err != nil || response1 == nil { + if restyResp1 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp1.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing RemoveTagMember", err, + "Failure at RemoveTagMember, unexpected response", "")) + return diags + } + + log.Printf("[DEBUG] Retrieved response %+v", responseInterfaceToString(*response1)) + taskId := response1.Response.TaskID + log.Printf("[DEBUG] TASKID => %s", taskId) + if taskId != "" { + time.Sleep(5 * time.Second) + response2, restyResp2, err := client.Task.GetTaskByID(taskId) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp2.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetTaskByID", err, + "Failure at GetTaskByID, unexpected response", "")) + return diags + } + if response2.Response != nil && response2.Response.IsError != nil && *response2.Response.IsError { + log.Printf("[DEBUG] Error reason %s", response2.Response.FailureReason) + diags = append(diags, diagError( + "Failure when executing DeleteTagMembership", err)) + return diags + } + } + } + // d.SetId("") is automatically called assuming delete returns no errors, but + // it is added here for explicitness. + d.SetId("") + + return diags +} + +func expandRequestTagMemberCreateAddMembersToTheTag(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestTagAddMembersToTheTag { + request := dnacentersdkgo.RequestTagAddMembersToTheTag{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".member_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".member_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".member_type")))) { + if v2, ok := d.GetOkExists(fixKeyAccess(key + ".member_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".member_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".member_id")))) { + x := make(map[string][]string) + x[v.(string)] = append(x[v.(string)], v2.(string)) + request = x + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestTagMembershipUpdatesTagMembership(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestTagUpdatesTagMembership { + request := dnacentersdkgo.RequestTagUpdatesTagMembership{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".tag_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".tag_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".tag_id")))) { + if v2, ok := d.GetOkExists(fixKeyAccess(key + ".member_id")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".member_id")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".member_id")))) { + x := make(map[string][]string) + x[v2.(string)] = append(x[v2.(string)], v.(string)) + request.MemberToTags = x + } + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".member_type")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".member_type")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".member_type")))) { + request.MemberType = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func searchResourceTagMembership(m interface{}, queryParams dnacentersdkgo.GetApplicationSetsQueryParams) (*dnacentersdkgo.ResponseApplicationPolicyGetApplicationSetsResponse, error) { + client := m.(*dnacentersdkgo.Client) + var err error + var foundItem *dnacentersdkgo.ResponseApplicationPolicyGetApplicationSetsResponse + var ite *dnacentersdkgo.ResponseApplicationPolicyGetApplicationSets + ite, _, err = client.ApplicationPolicy.GetApplicationSets(&queryParams) + + if ite == nil { + return foundItem, err + } + + if ite.Response == nil { + return foundItem, err + } + + items := ite.Response + itemsCopy := *items + for _, item := range itemsCopy { + // Call get by _ method and set value to foundItem and return + if item.Name == queryParams.Name { + var getItem *dnacentersdkgo.ResponseApplicationPolicyGetApplicationSetsResponse + getItem = &item + foundItem = getItem + return foundItem, err + } + } + return foundItem, err +} diff --git a/dnacenter/resource_wireless_dynamic_interface.go b/dnacenter/resource_wireless_dynamic_interface.go index 53628365..9a855d3e 100644 --- a/dnacenter/resource_wireless_dynamic_interface.go +++ b/dnacenter/resource_wireless_dynamic_interface.go @@ -297,9 +297,6 @@ func resourceWirelessDynamicInterfaceDelete(ctx context.Context, d *schema.Resou item, err := searchWirelessGetDynamicInterface(m, queryParams1) var vvInterfaceName string if err != nil || item == nil { - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetDynamicInterface", err, - "Failure at GetDynamicInterface, unexpected response", "")) return diags } diff --git a/dnacenter/resource_wireless_enterprise_ssid.go b/dnacenter/resource_wireless_enterprise_ssid.go index 1593c9ec..b066aef3 100644 --- a/dnacenter/resource_wireless_enterprise_ssid.go +++ b/dnacenter/resource_wireless_enterprise_ssid.go @@ -2,7 +2,9 @@ package dnacenter import ( "context" + "fmt" "reflect" + "strings" "time" "log" @@ -319,6 +321,12 @@ func resourceWirelessEnterpriseSSID() *schema.Resource { }, "traffic_type": &schema.Schema{ Description: `Traffic Type +`, + Type: schema.TypeString, + Optional: true, + }, + "site": &schema.Schema{ + Description: `site name hierarchy (ex: Global/aaa/zzz/...) `, Type: schema.TypeString, Optional: true, @@ -465,6 +473,64 @@ func resourceWirelessEnterpriseSSIDUpdate(ctx context.Context, d *schema.Resourc // NOTE: Consider adding getAllItems and search function to get missing params if d.HasChange("parameters") { + // NOTE: After testing, we consider that this trigger is only applicable for WPA2_PERSONAL security, so we limit it to the trigger being executed only with that type of security. + if d.HasChange("parameters.0.passphrase") && strings.ToLower(item.SecurityLevel) == "wpa2_personal" { + request2 := expandRequestWirelessPskOverridePSKOverride(ctx, "parameters", d) + if request2 != nil { + log.Printf("[DEBUG] request sent => %v", responseInterfaceToString(*request2)) + } + if request2 != nil { + newRequest2 := *request2 + newRequest2[0].SSID = vSSIDName + request2 = &newRequest2 + } + response2, restyResp2, err := client.Wireless.PSKOverride(request2) + if err != nil || response2 == nil { + if restyResp2 != nil { + log.Printf("[DEBUG] resty response for update operation => %v", restyResp2.String()) + diags = append(diags, diagErrorWithAltAndResponse( + "Failure when executing PSKOverride", err, restyResp2.String(), + "Failure at PSKOverride, unexpected response", "")) + return diags + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing PSKOverride", err, + "Failure at PSKOverride, unexpected response", "")) + return diags + } + executionId := response2.ExecutionID + log.Printf("[DEBUG] ExecutionID => %s", executionId) + time.Sleep(5 * time.Second) + response3, restyResp3, err := client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response2 == nil { + if restyResp3 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp3.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetExecutionByID", err, + "Failure at GetExecutionByID, unexpected response", "")) + return diags + } + for response3.Status == "IN_PROGRESS" { + time.Sleep(20 * time.Second) + response3, restyResp3, err = client.Task.GetBusinessAPIExecutionDetails(executionId) + if err != nil || response3 == nil { + if restyResp3 != nil { + log.Printf("[DEBUG] Retrieved error response %s", restyResp3.String()) + } + diags = append(diags, diagErrorWithAlt( + "Failure when executing GetExecutionByID", err, + "Failure at GetExecutionByID, unexpected response", "")) + return diags + } + } + if response3.Status == "FAILURE" { + log.Printf("[DEBUG] Error %s", response3.BapiError) + diags = append(diags, diagError( + "Failure when executing PSKOverride", err)) + return diags + } + } log.Printf("[DEBUG] Name used for update operation %v", queryParams1) request1 := expandRequestWirelessEnterpriseSSIDUpdateEnterpriseSSID(ctx, "parameters.0", d) if request1 != nil { @@ -662,6 +728,60 @@ func expandRequestWirelessEnterpriseSSIDCreateEnterpriseSSID(ctx context.Context return &request } +func expandRequestWirelessPskOverridePSKOverride(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestWirelessPSKOverride { + request := dnacentersdkgo.RequestWirelessPSKOverride{} + if v := expandRequestWirelessPskOverridePSKOverrideItemArray(ctx, key, d); v != nil { + request = *v + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestWirelessPskOverridePSKOverrideItemArray(ctx context.Context, key string, d *schema.ResourceData) *[]dnacentersdkgo.RequestItemWirelessPSKOverride { + request := []dnacentersdkgo.RequestItemWirelessPSKOverride{} + key = fixKeyAccess(key) + o := d.Get(key) + if o == nil { + return nil + } + objs := o.([]interface{}) + if len(objs) == 0 { + return nil + } + for item_no := range objs { + i := expandRequestWirelessPskOverridePSKOverrideItem(ctx, fmt.Sprintf("%s.%d", key, item_no), d) + if i != nil { + request = append(request, *i) + } + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + +func expandRequestWirelessPskOverridePSKOverrideItem(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestItemWirelessPSKOverride { + request := dnacentersdkgo.RequestItemWirelessPSKOverride{} + if v, ok := d.GetOkExists(fixKeyAccess(key + ".ssid_name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".ssid_name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".ssid_name")))) { + request.SSID = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".site")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".site")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".site")))) { + request.Site = interfaceToString(v) + } + if v, ok := d.GetOkExists(fixKeyAccess(key + ".passphrase")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".passphrase")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".passphrase")))) { + request.PassPhrase = interfaceToString(v) + } + if isEmptyValue(reflect.ValueOf(request)) { + return nil + } + + return &request +} + func expandRequestWirelessEnterpriseSSIDUpdateEnterpriseSSID(ctx context.Context, key string, d *schema.ResourceData) *dnacentersdkgo.RequestWirelessUpdateEnterpriseSSID { request := dnacentersdkgo.RequestWirelessUpdateEnterpriseSSID{} if v, ok := d.GetOkExists(fixKeyAccess(key + ".name")); !isEmptyValue(reflect.ValueOf(d.Get(fixKeyAccess(key+".name")))) && (ok || !reflect.DeepEqual(v, d.Get(fixKeyAccess(key+".name")))) { diff --git a/dnacenter/resource_wireless_profile.go b/dnacenter/resource_wireless_profile.go index ae038735..755dd207 100644 --- a/dnacenter/resource_wireless_profile.go +++ b/dnacenter/resource_wireless_profile.go @@ -479,9 +479,6 @@ func resourceWirelessProfileDelete(ctx context.Context, d *schema.ResourceData, item, err := searchWirelessGetWirelessProfile(m, queryParams1) var vvWirelessProfileName string if err != nil || item == nil { - diags = append(diags, diagErrorWithAlt( - "Failure when executing GetWirelessProfile", err, - "Failure at GetWirelessProfile, unexpected response", "")) return diags } diff --git a/dnacenter/utils.go b/dnacenter/utils.go index bff64db5..c2e2b20f 100644 --- a/dnacenter/utils.go +++ b/dnacenter/utils.go @@ -71,8 +71,8 @@ func isEmptyValue(v reflect.Value) bool { } func joinResourceID(result_params map[string]string) string { - var PARAMS_SEPARATOR string = "/" - var PARAM_VALUE_SEPARATOR string = "=" + var PARAMS_SEPARATOR string = "\\" + var PARAM_VALUE_SEPARATOR string = ":=" ID := "" params := []string{} for key, value := range result_params { @@ -86,8 +86,8 @@ func joinResourceID(result_params map[string]string) string { } func separateResourceID(ID string) map[string]string { - var PARAMS_SEPARATOR string = "/" - var PARAM_VALUE_SEPARATOR string = "=" + var PARAMS_SEPARATOR string = "\\" + var PARAM_VALUE_SEPARATOR string = ":=" params := strings.Split(ID, PARAMS_SEPARATOR) sort.Strings(params) // Sort params result_params := make(map[string]string) diff --git a/docs/data-sources/global_credential.md b/docs/data-sources/global_credential.md index 7cfc4528..85e34c1c 100644 --- a/docs/data-sources/global_credential.md +++ b/docs/data-sources/global_credential.md @@ -74,5 +74,12 @@ Read-Only: - **id** (String) - **instance_tenant_id** (String) - **instance_uuid** (String) +- **netconf_port** (String) +- **password** (String) +- **port** (Number) +- **read_community** (String) +- **secure** (String) +- **username** (String) +- **write_community** (String) diff --git a/docs/data-sources/service_provider.md b/docs/data-sources/service_provider.md index 5cc853f7..d887b3ec 100644 --- a/docs/data-sources/service_provider.md +++ b/docs/data-sources/service_provider.md @@ -50,7 +50,7 @@ Read-Only: - **namespace** (String) - **type** (String) - **value** (List of Object) (see [below for nested schema](#nestedobjatt--items--value)) -- **version** (String) +- **version** (Number) ### Nested Schema for `items.value` diff --git a/docs/data-sources/site.md b/docs/data-sources/site.md index 4bcc96e4..9621312c 100644 --- a/docs/data-sources/site.md +++ b/docs/data-sources/site.md @@ -51,7 +51,7 @@ output "dnacenter_site_example" { Read-Only: -- **additional_info** (List of String) +- **additional_info** (List of Object) (see [below for nested schema](#nestedobjatt--items--additional_info)) - **id** (String) - **instance_tenant_id** (String) - **name** (String) @@ -59,4 +59,31 @@ Read-Only: - **site_hierarchy** (String) - **site_name_hierarchy** (String) + +### Nested Schema for `items.additional_info` + +Read-Only: + +- **attributes** (List of Object) (see [below for nested schema](#nestedobjatt--items--additional_info--attributes)) +- **namespace** (String) + + +### Nested Schema for `items.additional_info.attributes` + +Read-Only: + +- **address** (String) +- **address_inherited_from** (String) +- **country** (String) +- **floor_index** (String) +- **height** (String) +- **latitude** (String) +- **length** (String) +- **longitude** (String) +- **offset_x** (String) +- **offset_y** (String) +- **rf_model** (String) +- **type** (String) +- **width** (String) + diff --git a/docs/data-sources/threat_detail.md b/docs/data-sources/threat_detail.md index dfa8a4ed..ebb11d64 100644 --- a/docs/data-sources/threat_detail.md +++ b/docs/data-sources/threat_detail.md @@ -13,21 +13,7 @@ It performs create operation on Devices. - The details for the Rogue and aWIPS threats -## Example Usage -```terraform -data "dnacenter_threat_detail" "example" { - provider = dnacenter - end_time = 1 - is_new_threat = "false" - limit = 1 - offset = 1 - site_id = ["string"] - start_time = 1 - threat_level = ["string"] - threat_type = ["string"] -} -``` ## Schema diff --git a/docs/data-sources/threat_detail_count.md b/docs/data-sources/threat_detail_count.md index d39114ac..24ef1d81 100644 --- a/docs/data-sources/threat_detail_count.md +++ b/docs/data-sources/threat_detail_count.md @@ -13,21 +13,7 @@ It performs create operation on Devices. - The details count for the Rogue and aWIPS threats -## Example Usage - -```terraform -data "dnacenter_threat_detail_count" "example" { - provider = dnacenter - end_time = 1 - is_new_threat = "false" - limit = 1 - offset = 1 - site_id = ["string"] - start_time = 1 - threat_level = ["string"] - threat_type = ["string"] -} -``` + ## Schema diff --git a/docs/data-sources/threat_summary.md b/docs/data-sources/threat_summary.md index 43f47ae2..f2ec8303 100644 --- a/docs/data-sources/threat_summary.md +++ b/docs/data-sources/threat_summary.md @@ -13,18 +13,7 @@ It performs create operation on Devices. - The Threat Summary for the Rogues and aWIPS -## Example Usage - -```terraform -data "dnacenter_threat_summary" "example" { - provider = dnacenter - end_time = 1 - site_id = ["string"] - start_time = 1 - threat_level = ["string"] - threat_type = ["string"] -} -``` + ## Schema diff --git a/docs/index.md b/docs/index.md index 44af9be3..60bf6c86 100644 --- a/docs/index.md +++ b/docs/index.md @@ -51,6 +51,4 @@ provider "dnacenter" { - **debug** (String) Flag for Cisco DNA Center to enable debugging. If not set, it uses the DNAC_DEBUG environment variable; defaults to `false`. - **password** (String, Sensitive) Cisco DNA Center password to authenticate. If not set, it uses the DNAC_PASSWORD environment variable. - **ssl_verify** (String, Sensitive) Flag to enable or disable SSL certificate verification. If not set, it uses the DNAC_SSL_VERIFY environment variable; defaults to `true`. -- **use_api_gateway** (String) Flag to enable or disable the usage of the DNAC's API Gateway. If not set, it uses the DNAC_USE_API_GATEWAY environment variable; defaults to `false`. -- **use_csrf_token** (String) Flag to enable or disable the usage of the X-CSRF-Token header. If not set, it uses the DNAC_USE_CSRF_TOKEN environment varible; defaults to `false`. - **username** (String, Sensitive) Cisco DNA Center username to authenticate. If not set, it uses the DNAC_USERNAME environment variable. diff --git a/docs/resources/configuration_template.md b/docs/resources/configuration_template.md index 4c9b7f74..c8b5592d 100644 --- a/docs/resources/configuration_template.md +++ b/docs/resources/configuration_template.md @@ -3,13 +3,15 @@ page_title: "dnacenter_configuration_template Resource - terraform-provider-dnacenter" subcategory: "" description: |- - It manages read, update and delete operations on Configuration Templates. - API to update a template.Deletes the template by its id + It manages create, read, update and delete operations on Configuration Templates. + API to create a template by project id.API to update a template.Deletes the template by its id --- # dnacenter_configuration_template (Resource) -It manages read, update and delete operations on Configuration Templates. +It manages create, read, update and delete operations on Configuration Templates. + +- API to create a template by project id. - API to update a template. @@ -241,11 +243,12 @@ output "dnacenter_configuration_template_example" { Required: - **name** (String) Name of template -- **template_id** (String) templateId path parameter. templateId(UUID) of template to be deleted +- **project_id** (String) Project UUID Optional: - **author** (String) Author of template +- **comments** (String) Template version comments - **composite** (String) Is it composite template - **containing_templates** (Block List) (see [below for nested schema](#nestedblock--parameters--containing_templates)) - **create_time** (Number) Create time of template @@ -258,7 +261,6 @@ Optional: - **last_update_time** (Number) Update time of template - **latest_version_time** (Number) Latest versioned template time - **parent_template_id** (String) Parent templateID -- **project_id** (String) Project UUID - **project_name** (String) Project name - **rollback_template_content** (String) Rollback template content - **rollback_template_params** (Block List) (see [below for nested schema](#nestedblock--parameters--rollback_template_params)) @@ -267,6 +269,7 @@ Optional: - **software_version** (String) Applicable device software version - **tags** (Block List) (see [below for nested schema](#nestedblock--parameters--tags)) - **template_content** (String) Template content +- **template_id** (String) templateId path parameter. templateId(UUID) of template to be deleted - **template_params** (Block List) (see [below for nested schema](#nestedblock--parameters--template_params)) - **validation_errors** (Block List, Max: 1) (see [below for nested schema](#nestedblock--parameters--validation_errors)) - **version** (String) Current version of template diff --git a/docs/resources/global_credential_cli.md b/docs/resources/global_credential_cli.md new file mode 100644 index 00000000..a01aad1c --- /dev/null +++ b/docs/resources/global_credential_cli.md @@ -0,0 +1,94 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_cli Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and update operations on Discovery. + Updates global CLI credentialsAdds global CLI credentialDeletes global credential for the given ID +--- + +# dnacenter_global_credential_cli (Resource) + +It manages create, read and update operations on Discovery. + +- Updates global CLI credentials + +- Adds global CLI credential + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_cli" "example" { + provider = dnacenter + parameters { + comments = "string" + credential_type = "string" + description = "string" + enable_password = "string" + id = "string" + instance_tenant_id = "string" + instance_uuid = "string" + password = "string" + username = "string" + } +} + +output "dnacenter_global_credential_cli_example" { + value = dnacenter_global_credential_cli.example + sensitive = true +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) Array of RequestDiscoveryCreateCLICredentials (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **enable_password** (String) +- **id** (String) The ID of this resource. +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **password** (String, Sensitive) +- **username** (String) + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credential.example "id:=string" +``` diff --git a/docs/resources/global_credential_http_read.md b/docs/resources/global_credential_http_read.md new file mode 100644 index 00000000..63add3be --- /dev/null +++ b/docs/resources/global_credential_http_read.md @@ -0,0 +1,100 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_http_read Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and update operations on Discovery. + Adds HTTP read credentialsUpdates global HTTP Read credentialDeletes global credential for the given ID +--- + +# dnacenter_global_credential_http_read (Resource) + +It manages create, read and update operations on Discovery. + +- Adds HTTP read credentials + +- Updates global HTTP Read credential + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_http_read" "example" { + provider = dnacenter + parameters { + secure = "false" + username = "string" + password = "string" + port = 1 + description = "string" + comments = "string" + credential_type = "string" + instance_tenant_id = "string" + instance_uuid = "string" + id = "string" + } +} + +output "dnacenter_global_credential_http_read_example" { + value = dnacenter_global_credential_http_read.example + sensitive = true +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) Array of RequestDiscoveryCreateHTTPReadCredentials (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) The ID of this resource. +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **password** (String, Sensitive) +- **port** (Number) +- **secure** (String) +- **username** (String) + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **password** (String) +- **port** (Number) +- **secure** (String) +- **username** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credential_http_read.example "id:=string" +``` diff --git a/docs/resources/global_credential_http_write.md b/docs/resources/global_credential_http_write.md new file mode 100644 index 00000000..bcf43c7c --- /dev/null +++ b/docs/resources/global_credential_http_write.md @@ -0,0 +1,100 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_http_write Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read, update and delete operations on Discovery. + - Adds global HTTP write credentials + Updates global HTTP write credentialsDeletes global credential for the given ID +--- + +# dnacenter_global_credential_http_write (Resource) + +It manages create, read, update and delete operations on Discovery. +- Adds global HTTP write credentials + +- Updates global HTTP write credentials + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_http_write" "example" { + provider = dnacenter + parameters { + secure = "false" + username = "string" + password = "string" + port = 1 + description = "string" + comments = "string" + credential_type = "string" + instance_tenant_id = "string" + instance_uuid = "string" + id = "string" + } +} + +output "dnacenter_global_credential_http_write_example" { + value = dnacenter_global_credential_http_write.example + sensitive = true +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) HttpWriteCredentials (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) The ID of this resource. +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **password** (String, Sensitive) +- **port** (Number) +- **secure** (String) +- **username** (String) + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **password** (String) +- **port** (Number) +- **secure** (String) +- **username** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credentail_http_write.example "id:=string" +``` diff --git a/docs/resources/global_credential_netconf.md b/docs/resources/global_credential_netconf.md new file mode 100644 index 00000000..4d3bc47c --- /dev/null +++ b/docs/resources/global_credential_netconf.md @@ -0,0 +1,94 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_netconf Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and update operations on Discovery. + Updates global netconf credentialsAdds global netconf credentialsDeletes global credential for the given ID +--- + +# dnacenter_global_credential_netconf (Resource) + +It manages create, read and update operations on Discovery. + +- Updates global netconf credentials + +- Adds global netconf credentials + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_netconf" "example" { + provider = dnacenter + parameters { + description = "string" + comments = "string" + credential_type = "string" + netconf_port = "string" + instance_tenant_id = "string" + instance_uuid = "string" + id = "string" + } +} + +output "dnacenter_global_credential_netconf_example" { + value = dnacenter_global_credential_netconf.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) Array of RequestDiscoveryCreateNetconfCredentials (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) The ID of this resource. +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **netconf_port** (String) + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **netconf_port** (String) +- **password** (String) +- **port** (Number) +- **secure** (String) +- **username** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credential.example "id:=string" +``` diff --git a/docs/resources/global_credential_snmpv2_read_community.md b/docs/resources/global_credential_snmpv2_read_community.md new file mode 100644 index 00000000..30b36cf3 --- /dev/null +++ b/docs/resources/global_credential_snmpv2_read_community.md @@ -0,0 +1,92 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_snmpv2_read_community Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and update operations on Discovery. + Updates global SNMP read communityAdds global SNMP read communityDeletes global credential for the given ID +--- + +# dnacenter_global_credential_snmpv2_read_community (Resource) + +It manages create, read and update operations on Discovery. + +- Updates global SNMP read community + +- Adds global SNMP read community + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_snmpv2_read_community" "example" { + provider = dnacenter + parameters { + description = "string" + comments = "string" + credential_type = "string" + read_community = "string" + } +} + +output "dnacenter_global_credential_snmpv2_read_community_example" { + value = dnacenter_global_credential_snmpv2_read_community.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) Array of RequestDiscoveryCreateSNMPReadCommunity (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **comments** (String) Comments to identify the credential +- **credential_type** (String) Credential type to identify the application that uses the credential +- **description** (String) Name/Description of the credential +- **id** (String) The ID of this resource. +- **instance_uuid** (String) +- **read_community** (String) SNMP read community + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **netconf_port** (String) +- **password** (String) +- **port** (Number) +- **read_community** (String) +- **secure** (String) +- **username** (String) +- **write_community** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credential_snmpv2_read_community.example "id:=string" +``` diff --git a/docs/resources/global_credential_snmpv2_write_community.md b/docs/resources/global_credential_snmpv2_write_community.md new file mode 100644 index 00000000..cb940645 --- /dev/null +++ b/docs/resources/global_credential_snmpv2_write_community.md @@ -0,0 +1,92 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_snmpv2_write_community Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and update operations on Discovery. + Adds global SNMP write communityUpdates global SNMP write communityDeletes global credential for the given ID +--- + +# dnacenter_global_credential_snmpv2_write_community (Resource) + +It manages create, read and update operations on Discovery. + +- Adds global SNMP write community + +- Updates global SNMP write community + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_snmpv2_write_community" "example" { + provider = dnacenter + parameters { + description = "string" + comments = "string" + credential_type = "string" + write_community = "string" + } +} + +output "dnacenter_global_credential_snmpv2_write_community_example" { + value = dnacenter_global_credential_snmpv2_read_community.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) Array of RequestDiscoveryCreateSNMPWriteCommunity (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **comments** (String) Comments to identify the credential +- **credential_type** (String) Credential type to identify the application that uses the credential +- **description** (String) Name/Description of the credential +- **id** (String) The ID of this resource. +- **instance_uuid** (String) +- **write_community** (String) SNMP write community + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **netconf_port** (String) +- **password** (String) +- **port** (Number) +- **read_community** (String) +- **secure** (String) +- **username** (String) +- **write_community** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credential_snmpv2_write_community.example "id:=string" +``` diff --git a/docs/resources/global_credential_snmpv3.md b/docs/resources/global_credential_snmpv3.md new file mode 100644 index 00000000..41bc809f --- /dev/null +++ b/docs/resources/global_credential_snmpv3.md @@ -0,0 +1,103 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_global_credential_snmpv3 Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and update operations on Discovery. + Updates global SNMPv3 credentialAdds global SNMPv3 credentialsDeletes global credential for the given ID +--- + +# dnacenter_global_credential_snmpv3 (Resource) + +It manages create, read and update operations on Discovery. + +- Updates global SNMPv3 credential + +- Adds global SNMPv3 credentials + +- Deletes global credential for the given ID + +## Example Usage + +```terraform +resource "dnacenter_global_credential_snmpv3" "example" { + provider = dnacenter + parameters { + auth_password = "string" + auth_type = "string" + comments = "string" + credential_type = "string" + description = "string" + id = "string" + instanceTenantId = "string" + instanceUuid = "string" + privacy_password = "string" + privacy_type = "string" + snmp_mode = "string" + username = "string" + } +} + +output "dnacenter_global_credential_snmpv3_example" { + value = dnacenter_global_credential_snmpv3.example +} +``` + + +## Schema + +### Optional + +- **id** (String) The ID of this resource. +- **parameters** (Block List, Max: 1) Array of RequestDiscoveryCreateSNMPv3Credentials (see [below for nested schema](#nestedblock--parameters)) + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **auth_password** (String) +- **auth_type** (String) +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) The ID of this resource. +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **privacy_password** (String) +- **privacy_type** (String) +- **snmp_mode** (String) +- **username** (String) + + + +### Nested Schema for `item` + +Read-Only: + +- **comments** (String) +- **credential_type** (String) +- **description** (String) +- **id** (String) +- **instance_tenant_id** (String) +- **instance_uuid** (String) +- **netconf_port** (String) +- **password** (String) +- **port** (Number) +- **read_community** (String) +- **secure** (String) +- **username** (String) +- **write_community** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_global_credential_snmpv3.example "id:=string" +``` diff --git a/docs/resources/golden_image.md b/docs/resources/golden_image.md new file mode 100644 index 00000000..a1f8d3dd --- /dev/null +++ b/docs/resources/golden_image.md @@ -0,0 +1,79 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_golden_image Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and delete operations on Software Image Management (SWIM). + Golden Tag image. Set siteId as -1 for Global site.Remove golden tag. Set siteId as -1 for Global site. +--- + +# dnacenter_golden_image (Resource) + +It manages create, read and delete operations on Software Image Management (SWIM). + +- Golden Tag image. Set siteId as -1 for Global site. + +- Remove golden tag. Set siteId as -1 for Global site. + +## Example Usage + +```terraform +resource "dnacenter_golden_image" "example" { + provider = dnacenter + parameters { + image_id = "string" + site_id = "string" + device_role = "string" + device_family_identifier = "string" + } +} + +output "dnacenter_golden_image_example" { + value = dnacenter_golden_image.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **device_family_identifier** (String) Device Family Identifier e.g. : 277696480-283933147, 277696480 +- **device_role** (String) Device Role. Permissible Values : ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION and CORE. +- **image_id** (String) imageId in uuid format. +- **site_id** (String) SiteId in uuid format. For Global Site "-1" to be used. + + + +### Nested Schema for `item` + +Read-Only: + +- **device_role** (String) +- **inherited_site_id** (String) +- **inherited_site_name** (String) +- **tagged_golden** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_golden_image.example "id:=string" +``` diff --git a/docs/resources/license_device.md b/docs/resources/license_device.md new file mode 100644 index 00000000..6080027f --- /dev/null +++ b/docs/resources/license_device.md @@ -0,0 +1,54 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_license_device Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and delete operations on Licenses. +--- + +# dnacenter_license_device (Resource) + +It manages create, read and delete operations on Licenses. + + + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Required: + +- **smart_account_id** (String) smart_account_id path parameter. Id of smart account +- **virtual_account_name** (String) virtual_account_name path parameter. Name of target virtual account + +Optional: + +- **device_uuids** (List of String) Comma separated device ids + + + +### Nested Schema for `item` + +Read-Only: + +- **domain** (String) +- **id** (String) +- **is_active_smart_account** (String) +- **name** (String) + + diff --git a/docs/resources/network_device_list.md b/docs/resources/network_device_list.md index c71798db..a4850992 100644 --- a/docs/resources/network_device_list.md +++ b/docs/resources/network_device_list.md @@ -53,6 +53,7 @@ resource "dnacenter_network_device_list" "example" { new_mgmt_ip_address = "string" } user_name = "string" + role = "string" } } @@ -97,6 +98,8 @@ Optional: - **meraki_org_id** (List of String) - **netconf_port** (String) - **password** (String, Sensitive) +- **role** (String) +- **role_source** (String) - **serial_number** (String) - **snmp_auth_passphrase** (String) - **snmp_auth_protocol** (String) diff --git a/docs/resources/nfv_provision_detail.md b/docs/resources/nfv_provision_detail.md new file mode 100644 index 00000000..3a033212 --- /dev/null +++ b/docs/resources/nfv_provision_detail.md @@ -0,0 +1,40 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_nfv_provision_detail Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create and read operations on Site Design. + Checks the provisioning detail of an ENCS device including log information. +--- + +# dnacenter_nfv_provision_detail (Resource) + +It manages create and read operations on Site Design. + +- Checks the provisioning detail of an ENCS device including log information. + + + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **device_ip** (String) Device Ip + + diff --git a/docs/resources/path_trace.md b/docs/resources/path_trace.md new file mode 100644 index 00000000..0d2fe3a4 --- /dev/null +++ b/docs/resources/path_trace.md @@ -0,0 +1,1472 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_path_trace Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and delete operations on Path Trace. + Initiates a new flow analysis with periodic refresh and stat collection options. Returns a request id and a task id to + get results and follow progress.Deletes a flow analysis request by its id +--- + +# dnacenter_path_trace (Resource) + +It manages create, read and delete operations on Path Trace. + +- Initiates a new flow analysis with periodic refresh and stat collection options. Returns a request id and a task id to +get results and follow progress. + +- Deletes a flow analysis request by its id + +## Example Usage + +```terraform +resource "dnacenter_path_trace" "example" { + provider = dnacenter + parameters { + + control_path = "false" + dest_ip = "string" + dest_port = "string" + flow_analysis_id = "string" + inclusions = ["string"] + periodic_refresh = "false" + protocol = "string" + source_ip = "string" + source_port = "string" + } +} + +output "dnacenter_path_trace_example" { + value = dnacenter_path_trace.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **control_path** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **flow_analysis_id** (String) flowAnalysisId path parameter. Flow analysis request id +- **inclusions** (List of String) +- **periodic_refresh** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) + + + +### Nested Schema for `item` + +Read-Only: + +- **detailed_status** (List of Object) (see [below for nested schema](#nestedobjatt--item--detailed_status)) +- **last_update** (String) +- **network_elements** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements)) +- **network_elements_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info)) +- **properties** (List of String) +- **request** (List of Object) (see [below for nested schema](#nestedobjatt--item--request)) + + +### Nested Schema for `item.detailed_status` + +Read-Only: + +- **acl_trace_calculation** (String) +- **acl_trace_calculation_failure_reason** (String) + + + +### Nested Schema for `item.network_elements` + +Read-Only: + +- **accuracy_list** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--accuracy_list)) +- **detailed_status** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--detailed_status)) +- **device_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--device_statistics)) +- **device_stats_collection** (String) +- **device_stats_collection_failure_reason** (String) +- **egress_physical_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface)) +- **egress_virtual_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface)) +- **flex_connect** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect)) +- **id** (String) +- **ingress_physical_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface)) +- **ingress_virtual_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface)) +- **ip** (String) +- **link_information_source** (String) +- **name** (String) +- **perf_mon_collection** (String) +- **perf_mon_collection_failure_reason** (String) +- **perf_mon_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--perf_mon_statistics)) +- **role** (String) +- **ssid** (String) +- **tunnels** (List of String) +- **type** (String) +- **wlan_id** (String) + + +### Nested Schema for `item.network_elements.accuracy_list` + +Read-Only: + +- **percent** (Number) +- **reason** (String) + + + +### Nested Schema for `item.network_elements.detailed_status` + +Read-Only: + +- **acl_trace_calculation** (String) +- **acl_trace_calculation_failure_reason** (String) + + + +### Nested Schema for `item.network_elements.device_statistics` + +Read-Only: + +- **cpu_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--device_statistics--cpu_statistics)) +- **memory_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--device_statistics--memory_statistics)) + + +### Nested Schema for `item.network_elements.device_statistics.memory_statistics` + +Read-Only: + +- **five_min_usage_in_percentage** (Number) +- **five_secs_usage_in_percentage** (Number) +- **one_min_usage_in_percentage** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements.device_statistics.memory_statistics` + +Read-Only: + +- **memory_usage** (Number) +- **refreshed_at** (Number) +- **total_memory** (Number) + + + + +### Nested Schema for `item.network_elements.egress_physical_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--vrf_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--vrf_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--vrf_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_physical_interface--vrf_name--vxlan_info)) + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements.egress_physical_interface.vrf_name` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + +### Nested Schema for `item.network_elements.egress_virtual_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--vrf_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--vrf_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--vrf_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--egress_virtual_interface--vrf_name--vxlan_info)) + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements.egress_virtual_interface.vrf_name` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + +### Nested Schema for `item.network_elements.flex_connect` + +Read-Only: + +- **authentication** (String) +- **data_switching** (String) +- **egress_acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--egress_acl_analysis)) +- **ingress_acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--ingress_acl_analysis)) +- **wireless_lan_controller_id** (String) +- **wireless_lan_controller_name** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--wireless_lan_controller_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--wireless_lan_controller_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--wireless_lan_controller_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--wireless_lan_controller_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--wireless_lan_controller_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--flex_connect--wireless_lan_controller_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements.flex_connect.wireless_lan_controller_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + + +### Nested Schema for `item.network_elements.ingress_physical_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--vrf_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--vrf_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--vrf_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_physical_interface--vrf_name--vxlan_info)) + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements.ingress_physical_interface.vrf_name` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + +### Nested Schema for `item.network_elements.ingress_virtual_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--vrf_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--vrf_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--vrf_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements--ingress_virtual_interface--vrf_name--vxlan_info)) + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements.ingress_virtual_interface.vrf_name` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + +### Nested Schema for `item.network_elements.perf_mon_statistics` + +Read-Only: + +- **byte_rate** (Number) +- **dest_ip_address** (String) +- **dest_port** (String) +- **input_interface** (String) +- **ipv4_dsc_p** (String) +- **ipv4_ttl** (Number) +- **output_interface** (String) +- **packet_bytes** (Number) +- **packet_count** (Number) +- **packet_loss** (Number) +- **packet_loss_percentage** (Number) +- **protocol** (String) +- **refreshed_at** (Number) +- **rtp_jitter_max** (Number) +- **rtp_jitter_mean** (Number) +- **rtp_jitter_min** (Number) +- **source_ip_address** (String) +- **source_port** (String) + + + + +### Nested Schema for `item.network_elements_info` + +Read-Only: + +- **accuracy_list** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--accuracy_list)) +- **detailed_status** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--detailed_status)) +- **device_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--device_statistics)) +- **device_stats_collection** (String) +- **device_stats_collection_failure_reason** (String) +- **egress_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface)) +- **flex_connect** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect)) +- **id** (String) +- **ingress_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface)) +- **ip** (String) +- **link_information_source** (String) +- **name** (String) +- **perf_mon_collection** (String) +- **perf_mon_collection_failure_reason** (String) +- **perf_monitor_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--perf_monitor_statistics)) +- **role** (String) +- **ssid** (String) +- **tunnels** (List of String) +- **type** (String) +- **wlan_id** (String) + + +### Nested Schema for `item.network_elements_info.accuracy_list` + +Read-Only: + +- **percent** (Number) +- **reason** (String) + + + +### Nested Schema for `item.network_elements_info.detailed_status` + +Read-Only: + +- **acl_trace_calculation** (String) +- **acl_trace_calculation_failure_reason** (String) + + + +### Nested Schema for `item.network_elements_info.device_statistics` + +Read-Only: + +- **cpu_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--device_statistics--cpu_statistics)) +- **memory_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--device_statistics--memory_statistics)) + + +### Nested Schema for `item.network_elements_info.device_statistics.memory_statistics` + +Read-Only: + +- **five_min_usage_in_percentage** (Number) +- **five_secs_usage_in_percentage** (Number) +- **one_min_usage_in_percentage** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements_info.device_statistics.memory_statistics` + +Read-Only: + +- **memory_usage** (Number) +- **refreshed_at** (Number) +- **total_memory** (Number) + + + + +### Nested Schema for `item.network_elements_info.egress_interface` + +Read-Only: + +- **physical_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--physical_interface)) +- **virtual_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface)) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis.result` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis--result--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis.result.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis--result--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis.result.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.interface_statistics` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.path_overlay_info` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--path_overlay_info--vxlan_info)) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.path_overlay_info.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.qos_statistics` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis.result` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis--result--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis.result.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--acl_analysis--result--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.acl_analysis.result.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.interface_statistics` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.path_overlay_info` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--egress_interface--virtual_interface--path_overlay_info--vxlan_info)) + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.path_overlay_info.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements_info.egress_interface.virtual_interface.qos_statistics` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + + +### Nested Schema for `item.network_elements_info.flex_connect` + +Read-Only: + +- **authentication** (String) +- **data_switching** (String) +- **egress_acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--egress_acl_analysis)) +- **ingress_acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--ingress_acl_analysis)) +- **wireless_lan_controller_id** (String) +- **wireless_lan_controller_name** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--wireless_lan_controller_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--wireless_lan_controller_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--wireless_lan_controller_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--wireless_lan_controller_name--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name.matching_aces` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--wireless_lan_controller_name--matching_aces--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name.matching_aces.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--flex_connect--wireless_lan_controller_name--matching_aces--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements_info.flex_connect.wireless_lan_controller_name.matching_aces.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + + +### Nested Schema for `item.network_elements_info.ingress_interface` + +Read-Only: + +- **physical_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--physical_interface)) +- **virtual_interface** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface)) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis.result` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis--result--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis.result.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis--result--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis.result.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.interface_statistics` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.path_overlay_info` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--path_overlay_info--vxlan_info)) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.path_overlay_info.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.qos_statistics` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface` + +Read-Only: + +- **acl_analysis** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis)) +- **id** (String) +- **interface_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--interface_statistics)) +- **interface_stats_collection** (String) +- **interface_stats_collection_failure_reason** (String) +- **name** (String) +- **path_overlay_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--path_overlay_info)) +- **qos_statistics** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--qos_statistics)) +- **qos_stats_collection** (String) +- **qos_stats_collection_failure_reason** (String) +- **used_vlan** (String) +- **vrf_name** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis` + +Read-Only: + +- **acl_name** (String) +- **matching_aces** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis--matching_aces)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis.result` + +Read-Only: + +- **ace** (String) +- **matching_ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis--result--matching_ports)) +- **result** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis.result.result` + +Read-Only: + +- **ports** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--acl_analysis--result--result--ports)) +- **protocol** (String) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.acl_analysis.result.result.protocol` + +Read-Only: + +- **dest_ports** (List of String) +- **source_ports** (List of String) + + + + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.interface_statistics` + +Read-Only: + +- **admin_status** (String) +- **input_packets** (Number) +- **input_queue_count** (Number) +- **input_queue_drops** (Number) +- **input_queue_flushes** (Number) +- **input_queue_max_depth** (Number) +- **input_ratebps** (Number) +- **operational_status** (String) +- **output_drop** (Number) +- **output_packets** (Number) +- **output_queue_count** (Number) +- **output_queue_depth** (Number) +- **output_ratebps** (Number) +- **refreshed_at** (Number) + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.path_overlay_info` + +Read-Only: + +- **control_plane** (String) +- **data_packet_encapsulation** (String) +- **dest_ip** (String) +- **dest_port** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **vxlan_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--network_elements_info--ingress_interface--virtual_interface--path_overlay_info--vxlan_info)) + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.path_overlay_info.vxlan_info` + +Read-Only: + +- **dscp** (String) +- **vnid** (String) + + + + +### Nested Schema for `item.network_elements_info.ingress_interface.virtual_interface.qos_statistics` + +Read-Only: + +- **class_map_name** (String) +- **drop_rate** (Number) +- **num_bytes** (Number) +- **num_packets** (Number) +- **offered_rate** (Number) +- **queue_bandwidthbps** (String) +- **queue_depth** (Number) +- **queue_no_buffer_drops** (Number) +- **queue_total_drops** (Number) +- **refreshed_at** (Number) + + + + + +### Nested Schema for `item.network_elements_info.perf_monitor_statistics` + +Read-Only: + +- **byte_rate** (Number) +- **dest_ip_address** (String) +- **dest_port** (String) +- **input_interface** (String) +- **ipv4_dsc_p** (String) +- **ipv4_ttl** (Number) +- **output_interface** (String) +- **packet_bytes** (Number) +- **packet_count** (Number) +- **packet_loss** (Number) +- **packet_loss_percentage** (Number) +- **protocol** (String) +- **refreshed_at** (Number) +- **rtp_jitter_max** (Number) +- **rtp_jitter_mean** (Number) +- **rtp_jitter_min** (Number) +- **source_ip_address** (String) +- **source_port** (String) + + + + +### Nested Schema for `item.request` + +Read-Only: + +- **control_path** (String) +- **create_time** (Number) +- **dest_ip** (String) +- **dest_port** (String) +- **failure_reason** (String) +- **id** (String) +- **inclusions** (List of String) +- **last_update_time** (Number) +- **periodic_refresh** (String) +- **protocol** (String) +- **source_ip** (String) +- **source_port** (String) +- **status** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_path_trace.example "flow_analysis_id:=string" +``` diff --git a/docs/resources/sensor.md b/docs/resources/sensor.md new file mode 100644 index 00000000..2473048c --- /dev/null +++ b/docs/resources/sensor.md @@ -0,0 +1,119 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_sensor Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and delete operations on Sensors. + Intent API to create a SENSOR test template with a new SSID, existing SSID, or both new and existing SSIDIntent API to delete an existing SENSOR test template +--- + +# dnacenter_sensor (Resource) + +It manages create, read and delete operations on Sensors. + +- Intent API to create a SENSOR test template with a new SSID, existing SSID, or both new and existing SSID + +- Intent API to delete an existing SENSOR test template + + + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **ap_coverage** (Block List) (see [below for nested schema](#nestedblock--parameters--ap_coverage)) +- **connection** (String) Connection +- **model_version** (Number) Model Version +- **name** (String) Name +- **ssids** (Block List) (see [below for nested schema](#nestedblock--parameters--ssids)) + + +### Nested Schema for `parameters.ap_coverage` + +Optional: + +- **bands** (String) Bands +- **number_of_aps_to_test** (String) Number Of Aps To Test +- **rssi_threshold** (String) Rssi Threshold + + + +### Nested Schema for `parameters.ssids` + +Optional: + +- **auth_type** (String) Auth Type +- **categories** (List of String) Categories +- **profile_name** (String) Profile Name +- **psk** (String) Psk +- **qos_policy** (String) Qos Policy +- **ssid** (String) Ssid +- **tests** (Block List) (see [below for nested schema](#nestedblock--parameters--ssids--tests)) +- **third_party** (Block List, Max: 1) (see [below for nested schema](#nestedblock--parameters--ssids--third_party)) + + +### Nested Schema for `parameters.ssids.tests` + +Optional: + +- **config** (List of String) Config +- **name** (String) Name + + + +### Nested Schema for `parameters.ssids.third_party` + +Optional: + +- **selected** (String) Selected + + + + + +### Nested Schema for `item` + +Read-Only: + +- **backhaul_type** (String) +- **ethernet_mac_address** (String) +- **ip_address** (String) +- **is_led_enabled** (String) +- **last_seen** (Number) +- **location** (String) +- **name** (String) +- **radio_mac_address** (String) +- **serial_number** (String) +- **ssh_config** (List of Object) (see [below for nested schema](#nestedobjatt--item--ssh_config)) +- **status** (String) +- **type** (String) +- **version** (String) + + +### Nested Schema for `item.ssh_config` + +Read-Only: + +- **enable_password** (String) +- **ssh_password** (String) +- **ssh_state** (String) +- **ssh_user_name** (String) + + diff --git a/docs/resources/service_provider.md b/docs/resources/service_provider.md new file mode 100644 index 00000000..3ac2548b --- /dev/null +++ b/docs/resources/service_provider.md @@ -0,0 +1,115 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_service_provider Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read, update and delete operations on Network Settings. + API to create service provider profile(QOS).API to update SP profile.API to delete Service Provider profile (QoS). +--- + +# dnacenter_service_provider (Resource) + +It manages create, read, update and delete operations on Network Settings. + +- API to create service provider profile(QOS). + +- API to update SP profile. + +- API to delete Service Provider profile (QoS). + +## Example Usage + +```terraform +resource "dnacenter_service_provider" "example" { + provider = dnacenter + parameters { + + settings { + qos { + profile_name = "Test_tf_new" + model = "8-class-model" + wan_provider = "test1-provider" + } + } + } +} + +output "dnacenter_service_provider_example" { + value = dnacenter_service_provider.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Optional: + +- **settings** (Block List) (see [below for nested schema](#nestedblock--parameters--settings)) + + +### Nested Schema for `parameters.settings` + +Optional: + +- **qos** (Block List) (see [below for nested schema](#nestedblock--parameters--settings--qos)) + + +### Nested Schema for `parameters.settings.qos` + +Optional: + +- **model** (String) Model +- **profile_name** (String) Profile Name +- **wan_provider** (String) Wan Provider + + + + + +### Nested Schema for `item` + +Read-Only: + +- **group_uuid** (String) +- **inherited_group_name** (String) +- **inherited_group_uuid** (String) +- **instance_type** (String) +- **instance_uuid** (String) +- **key** (String) +- **namespace** (String) +- **type** (String) +- **value** (List of Object) (see [below for nested schema](#nestedobjatt--item--value)) +- **version** (Number) + + +### Nested Schema for `item.value` + +Read-Only: + +- **sla_profile_name** (String) +- **sp_profile_name** (String) +- **wan_provider** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_service_provicer.example "id:=string" +``` diff --git a/docs/resources/site.md b/docs/resources/site.md new file mode 100644 index 00000000..332fd4d4 --- /dev/null +++ b/docs/resources/site.md @@ -0,0 +1,175 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_site Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read, update and delete operations on Sites. + Creates site with area/building/floor with specified hierarchy.Update site area/building/floor with specified hierarchy and new valuesDelete site with area/building/floor by siteId. +--- + +# dnacenter_site (Resource) + +It manages create, read, update and delete operations on Sites. + +- Creates site with area/building/floor with specified hierarchy. + +- Update site area/building/floor with specified hierarchy and new values + +- Delete site with area/building/floor by siteId. + +## Example Usage + +```terraform +resource "dnacenter_site" "example" { + provider = dnacenter + parameters { + site { + area { + name = "string" + parent_name = "string" + } + building { + name = "string" + address = "string" + parent_name = "string" + latitude = 1 + longitude = 1 + } + floor { + height = 1 + length = 1 + name = "string" + parent_name = "string" + rf_model = "string" + width = 1 + } + } + type = "string" + } +} + +output "dnacenter_site_example" { + value = dnacenter_site.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Required: + +- **type** (String) Type of site to create (eg: area, building, floor) + +Optional: + +- **site** (Block List, Max: 1) (see [below for nested schema](#nestedblock--parameters--site)) +- **site_id** (String) siteId path parameter. Site id to which site details to be updated. + + +### Nested Schema for `parameters.site` + +Optional: + +- **area** (Block List, Max: 1) (see [below for nested schema](#nestedblock--parameters--site--area)) +- **building** (Block List, Max: 1) (see [below for nested schema](#nestedblock--parameters--site--building)) +- **floor** (Block List, Max: 1) (see [below for nested schema](#nestedblock--parameters--site--floor)) + + +### Nested Schema for `parameters.site.area` + +Optional: + +- **name** (String) Name of the area (eg: Area1) +- **parent_name** (String) Parent name of the area to be created + + + +### Nested Schema for `parameters.site.building` + +Optional: + +- **address** (String) Address of the building to be created +- **latitude** (Number) Latitude coordinate of the building (eg:37.338) +- **longitude** (Number) Longitude coordinate of the building (eg:-121.832) +- **name** (String) Name of the building (eg: building1) +- **parent_name** (String) Parent name of building to be created + + + +### Nested Schema for `parameters.site.floor` + +Optional: + +- **height** (Number) Height of the floor (eg: 15) +- **length** (Number) Length of the floor (eg: 100) +- **name** (String) Name of the floor (eg:floor-1) +- **parent_name** (String) Parent name of the floor to be created +- **rf_model** (String) Type of floor. Allowed values are 'Cubes And Walled Offices', 'Drywall Office Only', 'Indoor High Ceiling', 'Outdoor Open Space'. +- **width** (Number) Width of the floor (eg:100) + + + + + +### Nested Schema for `item` + +Read-Only: + +- **additional_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--additional_info)) +- **id** (String) +- **instance_tenant_id** (String) +- **name** (String) +- **parent_id** (String) +- **site_hierarchy** (String) +- **site_name_hierarchy** (String) + + +### Nested Schema for `item.additional_info` + +Read-Only: + +- **attributes** (List of Object) (see [below for nested schema](#nestedobjatt--item--additional_info--attributes)) +- **namespace** (String) + + +### Nested Schema for `item.additional_info.attributes` + +Read-Only: + +- **address** (String) +- **address_inherited_from** (String) +- **country** (String) +- **floor_index** (String) +- **height** (String) +- **latitude** (String) +- **length** (String) +- **longitude** (String) +- **offset_x** (String) +- **offset_y** (String) +- **rf_model** (String) +- **type** (String) +- **width** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_site.example "id:=string" +``` diff --git a/docs/resources/swim_image_file.md b/docs/resources/swim_image_file.md new file mode 100644 index 00000000..492e0c35 --- /dev/null +++ b/docs/resources/swim_image_file.md @@ -0,0 +1,105 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_swim_image_file Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create and read operations on Software Image Management (SWIM). + Fetches a software image from local file system and uploads to DNA Center. Supported software image files extensions + are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. + Upload the file to the file form data field +--- + +# dnacenter_swim_image_file (Resource) + +It manages create and read operations on Software Image Management (SWIM). + +- Fetches a software image from local file system and uploads to DNA Center. Supported software image files extensions +are bin, img, tar, smu, pie, aes, iso, ova, tar_gz and qcow2. +Upload the file to the **file** form data field + + + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Required: + +- **file_name** (String) File name. +- **file_path** (String) File absolute path. + +Optional: + +- **is_third_party** (Boolean) isThirdParty query parameter. Third party Image check +- **third_party_application_type** (String) thirdPartyApplicationType query parameter. Third Party Application Type +- **third_party_image_family** (String) thirdPartyImageFamily query parameter. Third Party image family +- **third_party_vendor** (String) thirdPartyVendor query parameter. Third Party Vendor + + + +### Nested Schema for `item` + +Read-Only: + +- **applicable_devices_for_image** (List of Object) (see [below for nested schema](#nestedobjatt--item--applicable_devices_for_image)) +- **application_type** (String) +- **created_time** (String) +- **extended_attributes** (String) +- **family** (String) +- **feature** (String) +- **file_service_id** (String) +- **file_size** (String) +- **image_integrity_status** (String) +- **image_name** (String) +- **image_series** (List of String) +- **image_source** (String) +- **image_type** (String) +- **image_uuid** (String) +- **import_source_type** (String) +- **is_tagged_golden** (String) +- **md5_checksum** (String) +- **name** (String) +- **profile_info** (List of Object) (see [below for nested schema](#nestedobjatt--item--profile_info)) +- **sha_check_sum** (String) +- **vendor** (String) +- **version** (String) + + +### Nested Schema for `item.applicable_devices_for_image` + +Read-Only: + +- **mdf_id** (String) +- **product_id** (List of String) +- **product_name** (String) + + + +### Nested Schema for `item.profile_info` + +Read-Only: + +- **description** (String) +- **extended_attributes** (String) +- **memory** (Number) +- **product_type** (String) +- **profile_name** (String) +- **shares** (Number) +- **v_cpu** (Number) + + diff --git a/docs/resources/tag_membership.md b/docs/resources/tag_membership.md new file mode 100644 index 00000000..e4a89311 --- /dev/null +++ b/docs/resources/tag_membership.md @@ -0,0 +1,75 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "dnacenter_tag_membership Resource - terraform-provider-dnacenter" +subcategory: "" +description: |- + It manages create, read and delete operations on Tag member. + • Adds members to the tag specified by id + • Removes Tag member from the tag specified by id +--- + +# dnacenter_tag_membership (Resource) + +It manages create, read and delete operations on Tag member. + + • Adds members to the tag specified by id + • Removes Tag member from the tag specified by id + +## Example Usage + +```terraform +resource "dnacenter_tag_membership" "example" { + provider = dnacenter + parameters { + tag_id = "string" + member_type = "string" + member_id = "string" + + } +} + +output "dnacenter_tag_membership_example" { + value = dnacenter_tag_membership.example +} +``` + + +## Schema + +### Required + +- **parameters** (Block List, Min: 1, Max: 1) Array of RequestApplicationPolicyCreateApplicationSet (see [below for nested schema](#nestedblock--parameters)) + +### Optional + +- **id** (String) The ID of this resource. + +### Read-Only + +- **item** (List of Object) (see [below for nested schema](#nestedatt--item)) +- **last_updated** (String) + + +### Nested Schema for `parameters` + +Required: + +- **member_id** (String) memberId path parameter. TagMember id to be removed from tag +- **member_type** (String) +- **tag_id** (String) id path parameter. Tag ID + + + +### Nested Schema for `item` + +Read-Only: + +- **instance_uuid** (String) + +## Import + +Import is supported using the following syntax: + +```shell +terraform import dnacenter_tag_membership.example "id:=string" +``` diff --git a/docs/resources/wireless_enterprise_ssid.md b/docs/resources/wireless_enterprise_ssid.md index de4c23f4..2cd7d62b 100644 --- a/docs/resources/wireless_enterprise_ssid.md +++ b/docs/resources/wireless_enterprise_ssid.md @@ -43,6 +43,7 @@ resource "dnacenter_wireless_enterprise_ssid" "example" { session_time_out = 1 ssid_name = "string" traffic_type = "string" + site = "string" } } @@ -92,6 +93,7 @@ Optional: - **radio_policy** (String) Radio Policy. Allowed values are 'Dual band operation (2.4GHz and 5GHz)', 'Dual band operation with band select', '5GHz only', '2.4GHz only'. - **security_level** (String) Security Level - **session_time_out** (Number) Session Time Out +- **site** (String) site name hierarchy (ex: Global/aaa/zzz/...) - **ssid_name** (String) ssidName path parameter. Enter the SSID name to be deleted - **traffic_type** (String) Traffic Type diff --git a/examples/data-sources/dnacenter_threat_detail/data-source.tf b/examples/data-sources/dnacenter_threat_detail/data-source.tf deleted file mode 100644 index 06f26bb3..00000000 --- a/examples/data-sources/dnacenter_threat_detail/data-source.tf +++ /dev/null @@ -1,12 +0,0 @@ - -data "dnacenter_threat_detail" "example" { - provider = dnacenter - end_time = 1 - is_new_threat = "false" - limit = 1 - offset = 1 - site_id = ["string"] - start_time = 1 - threat_level = ["string"] - threat_type = ["string"] -} \ No newline at end of file diff --git a/examples/data-sources/dnacenter_threat_detail_count/data-source.tf b/examples/data-sources/dnacenter_threat_detail_count/data-source.tf deleted file mode 100644 index 0d36a6d4..00000000 --- a/examples/data-sources/dnacenter_threat_detail_count/data-source.tf +++ /dev/null @@ -1,12 +0,0 @@ - -data "dnacenter_threat_detail_count" "example" { - provider = dnacenter - end_time = 1 - is_new_threat = "false" - limit = 1 - offset = 1 - site_id = ["string"] - start_time = 1 - threat_level = ["string"] - threat_type = ["string"] -} \ No newline at end of file diff --git a/examples/data-sources/dnacenter_threat_summary/data-source.tf b/examples/data-sources/dnacenter_threat_summary/data-source.tf deleted file mode 100644 index 7261543a..00000000 --- a/examples/data-sources/dnacenter_threat_summary/data-source.tf +++ /dev/null @@ -1,9 +0,0 @@ - -data "dnacenter_threat_summary" "example" { - provider = dnacenter - end_time = 1 - site_id = ["string"] - start_time = 1 - threat_level = ["string"] - threat_type = ["string"] -} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_cli/import.sh b/examples/resources/dnacenter_global_credential_cli/import.sh new file mode 100644 index 00000000..4606df05 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_cli/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_cli/resource.tf b/examples/resources/dnacenter_global_credential_cli/resource.tf new file mode 100644 index 00000000..91d8d012 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_cli/resource.tf @@ -0,0 +1,20 @@ + +resource "dnacenter_global_credential_cli" "example" { + provider = dnacenter + parameters { + comments = "string" + credential_type = "string" + description = "string" + enable_password = "string" + id = "string" + instance_tenant_id = "string" + instance_uuid = "string" + password = "string" + username = "string" + } +} + +output "dnacenter_global_credential_cli_example" { + value = dnacenter_global_credential_cli.example + sensitive = true +} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_http_read/import.sh b/examples/resources/dnacenter_global_credential_http_read/import.sh new file mode 100644 index 00000000..fb24ac09 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_http_read/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_http_read.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_http_read/resource.tf b/examples/resources/dnacenter_global_credential_http_read/resource.tf new file mode 100644 index 00000000..1907dd27 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_http_read/resource.tf @@ -0,0 +1,21 @@ + +resource "dnacenter_global_credential_http_read" "example" { + provider = dnacenter + parameters { + secure = "false" + username = "string" + password = "string" + port = 1 + description = "string" + comments = "string" + credential_type = "string" + instance_tenant_id = "string" + instance_uuid = "string" + id = "string" + } +} + +output "dnacenter_global_credential_http_read_example" { + value = dnacenter_global_credential_http_read.example + sensitive = true +} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_http_write/import.sh b/examples/resources/dnacenter_global_credential_http_write/import.sh new file mode 100644 index 00000000..69e7c1fb --- /dev/null +++ b/examples/resources/dnacenter_global_credential_http_write/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credentail_http_write.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_http_write/resource.tf b/examples/resources/dnacenter_global_credential_http_write/resource.tf new file mode 100644 index 00000000..8b8ac2af --- /dev/null +++ b/examples/resources/dnacenter_global_credential_http_write/resource.tf @@ -0,0 +1,21 @@ + +resource "dnacenter_global_credential_http_write" "example" { + provider = dnacenter + parameters { + secure = "false" + username = "string" + password = "string" + port = 1 + description = "string" + comments = "string" + credential_type = "string" + instance_tenant_id = "string" + instance_uuid = "string" + id = "string" + } +} + +output "dnacenter_global_credential_http_write_example" { + value = dnacenter_global_credential_http_write.example + sensitive = true +} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_netconf/import.sh b/examples/resources/dnacenter_global_credential_netconf/import.sh new file mode 100644 index 00000000..4606df05 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_netconf/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_netconf/resource.tf b/examples/resources/dnacenter_global_credential_netconf/resource.tf new file mode 100644 index 00000000..32daa13d --- /dev/null +++ b/examples/resources/dnacenter_global_credential_netconf/resource.tf @@ -0,0 +1,17 @@ + +resource "dnacenter_global_credential_netconf" "example" { + provider = dnacenter + parameters { + description = "string" + comments = "string" + credential_type = "string" + netconf_port = "string" + instance_tenant_id = "string" + instance_uuid = "string" + id = "string" + } +} + +output "dnacenter_global_credential_netconf_example" { + value = dnacenter_global_credential_netconf.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_snmpv2_read_community/import.sh b/examples/resources/dnacenter_global_credential_snmpv2_read_community/import.sh new file mode 100644 index 00000000..77059761 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_snmpv2_read_community/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_snmpv2_read_community.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_snmpv2_read_community/resource.tf b/examples/resources/dnacenter_global_credential_snmpv2_read_community/resource.tf new file mode 100644 index 00000000..0a17231e --- /dev/null +++ b/examples/resources/dnacenter_global_credential_snmpv2_read_community/resource.tf @@ -0,0 +1,14 @@ + +resource "dnacenter_global_credential_snmpv2_read_community" "example" { + provider = dnacenter + parameters { + description = "string" + comments = "string" + credential_type = "string" + read_community = "string" + } +} + +output "dnacenter_global_credential_snmpv2_read_community_example" { + value = dnacenter_global_credential_snmpv2_read_community.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_snmpv2_write_community/import.sh b/examples/resources/dnacenter_global_credential_snmpv2_write_community/import.sh new file mode 100644 index 00000000..79d2c8af --- /dev/null +++ b/examples/resources/dnacenter_global_credential_snmpv2_write_community/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_snmpv2_write_community.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_snmpv2_write_community/resource.tf b/examples/resources/dnacenter_global_credential_snmpv2_write_community/resource.tf new file mode 100644 index 00000000..837f75a4 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_snmpv2_write_community/resource.tf @@ -0,0 +1,14 @@ + +resource "dnacenter_global_credential_snmpv2_write_community" "example" { + provider = dnacenter + parameters { + description = "string" + comments = "string" + credential_type = "string" + write_community = "string" + } +} + +output "dnacenter_global_credential_snmpv2_write_community_example" { + value = dnacenter_global_credential_snmpv2_read_community.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_snmpv3/import.sh b/examples/resources/dnacenter_global_credential_snmpv3/import.sh new file mode 100644 index 00000000..39d76b56 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_snmpv3/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_snmpv3.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_global_credential_snmpv3/resource.tf b/examples/resources/dnacenter_global_credential_snmpv3/resource.tf new file mode 100644 index 00000000..fdecb1d5 --- /dev/null +++ b/examples/resources/dnacenter_global_credential_snmpv3/resource.tf @@ -0,0 +1,22 @@ + +resource "dnacenter_global_credential_snmpv3" "example" { + provider = dnacenter + parameters { + auth_password = "string" + auth_type = "string" + comments = "string" + credential_type = "string" + description = "string" + id = "string" + instanceTenantId = "string" + instanceUuid = "string" + privacy_password = "string" + privacy_type = "string" + snmp_mode = "string" + username = "string" + } +} + +output "dnacenter_global_credential_snmpv3_example" { + value = dnacenter_global_credential_snmpv3.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_golden_image/import.sh b/examples/resources/dnacenter_golden_image/import.sh new file mode 100644 index 00000000..21a0b137 --- /dev/null +++ b/examples/resources/dnacenter_golden_image/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_golden_image.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_golden_image/resource.tf b/examples/resources/dnacenter_golden_image/resource.tf new file mode 100644 index 00000000..233b3aa2 --- /dev/null +++ b/examples/resources/dnacenter_golden_image/resource.tf @@ -0,0 +1,14 @@ + +resource "dnacenter_golden_image" "example" { + provider = dnacenter + parameters { + image_id = "string" + site_id = "string" + device_role = "string" + device_family_identifier = "string" + } +} + +output "dnacenter_golden_image_example" { + value = dnacenter_golden_image.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_network_device_list/resource.tf b/examples/resources/dnacenter_network_device_list/resource.tf index 089a6bea..fc345002 100644 --- a/examples/resources/dnacenter_network_device_list/resource.tf +++ b/examples/resources/dnacenter_network_device_list/resource.tf @@ -34,6 +34,7 @@ resource "dnacenter_network_device_list" "example" { new_mgmt_ip_address = "string" } user_name = "string" + role = "string" } } diff --git a/examples/resources/dnacenter_service_provider/import.sh b/examples/resources/dnacenter_service_provider/import.sh new file mode 100644 index 00000000..fcb4e83d --- /dev/null +++ b/examples/resources/dnacenter_service_provider/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_service_provicer.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_service_provider/resource.tf b/examples/resources/dnacenter_service_provider/resource.tf new file mode 100644 index 00000000..fcd22abd --- /dev/null +++ b/examples/resources/dnacenter_service_provider/resource.tf @@ -0,0 +1,17 @@ +resource "dnacenter_service_provider" "example" { + provider = dnacenter + parameters { + + settings { + qos { + profile_name = "Test_tf_new" + model = "8-class-model" + wan_provider = "test1-provider" + } + } + } +} + +output "dnacenter_service_provider_example" { + value = dnacenter_service_provider.example +} diff --git a/examples/resources/dnacenter_site/import.sh b/examples/resources/dnacenter_site/import.sh new file mode 100644 index 00000000..7d2d21bf --- /dev/null +++ b/examples/resources/dnacenter_site/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_site.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_site/resource.tf b/examples/resources/dnacenter_site/resource.tf new file mode 100644 index 00000000..610256b6 --- /dev/null +++ b/examples/resources/dnacenter_site/resource.tf @@ -0,0 +1,32 @@ + +resource "dnacenter_site" "example" { + provider = dnacenter + parameters { + site { + area { + name = "string" + parent_name = "string" + } + building { + name = "string" + address = "string" + parent_name = "string" + latitude = 1 + longitude = 1 + } + floor { + height = 1 + length = 1 + name = "string" + parent_name = "string" + rf_model = "string" + width = 1 + } + } + type = "string" + } +} + +output "dnacenter_site_example" { + value = dnacenter_site.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_swin_image_file/import.sh b/examples/resources/dnacenter_swin_image_file/import.sh new file mode 100644 index 00000000..87f0a31c --- /dev/null +++ b/examples/resources/dnacenter_swin_image_file/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_swim_image_file.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_swin_image_file/resource.tf b/examples/resources/dnacenter_swin_image_file/resource.tf new file mode 100644 index 00000000..a9931a20 --- /dev/null +++ b/examples/resources/dnacenter_swin_image_file/resource.tf @@ -0,0 +1,12 @@ + +resource "dnacenter_swim_image_file" "example" { + provider = dnacenter + parameters { + file_path = "string" + file_name = "string" + } +} + +output "dnacenter_swim_image_file_example" { + value = dnacenter_swim_image_file.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_tag_membership/import.sh b/examples/resources/dnacenter_tag_membership/import.sh new file mode 100644 index 00000000..4e9789fb --- /dev/null +++ b/examples/resources/dnacenter_tag_membership/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_tag_membership.example "id:=string" \ No newline at end of file diff --git a/examples/resources/dnacenter_tag_membership/resource.tf b/examples/resources/dnacenter_tag_membership/resource.tf new file mode 100644 index 00000000..8b2007e1 --- /dev/null +++ b/examples/resources/dnacenter_tag_membership/resource.tf @@ -0,0 +1,14 @@ + +resource "dnacenter_tag_membership" "example" { + provider = dnacenter + parameters { + tag_id = "string" + member_type = "string" + member_id = "string" + + } +} + +output "dnacenter_tag_membership_example" { + value = dnacenter_tag_membership.example +} \ No newline at end of file diff --git a/examples/resources/dnacenter_wireless_enterprise_ssid/resource.tf b/examples/resources/dnacenter_wireless_enterprise_ssid/resource.tf index 58848f55..5cc9bc21 100644 --- a/examples/resources/dnacenter_wireless_enterprise_ssid/resource.tf +++ b/examples/resources/dnacenter_wireless_enterprise_ssid/resource.tf @@ -22,6 +22,7 @@ resource "dnacenter_wireless_enterprise_ssid" "example" { session_time_out = 1 ssid_name = "string" traffic_type = "string" + site = "string" } } diff --git a/examples/samples/data-sources/dnacenter_app_policy/main.tf b/examples/samples/data-sources/dnacenter_app_policy/main.tf index d199ea61..4a066a60 100644 --- a/examples/samples/data-sources/dnacenter_app_policy/main.tf +++ b/examples/samples/data-sources/dnacenter_app_policy/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -15,4 +15,4 @@ data "dnacenter_app_policy" "example" { output "dnacenter_app_policy_example" { value = data.dnacenter_app_policy.example.items -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_app_policy_intent_create/data-source.tf b/examples/samples/data-sources/dnacenter_app_policy_intent_create/data-source.tf index b8755954..41e42665 100644 --- a/examples/samples/data-sources/dnacenter_app_policy_intent_create/data-source.tf +++ b/examples/samples/data-sources/dnacenter_app_policy_intent_create/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # hashicorp.com/edu/dnacenter is the local built source change to cisco-en-programmability/dnacenter to use downloaded version from registry } @@ -89,4 +89,4 @@ data "dnacenter_app_policy_intent_create" "example" { } ] } -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_app_policy_queuing_profile/data-source.tf b/examples/samples/data-sources/dnacenter_app_policy_queuing_profile/data-source.tf index 1eb4c9ef..e75e1bf4 100644 --- a/examples/samples/data-sources/dnacenter_app_policy_queuing_profile/data-source.tf +++ b/examples/samples/data-sources/dnacenter_app_policy_queuing_profile/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_app_policy_queuing_profile_count/data-source.tf b/examples/samples/data-sources/dnacenter_app_policy_queuing_profile_count/data-source.tf index 57a57574..edd4ba77 100644 --- a/examples/samples/data-sources/dnacenter_app_policy_queuing_profile_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_app_policy_queuing_profile_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_application_sets/data-source.tf b/examples/samples/data-sources/dnacenter_application_sets/data-source.tf index d158acf6..a5b88bac 100644 --- a/examples/samples/data-sources/dnacenter_application_sets/data-source.tf +++ b/examples/samples/data-sources/dnacenter_application_sets/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_applications/data-source.tf b/examples/samples/data-sources/dnacenter_applications/data-source.tf index b1c0d59f..fbea5039 100644 --- a/examples/samples/data-sources/dnacenter_applications/data-source.tf +++ b/examples/samples/data-sources/dnacenter_applications/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_applications_count/data-source.tf b/examples/samples/data-sources/dnacenter_applications_count/data-source.tf index d2120337..894a44c9 100644 --- a/examples/samples/data-sources/dnacenter_applications_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_applications_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_business_sda_hostonboarding_ssid_ippool/data-source.tf b/examples/samples/data-sources/dnacenter_business_sda_hostonboarding_ssid_ippool/data-source.tf index f53c506a..307d8bba 100644 --- a/examples/samples/data-sources/dnacenter_business_sda_hostonboarding_ssid_ippool/data-source.tf +++ b/examples/samples/data-sources/dnacenter_business_sda_hostonboarding_ssid_ippool/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_client_detail/data-source.tf b/examples/samples/data-sources/dnacenter_client_detail/data-source.tf index ef859f88..0683d14c 100644 --- a/examples/samples/data-sources/dnacenter_client_detail/data-source.tf +++ b/examples/samples/data-sources/dnacenter_client_detail/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_client_enrichment_details/data-source.tf b/examples/samples/data-sources/dnacenter_client_enrichment_details/data-source.tf index a53b1948..19b0a989 100644 --- a/examples/samples/data-sources/dnacenter_client_enrichment_details/data-source.tf +++ b/examples/samples/data-sources/dnacenter_client_enrichment_details/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_compliance_device_status_count/data-source.tf b/examples/samples/data-sources/dnacenter_compliance_device_status_count/data-source.tf index eafb3088..1c5b7472 100644 --- a/examples/samples/data-sources/dnacenter_compliance_device_status_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_compliance_device_status_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_configuration_template/data-source.tf b/examples/samples/data-sources/dnacenter_configuration_template/data-source.tf index 64bd775a..1258b627 100644 --- a/examples/samples/data-sources/dnacenter_configuration_template/data-source.tf +++ b/examples/samples/data-sources/dnacenter_configuration_template/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_configuration_template_project/data-source.tf b/examples/samples/data-sources/dnacenter_configuration_template_project/data-source.tf index fd89ce2b..78e1bbb5 100644 --- a/examples/samples/data-sources/dnacenter_configuration_template_project/data-source.tf +++ b/examples/samples/data-sources/dnacenter_configuration_template_project/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -30,4 +30,4 @@ data "dnacenter_configuration_template_project" "example" { output "dnacenter_configuration_template_project_example" { value = data.dnacenter_configuration_template_project.example.item } -*/ \ No newline at end of file +*/ diff --git a/examples/samples/data-sources/dnacenter_device_replacement/data-source.tf b/examples/samples/data-sources/dnacenter_device_replacement/data-source.tf index 7aa6c5ec..2d0e3e8b 100644 --- a/examples/samples/data-sources/dnacenter_device_replacement/data-source.tf +++ b/examples/samples/data-sources/dnacenter_device_replacement/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_device_replacement_count/data-source.tf b/examples/samples/data-sources/dnacenter_device_replacement_count/data-source.tf index 7a803398..28d56c68 100644 --- a/examples/samples/data-sources/dnacenter_device_replacement_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_device_replacement_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_discovery/data-source.tf b/examples/samples/data-sources/dnacenter_discovery/data-source.tf index 1f36d458..7dbd7234 100644 --- a/examples/samples/data-sources/dnacenter_discovery/data-source.tf +++ b/examples/samples/data-sources/dnacenter_discovery/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_discovery_device_count/data-source.tf b/examples/samples/data-sources/dnacenter_discovery_device_count/data-source.tf index d130db74..75cf0bc2 100644 --- a/examples/samples/data-sources/dnacenter_discovery_device_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_discovery_device_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_endpoint_analytics_profiling_rules/data-source.tf b/examples/samples/data-sources/dnacenter_endpoint_analytics_profiling_rules/data-source.tf index eab7a5d1..ac7e3faa 100644 --- a/examples/samples/data-sources/dnacenter_endpoint_analytics_profiling_rules/data-source.tf +++ b/examples/samples/data-sources/dnacenter_endpoint_analytics_profiling_rules/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_event_count/data-source.tf b/examples/samples/data-sources/dnacenter_event_count/data-source.tf index 725630d8..f131a112 100644 --- a/examples/samples/data-sources/dnacenter_event_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_event_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_event_subscription/data-source.tf b/examples/samples/data-sources/dnacenter_event_subscription/data-source.tf index f7b8dc54..f2f4e5aa 100644 --- a/examples/samples/data-sources/dnacenter_event_subscription/data-source.tf +++ b/examples/samples/data-sources/dnacenter_event_subscription/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_event_subscription_count/data-source.tf b/examples/samples/data-sources/dnacenter_event_subscription_count/data-source.tf index 37ef4e02..00cb4495 100644 --- a/examples/samples/data-sources/dnacenter_event_subscription_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_event_subscription_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_event_subscription_email/data-source.tf b/examples/samples/data-sources/dnacenter_event_subscription_email/data-source.tf index e0052a41..8721f2e1 100644 --- a/examples/samples/data-sources/dnacenter_event_subscription_email/data-source.tf +++ b/examples/samples/data-sources/dnacenter_event_subscription_email/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_event_subscription_rest/data-source.tf b/examples/samples/data-sources/dnacenter_event_subscription_rest/data-source.tf index 97b9a3cb..a28985d0 100644 --- a/examples/samples/data-sources/dnacenter_event_subscription_rest/data-source.tf +++ b/examples/samples/data-sources/dnacenter_event_subscription_rest/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_event_subscription_syslog/data-source.tf b/examples/samples/data-sources/dnacenter_event_subscription_syslog/data-source.tf index b7080b82..30028931 100644 --- a/examples/samples/data-sources/dnacenter_event_subscription_syslog/data-source.tf +++ b/examples/samples/data-sources/dnacenter_event_subscription_syslog/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_file/data-source.tf b/examples/samples/data-sources/dnacenter_file/data-source.tf index 2ababc49..e14a9537 100644 --- a/examples/samples/data-sources/dnacenter_file/data-source.tf +++ b/examples/samples/data-sources/dnacenter_file/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -13,4 +13,4 @@ provider "dnacenter" { data "dnacenter__file" "example" { provider = dnacenter -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_global_pool/data-source.tf b/examples/samples/data-sources/dnacenter_global_pool/data-source.tf index cf7510c0..38557542 100644 --- a/examples/samples/data-sources/dnacenter_global_pool/data-source.tf +++ b/examples/samples/data-sources/dnacenter_global_pool/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_http_read_credential/data-source.tf b/examples/samples/data-sources/dnacenter_http_read_credential/data-source.tf index 7de655a0..377a5bc3 100644 --- a/examples/samples/data-sources/dnacenter_http_read_credential/data-source.tf +++ b/examples/samples/data-sources/dnacenter_http_read_credential/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -26,4 +26,4 @@ data "dnacdnacenter_http_read_credential" "example" { secure = "false" username = "string" } -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_network_device/data-source.tf b/examples/samples/data-sources/dnacenter_network_device/data-source.tf index e317dbdc..c731aa7b 100644 --- a/examples/samples/data-sources/dnacenter_network_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_network_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_network_device_config_count/data-source.tf b/examples/samples/data-sources/dnacenter_network_device_config_count/data-source.tf index 0dbde050..18b7d6f7 100644 --- a/examples/samples/data-sources/dnacenter_network_device_config_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_network_device_config_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_network_device_count/data-source.tf b/examples/samples/data-sources/dnacenter_network_device_count/data-source.tf index bc8db162..f5863c8b 100644 --- a/examples/samples/data-sources/dnacenter_network_device_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_network_device_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_network_device_list/data-source.tf b/examples/samples/data-sources/dnacenter_network_device_list/data-source.tf index 15505bd3..60a30b90 100644 --- a/examples/samples/data-sources/dnacenter_network_device_list/data-source.tf +++ b/examples/samples/data-sources/dnacenter_network_device_list/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_network_device_module_count/data-source.tf b/examples/samples/data-sources/dnacenter_network_device_module_count/data-source.tf index 7304c15d..5fb715d8 100644 --- a/examples/samples/data-sources/dnacenter_network_device_module_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_network_device_module_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_network_device_sync/data-source.tf b/examples/samples/data-sources/dnacenter_network_device_sync/data-source.tf index cef3c622..ef93ee28 100644 --- a/examples/samples/data-sources/dnacenter_network_device_sync/data-source.tf +++ b/examples/samples/data-sources/dnacenter_network_device_sync/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -14,4 +14,4 @@ provider "dnacenter" { data "dnacdnacenter_network_device_sync" "example" { provider = dnacenter force_sync = "false" -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_nfv_profile/data-source.tf b/examples/samples/data-sources/dnacenter_nfv_profile/data-source.tf index 5c3724d0..0d822c0b 100644 --- a/examples/samples/data-sources/dnacenter_nfv_profile/data-source.tf +++ b/examples/samples/data-sources/dnacenter_nfv_profile/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_path_trace/data-source.tf b/examples/samples/data-sources/dnacenter_path_trace/data-source.tf index 7e1bded0..325542dd 100644 --- a/examples/samples/data-sources/dnacenter_path_trace/data-source.tf +++ b/examples/samples/data-sources/dnacenter_path_trace/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -42,4 +42,4 @@ data "dnacenter_path_trace" "example" { output "dnacenter_path_trace_example" { value = data.dnacenter_path_trace.example.item } -*/ \ No newline at end of file +*/ diff --git a/examples/samples/data-sources/dnacenter_pnp_device/data-source.tf b/examples/samples/data-sources/dnacenter_pnp_device/data-source.tf index 57444a72..8bf2e458 100644 --- a/examples/samples/data-sources/dnacenter_pnp_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_pnp_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -49,4 +49,4 @@ data "dnacenter_pnp_device" "example" { output "dnacenter_pnp_device_example" { value = data.dnacenter_pnp_device.example } -*/ \ No newline at end of file +*/ diff --git a/examples/samples/data-sources/dnacenter_pnp_global_settings/data-source.tf b/examples/samples/data-sources/dnacenter_pnp_global_settings/data-source.tf index 2d2fd610..29d576fa 100644 --- a/examples/samples/data-sources/dnacenter_pnp_global_settings/data-source.tf +++ b/examples/samples/data-sources/dnacenter_pnp_global_settings/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_pnp_workflow/data-source.tf b/examples/samples/data-sources/dnacenter_pnp_workflow/data-source.tf index d6935e24..7d1d81a2 100644 --- a/examples/samples/data-sources/dnacenter_pnp_workflow/data-source.tf +++ b/examples/samples/data-sources/dnacenter_pnp_workflow/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_pnp_workflow_count/data-source.tf b/examples/samples/data-sources/dnacenter_pnp_workflow_count/data-source.tf index 59aa6e49..3bbb8f2b 100644 --- a/examples/samples/data-sources/dnacenter_pnp_workflow_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_pnp_workflow_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_qos_device_interface/data-source.tf b/examples/samples/data-sources/dnacenter_qos_device_interface/data-source.tf index c9b76811..c0e0d860 100644 --- a/examples/samples/data-sources/dnacenter_qos_device_interface/data-source.tf +++ b/examples/samples/data-sources/dnacenter_qos_device_interface/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_qos_device_interface_info_count/data-source.tf b/examples/samples/data-sources/dnacenter_qos_device_interface_info_count/data-source.tf index 95027a3d..f7a60d1c 100644 --- a/examples/samples/data-sources/dnacenter_qos_device_interface_info_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_qos_device_interface_info_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_reports/data-source.tf b/examples/samples/data-sources/dnacenter_reports/data-source.tf index ecefe1f5..9514b549 100644 --- a/examples/samples/data-sources/dnacenter_reports/data-source.tf +++ b/examples/samples/data-sources/dnacenter_reports/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_reserve_ip_subpool/data-source.tf b/examples/samples/data-sources/dnacenter_reserve_ip_subpool/data-source.tf index 75fb1ddc..4b16af68 100644 --- a/examples/samples/data-sources/dnacenter_reserve_ip_subpool/data-source.tf +++ b/examples/samples/data-sources/dnacenter_reserve_ip_subpool/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_fabric/data-source.tf b/examples/samples/data-sources/dnacenter_sda_fabric/data-source.tf index cf3a34db..3e7fbbb1 100644 --- a/examples/samples/data-sources/dnacenter_sda_fabric/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_fabric/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_fabric_authentication_profile/data-source.tf b/examples/samples/data-sources/dnacenter_sda_fabric_authentication_profile/data-source.tf index 6af91344..4550bc54 100644 --- a/examples/samples/data-sources/dnacenter_sda_fabric_authentication_profile/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_fabric_authentication_profile/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_fabric_border_device/data-source.tf b/examples/samples/data-sources/dnacenter_sda_fabric_border_device/data-source.tf index 2efc2537..e2ab234a 100644 --- a/examples/samples/data-sources/dnacenter_sda_fabric_border_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_fabric_border_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_fabric_control_plane_device/data-source.tf b/examples/samples/data-sources/dnacenter_sda_fabric_control_plane_device/data-source.tf index 8039dafc..b304b249 100644 --- a/examples/samples/data-sources/dnacenter_sda_fabric_control_plane_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_fabric_control_plane_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_fabric_edge_device/data-source.tf b/examples/samples/data-sources/dnacenter_sda_fabric_edge_device/data-source.tf index 21ae848c..28fb4204 100644 --- a/examples/samples/data-sources/dnacenter_sda_fabric_edge_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_fabric_edge_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_fabric_site/data-source.tf b/examples/samples/data-sources/dnacenter_sda_fabric_site/data-source.tf index 725c469d..8ea24438 100644 --- a/examples/samples/data-sources/dnacenter_sda_fabric_site/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_fabric_site/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_port_assignment_for_access_point/data-source.tf b/examples/samples/data-sources/dnacenter_sda_port_assignment_for_access_point/data-source.tf index 1ed35aed..003319b0 100644 --- a/examples/samples/data-sources/dnacenter_sda_port_assignment_for_access_point/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_port_assignment_for_access_point/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_port_assignment_for_user_device/data-source.tf b/examples/samples/data-sources/dnacenter_sda_port_assignment_for_user_device/data-source.tf index ac8ac58a..acc22b92 100644 --- a/examples/samples/data-sources/dnacenter_sda_port_assignment_for_user_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_port_assignment_for_user_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_provision_device/data-source.tf b/examples/samples/data-sources/dnacenter_sda_provision_device/data-source.tf index 372d00c0..78be972b 100644 --- a/examples/samples/data-sources/dnacenter_sda_provision_device/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_provision_device/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf b/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf index acb4fc8f..7578b483 100644 --- a/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_virtual_network/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_virtual_network_ip_pool/data-source.tf b/examples/samples/data-sources/dnacenter_sda_virtual_network_ip_pool/data-source.tf index c29230dd..7888f9d2 100644 --- a/examples/samples/data-sources/dnacenter_sda_virtual_network_ip_pool/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_virtual_network_ip_pool/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sda_virtual_network_v2/data-source.tf b/examples/samples/data-sources/dnacenter_sda_virtual_network_v2/data-source.tf index b62d9d21..0a3bf3a7 100644 --- a/examples/samples/data-sources/dnacenter_sda_virtual_network_v2/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sda_virtual_network_v2/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sensor/data-source.tf b/examples/samples/data-sources/dnacenter_sensor/data-source.tf index 6e41955e..797cf660 100644 --- a/examples/samples/data-sources/dnacenter_sensor/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sensor/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_sensor_test_run/data-source.tf b/examples/samples/data-sources/dnacenter_sensor_test_run/data-source.tf index fe354492..ceab90ad 100644 --- a/examples/samples/data-sources/dnacenter_sensor_test_run/data-source.tf +++ b/examples/samples/data-sources/dnacenter_sensor_test_run/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -14,4 +14,4 @@ provider "dnacenter" { data "dnacenter_sensor_test_run" "example" { provider = dnacenter template_name = "Test" -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_site_count/data-source.tf b/examples/samples/data-sources/dnacenter_site_count/data-source.tf index 97dce86c..e866fe81 100644 --- a/examples/samples/data-sources/dnacenter_site_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_site_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_site_design_floormap/data-source.tf b/examples/samples/data-sources/dnacenter_site_design_floormap/data-source.tf index cb0bc363..7de2f495 100644 --- a/examples/samples/data-sources/dnacenter_site_design_floormap/data-source.tf +++ b/examples/samples/data-sources/dnacenter_site_design_floormap/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_site_update/data-source.tf b/examples/samples/data-sources/dnacenter_site_update/data-source.tf index 4598c6af..aba123d4 100644 --- a/examples/samples/data-sources/dnacenter_site_update/data-source.tf +++ b/examples/samples/data-sources/dnacenter_site_update/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -24,4 +24,4 @@ data "dnacenter_site_update" "example" { } } type = "building" -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_snmp_properties/data-source.tf b/examples/samples/data-sources/dnacenter_snmp_properties/data-source.tf index 51b14f5d..46ececf9 100644 --- a/examples/samples/data-sources/dnacenter_snmp_properties/data-source.tf +++ b/examples/samples/data-sources/dnacenter_snmp_properties/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_swim_trigger_distribution/data-source.tf b/examples/samples/data-sources/dnacenter_swim_trigger_distribution/data-source.tf index b704a4d5..ac3549a3 100644 --- a/examples/samples/data-sources/dnacenter_swim_trigger_distribution/data-source.tf +++ b/examples/samples/data-sources/dnacenter_swim_trigger_distribution/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -18,4 +18,4 @@ data "dnacdnacenter_swim_trigger_distribution" "example" { device_uuid = "3eb928b8-2414-4121-ac35-1247e5d666a4" image_uuid = "6af2b040-a312-4f57-8c8e-21f5e3e07597" } -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_system_health_count/data-source.tf b/examples/samples/data-sources/dnacenter_system_health_count/data-source.tf index c44306c9..fb816b05 100644 --- a/examples/samples/data-sources/dnacenter_system_health_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_system_health_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_tag/data-source.tf b/examples/samples/data-sources/dnacenter_tag/data-source.tf index 2ced41c4..29cd5d5a 100644 --- a/examples/samples/data-sources/dnacenter_tag/data-source.tf +++ b/examples/samples/data-sources/dnacenter_tag/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_tag_count/data-source.tf b/examples/samples/data-sources/dnacenter_tag_count/data-source.tf index 3b6fe23d..24ec7903 100644 --- a/examples/samples/data-sources/dnacenter_tag_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_tag_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_tag_member/data-source.tf b/examples/samples/data-sources/dnacenter_tag_member/data-source.tf index 721f1845..de33cf15 100644 --- a/examples/samples/data-sources/dnacenter_tag_member/data-source.tf +++ b/examples/samples/data-sources/dnacenter_tag_member/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_task_count/data-source.tf b/examples/samples/data-sources/dnacenter_task_count/data-source.tf index bba45e06..e0d265dd 100644 --- a/examples/samples/data-sources/dnacenter_task_count/data-source.tf +++ b/examples/samples/data-sources/dnacenter_task_count/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_wireless_dynamic_interface/data-source.tf b/examples/samples/data-sources/dnacenter_wireless_dynamic_interface/data-source.tf index d7722c8f..7fb3252a 100644 --- a/examples/samples/data-sources/dnacenter_wireless_dynamic_interface/data-source.tf +++ b/examples/samples/data-sources/dnacenter_wireless_dynamic_interface/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_wireless_enterprise_ssid/data-source.tf b/examples/samples/data-sources/dnacenter_wireless_enterprise_ssid/data-source.tf index be535ca2..5950d509 100644 --- a/examples/samples/data-sources/dnacenter_wireless_enterprise_ssid/data-source.tf +++ b/examples/samples/data-sources/dnacenter_wireless_enterprise_ssid/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_wireless_profile/data-source.tf b/examples/samples/data-sources/dnacenter_wireless_profile/data-source.tf index cf208665..ea5ccaa5 100644 --- a/examples/samples/data-sources/dnacenter_wireless_profile/data-source.tf +++ b/examples/samples/data-sources/dnacenter_wireless_profile/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/data-sources/dnacenter_wireless_psk_override/data-source.tf b/examples/samples/data-sources/dnacenter_wireless_psk_override/data-source.tf index 9ffaf41d..312f03b0 100644 --- a/examples/samples/data-sources/dnacenter_wireless_psk_override/data-source.tf +++ b/examples/samples/data-sources/dnacenter_wireless_psk_override/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -18,4 +18,4 @@ data "dnacenter_wireless_psk_override" "example" { site = "Global/San Francisco" ssid = "test999_pop" } -} \ No newline at end of file +} diff --git a/examples/samples/data-sources/dnacenter_wireless_rf_profile/data-source.tf b/examples/samples/data-sources/dnacenter_wireless_rf_profile/data-source.tf index b0681290..7dd1a341 100644 --- a/examples/samples/data-sources/dnacenter_wireless_rf_profile/data-source.tf +++ b/examples/samples/data-sources/dnacenter_wireless_rf_profile/data-source.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_app_policy_queuing_profile/main.tf b/examples/samples/resources/dnacenter_app_policy_queuing_profile/main.tf index 78cd8bc4..836a33b2 100644 --- a/examples/samples/resources/dnacenter_app_policy_queuing_profile/main.tf +++ b/examples/samples/resources/dnacenter_app_policy_queuing_profile/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_application_sets/main.tf b/examples/samples/resources/dnacenter_application_sets/main.tf index ac570a90..89d0eaa2 100644 --- a/examples/samples/resources/dnacenter_application_sets/main.tf +++ b/examples/samples/resources/dnacenter_application_sets/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_applications/main.tf b/examples/samples/resources/dnacenter_applications/main.tf index a89e01ef..8b85d651 100644 --- a/examples/samples/resources/dnacenter_applications/main.tf +++ b/examples/samples/resources/dnacenter_applications/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_business_sda_hostonboarding_ssid_ippool/main.tf b/examples/samples/resources/dnacenter_business_sda_hostonboarding_ssid_ippool/main.tf index 352892a9..1589b509 100644 --- a/examples/samples/resources/dnacenter_business_sda_hostonboarding_ssid_ippool/main.tf +++ b/examples/samples/resources/dnacenter_business_sda_hostonboarding_ssid_ippool/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -22,4 +22,4 @@ resource "dnacenter_business_sda_hostonboarding_ssid_ippool" "example" { output "dnacenter_business_sda_hostonboarding_ssid_ippool_example" { value = dnacenter_business_sda_hostonboarding_ssid_ippool.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_compliance/import.sh b/examples/samples/resources/dnacenter_compliance/import.sh new file mode 100644 index 00000000..514da970 --- /dev/null +++ b/examples/samples/resources/dnacenter_compliance/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_compliance.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_compliance/resource.tf b/examples/samples/resources/dnacenter_compliance/resource.tf new file mode 100644 index 00000000..5ecad334 --- /dev/null +++ b/examples/samples/resources/dnacenter_compliance/resource.tf @@ -0,0 +1,23 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +resource "dnacenter_compliance" "example" { + provider = dnacenter + parameters { + trigger_full = true + categories = ["PSIRT"] + device_uuids = ["3eb928b8-2414-4121-ac35-1247e5d666a4"] + } +} + +output "dnacenter_compliance_example" { + value = dnacenter_compliance.example +} diff --git a/examples/samples/resources/dnacenter_configuration_template/import.sh b/examples/samples/resources/dnacenter_configuration_template/import.sh new file mode 100644 index 00000000..a7f201f4 --- /dev/null +++ b/examples/samples/resources/dnacenter_configuration_template/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_configuration_template.example "id:= string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_configuration_template/main.tf b/examples/samples/resources/dnacenter_configuration_template/resource.tf similarity index 90% rename from examples/samples/resources/dnacenter_configuration_template/main.tf rename to examples/samples/resources/dnacenter_configuration_template/resource.tf index 33b29b02..c02eff89 100644 --- a/examples/samples/resources/dnacenter_configuration_template/main.tf +++ b/examples/samples/resources/dnacenter_configuration_template/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -13,7 +13,7 @@ resource "dnacenter_configuration_template" "example" { provider = dnacenter parameters { - author = "string" + author = "Test" composite = "false" containing_templates { /* @@ -103,7 +103,7 @@ resource "dnacenter_configuration_template" "example" { } #create_time = 1 custom_params_order = "false" - description = "TestTerraform" + description = "Test Terraform by ID Update" device_types { product_family = "Routers" @@ -111,13 +111,13 @@ resource "dnacenter_configuration_template" "example" { #product_type = "string" } failure_policy = "CONTINUE_ON_ERROR" - id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" - language = "VELOCITY" + #id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" + language = "VELOCITY" #last_update_time = 1 #latest_version_time = 1 - name = "DMVPN Spoke for Branch Router - System Default for Test Project" - parent_template_id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" - #project_id = "c3e77f82-bea7-45db-9eab-c7140b54a4a8" + name = "DMVPN Spoke for Branch Router - System Default for Test Project n3" + parent_template_id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" + project_id = "c3e77f82-bea7-45db-9eab-c7140b54a4a8" project_name = "Cloud Test Template 2" rollback_template_content = "string" rollback_template_params { @@ -159,7 +159,7 @@ resource "dnacenter_configuration_template" "example" { tags { } #template_content = "string" - template_id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" + #template_id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" template_params { /* binding = "string" @@ -200,7 +200,8 @@ resource "dnacenter_configuration_template" "example" { template_id = "fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" template_version = null } - version = "1.0" + version = "1.0" + comments = "Test tf" } } diff --git a/examples/samples/resources/dnacenter_configuration_template_project/main.tf b/examples/samples/resources/dnacenter_configuration_template_project/main.tf index 42b65fce..97979857 100644 --- a/examples/samples/resources/dnacenter_configuration_template_project/main.tf +++ b/examples/samples/resources/dnacenter_configuration_template_project/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_device_replacement/main.tf b/examples/samples/resources/dnacenter_device_replacement/main.tf index 4e39d270..e5547d0e 100644 --- a/examples/samples/resources/dnacenter_device_replacement/main.tf +++ b/examples/samples/resources/dnacenter_device_replacement/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -31,4 +31,4 @@ resource "dnacenter_device_replacement" "example" { output "dnacenter_device_replacement_example" { value = dnacenter_device_replacement.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_discovery/main.tf b/examples/samples/resources/dnacenter_discovery/main.tf index a5296b1f..7eae8074 100644 --- a/examples/samples/resources/dnacenter_discovery/main.tf +++ b/examples/samples/resources/dnacenter_discovery/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_endpoint_analytics_profiling_rules/main.tf b/examples/samples/resources/dnacenter_endpoint_analytics_profiling_rules/main.tf index 0af6f2e9..0d7ba55e 100644 --- a/examples/samples/resources/dnacenter_endpoint_analytics_profiling_rules/main.tf +++ b/examples/samples/resources/dnacenter_endpoint_analytics_profiling_rules/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } diff --git a/examples/samples/resources/dnacenter_event_subscription/main.tf b/examples/samples/resources/dnacenter_event_subscription/main.tf index df4779c0..07c1b741 100644 --- a/examples/samples/resources/dnacenter_event_subscription/main.tf +++ b/examples/samples/resources/dnacenter_event_subscription/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -40,4 +40,4 @@ resource "dnacenter_event_subscription" "example" { output "dnacenter_event_subscription_example" { value = dnacenter_event_subscription.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_global_credential_cli/import.sh b/examples/samples/resources/dnacenter_global_credential_cli/import.sh new file mode 100644 index 00000000..4606df05 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_cli/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_global_credential_cli/resource.tf b/examples/samples/resources/dnacenter_global_credential_cli/resource.tf new file mode 100644 index 00000000..90486c81 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_cli/resource.tf @@ -0,0 +1,29 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} +resource "dnacenter_global_credential_cli" "example" { + provider = dnacenter + parameters { + comments = "test4_comment" + credential_type = "GLOBAL" + description = "string" + enable_password = "string" + #id= "string" + #instance_tenant_id= "string" + #instance_uuid= "string" + password = "string" + username = "TEST4" + } +} + +output "dnacenter_global_credential_cli_example" { + value = dnacenter_global_credential_cli.example + sensitive = true +} diff --git a/examples/samples/resources/dnacenter_global_credential_http_read/import.sh b/examples/samples/resources/dnacenter_global_credential_http_read/import.sh new file mode 100644 index 00000000..fb24ac09 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_http_read/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_http_read.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_global_credential_http_read/resource.tf b/examples/samples/resources/dnacenter_global_credential_http_read/resource.tf new file mode 100644 index 00000000..f4c19252 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_http_read/resource.tf @@ -0,0 +1,35 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_global_credential_http_read" "example" { + provider = dnacenter + parameters { + secure = true + username = "userTF3" + password = "123" + port = 23 + description = "This is a test for tf" + #comments= null + credential_type = "APP" + #instance_tenant_id= "6168b750e7a2701a37d64526" + #instance_uuid= "aed1c6d9-e32d-47b5-a7c4-9e8cb15060a1" + #id= "aed1c6d9-e32d-47b5-a7c4-9e8cb15060a1" + } +} + +output "dnacenter_global_credential_http_read_example" { + value = dnacenter_global_credential_http_read.example + sensitive = true +} diff --git a/examples/samples/resources/dnacenter_global_credential_http_write/import.sh b/examples/samples/resources/dnacenter_global_credential_http_write/import.sh new file mode 100644 index 00000000..69e7c1fb --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_http_write/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credentail_http_write.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_global_credential_http_write/resource.tf b/examples/samples/resources/dnacenter_global_credential_http_write/resource.tf new file mode 100644 index 00000000..74edbf6e --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_http_write/resource.tf @@ -0,0 +1,35 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_global_credential_http_write" "example" { + provider = dnacenter + parameters { + secure = true + username = "userTF3" + password = "123" + port = 23 + description = "New description" + #comments= null + credential_type = "APP" + #instance_tenant_id= "6168b750e7a2701a37d64526" + #instance_uuid= "aed1c6d9-e32d-47b5-a7c4-9e8cb15060a1" + #id= "aed1c6d9-e32d-47b5-a7c4-9e8cb15060a1" + } +} + +output "dnacenter_global_credential_http_write_example" { + value = dnacenter_global_credential_http_write.example + sensitive = true +} diff --git a/examples/samples/resources/dnacenter_global_credential_netconf/import.sh b/examples/samples/resources/dnacenter_global_credential_netconf/import.sh new file mode 100644 index 00000000..4606df05 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_netconf/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_global_credential_netconf/resource.tf b/examples/samples/resources/dnacenter_global_credential_netconf/resource.tf new file mode 100644 index 00000000..204ac8ce --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_netconf/resource.tf @@ -0,0 +1,31 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_global_credential_netconf" "example" { + provider = dnacenter + parameters { + description = "Description" + comments = "New comments" + credential_type = "APP" + netconf_port = "1" + #instance_tenant_id= "6168b750e7a2701a37d64526" + #instance_uuid= "aed1c6d9-e32d-47b5-a7c4-9e8cb15060a1" + #id= "aed1c6d9-e32d-47b5-a7c4-9e8cb15060a1" + } +} + +output "dnacenter_global_credential_netconf_example" { + value = dnacenter_global_credential_netconf.example +} diff --git a/examples/samples/resources/dnacenter_global_credential_snmpv2_read_community/import.sh b/examples/samples/resources/dnacenter_global_credential_snmpv2_read_community/import.sh new file mode 100644 index 00000000..29d59b1a --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_snmpv2_read_community/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_snmpv2_read_community.example "id:=8cc3db21-8071-4423-a58d-9b080164f07c" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_global_credential_snmpv2_read_community/resource.tf b/examples/samples/resources/dnacenter_global_credential_snmpv2_read_community/resource.tf new file mode 100644 index 00000000..229362ab --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_snmpv2_read_community/resource.tf @@ -0,0 +1,28 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_global_credential_snmpv2_read_community" "example" { + provider = dnacenter + parameters { + description = "Description 4" + comments = "New Comments" + credential_type = "APP" + read_community = "Test4" + } +} + +output "dnacenter_global_credential_snmpv2_read_community_example" { + value = dnacenter_global_credential_snmpv2_read_community.example +} diff --git a/examples/samples/resources/dnacenter_global_credential_snmpv3/import.sh b/examples/samples/resources/dnacenter_global_credential_snmpv3/import.sh new file mode 100644 index 00000000..39d76b56 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_snmpv3/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_global_credential_snmpv3.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_global_credential_snmpv3/resource.tf b/examples/samples/resources/dnacenter_global_credential_snmpv3/resource.tf new file mode 100644 index 00000000..6dd03591 --- /dev/null +++ b/examples/samples/resources/dnacenter_global_credential_snmpv3/resource.tf @@ -0,0 +1,36 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_global_credential_snmpv3" "example" { + provider = dnacenter + parameters { + auth_password = "12345678" + auth_type = "SHA" + comments = "Test" + credential_type = "APP" + description = "Description 3" + #id= "string" + #instanceTenantId= "string" + #instanceUuid= "string" + privacy_password = "privacy_password_test" + privacy_type = "AES128" + snmp_mode = "AUTHPRIV" + username = "Global_credential_test3" + } +} + +output "dnacenter_global_credential_snmpv3_example" { + value = dnacenter_global_credential_snmpv3.example +} diff --git a/examples/samples/resources/dnacenter_global_pool/resource.tf b/examples/samples/resources/dnacenter_global_pool/resource.tf index 31c3f227..e3509e3c 100644 --- a/examples/samples/resources/dnacenter_global_pool/resource.tf +++ b/examples/samples/resources/dnacenter_global_pool/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -31,4 +31,4 @@ resource "dnacenter_global_pool" "example" { output "dnacenter_global_pool_example" { value = dnacenter_global_pool.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_golden_image/import.sh b/examples/samples/resources/dnacenter_golden_image/import.sh new file mode 100644 index 00000000..21a0b137 --- /dev/null +++ b/examples/samples/resources/dnacenter_golden_image/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_golden_image.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_golden_image/resource.tf b/examples/samples/resources/dnacenter_golden_image/resource.tf new file mode 100644 index 00000000..30682561 --- /dev/null +++ b/examples/samples/resources/dnacenter_golden_image/resource.tf @@ -0,0 +1,24 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +resource "dnacenter_golden_image" "example" { + provider = dnacenter + parameters { + image_id = "e7f80aaa-62d3-4390-a8ee-49bbfba036a3" + site_id = "2397da83-4e12-4d04-9bd3-a57b2ad91652" + device_role = "ALL" + device_family_identifier = "Routers" + } +} + +output "dnacenter_golden_image_example" { + value = dnacenter_golden_image.example +} diff --git a/examples/samples/resources/dnacenter_network_device/resource.tf b/examples/samples/resources/dnacenter_network_device/resource.tf index 442d378a..0f46cafe 100644 --- a/examples/samples/resources/dnacenter_network_device/resource.tf +++ b/examples/samples/resources/dnacenter_network_device/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -18,4 +18,18 @@ resource "dnacenter_network_device" "example" { output "dnacenter_network_device_example" { value = dnacenter_network_device.example -} \ No newline at end of file +} + +resource "dnacenter_compliance" "example" { + depends_on = [dnacenter_network_device.example] + provider = dnacenter + parameters { + trigger_full = true + categories = ["PSIRT"] + device_uuids = [dnacenter_network_device.example.item.0.id] + } +} + +output "dnacenter_compliance_example" { + value = dnacenter_compliance.example +} diff --git a/examples/samples/resources/dnacenter_network_device_list/import.sh b/examples/samples/resources/dnacenter_network_device_list/import.sh new file mode 100644 index 00000000..573ee8d9 --- /dev/null +++ b/examples/samples/resources/dnacenter_network_device_list/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_network_device_list.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_network_device_list/main.tf b/examples/samples/resources/dnacenter_network_device_list/resource.tf similarity index 92% rename from examples/samples/resources/dnacenter_network_device_list/main.tf rename to examples/samples/resources/dnacenter_network_device_list/resource.tf index 20b8a57f..bfd335b8 100644 --- a/examples/samples/resources/dnacenter_network_device_list/main.tf +++ b/examples/samples/resources/dnacenter_network_device_list/resource.tf @@ -1,8 +1,9 @@ + terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -50,10 +51,14 @@ resource "dnacenter_network_device_list" "example" { } user_name = "string" */ + #role = "DISTRIBUTION" + #role_source = "AUTO" + role = "ACCESS" + role_source = "MANUAL" } } output "dnacenter_network_device_list_example" { value = dnacenter_network_device_list.example sensitive = true -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_nfv_profile/resource.tf b/examples/samples/resources/dnacenter_nfv_profile/resource.tf index 152bec65..2fb21efb 100644 --- a/examples/samples/resources/dnacenter_nfv_profile/resource.tf +++ b/examples/samples/resources/dnacenter_nfv_profile/resource.tf @@ -3,7 +3,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -71,4 +71,4 @@ resource "dnacenter_nfv_profile" "example" { output "dnacenter_nfv_profile_example" { value = dnacenter_nfv_profile.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_path_trace/resource.tf b/examples/samples/resources/dnacenter_path_trace/resource.tf index 00dc8b54..a57e8162 100644 --- a/examples/samples/resources/dnacenter_path_trace/resource.tf +++ b/examples/samples/resources/dnacenter_path_trace/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -26,4 +26,4 @@ resource "dnacenter_path_trace" "example" { output "dnacenter_path_trace_example" { value = dnacenter_path_trace.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_pnp_device/main.tf b/examples/samples/resources/dnacenter_pnp_device/main.tf index ee994bfb..78a2e901 100644 --- a/examples/samples/resources/dnacenter_pnp_device/main.tf +++ b/examples/samples/resources/dnacenter_pnp_device/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -33,4 +33,4 @@ resource "dnacenter_pnp_device" "example" { output "dnacenter_pnp_device_example" { value = dnacenter_pnp_device.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_pnp_global_settings/resource.tf b/examples/samples/resources/dnacenter_pnp_global_settings/resource.tf index f31a0d13..b01fe0b0 100644 --- a/examples/samples/resources/dnacenter_pnp_global_settings/resource.tf +++ b/examples/samples/resources/dnacenter_pnp_global_settings/resource.tf @@ -3,7 +3,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -77,4 +77,4 @@ resource "dnacenter_pnp_global_settings" "example" { output "dnacenter_pnp_global_settings_example" { value = dnacenter_pnp_global_settings.example sensitive = true -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_pnp_workflow/main.tf b/examples/samples/resources/dnacenter_pnp_workflow/main.tf index 142a8593..1a6d5a56 100644 --- a/examples/samples/resources/dnacenter_pnp_workflow/main.tf +++ b/examples/samples/resources/dnacenter_pnp_workflow/main.tf @@ -3,7 +3,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -57,4 +57,4 @@ resource "dnacenter_pnp_workflow" "example" { output "dnacenter_pnp_workflow_example" { value = dnacenter_pnp_workflow.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_qos_device_interface/resource.tf b/examples/samples/resources/dnacenter_qos_device_interface/resource.tf index 81fcd6f2..52f2a96b 100644 --- a/examples/samples/resources/dnacenter_qos_device_interface/resource.tf +++ b/examples/samples/resources/dnacenter_qos_device_interface/resource.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -31,4 +31,4 @@ resource "dnacenter_qos_device_interface" "example" { output "dnacenter_qos_device_interface_example" { value = dnacenter_qos_device_interface.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_reports/resource.tf b/examples/samples/resources/dnacenter_reports/resource.tf index 3c0e078c..400f8ab9 100644 --- a/examples/samples/resources/dnacenter_reports/resource.tf +++ b/examples/samples/resources/dnacenter_reports/resource.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -50,4 +50,4 @@ resource "dnacenter_reports" "example" { output "dnacenter_reports_example" { value = dnacenter_reports.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf b/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf index bb74498d..01494b43 100644 --- a/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf +++ b/examples/samples/resources/dnacenter_reserve_ip_subpool/resource.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -41,4 +41,4 @@ resource "dnacenter_reserve_ip_subpool" "example" { output "dnacenter_reserve_ip_subpool_example" { value = dnacenter_reserve_ip_subpool.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_sda_fabric/main.tf b/examples/samples/resources/dnacenter_sda_fabric/main.tf index 0dea81f8..cad98e29 100644 --- a/examples/samples/resources/dnacenter_sda_fabric/main.tf +++ b/examples/samples/resources/dnacenter_sda_fabric/main.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -17,4 +17,4 @@ resource "dnacenter_sda_fabric" "example" { output "dnacenter_sda_fabric_example" { value = dnacenter_sda_fabric.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_service_provider/import.sh b/examples/samples/resources/dnacenter_service_provider/import.sh new file mode 100644 index 00000000..fcb4e83d --- /dev/null +++ b/examples/samples/resources/dnacenter_service_provider/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_service_provicer.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_service_provider/resource.tf b/examples/samples/resources/dnacenter_service_provider/resource.tf new file mode 100644 index 00000000..31ca83fd --- /dev/null +++ b/examples/samples/resources/dnacenter_service_provider/resource.tf @@ -0,0 +1,32 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_service_provider" "example" { + provider = dnacenter + parameters { + + settings { + qos { + profile_name = "Test_tf_new" + model = "8-class-model" + wan_provider = "test1-provider" + } + } + } +} + +output "dnacenter_service_provider_example" { + value = dnacenter_service_provider.example +} diff --git a/examples/samples/resources/dnacenter_site/import.sh b/examples/samples/resources/dnacenter_site/import.sh new file mode 100644 index 00000000..7d2d21bf --- /dev/null +++ b/examples/samples/resources/dnacenter_site/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_site.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_site/resource.tf b/examples/samples/resources/dnacenter_site/resource.tf new file mode 100644 index 00000000..8a01e990 --- /dev/null +++ b/examples/samples/resources/dnacenter_site/resource.tf @@ -0,0 +1,41 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_site" "example" { + provider = dnacenter + parameters { + site { + /* + area { + name= "test_tf_area4" + parent_name= "string" + } + + */ + building { + name = "testBuilding" + address = "255 China Basin Street, San Francisco, California 94158, United States" + parent_name = "Global" + latitude = 37.77178651716143 + longitude = -122.39062051589885 + } + } + type = "building" + } +} + +output "dnacenter_site_example" { + value = dnacenter_site.example +} diff --git a/examples/samples/resources/dnacenter_snmp_properties/resource.tf b/examples/samples/resources/dnacenter_snmp_properties/resource.tf index 3f7f273e..9a862b2f 100644 --- a/examples/samples/resources/dnacenter_snmp_properties/resource.tf +++ b/examples/samples/resources/dnacenter_snmp_properties/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -22,4 +22,4 @@ resource "dnacenter_snmp_properties" "example" { output "dnacenter_snmp_properties_example" { value = dnacenter_snmp_properties.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_swin_image_file/import.sh b/examples/samples/resources/dnacenter_swin_image_file/import.sh new file mode 100644 index 00000000..87f0a31c --- /dev/null +++ b/examples/samples/resources/dnacenter_swin_image_file/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_swim_image_file.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_swin_image_file/resource.tf b/examples/samples/resources/dnacenter_swin_image_file/resource.tf new file mode 100644 index 00000000..65fafdb1 --- /dev/null +++ b/examples/samples/resources/dnacenter_swin_image_file/resource.tf @@ -0,0 +1,26 @@ + +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +provider "dnacenter" { + debug = "true" +} + +resource "dnacenter_swim_image_file" "example" { + provider = dnacenter + parameters { + file_path = "$PATH/terraform-provider-dnacenter/examples/samples/resources/dnacenter_swin_image_file/testIMG1.zip" + file_name = "testIMG1.zip" + } +} + +output "dnacenter_swim_image_file_example" { + value = dnacenter_swim_image_file.example +} diff --git a/examples/samples/resources/dnacenter_tag/resource.tf b/examples/samples/resources/dnacenter_tag/resource.tf index d064aef7..ecf359d4 100644 --- a/examples/samples/resources/dnacenter_tag/resource.tf +++ b/examples/samples/resources/dnacenter_tag/resource.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -34,4 +34,4 @@ resource "dnacenter_tag" "example" { output "dnacenter_tag_example" { value = dnacenter_tag.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_tag_membership/import.sh b/examples/samples/resources/dnacenter_tag_membership/import.sh new file mode 100644 index 00000000..4e9789fb --- /dev/null +++ b/examples/samples/resources/dnacenter_tag_membership/import.sh @@ -0,0 +1 @@ +terraform import dnacenter_tag_membership.example "id:=string" \ No newline at end of file diff --git a/examples/samples/resources/dnacenter_tag_membership/resource.tf b/examples/samples/resources/dnacenter_tag_membership/resource.tf new file mode 100644 index 00000000..d823fe8e --- /dev/null +++ b/examples/samples/resources/dnacenter_tag_membership/resource.tf @@ -0,0 +1,25 @@ +terraform { + required_providers { + dnacenter = { + version = "0.2.0-beta" + source = "hashicorp.com/edu/dnacenter" + # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry + } + } +} + +resource "dnacenter_tag_membership" "example" { + provider = dnacenter + parameters { + #tag_id= "68f7ebd1-81fc-4099-944c-ac38ef6455a5" + tag_id = "f8f4a38f-e0e8-4fb2-91ca-d79ac4078f18" + member_type = "template" + member_id = "8bf887f3-7cc2-4bd2-9407-df0fe6b7f63a" + #member_id="fe2bd8b9-2cf0-4b73-b7dc-755ff0f26363" + + } +} + +output "dnacenter_tag_membership_example" { + value = dnacenter_tag_membership.example +} diff --git a/examples/samples/resources/dnacenter_wireless_dynamic_interface/resource.tf b/examples/samples/resources/dnacenter_wireless_dynamic_interface/resource.tf index 13055c56..d3d8e43d 100644 --- a/examples/samples/resources/dnacenter_wireless_dynamic_interface/resource.tf +++ b/examples/samples/resources/dnacenter_wireless_dynamic_interface/resource.tf @@ -1,7 +1,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -18,4 +18,4 @@ resource "dnacenter_wireless_dynamic_interface" "example" { output "dnacenter_wireless_dynamic_interface_example" { value = dnacenter_wireless_dynamic_interface.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf b/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf index d85b682f..90a87e2f 100644 --- a/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf +++ b/examples/samples/resources/dnacenter_wireless_enterprise_ssid/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -24,16 +24,17 @@ resource "dnacenter_wireless_enterprise_ssid" "example" { enable_session_time_out = "true" fast_transition = "Adaptive" mfp_client_protection = "Optional" - name = "Test" - passphrase = "" + name = "TestPersonal2" + passphrase = "testtest3" radio_policy = "Dual band operation (2.4GHz and 5GHz)" - security_level = "WPA2_ENTERPRISE" + security_level = "WPA2_PERSONAL" session_time_out = 0 traffic_type = "voicedata" + site = "Global/New Jersey" } } output "dnacenter_wireless_enterprise_ssid_example" { value = dnacenter_wireless_enterprise_ssid.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_wireless_profile/resource.tf b/examples/samples/resources/dnacenter_wireless_profile/resource.tf index c6a86ddb..867b32e3 100644 --- a/examples/samples/resources/dnacenter_wireless_profile/resource.tf +++ b/examples/samples/resources/dnacenter_wireless_profile/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -33,4 +33,4 @@ resource "dnacenter_wireless_profile" "example" { output "dnacenter_wireless_profile_example" { value = dnacenter_wireless_profile.example -} \ No newline at end of file +} diff --git a/examples/samples/resources/dnacenter_wireless_rf_profile/resource.tf b/examples/samples/resources/dnacenter_wireless_rf_profile/resource.tf index 2eaf2eb1..9e9a9fc6 100644 --- a/examples/samples/resources/dnacenter_wireless_rf_profile/resource.tf +++ b/examples/samples/resources/dnacenter_wireless_rf_profile/resource.tf @@ -2,7 +2,7 @@ terraform { required_providers { dnacenter = { - version = "0.1.0-beta.2" + version = "0.2.0-beta" source = "hashicorp.com/edu/dnacenter" # "hashicorp.com/edu/dnacenter" is the local built source, change to "cisco-en-programmability/dnacenter" to use downloaded version from registry } @@ -45,4 +45,4 @@ resource "dnacenter_wireless_rf_profile" "example" { output "dnacenter_wireless_rf_profile_example" { value = dnacenter_wireless_rf_profile.example -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index fd51ef69..e5aaf9cf 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module terraform-provider-dnacenter go 1.17 require ( - github.com/cisco-en-programmability/dnacenter-go-sdk/v3 v3.4.1 + github.com/cisco-en-programmability/dnacenter-go-sdk/v3 v3.5.1 github.com/hashicorp/terraform-plugin-docs v0.5.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 ) diff --git a/go.sum b/go.sum index acbbf6a6..978a3ed0 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXH github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cisco-en-programmability/dnacenter-go-sdk/v3 v3.4.1 h1:E0nUfspNnNROIImSJiW3+cLhG6SxAfz3M9NZkG3rEbc= -github.com/cisco-en-programmability/dnacenter-go-sdk/v3 v3.4.1/go.mod h1:VR6YN5I+WTSPOjNWiqIx6YPULwZWE0waW2yRLQq9ETQ= +github.com/cisco-en-programmability/dnacenter-go-sdk/v3 v3.5.1 h1:00/fxTrh1hwvbgUW0vZmzXoJmwfIuWLaTVL9cGYFPLc= +github.com/cisco-en-programmability/dnacenter-go-sdk/v3 v3.5.1/go.mod h1:VR6YN5I+WTSPOjNWiqIx6YPULwZWE0waW2yRLQq9ETQ= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=