diff --git a/CHANGELOG.md b/CHANGELOG.md index bff0d5aa0..5b0c09b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,85 @@ # RELEASE NOTES +## 6.5.0 (Oct 10, 2024) + +#### FEATURES/ENHANCEMENTS: + +* Global + * Migrated Terraform to version 1.9.5. + * Updated SDK v2 and framework libraries. + +* Appsec + * Added the `exceptions` block to the `akamai_appsec_siem_settings` resource with these nested fields: + * `api_request_constraints` + * `apr_protection` + * `bot_management` + * `client_rep` + * `custom_rules` + * `ip_geo` + * `malware_protection` + * `rate` + * `url_protection` + * `slow_post` + * `waf` + +* GTM + * Added the retry logic to the `akamai_gtm_property` resource to handle errors caused by the prolonged creation time, leading to Property Validation Failure with the "no datacenter is assigned to map target (all others)" error from the API. + +* IAM + * Added new data sources: + * `akamai_iam_accessible_groups` - reads the groups and subgroups accessible for a given user. + * `akamai_iam_account_switch_keys` - reads the account switch keys. + * `akamai_iam_allowed_apis` - reads the list of APIs available to a given user. + * `akamai_iam_authorized_users` - reads the list of authorized API client users. + * `akamai_iam_blocked_properties` - reads blocked properties for a certain user in a group. + * `akamai_iam_cidr_block` - reads details of a specified CIDR block. + * `akamai_iam_cidr_blocks` - lists all CIDR blocks available to you on your allowlist. + * `akamai_iam_group` - reads details about a given group and any of its subgroups. + * `akamai_iam_password_policy` - reads the password policy parameters. + * `akamai_iam_property_users` - lists users for a given property or include. + * `akamai_iam_role` - reads details of a specified role. + * `akamai_iam_user` - reads details of a specific user account. + * `akamai_iam_users` - lists all users with access to your account. + * `akamai_iam_users_affected_by_moving_group` - lists the users affected by moving a group. + * Added new resources: + * `akamai_iam_cidr_block` - manages CIDR block assigned to the allowlist. + * `akamai_iam_ip_allowlist` - enables or disable your account's allowlist. + * Added new attributes to the `resource_akamai_iam_user` resource. + * `user_notifications` to support user notifications. + * `enable_mfa` to support authentication of type "MFA". + * `password` to allow users to set a password when creating and updating a user. + * Made the `enable_tfa` attribute optional in the `resource_akamai_iam_user` resource. + * Added the `asset_id` schema field (an IAM identifier of a property or include) to: + * The `akamai_property` resource and data source, + * The `akamai_property_include` resource and data source. + * Improved date handling to use `time.Time` instead of `string`. + +* PAPI + * Added a new optional param to the import id of the `akamai_edge_hostname` resource. + It allows to specify the product ID of the imported hostname and save it in the state. + +#### BUG FIXES: + +* PAPI + * Added support for status code `429 Too Many Requests` containing `X-RateLimit-Next` header. + When `X-RateLimit-Next` is present, the wait time before retry is calculated as the time + difference between this header and the `Date` header. + * Fixed an issue with the `akamai_property_activation` resource where updating it with an active or previously active property version for a configuration without a state file didn’t trigger a new property activation. + +#### DEPRECATIONS: + +* PAPI + * Deprecated fields `product_id` and `rule_format` from `akamai_properties` datasource. Please use `akamai_property` to fetch this data. + ## 6.4.0 (Sep 04, 2024) #### FEATURES/ENHANCEMENTS: * Global - * Updated SDKv2 and framework libraries as result of updating `terraform-plugin-testing` + * Updated SDK v2 and framework libraries as a result of updating `terraform-plugin-testing`. * Appsec - * Added `request_body_inspection_limit_override` field to `akamai_appsec_advanced_settings_request_body` resource + * Added the `request_body_inspection_limit_override` field to the `akamai_appsec_advanced_settings_request_body` resource. * CPS * Added `acknowledge_post_verification_warnings` to the `akamai_cps_dv_validation` resource to allow for acknowledgement of post-verification warnings diff --git a/build/internal/docker_jenkins.bash b/build/internal/docker_jenkins.bash index a089d06c9..5c93c5dac 100755 --- a/build/internal/docker_jenkins.bash +++ b/build/internal/docker_jenkins.bash @@ -26,7 +26,7 @@ COVERAGE_HTML="$COVERAGE_DIR"/index.html WORKDIR="${WORKDIR-$(pwd)}" echo "WORKDIR is $WORKDIR" -TERRAFORM_VERSION="1.7.5" +TERRAFORM_VERSION="1.9.5" STASH_SERVER=git.source.akamai.com GIT_IP=$(dig +short $STASH_SERVER) @@ -91,7 +91,7 @@ docker exec akatf-container sh -c 'git clone ssh://git@git.source.akamai.com:799 echo "Checkout branches" docker exec akatf-container sh -c 'cd edgegrid; git checkout ${EDGEGRID_BRANCH_NAME}; cd ../terraform-provider-akamai; git checkout ${PROVIDER_BRANCH_NAME}; - go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8=../edgegrid' + go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9=../edgegrid' echo "Installing terraform" docker exec akatf-container sh -c 'cd terraform-provider-akamai; make tools.terraform' diff --git a/build/internal/package/Dockerfile b/build/internal/package/Dockerfile index 535c19678..5901a0d8f 100644 --- a/build/internal/package/Dockerfile +++ b/build/internal/package/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.12-alpine3.20 +FROM golang:1.21.12-alpine3.19 ENV PROVIDER_VERSION="1.0.0" \ CGO_ENABLED=0 \ diff --git a/build/internal/package/nexus-release.bash b/build/internal/package/nexus-release.bash index cfeb8909e..0f0fe1631 100755 --- a/build/internal/package/nexus-release.bash +++ b/build/internal/package/nexus-release.bash @@ -84,7 +84,7 @@ checkout_edgegrid() { } adjust_edgegrid() { - go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8="./akamaiopen-edgegrid-golang" + go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9="./akamaiopen-edgegrid-golang" go mod tidy -compat=1.21.12 } diff --git a/build/internal/releaser/goreleaser_build.bash b/build/internal/releaser/goreleaser_build.bash index 6c3b271c8..5a6909db2 100755 --- a/build/internal/releaser/goreleaser_build.bash +++ b/build/internal/releaser/goreleaser_build.bash @@ -1,4 +1,4 @@ cd /workspace/terraform-provider-akamai -go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8=../akamaiopen-edgegrid-golang/ +go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9=../akamaiopen-edgegrid-golang/ git tag v10.0.0 goreleaser build --single-target --skip-validate --config ./.goreleaser.yml --output /root/.terraform.d/plugins/registry.terraform.io/akamai/akamai/10.0.0/linux_amd64/terraform-provider-akamai_v10.0.0 diff --git a/docs/data-sources/data-sources.md b/docs/data-sources/data-sources.md index 3792a751c..d92db7db5 100644 --- a/docs/data-sources/data-sources.md +++ b/docs/data-sources/data-sources.md @@ -8,18 +8,18 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi | Subprovider | Description | |---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/appsec-datasources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/botman-datasources) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-datasources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/cli-data-sources) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/cam-ds) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/cw-data-sources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/cl-datasources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/ds-datasources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/edns-datasources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/ew-datasources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/gtm-datasources) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/iam-datasources) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/ivm-datasources) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/nl-datasources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/pm-datasources) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/appsec-datasources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/botman-datasources) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-datasources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/cli-data-sources) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/cam-ds) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/cw-data-sources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/cl-datasources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/ds-datasources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/edns-datasources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/ew-datasources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/gtm-datasources) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/iam-datasources) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/ivm-datasources) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/nl-datasources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/pm-datasources) | Define rules and behaviors that govern your website delivery based on match criteria. | diff --git a/docs/guides/get-started.md b/docs/guides/get-started.md index 408f748a3..ba3616d3d 100644 --- a/docs/guides/get-started.md +++ b/docs/guides/get-started.md @@ -21,7 +21,7 @@ Your Akamai Terraform configuration starts with listing us as a required provide required_providers { akamai = { source = "akamai/akamai" - version = "6.4.0" + version = "6.5.0" } } } @@ -99,21 +99,21 @@ Use the table to find information about the subprovider you’re using. | Subprovider | Description | |----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | ### Get contract and group IDs diff --git a/docs/index.md b/docs/index.md index 6e45e5721..12c00001f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,21 +35,21 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi | Subprovider | Description | |----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | ## Links to resources diff --git a/docs/resources/resources.md b/docs/resources/resources.md index fc4c279eb..cf8390b80 100644 --- a/docs/resources/resources.md +++ b/docs/resources/resources.md @@ -8,18 +8,18 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi | Subprovider | Description | |-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/appsec-resources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/botman-resources) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-resources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/cli-resources) |Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/cam-rc) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys.| -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/cw-resources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/cl-resources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/ds-resources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/edns-resources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/ew-resources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/gtm-resources) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/iam-resources) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/ivm-resources) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/nl-resources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/pm-resources) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/appsec-resources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/botman-resources) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-resources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/cli-resources) |Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/cam-rc) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys.| +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/cw-resources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/cl-resources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/ds-resources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/edns-resources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/ew-resources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/gtm-resources) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/iam-resources) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/ivm-resources) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/nl-resources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/pm-resources) | Define rules and behaviors that govern your website delivery based on match criteria. | diff --git a/go.mod b/go.mod index cf505f307..59d541883 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/akamai/terraform-provider-akamai/v6 go 1.21 require ( - github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.4.0 + github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 v9.0.0 github.com/allegro/bigcache/v2 v2.2.5 github.com/apex/log v1.9.0 github.com/dlclark/regexp2 v1.10.0 @@ -13,14 +13,14 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-hclog v1.6.3 - github.com/hashicorp/terraform-plugin-framework v1.8.0 + github.com/hashicorp/terraform-plugin-framework v1.11.0 github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 - github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 github.com/hashicorp/terraform-plugin-go v0.23.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-mux v0.16.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 - github.com/hashicorp/terraform-plugin-testing v1.9.0 + github.com/hashicorp/terraform-plugin-testing v1.10.0 github.com/iancoleman/strcase v0.3.0 github.com/jedib0t/go-pretty/v6 v6.0.4 github.com/jinzhu/copier v0.3.2 @@ -28,7 +28,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/tj/assert v0.0.3 golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.8.0 ) require ( @@ -46,9 +46,10 @@ require ( github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/hc-install v0.7.0 // indirect + github.com/hashicorp/hc-install v0.8.0 // indirect github.com/hashicorp/hcl/v2 v2.21.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect @@ -73,13 +74,13 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.14.4 // indirect + github.com/zclconf/go-cty v1.15.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.25.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect @@ -90,4 +91,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -// replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 => ../AkamaiOPEN-edgegrid-golang +// replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 => ../AkamaiOPEN-edgegrid-golang diff --git a/go.sum b/go.sum index c3bd65481..d1aaa5029 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97 github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.4.0 h1:zZJimNqkV3o7qZqBnprKyHCqUOTzoEaabG4qB3z0E2g= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.4.0/go.mod h1:2xRRnHx8dnw0i8IZPYOI0I7xbr1gnAN1uIYo7acMIbg= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 v9.0.0 h1:TGI1yfVRiKC9qWT35YJeA1Rtiofx9CtTfATZE3lopyQ= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 v9.0.0/go.mod h1:1tYxzSXTnUxMbzafz3QhRSj1rc9Ag6iF8rju1AyqMuo= github.com/allegro/bigcache/v2 v2.2.5 h1:mRc8r6GQjuJsmSKQNPsR5jQVXc8IJ1xsW5YXUYMLfqI= github.com/allegro/bigcache/v2 v2.2.5/go.mod h1:FppZsIO+IZk7gCuj5FiIDHGygD9xvWQcqg1uIPMb6tY= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI= @@ -86,13 +86,15 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= -github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= +github.com/hashicorp/hc-install v0.8.0 h1:LdpZeXkZYMQhoKPCecJHlKvUkQFixN/nvyR1CdfOLjI= +github.com/hashicorp/hc-install v0.8.0/go.mod h1:+MwJYjDfCruSD/udvBmRB22Nlkwwkwf5sAB6uTIhSaU= github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= @@ -101,12 +103,12 @@ github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVW github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-framework v1.8.0 h1:P07qy8RKLcoBkCrY2RHJer5AEvJnDuXomBgou6fD8kI= -github.com/hashicorp/terraform-plugin-framework v1.8.0/go.mod h1:/CpTukO88PcL/62noU7cuyaSJ4Rsim+A/pa+3rUVufY= +github.com/hashicorp/terraform-plugin-framework v1.11.0 h1:M7+9zBArexHFXDx/pKTxjE6n/2UCXY6b8FIq9ZYhwfE= +github.com/hashicorp/terraform-plugin-framework v1.11.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1/go.mod h1:MsjL1sQ9L7wGwzJ5RjcI6FzEMdyoBnw+XK8ZnOvQOLY= -github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= -github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= +github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E= +github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo= github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= @@ -115,8 +117,8 @@ github.com/hashicorp/terraform-plugin-mux v0.16.0 h1:RCzXHGDYwUwwqfYYWJKBFaS3fQs github.com/hashicorp/terraform-plugin-mux v0.16.0/go.mod h1:PF79mAsPc8CpusXPfEVa4X8PtkB+ngWoiUClMrNZlYo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE= github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg= -github.com/hashicorp/terraform-plugin-testing v1.9.0 h1:xOsQRqqlHKXpFq6etTxih3ubdK3HVDtfE1IY7Rpd37o= -github.com/hashicorp/terraform-plugin-testing v1.9.0/go.mod h1:fhhVx/8+XNJZTD5o3b4stfZ6+q7z9+lIWigIYdT6/44= +github.com/hashicorp/terraform-plugin-testing v1.10.0 h1:2+tmRNhvnfE4Bs8rB6v58S/VpqzGC6RCh9Y8ujdn+aw= +github.com/hashicorp/terraform-plugin-testing v1.10.0/go.mod h1:iWRW3+loP33WMch2P/TEyCxxct/ZEcCGMquSLSCVsrc= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -231,8 +233,8 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= +github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= @@ -242,13 +244,13 @@ go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6m golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -259,8 +261,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -277,8 +279,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -286,8 +288,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/internal/test/test.go b/internal/test/test.go index 7c8210fbf..e6c811ff3 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -2,9 +2,13 @@ package test import ( + "math/rand" + "net/http" + "sync" "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -15,3 +19,88 @@ func NewTimeFromString(t *testing.T, s string) time.Time { require.NoError(t, err) return parsedTime } + +// XRateLimitHTTPHandler first returns status 429 with the X-RateLimit-Next header set to +// time.Now() plus a random value between 1 and 5 milliseconds. It keeps sending 429 until the +// X-RateLimit-Next point in time. Then it starts to return SuccessCode and SuccessBody +// indefinitely. +type XRateLimitHTTPHandler struct { + T *testing.T + SuccessCode int + SuccessBody string + + mutex sync.Mutex + availableAt time.Time + returnedCodes []int + returnTimes []time.Time +} + +func (h *XRateLimitHTTPHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { + av := h.AvailableAt() + + if av.IsZero() { + busyInterval := time.Duration(1+rand.Intn(4)) * time.Millisecond + h.setAvailableAt(time.Now().Add(busyInterval)) + h.setTooManyRequests(w) + return + } + + now := time.Now() + if now.Before(av) { + h.setTooManyRequests(w) + } else { + h.setStatusCode(w, h.SuccessCode) + _, err := w.Write([]byte(h.SuccessBody)) + assert.NoError(h.T, err) + } +} + +// AvailableAt returns the point in time at which the handler stops returning status code 429 +func (h *XRateLimitHTTPHandler) AvailableAt() time.Time { + h.mutex.Lock() + defer h.mutex.Unlock() + return h.availableAt +} + +// ReturnedCodes returns a list of status codes from subsequent handler responses +func (h *XRateLimitHTTPHandler) ReturnedCodes() []int { + h.mutex.Lock() + defer h.mutex.Unlock() + res := make([]int, len(h.returnedCodes)) + copy(res, h.returnedCodes) + return res +} + +// ReturnTimes returns a list of times at which subsequent responses were written +func (h *XRateLimitHTTPHandler) ReturnTimes() []time.Time { + h.mutex.Lock() + defer h.mutex.Unlock() + res := make([]time.Time, len(h.returnTimes)) + copy(res, h.returnTimes) + return res +} + +func (h *XRateLimitHTTPHandler) setTooManyRequests(w http.ResponseWriter) { + // Do not use Add() to avoid canonicalization to X-Ratelimit-Next + nextStr := h.availableAt.Format(time.RFC3339Nano) + w.Header()["X-RateLimit-Next"] = []string{nextStr} + h.setStatusCode(w, http.StatusTooManyRequests) + body := "Your request did not succeed as this operation has reached the limit " + + "for your account. Please try after " + nextStr + _, err := w.Write([]byte(body)) + assert.NoError(h.T, err) +} + +func (h *XRateLimitHTTPHandler) setStatusCode(w http.ResponseWriter, statusCode int) { + w.WriteHeader(statusCode) + h.mutex.Lock() + defer h.mutex.Unlock() + h.returnedCodes = append(h.returnedCodes, statusCode) + h.returnTimes = append(h.returnTimes, time.Now()) +} + +func (h *XRateLimitHTTPHandler) setAvailableAt(availableAt time.Time) { + h.mutex.Lock() + defer h.mutex.Unlock() + h.availableAt = availableAt +} diff --git a/pkg/akamai/configure_context.go b/pkg/akamai/configure_context.go index 0dcfcf19e..105529c9b 100644 --- a/pkg/akamai/configure_context.go +++ b/pkg/akamai/configure_context.go @@ -10,12 +10,13 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/retryablehttp" + "github.com/apex/log" "github.com/google/uuid" "github.com/spf13/cast" ) @@ -62,6 +63,90 @@ func sessionWithoutRetry(opts []session.Option) (session.Session, error) { return session.New(opts...) } +func overrideRetryPolicy(basePolicy retryablehttp.CheckRetry) retryablehttp.CheckRetry { + return func(ctx context.Context, resp *http.Response, err error) (bool, error) { + + // do not retry on context.Canceled or context.DeadlineExceeded + if ctx.Err() != nil { + return false, ctx.Err() + } + + // Retry all PAPI requests resulting status code 429 + // The backoff time is calculated in getXRateLimitBackoff + is429 := resp != nil && resp.StatusCode == http.StatusTooManyRequests + if is429 && strings.HasPrefix(resp.Request.URL.Path, "/papi/") { + return true, nil + } + + var urlErr *url.Error + if (resp != nil && resp.Request.Method == http.MethodGet) || + (resp == nil && errors.As(err, &urlErr) && strings.ToUpper(urlErr.Op) == http.MethodGet) { + + if resp != nil && resp.StatusCode == http.StatusConflict { + return true, nil + } + return basePolicy(ctx, resp, err) + } + return false, nil + } +} + +// Note that Date's resolution is seconds (e.g. Mon, 01 Jul 2024 14:32:14 GMT), +// while X-RateLimit-Next's resolution is milliseconds (2024-07-01T14:32:28.645Z). +// This may cause the wait time to be inflated by at most one second, like for the +// actual server response time around 2024-07-01T14:32:14.999Z. This is acceptable behavior +// as retry does not occur earlier than expected. +func getXRateLimitBackoff(resp *http.Response, logger log.Interface) (time.Duration, bool) { + nextHeader := resp.Header.Get("X-RateLimit-Next") + if nextHeader == "" { + return 0, false + } + next, err := time.Parse(time.RFC3339Nano, nextHeader) + if err != nil { + if logger != nil { + logger.WithError(err).Error("Could not parse X-RateLimit-Next header") + } + return 0, false + } + + dateHeader := resp.Header.Get("Date") + if dateHeader == "" { + if logger != nil { + logger.Warnf("No Date header for X-RateLimit-Next: %s", nextHeader) + } + return 0, false + } + date, err := time.Parse(time.RFC1123, dateHeader) + if err != nil { + if logger != nil { + logger.WithError(err).Error("Could not parse Date header") + } + return 0, false + } + + // Next in the past does not make sense + if next.Before(date) { + if logger != nil { + logger.Warnf("X-RateLimit-Next: %s before Date: %s", nextHeader, dateHeader) + } + return 0, false + } + return next.Sub(date), true +} + +func overrideBackoff(baseBackoff retryablehttp.Backoff, logger log.Interface) retryablehttp.Backoff { + return func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { + if resp != nil { + if resp.StatusCode == http.StatusTooManyRequests { + if wait, ok := getXRateLimitBackoff(resp, logger); ok { + return wait + } + } + } + return baseBackoff(min, max, attemptNum, resp) + } +} + func sessionWithRetry(cfg contextConfig, opts []session.Option) (session.Session, error) { if cfg.retryMax == 0 { cfg.retryMax = 10 @@ -97,20 +182,9 @@ func sessionWithRetry(cfg contextConfig, opts []session.Option) (session.Session return sess.Sign(req) } - retryClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) { - var urlErr *url.Error - if (resp != nil && resp.Request.Method == http.MethodGet) || - (resp == nil && errors.As(err, &urlErr) && strings.ToUpper(urlErr.Op) == http.MethodGet) { - if ctx.Err() != nil { - return false, ctx.Err() - } - if resp != nil && resp.StatusCode == http.StatusConflict { - return true, nil - } - return retryablehttp.DefaultRetryPolicy(ctx, resp, err) - } - return false, nil - } + retryClient.CheckRetry = overrideRetryPolicy(retryablehttp.DefaultRetryPolicy) + + retryClient.Backoff = overrideBackoff(retryablehttp.DefaultBackoff, sess.Log(cfg.ctx)) return sess, nil } diff --git a/pkg/akamai/configure_context_test.go b/pkg/akamai/configure_context_test.go index 2d318a0f9..93847f226 100644 --- a/pkg/akamai/configure_context_test.go +++ b/pkg/akamai/configure_context_test.go @@ -1,10 +1,24 @@ package akamai import ( + "context" + "crypto/tls" + "crypto/x509" + "errors" + "net/http" + "net/http/httptest" + "net/url" + "strings" "testing" "time" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/retryablehttp" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func Test_validateRetryConfiguration(t *testing.T) { @@ -101,3 +115,293 @@ func Test_validateRetryConfiguration(t *testing.T) { }) } } + +func newRequest(t *testing.T, method, url string) *http.Request { + r, err := http.NewRequest(method, url, nil) + assert.NoError(t, err) + return r +} + +func TestOverrideRetryPolicy(t *testing.T) { + basePolicy := func(ctx context.Context, resp *http.Response, err error) (bool, error) { + return false, errors.New("base policy: dummy, not implemented") + } + policy := overrideRetryPolicy(basePolicy) + + tests := map[string]struct { + ctx context.Context + resp *http.Response + err error + expectedResult bool + expectedError string + }{ + "should retry for PAPI GET with status 429": { + ctx: context.Background(), + resp: &http.Response{ + Request: newRequest(t, http.MethodGet, "/papi/v1/sth"), + StatusCode: http.StatusTooManyRequests, + }, + expectedResult: true, + }, + "should retry for PAPI POST with status 429": { + ctx: context.Background(), + resp: &http.Response{ + Request: newRequest(t, http.MethodPost, "/papi/v1/sth"), + StatusCode: http.StatusTooManyRequests, + }, + expectedResult: true, + }, + "should not retry for PAPI POST with other 4xx status": { + ctx: context.Background(), + resp: &http.Response{ + Request: newRequest(t, http.MethodPost, "/papi/v1/sth"), + StatusCode: http.StatusBadRequest, + }, + expectedResult: false, + }, + "should retry for GET with status 409 conflict": { + ctx: context.Background(), + resp: &http.Response{ + Request: &http.Request{Method: http.MethodGet}, + StatusCode: http.StatusConflict, + }, + expectedResult: true, + }, + "should call base policy for other GETs": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodGet}}, + expectedError: "base policy: dummy, not implemented", + }, + "should forward context error when present": { + ctx: func() context.Context { + ctx, cancel := context.WithCancel(context.Background()) + cancel() + return ctx + }(), + resp: &http.Response{Request: &http.Request{Method: http.MethodGet}}, + expectedError: "context canceled", + }, + "should not retry for POST": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodPost}}, + expectedResult: false, + }, + "should not retry for PUT": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodPut}}, + expectedResult: false, + }, + "should not retry for PATCH": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodPatch}}, + expectedResult: false, + }, + "should not retry for HEAD": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodHead}}, + expectedResult: false, + }, + "should not retry for DELETE": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodDelete}}, + expectedResult: false, + }, + } + for name, tst := range tests { + t.Run(name, func(t *testing.T) { + shouldRetry, err := policy(tst.ctx, tst.resp, tst.err) + if len(tst.expectedError) > 0 { + assert.ErrorContains(t, err, tst.expectedError) + } else { + assert.NoError(t, err) + assert.Equal(t, tst.expectedResult, shouldRetry) + } + }) + } +} + +func stat429ResponseWaiting(wait time.Duration) *http.Response { + res := http.Response{ + StatusCode: http.StatusTooManyRequests, + Header: http.Header{}, + } + + now := time.Now().UTC().Round(time.Second) + date := strings.Replace(now.Format(time.RFC1123), "UTC", "GMT", 1) + res.Header.Add("Date", date) + if wait != 0 { + // Add: allow to canonicalize to X-Ratelimit-Next or the header won't be recognized + res.Header.Add("X-RateLimit-Next", now.Add(wait).Format(time.RFC3339Nano)) + } + return &res +} + +func Test_overrideBackoff(t *testing.T) { + baseWait := time.Duration(24) * time.Hour + baseBackoff := func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { + return baseWait + } + backoff := overrideBackoff(baseBackoff, nil) + + tests := map[string]struct { + resp *http.Response + expectedResult time.Duration + }{ + "correctly calculates backoff from X-RateLimit-Next": { + resp: stat429ResponseWaiting(time.Duration(5729) * time.Millisecond), + expectedResult: time.Duration(5729) * time.Millisecond, + }, + "falls back for next in the past": { + resp: stat429ResponseWaiting(-time.Duration(5729) * time.Millisecond), + expectedResult: baseWait, + }, + "falls back for no X-RateLimit-Next header": { + resp: stat429ResponseWaiting(0), + expectedResult: baseWait, + }, + "falls back for invalid X-RateLimit-Next header": { + resp: func() *http.Response { + r := stat429ResponseWaiting(time.Duration(5729) * time.Millisecond) + r.Header.Set("X-RateLimit-Next", "2024-07-01T14:32:28.645???") + return r + }(), + expectedResult: baseWait, + }, + "falls back for no Date header": { + resp: func() *http.Response { + r := stat429ResponseWaiting(time.Duration(5729) * time.Millisecond) + r.Header.Del("Date") + return r + }(), + expectedResult: baseWait, + }, + "falls back for invalid Date header": { + resp: func() *http.Response { + r := stat429ResponseWaiting(time.Duration(5729) * time.Millisecond) + r.Header.Set("Date", "Mon, 01 Jul 2024 99:99:99 GMT") + return r + }(), + expectedResult: baseWait, + }, + } + for name, tst := range tests { + t.Run(name, func(t *testing.T) { + wait := backoff(1, 30, 1, tst.resp) + assert.Equal(t, tst.expectedResult, wait) + }) + } +} + +func mockSession(t *testing.T, mockServer *httptest.Server) session.Session { + serverURL, err := url.Parse(mockServer.URL) + require.NoError(t, err) + config := edgegrid.Config{Host: serverURL.Host} + + meta, err := configureContext(contextConfig{ + edgegridConfig: &config, + ctx: context.Background(), + }) + assert.NoError(t, err) + + certPool := x509.NewCertPool() + certPool.AddCert(mockServer.Certificate()) + rt := meta.Session().Client().Transport.(*retryablehttp.RoundTripper) + transport := rt.Client.HTTPClient.Transport.(*http.Transport) + transport.TLSClientConfig = &tls.Config{ + RootCAs: certPool, + } + + return meta.Session() +} + +func TestXRateLimitGet(t *testing.T) { + xrlHandler := test.XRateLimitHTTPHandler{ + T: t, + SuccessCode: http.StatusOK, + SuccessBody: ` + { + "properties": { + "items": [ + { + "accountId": "dummy_account_id", + "contractId": "ctr_test1", + "groupId": "grp_test1", + "propertyId": "prp_test1", + "propertyName": "my_property", + "latestVersion": 1, + "stagingVersion": null, + "productionVersion": null, + "assetId": "12345678" + } + ] + } + }`, + } + + mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/papi/v1/properties/prp_test1?contractId=ctr_test1&groupId=grp_test1", r.URL.String()) + assert.Equal(t, http.MethodGet, r.Method) + xrlHandler.ServeHTTP(w, r) + })) + defer mockServer.Close() + + client := papi.Client(mockSession(t, mockServer)) + result, err := client.GetProperty(context.Background(), papi.GetPropertyRequest{ + ContractID: "ctr_test1", + GroupID: "grp_test1", + PropertyID: "prp_test1", + }) + require.NoError(t, err) + assert.Equal(t, "my_property", result.Property.PropertyName) + // We expect exactly two requests to the server: + // - the first resulting in code 429 + // - the second after a proper backoff, resulting in status 200 + assert.Equal(t, []int{http.StatusTooManyRequests, http.StatusOK}, xrlHandler.ReturnedCodes()) + assert.Less(t, + xrlHandler.ReturnTimes()[1], + xrlHandler.AvailableAt().Add(time.Duration(time.Millisecond)*1100)) +} + +func TestXRateLimitPost(t *testing.T) { + xrlHandler := test.XRateLimitHTTPHandler{ + T: t, + SuccessCode: http.StatusCreated, + SuccessBody: ` + { + "activationLink": "/papi/v1/properties/prp_12345/activations/dummy_activation?contractId=ctr_test1&groupId=grp_test1" + }`, + } + + mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/papi/v1/properties/prp_12345/activations?contractId=ctr_test1&groupId=grp_test1", r.URL.String()) + assert.Equal(t, http.MethodPost, r.Method) + xrlHandler.ServeHTTP(w, r) + })) + defer mockServer.Close() + + client := papi.Client(mockSession(t, mockServer)) + result, err := client.CreateActivation(context.Background(), papi.CreateActivationRequest{ + PropertyID: "prp_12345", + ContractID: "ctr_test1", + GroupID: "grp_test1", + Activation: papi.Activation{ + PropertyVersion: 1, + Network: papi.ActivationNetworkStaging, + UseFastFallback: false, + NotifyEmails: []string{ + "you@example.com", + "them@example.com", + }, + AcknowledgeWarnings: []string{"foobarbaz"}, + }, + }) + require.NoError(t, err) + assert.Equal(t, "dummy_activation", result.ActivationID) + // We expect exactly two requests to the server: + // - the first resulting in code 429 + // - the second after a proper backoff, resulting in status 201 + assert.Equal(t, []int{http.StatusTooManyRequests, http.StatusCreated}, xrlHandler.ReturnedCodes()) + assert.Less(t, + xrlHandler.ReturnTimes()[1], + xrlHandler.AvailableAt().Add(time.Duration(time.Millisecond)*1100)) +} diff --git a/pkg/akamai/edgegrid.go b/pkg/akamai/edgegrid.go index 303897e74..cb5051cd4 100644 --- a/pkg/akamai/edgegrid.go +++ b/pkg/akamai/edgegrid.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" ) // ErrWrongEdgeGridConfiguration is returned when the configuration could not be read diff --git a/pkg/akamai/edgegrid_test.go b/pkg/akamai/edgegrid_test.go index 466ca47e6..4daea7d45 100644 --- a/pkg/akamai/edgegrid_test.go +++ b/pkg/akamai/edgegrid_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/akamai/sdk_provider_test.go b/pkg/akamai/sdk_provider_test.go index b4497c7b3..7e3924b28 100644 --- a/pkg/akamai/sdk_provider_test.go +++ b/pkg/akamai/sdk_provider_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" "github.com/akamai/terraform-provider-akamai/v6/pkg/akamai" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" diff --git a/pkg/common/date/parse.go b/pkg/common/date/parse.go index 93c9fd518..3ca7ffc9d 100644 --- a/pkg/common/date/parse.go +++ b/pkg/common/date/parse.go @@ -37,6 +37,15 @@ func FormatRFC3339(t time.Time) string { return t.Format(time.RFC3339) } +// FormatRFC3339Nano returns a textual representation of time formatted according to the RFC3339Nano standard. +// It returns an empty string if the provided time is equal to zero +func FormatRFC3339Nano(t time.Time) string { + if t.IsZero() { + return "" + } + return t.Format(time.RFC3339Nano) +} + // ToString returns given date in the string format func ToString(value time.Time) (string, error) { bytes, err := value.MarshalText() diff --git a/pkg/common/date/parse_test.go b/pkg/common/date/parse_test.go index 314263f59..b7c170baf 100644 --- a/pkg/common/date/parse_test.go +++ b/pkg/common/date/parse_test.go @@ -3,6 +3,7 @@ package date import ( "errors" "testing" + "time" "github.com/stretchr/testify/assert" ) @@ -34,3 +35,26 @@ func TestParse(t *testing.T) { }) } } + +func TestFormatRFC3339Nano(t *testing.T) { + tests := map[string]struct { + date time.Time + want string + }{ + "non zero time": { + date: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + want: "2000-01-01T00:00:00Z", + }, + "zero time": { + date: time.Time{}, + want: "", + }, + } + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + if got := FormatRFC3339Nano(tt.date); got != tt.want { + t.Errorf("FormatRFC3339Nano() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/common/test/statecheckers.go b/pkg/common/test/statecheckers.go new file mode 100644 index 000000000..8958f5bec --- /dev/null +++ b/pkg/common/test/statecheckers.go @@ -0,0 +1,136 @@ +// Package test contains reusable structure and functions used during testing of sub-providers +package test + +import ( + "fmt" + "maps" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" +) + +// checkData contains information about expected value of an attribute and whether such attribute should be present. +type checkData struct { + isMissing bool + value string +} + +// StateChecker allows to check the attributes in the terraform state. +type StateChecker struct { + resourceName string + attributes map[string]checkData +} + +// NewStateChecker creates a new instance of a StateChecker that checks attributes for a resource with provided name. +func NewStateChecker(resourceName string) StateChecker { + return StateChecker{ + attributes: map[string]checkData{}, + resourceName: resourceName, + } +} + +// Build processes all attributes and creates checks for them based on assigned values. +func (c StateChecker) Build() resource.TestCheckFunc { + + if len(c.attributes) == 0 { + panic("there must be at least one check in order to build the checker") + } + + var checks []resource.TestCheckFunc + for key, data := range c.attributes { + if data.isMissing { + checks = append(checks, resource.TestCheckNoResourceAttr(c.resourceName, key)) + } else { + checks = append(checks, resource.TestCheckResourceAttr(c.resourceName, key, data.value)) + } + } + + return resource.ComposeAggregateTestCheckFunc(checks...) +} + +// CheckEqual adds a check for provided attribute name and corresponding value. +func (c StateChecker) CheckEqual(attr, val string) StateChecker { + copied := NewStateChecker(c.resourceName) + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + value: val, + } + return copied +} + +// CheckMissing adds a check for a provided attribute name to not be present in the state. +func (c StateChecker) CheckMissing(attr string) StateChecker { + copied := NewStateChecker(c.resourceName) + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + isMissing: true, + } + return copied +} + +// ImportChecker allows to check the attributes in the state after terraform import. +type ImportChecker struct { + attributes map[string]checkData +} + +// NewImportChecker creates a new instance of a ImportChecker that checks attributes for provided resource name after the resource is imported. +func NewImportChecker() ImportChecker { + return ImportChecker{ + attributes: map[string]checkData{}, + } +} + +// Build processes all attributes and creates checks for them based on assigned values. +func (c ImportChecker) Build() resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + if len(c.attributes) == 0 { + panic("there must be at least one check in order to build the checker") + } + + state := s[0] + + for key, data := range c.attributes { + if err := assertAttributeFor(state, key, data); err != nil { + return err + } + } + return nil + } +} + +// CheckEqual adds a check for provided attribute name and corresponding value. +func (c ImportChecker) CheckEqual(attr, val string) ImportChecker { + copied := NewImportChecker() + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + value: val, + } + return copied +} + +// CheckMissing adds a check for a provided attribute name to not be present in the state. +func (c ImportChecker) CheckMissing(attr string) ImportChecker { + copied := NewImportChecker() + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + isMissing: true, + } + return copied +} + +// assertAttributeFor checks whether given attribute is present in the state and has a correct value. +func assertAttributeFor(state *terraform.InstanceState, key string, data checkData) error { + valueInState, exists := state.Attributes[key] + + if data.isMissing && exists { + return fmt.Errorf("attribute %q was present and has a value: %q, but shouldn't be", key, data.value) + } + if !data.isMissing && !exists { + return fmt.Errorf(fmt.Sprintf("attribute %q was not present, but should have a value: %q", key, data.value)) + } + if !data.isMissing && (data.value != valueInState) { + return fmt.Errorf("attribute %q has incorrect value %q, but should have %q", key, valueInState, data.value) + } + + return nil +} diff --git a/pkg/common/test/statecheckers_test.go b/pkg/common/test/statecheckers_test.go new file mode 100644 index 000000000..57ac8c244 --- /dev/null +++ b/pkg/common/test/statecheckers_test.go @@ -0,0 +1,455 @@ +package test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testprovider" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" +) + +var providerBlock = `provider "akamai" { + edgerc = "../testutils/edgerc" +} +` + +func TestStateChecker(t *testing.T) { + checker := NewStateChecker("akamai_test.sample-resource") + + tests := map[string]struct { + checks resource.TestCheckFunc + config string + error *regexp.Regexp + }{ + "happy path - correct attribute value, two checks passing": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("input", "my output value"). + CheckEqual("output", "my output value"). + Build(), + }, + "happy path - overwrite attribute check with last CheckEqual": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("output", "wrong value"). + CheckEqual("output", "my output value"). + Build(), + }, + "happy path - CheckMissing overwrites CheckEqual for the same attribute": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("not_existing_attribute", "wrong value"). + CheckMissing("not_existing_attribute"). + Build(), + }, + "happy path - CheckEqual overwrites CheckMissing for the same attribute": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("output"). + CheckEqual("output", "my output value"). + Build(), + }, + "happy path - two attributes are missing": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("no_such_attribute"). + CheckMissing("no_such_attribute_2"). + Build(), + }, + "happy path - attribute value is an empty string": { + config: ` + resource "akamai_test" "sample-resource" { + input = "" + }`, + checks: checker.CheckEqual("output", "").Build(), + }, + "happy path - attribute value is a number": { + config: ` + resource "akamai_test" "sample-resource" { + input = "1" + }`, + checks: checker.CheckEqual("output", "1").Build(), + }, + "expect error - check for missing attributes but one is present": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("no_such_attribute"). + CheckMissing("output"). + Build(), + error: regexp.MustCompile("Attribute 'output' found when not expected"), + }, + "expect error - one check fails": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("input", "my output value"). + CheckEqual("output", "my output value - updated"). + Build(), + error: regexp.MustCompile("Attribute 'output' expected \"my output value - updated\", got \"my output value\""), + }, + "expect error - ": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("no_such_attribute", "no_such_value"). + Build(), + error: regexp.MustCompile("Attribute 'no_such_attribute' not found"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(testprovider.NewMockSubprovider()), + Steps: []resource.TestStep{ + { + Config: providerBlock + tc.config, + Check: tc.checks, + ExpectError: tc.error, + }, + }, + }) + }) + } +} + +func TestImportChecker(t *testing.T) { + checker := NewImportChecker() + + tests := map[string]struct { + importID string + config string + checks func(s []*terraform.InstanceState) error + error *regexp.Regexp + }{ + "happy path - correct attribute value": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker.CheckEqual("output", "abcdefghijklmnop").Build(), + }, + "happy path - attribute is missing": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker.CheckMissing("no_such_attribute").Build(), + }, + "happy path - attribute value is an empty string": { + importID: "1,", + config: ` + resource "akamai_test" "sample-resource" { + input = "" + }`, + checks: checker.CheckEqual("output", "").Build(), + }, + "happy path - attribute value is a number": { + importID: "1,1", + config: ` + resource "akamai_test" "sample-resource" { + input = "1" + }`, + checks: checker.CheckEqual("output", "1").Build(), + }, + "happy path - overwrite check with correct value": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("output", "wrong value"). + CheckEqual("output", "abcdefghijklmnop"). + Build(), + }, + "happy path - overwrite check missing with correct value check": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("output"). + CheckEqual("output", "abcdefghijklmnop"). + Build(), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(testprovider.NewMockSubprovider()), + Steps: []resource.TestStep{ + { + Config: providerBlock + tc.config, + ImportStateCheck: tc.checks, + ImportStateId: tc.importID, + ImportState: true, + ResourceName: "akamai_test.sample-resource", + ExpectError: tc.error, + }, + }, + }) + }) + } +} + +func TestStateCheckerMethods(t *testing.T) { + tests := map[string]struct { + checker StateChecker + expectedAttributes map[string]checkData + error bool + }{ + "basic": { + checker: NewStateChecker("test"). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckMissing("missing"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "missing": { + isMissing: true, + value: "", + }, + }, + }, + "only missing": { + checker: NewStateChecker("test"). + CheckMissing("missing"). + CheckMissing("missing2"). + CheckMissing("missing3"), + expectedAttributes: map[string]checkData{ + "missing": { + isMissing: true, + value: "", + }, + "missing2": { + isMissing: true, + value: "", + }, + "missing3": { + isMissing: true, + value: "", + }, + }, + }, + "only existing attributes": { + checker: NewStateChecker("test"). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckEqual("attr3", "val3"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "attr3": { + isMissing: false, + value: "val3", + }, + }, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + assert.Equal(t, test.expectedAttributes, test.checker.attributes) + }) + } +} + +func TestImportCheckerMethods(t *testing.T) { + importTests := map[string]struct { + checker ImportChecker + expectedAttributes map[string]checkData + }{ + "basic": { + checker: NewImportChecker(). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckMissing("missing"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "missing": { + isMissing: true, + value: "", + }, + }, + }, + "only missing": { + checker: NewImportChecker(). + CheckMissing("missing"). + CheckMissing("missing2"). + CheckMissing("missing3"), + expectedAttributes: map[string]checkData{ + "missing": { + isMissing: true, + value: "", + }, + "missing2": { + isMissing: true, + value: "", + }, + "missing3": { + isMissing: true, + value: "", + }, + }, + }, + "only existing attributes": { + checker: NewImportChecker(). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckEqual("attr3", "val3"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "attr3": { + isMissing: false, + value: "val3", + }, + }, + }, + } + + for name, test := range importTests { + t.Run(name, func(t *testing.T) { + assert.Equal(t, test.expectedAttributes, test.checker.attributes) + }) + } +} + +func TestStateCheckersPanic(t *testing.T) { + stateCheck := func() { + _ = NewStateChecker("test").Build() + } + assert.PanicsWithValue(t, "there must be at least one check in order to build the checker", stateCheck) + + importCheck := func() { + checkFunc := NewImportChecker().Build() + + givenState := &terraform.InstanceState{ + Attributes: map[string]string{}, + } + _ = checkFunc([]*terraform.InstanceState{givenState}) + } + assert.PanicsWithValue(t, "there must be at least one check in order to build the checker", importCheck) +} + +func TestAssertAttributeFor(t *testing.T) { + givenState := &terraform.InstanceState{ + Attributes: map[string]string{ + "attr": "val", + }, + } + + tests := map[string]struct { + key string + checkData checkData + expectError error + }{ + "'attr' exists and has correct value - no error": { + key: "attr", + checkData: checkData{ + isMissing: false, + value: "val", + }, + expectError: nil, + }, + "'not-existing-attr' does not exists - no error": { + key: "not-existing-attr", + checkData: checkData{ + isMissing: true, + }, + expectError: nil, + }, + "'not-existing-attr' does not exists, but expecting to exist - expect error": { + key: "not-existing-attr", + checkData: checkData{ + isMissing: false, + value: "val", + }, + expectError: fmt.Errorf(`attribute "not-existing-attr" was not present, but should have a value: "val"`), + }, + "'attr' does exists, but has a different value - expect error": { + key: "attr", + checkData: checkData{ + isMissing: false, + value: "actual value", + }, + expectError: fmt.Errorf(`attribute "attr" has incorrect value "val", but should have "actual value"`), + }, + "'attr' does exists, but should not - expect error": { + key: "attr", + checkData: checkData{ + isMissing: true, + value: "val", + }, + expectError: fmt.Errorf(`attribute "attr" was present and has a value: "val", but shouldn't be`), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + err := assertAttributeFor(givenState, test.key, test.checkData) + if test.expectError != nil { + assert.EqualError(t, err, test.expectError.Error()) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/pkg/common/testprovider/provider.go b/pkg/common/testprovider/provider.go new file mode 100644 index 000000000..1facc7bce --- /dev/null +++ b/pkg/common/testprovider/provider.go @@ -0,0 +1,40 @@ +// Package testprovider is a package containing a terraform provider for internal testing purposes +package testprovider + +import ( + "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +// NewMockSubprovider return the test subprovider used for internal testing +func NewMockSubprovider() subprovider.Subprovider { + return &mockSubprovider{} +} + +type ( + mockSubprovider struct{} +) + +// SDKResources returns the test resources implemented using terraform-plugin-sdk +func (p *mockSubprovider) SDKResources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} + +// SDKDataSources returns the test data sources implemented using terraform-plugin-sdk +func (p *mockSubprovider) SDKDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} + +// FrameworkResources returns the test resources implemented using terraform-plugin-framework +func (p *mockSubprovider) FrameworkResources() []func() resource.Resource { + return []func() resource.Resource{ + NewTestResource, + } +} + +// FrameworkDataSources returns the test data sources implemented using terraform-plugin-framework +func (p *mockSubprovider) FrameworkDataSources() []func() datasource.DataSource { + return []func() datasource.DataSource{} +} diff --git a/pkg/common/testprovider/test_resource.go b/pkg/common/testprovider/test_resource.go new file mode 100644 index 000000000..b79089475 --- /dev/null +++ b/pkg/common/testprovider/test_resource.go @@ -0,0 +1,145 @@ +package testprovider + +import ( + "context" + "strconv" + "strings" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &TestResource{} + _ resource.ResourceWithImportState = &TestResource{} +) + +// TestResource represents akamai_test to be used in internal testing +type TestResource struct{} + +// NewTestResource returns new akamai test resource to be used in internal testing +func NewTestResource() resource.Resource { + return &TestResource{} +} + +// testResourceModel is a model for akamai_test_resource resource +type testResourceModel struct { + ID types.Int64 `tfsdk:"id"` + Input types.String `tfsdk:"input"` + Output types.String `tfsdk:"output"` +} + +// Metadata implements resource.Resource. +func (r *TestResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_test" +} + +// Schema implements resource.Resource. +func (r *TestResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "input": schema.StringAttribute{ + Required: true, + Description: "Required attribute, its value is copied to 'output' attribute.", + }, + "output": schema.StringAttribute{ + Computed: true, + Description: "Read-only attribute, its value comes from 'input' attribute.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "id": schema.Int64Attribute{ + Computed: true, + Description: "Resource's unique and randomly generated identifier.", + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.UseStateForUnknown(), + }, + }, + }, + } +} + +// Create implements resource.Resource. +func (r *TestResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating Akamai Test Resource") + + var data *testResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + data.Output = data.Input + data.ID = types.Int64Value(int64(uuid.New().ID())) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// Read implements resource.Resource. +func (r *TestResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading Akamai Test Resource") + + var data *testResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// Update implements resource.Resource. +func (r *TestResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating Akamai Test Resource") + + var data *testResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + data.Output = data.Input + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// Delete implements resource.Resource. +func (r *TestResource) Delete(ctx context.Context, _ resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Deleting Akamai Test Resource") + resp.State.RemoveResource(ctx) +} + +// ImportState implements resource.ResourceWithImportState. +func (r *TestResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing Configuration Resource") + + var data = &testResourceModel{} + + id := strings.Split(req.ID, ",") + if len(id) != 2 { + resp.Diagnostics.AddError("incorrect import ID", "import ID should have format: ,") + return + } + + idInt, err := strconv.ParseInt(id[0], 10, 64) + if err != nil { + resp.Diagnostics.AddError("parsing error", err.Error()) + return + } + data.ID = types.Int64Value(idInt) + data.Input = types.StringValue(id[1]) + data.Output = types.StringValue(id[1]) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/common/tf/util.go b/pkg/common/tf/util.go index 5c47e4b50..cc6140a88 100644 --- a/pkg/common/tf/util.go +++ b/pkg/common/tf/util.go @@ -31,3 +31,12 @@ func MaxDuration(x, y time.Duration) time.Duration { } return x } + +// InterfaceSliceToStringSlice converts schema.Set to slice of string +func InterfaceSliceToStringSlice(list []interface{}) []string { + stringList := make([]string, len(list)) + for i, v := range list { + stringList[i] = v.(string) + } + return stringList +} diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go index 76cbc177f..3dc23bcb2 100644 --- a/pkg/meta/meta.go +++ b/pkg/meta/meta.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/apex/log" "github.com/hashicorp/go-hclog" diff --git a/pkg/meta/meta_test.go b/pkg/meta/meta_test.go index af559b879..95d8c6e94 100644 --- a/pkg/meta/meta_test.go +++ b/pkg/meta/meta_test.go @@ -3,7 +3,7 @@ package meta import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/hashicorp/go-hclog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/config_versions.go b/pkg/providers/appsec/config_versions.go index b4c59ea3c..194d08582 100644 --- a/pkg/providers/appsec/config_versions.go +++ b/pkg/providers/appsec/config_versions.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go index 0059da090..537ee2b51 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go index acbf3e564..cae070683 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go index 2d8b5a209..b753d530e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go index a55045e22..58a8b55b3 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go index c032586af..fa13d15a9 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go index fa2b7bc48..5e6f97560 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go index 2a3b68249..ee22e6521 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go index a2b30ab36..a6b6da4dd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go index e4b3d33f0..765562e6a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go index 45f26d296..1d4331676 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go index 92ae835f1..bf1208343 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go index b831f214a..0ab23793f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go index 15f830de1..a00c0b4d2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go index 6d8a3b28c..fd66ecedd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go b/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go index 0f6ee9df8..7ccf1fbdc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go b/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go index 73e79124b..1127ae601 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go index c524aacf7..dcd2bc329 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go index a97832f3e..836c086aa 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go index 0a72b1cb5..766b463ff 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go index d34a5d146..045df0ef2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go index 5d8cc00ae..21f91e297 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go index e3e6a7e9e..b4c442094 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go index c4455a1d5..05f8d9d78 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go index b21d66065..aeb63db9b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_attack_groups.go b/pkg/providers/appsec/data_akamai_appsec_attack_groups.go index 201575bc3..82d0e6724 100644 --- a/pkg/providers/appsec/data_akamai_appsec_attack_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_attack_groups.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go b/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go index 5b94af02c..5a2efb1c2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go index bf637a83b..05a800669 100644 --- a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go +++ b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go index ec93517a2..c11f76378 100644 --- a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration.go b/pkg/providers/appsec/data_akamai_appsec_configuration.go index ff2f84a19..d6979f24a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_test.go b/pkg/providers/appsec/data_akamai_appsec_configuration_test.go index f2d779437..a4a8abd07 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_version.go b/pkg/providers/appsec/data_akamai_appsec_configuration_version.go index 905c64741..a6ab98d18 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_version.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_version.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go b/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go index 7b6775734..5839c72ba 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go b/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go index 11be6ebda..a5ea7753c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go b/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go index 1abab46ff..fd9f5d4dc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_deny.go b/pkg/providers/appsec/data_akamai_appsec_custom_deny.go index 7b20f0751..e12b1567e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_deny.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_deny.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go b/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go index c95c70482..953435e61 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go index 88c2a8a2b..9c6df772a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go index 42a878928..2b8cad02c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rules.go b/pkg/providers/appsec/data_akamai_appsec_custom_rules.go index b527763f3..19f8334d8 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rules.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go index d345516f9..fa7d32b66 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval.go b/pkg/providers/appsec/data_akamai_appsec_eval.go index 9196520fa..a0b9a2823 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_groups.go b/pkg/providers/appsec/data_akamai_appsec_eval_groups.go index a5f611aa3..e85c1899d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_groups.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go index da0b089c1..dc936eba1 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go index f444b972d..e3a8da9b9 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go index fca28e254..8d9a169e5 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go index 06f82ecb5..cedbf2159 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go index 26434f7f8..89476452f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_rules.go b/pkg/providers/appsec/data_akamai_appsec_eval_rules.go index 414daef14..4f7ca1f6e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_rules.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go index dcb61b08e..60cdf1683 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_test.go index 779f539fe..625634a4e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_export_configuration.go b/pkg/providers/appsec/data_akamai_appsec_export_configuration.go index ccda47ba2..049ea2e6c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_export_configuration.go +++ b/pkg/providers/appsec/data_akamai_appsec_export_configuration.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go b/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go index b8f38f21c..97c2ac19b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go index 3b4dfadbd..c64159e81 100644 --- a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go index 1954366b4..273c40d63 100644 --- a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_ip_geo.go b/pkg/providers/appsec/data_akamai_appsec_ip_geo.go index 2da6c313e..39f71d71e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_ip_geo.go +++ b/pkg/providers/appsec/data_akamai_appsec_ip_geo.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go b/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go index 9be2ac16b..f4a0369d8 100644 --- a/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go b/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go index a2342968c..78563f156 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go b/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go index b9d8d10fb..6e87387e9 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policies.go b/pkg/providers/appsec/data_akamai_appsec_malware_policies.go index 31c049c76..c84c68302 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policies.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policies.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go b/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go index 390479f7e..074ad8606 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go index 71bf04f53..356f32983 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go index bd0108dae..95c9853ed 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_match_targets.go b/pkg/providers/appsec/data_akamai_appsec_match_targets.go index 866d69c36..6403292bf 100644 --- a/pkg/providers/appsec/data_akamai_appsec_match_targets.go +++ b/pkg/providers/appsec/data_akamai_appsec_match_targets.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go b/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go index 333876b2d..8e6fc1235 100644 --- a/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box.go index f33bd8662..de4e6b76a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go index a909942d7..b0823546b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go index 52a5c5e38..d2065447c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go index 6713f6e00..6ceb25d25 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policies.go b/pkg/providers/appsec/data_akamai_appsec_rate_policies.go index 17a4c6022..b3fba418b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policies.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policies.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go b/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go index 5fd4984ad..5b3ee03eb 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go index d69c4d3a7..32871d60c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go index a58b8597b..319b3e569 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go index 2b642e287..f2f3194dc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go index 121032441..f26934d3d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go index 6698f1b07..c4726c22a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go index ba7d82cef..ce62a7924 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go index 05a6b7f62..80d01c35b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go index cc3fe5850..b503401e4 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go index 85e24fb57..3de51f148 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go +++ b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go index 67f06acf9..9f915e3b0 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rules.go b/pkg/providers/appsec/data_akamai_appsec_rules.go index 617620e7d..396021630 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_rules.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_rules_test.go index a411e216f..20e08dbb1 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rules_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rules_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy.go b/pkg/providers/appsec/data_akamai_appsec_security_policy.go index 1048a472c..3e809ebc4 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go index 9de5ffb44..87cf7b178 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go index eee52f61e..211bf3510 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go b/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go index 4b7f9c0c5..897213822 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go index bdcf7523b..5baab7029 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go index 22d81cf45..9a498759f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go index 7b000e1e3..1718f4c71 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go index 5b2259bea..090d0a6cc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go b/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go index 421463425..95f5c8067 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go b/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go index be79b2797..51560932b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_settings.go b/pkg/providers/appsec/data_akamai_appsec_siem_settings.go index 1db282c82..d6fd6ca79 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go b/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go index ec1107c73..b5baeb71a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go index 2e46f7635..cd71352b5 100644 --- a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go +++ b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go index 9145d68b0..1aec232d3 100644 --- a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_threat_intel.go b/pkg/providers/appsec/data_akamai_appsec_threat_intel.go index e16bd039a..11a3c208f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_threat_intel.go +++ b/pkg/providers/appsec/data_akamai_appsec_threat_intel.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go b/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go index 09307073d..922a8c764 100644 --- a/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go index e35263b38..9b61c1bcc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go +++ b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" diff --git a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go index 015567996..301268d90 100644 --- a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_version_notes.go b/pkg/providers/appsec/data_akamai_appsec_version_notes.go index f727bc8ca..bea4aefcd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_version_notes.go +++ b/pkg/providers/appsec/data_akamai_appsec_version_notes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go b/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go index a04829a97..1a4ea5200 100644 --- a/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_waf_mode.go b/pkg/providers/appsec/data_akamai_appsec_waf_mode.go index 392ef79bd..2ee5a6cff 100644 --- a/pkg/providers/appsec/data_akamai_appsec_waf_mode.go +++ b/pkg/providers/appsec/data_akamai_appsec_waf_mode.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go b/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go index 8a4e973ae..8e0f0837f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go index 216676649..e355a4899 100644 --- a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go index 682c7323e..706008ae2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/diff_suppress_funcs.go b/pkg/providers/appsec/diff_suppress_funcs.go index 8a62efd45..5892fc6ac 100644 --- a/pkg/providers/appsec/diff_suppress_funcs.go +++ b/pkg/providers/appsec/diff_suppress_funcs.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/appsec/provider.go b/pkg/providers/appsec/provider.go index eb1b9fb71..10148222a 100644 --- a/pkg/providers/appsec/provider.go +++ b/pkg/providers/appsec/provider.go @@ -4,7 +4,7 @@ package appsec import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/appsec/provider_test.go b/pkg/providers/appsec/provider_test.go index 127884fac..56bbc877f 100644 --- a/pkg/providers/appsec/provider_test.go +++ b/pkg/providers/appsec/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/appsec/resource_akamai_appsec_activations.go b/pkg/providers/appsec/resource_akamai_appsec_activations.go index 50933d06c..3690f84ac 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_activations.go +++ b/pkg/providers/appsec/resource_akamai_appsec_activations.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/go-hclog" diff --git a/pkg/providers/appsec/resource_akamai_appsec_activations_test.go b/pkg/providers/appsec/resource_akamai_appsec_activations_test.go index 7f5a41141..3ae81985c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_activations_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_activations_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go index 8f5c6a060..010868760 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go index 93b1f6ee6..774d7b1ab 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go index 2a1896c58..40a716cec 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go index 36d77dc77..4752edc8a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go index 65d44f25b..d39221798 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go index 60a2f14a8..6349d82e1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go index 8bc291d33..fbef0bc26 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go index 808773cf5..a342059a0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go index 9a1844df8..62a1b2b73 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go index 7b8f7f5f0..1ff249bdd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go index f553f5e13..fef016363 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go index 0132428e0..ae1edddd6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go index 76d685985..b0e5b2038 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go index 55a1effd5..ca0b1dd6f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go index b542bfca8..67bdc25d8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go index a1d32ae90..8de106ca3 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go index 6af5ab00a..cfca2712a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go index cd033b414..17f77d826 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_attack_group.go b/pkg/providers/appsec/resource_akamai_appsec_attack_group.go index 96f3c845c..ee0e56aba 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_attack_group.go +++ b/pkg/providers/appsec/resource_akamai_appsec_attack_group.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go b/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go index 4b1cd8adc..c304814fe 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go index 37faa9689..12ecc2098 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go +++ b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go index 05c69e463..f46275576 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration.go b/pkg/providers/appsec/resource_akamai_appsec_configuration.go index f8a335fd4..31dff58cd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go index 24bedfbf8..cc360b746 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go index 5d763d34e..673e33ed0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go index 2fec878f8..e92340655 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go b/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go index dfbb5b5e9..133cadc91 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go @@ -7,7 +7,7 @@ import ( "log" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go b/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go index d0bf1ceb6..e7282c7ce 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go index 89dc81e26..2249035a1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go index cf2bbac0e..0376ffc7f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go index b477d01d3..c44ffdd44 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go index e7f2a20ef..0936c3fae 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval.go b/pkg/providers/appsec/resource_akamai_appsec_eval.go index 5f59dcbe8..b1b45a05c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_group.go b/pkg/providers/appsec/resource_akamai_appsec_eval_group.go index fa6e98011..d525d6df8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_group.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_group.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go index fcc848e5b..e11b4a5ce 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go index 2e3fd869f..60ee3d635 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go index 8d7932082..7f519b309 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go index 51f3c5180..e383747af 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go index 2e167e49d..bea87c1eb 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go b/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go index c0c2b5aa1..91bf0eef8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go index aad6f047b..12e787d25 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_test.go index b6cb1ade1..79ae3a1cd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go index 26aba5bc1..deb532991 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go index 5f4d03cd5..c8eb0edae 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go index 0257710ee..c8c4fc4f6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go index 490a2b210..fc2dd8d87 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go index 6f7e5fc62..6a05fd264 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go index e2b766969..459d942e0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go index 5f28c1feb..4f359c75c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go index 0b429acd0..1222c370f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go index 6d551242c..3d967711d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go index deb4c7042..ae0490349 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go b/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go index 7461797a0..7ec7468df 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go index e8b472ea2..701f4ca31 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target.go b/pkg/providers/appsec/resource_akamai_appsec_match_target.go index 9f703002a..f435570bc 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target.go @@ -8,7 +8,7 @@ import ( "sort" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go index 60938a8e0..dd5f4f517 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go index 485133a1a..077f9efff 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go b/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go index 301a3e643..246698e7b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go index 79432ab8a..07a4e560d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go index 0e0ab7772..abd7d7aee 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go index 7e90f2e87..ad5db0805 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go index 1560545dc..b36d54bc7 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go index 33f8749ba..600f76b97 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go index 899c7b739..102df8a7a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go index b2c219434..8417f3c2a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go index 71522e747..3de6fbc6f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go b/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go index 3534a8c45..ae8d76c8e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go index 0d4777187..546cc6877 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go index d767ac40c..bccc8663f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go index c65798db7..d3c7139ef 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go index d6da76651..7c1d3e36f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go index 9e2f7e9ce..a6bc704cf 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go index d5559ba9d..9e1b7377c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go index a6cf6b892..9e171a258 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go index 55f18093a..7a1224eae 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go index 7c189e4c9..d43bcd459 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule.go b/pkg/providers/appsec/resource_akamai_appsec_rule.go index 82c20d75a..8220e995e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule.go @@ -8,7 +8,7 @@ import ( "strconv" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_rule_test.go index 3a18b4783..9604836f0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go index 70e13fddc..8e3e18077 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go index 47828d12b..5bcdf70b8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy.go index 2aec6397d..bb898d7c6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go index 8ee6db539..8e2eab0ff 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go index 0b7a2a31a..e0b2dbff0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go index 849491dfe..a75ed2aa4 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go index 2404aa27c..c49274fb1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go index 22a2bb143..d9100b8d2 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go index 3fa8a24f2..25454a75c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go +++ b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go index 7ce77b312..94dfcebd6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go index d06130ee4..9b964bb86 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -61,6 +61,98 @@ func resourceSiemSettings() *schema.Resource { Required: true, Description: "Unique identifier of the SIEM settings being modified", }, + "exceptions": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ConfigMode: schema.SchemaConfigModeAttr, + Elem: getExceptionsResource(), + Description: "Describes all the protections and actions to be excluded from SIEM events", + }, + }, + } +} + +func getExceptionsResource() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip_geo": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include ip geo events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "bot_management": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include bot management events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "rate": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include rate events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "url_protection": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include url protection events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "slow_post": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include slow post events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "custom_rules": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include custom rules events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "waf": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include waf events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "api_request_constraints": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include api request constraints events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "client_rep": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include client reputation events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "malware_protection": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include malware protection events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "apr_protection": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include apr protection events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, }, } } @@ -105,6 +197,11 @@ func resourceSiemSettingsCreate(ctx context.Context, d *schema.ResourceData, m i return diag.FromErr(err) } + exceptions, err := getAllExceptions(d) + if err != nil { + return diag.FromErr(err) + } + createSiemSettings := appsec.UpdateSiemSettingsRequest{ ConfigID: configID, Version: version, @@ -113,6 +210,7 @@ func resourceSiemSettingsCreate(ctx context.Context, d *schema.ResourceData, m i FirewallPolicyIds: spIDs, EnabledBotmanSiemEvents: enableBotmanSiem, SiemDefinitionID: siemID, + Exceptions: exceptions, } _, err = client.UpdateSiemSettings(ctx, createSiemSettings) @@ -171,6 +269,10 @@ func resourceSiemSettingsRead(ctx context.Context, d *schema.ResourceData, m int return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } + if err := setActionsFromExceptions(d, siemsettings.Exceptions); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + return nil } @@ -214,6 +316,11 @@ func resourceSiemSettingsUpdate(ctx context.Context, d *schema.ResourceData, m i return diag.FromErr(err) } + exceptions, err := getAllExceptions(d) + if err != nil { + return diag.FromErr(err) + } + updateSiemSettings := appsec.UpdateSiemSettingsRequest{ ConfigID: configID, Version: version, @@ -222,6 +329,7 @@ func resourceSiemSettingsUpdate(ctx context.Context, d *schema.ResourceData, m i FirewallPolicyIds: spIDs, EnabledBotmanSiemEvents: enableBotmanSiem, SiemDefinitionID: siemID, + Exceptions: exceptions, } _, err = client.UpdateSiemSettings(ctx, updateSiemSettings) @@ -261,3 +369,76 @@ func resourceSiemSettingsDelete(ctx context.Context, d *schema.ResourceData, m i } return nil } + +func getAllExceptions(d *schema.ResourceData) ([]appsec.Exception, error) { + exceptions := make([]appsec.Exception, 0) + exceptionsMap := getConfigParamProtectionMapping() + exceptionsConfig, err := tf.GetListValue("exceptions", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return nil, fmt.Errorf(err.Error()) + } + + for _, exception := range exceptionsConfig { + exceptionMap := exception.(map[string]interface{}) + for key := range exceptionMap { + actions := make([]string, 0) + if _, ok := exceptionsMap[key]; ok { + actionsSet, ok := exceptionMap[key].(*schema.Set) + if !ok { + return nil, fmt.Errorf("wrong type conversion: expected *schema.Set, got %T", actionsSet) + } + for _, action := range actionsSet.List() { + actions = append(actions, action.(string)) + } + if len(actions) > 0 { + exceptions = append(exceptions, appsec.Exception{Protection: exceptionsMap[key], ActionTypes: actions}) + } + } + } + } + return exceptions, nil +} + +func setActionsFromExceptions(d *schema.ResourceData, exceptions []appsec.Exception) error { + if err := d.Set("exceptions", exceptionsToState(exceptions)); err != nil { + return fmt.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + return nil +} + +func getConfigParamProtectionMapping() map[string]string { + exceptionsMap := map[string]string{ + "bot_management": "botmanagement", + "rate": "rate", + "ip_geo": "ipgeo", + "url_protection": "urlProtection", + "slow_post": "slowpost", + "custom_rules": "customrules", + "waf": "waf", + "api_request_constraints": "apirequestconstraints", + "client_rep": "clientrep", + "malware_protection": "malwareprotection", + "apr_protection": "aprProtection", + } + return exceptionsMap +} + +func exceptionsToState(exceptions []appsec.Exception) []interface{} { + exceptionsMap := getConfigParamProtectionMapping() + out := make([]interface{}, 0, len(exceptions)) + exceptionMap := make(map[string]interface{}) + + for configParamName, configParamVal := range exceptionsMap { + for _, t := range exceptions { + if configParamVal == t.Protection { + exceptionMap[configParamName] = t.ActionTypes + break + } + } + } + if len(exceptionMap) > 0 { + out = append(out, exceptionMap) + } + + return out +} diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go index fbc5a1983..8dc926fe0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go @@ -2,9 +2,10 @@ package appsec import ( "encoding/json" + "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -43,7 +44,7 @@ func TestAkamaiSiemSettings_res_basic(t *testing.T) { client.On("UpdateSiemSettings", mock.Anything, - appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}}, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, Exceptions: []appsec.Exception{}}, ).Return(&updateSiemSettingsResponse, nil) client.On("RemoveSiemSettings", @@ -69,4 +70,180 @@ func TestAkamaiSiemSettings_res_basic(t *testing.T) { client.AssertExpectations(t) }) + t.Run("match by SiemSettings ID when SIEM exceptions are added", func(t *testing.T) { + client := &appsec.Mock{} + + updateSiemSettingsResponse := appsec.UpdateSiemSettingsResponse{} + err := json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &updateSiemSettingsResponse) + require.NoError(t, err) + + getSiemSettingsResponse := appsec.GetSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &getSiemSettingsResponse) + require.NoError(t, err) + + removeSiemSettingsResponse := appsec.RemoveSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &removeSiemSettingsResponse) + require.NoError(t, err) + + config := appsec.GetConfigurationResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResConfiguration/LatestConfiguration.json"), &config) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&config, nil) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponse, nil) + + client.On("UpdateSiemSettings", + mock.Anything, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, + Exceptions: []appsec.Exception{ + { + Protection: "rate", + ActionTypes: []string{"alert"}, + }, + }}, + ).Return(&updateSiemSettingsResponse, nil) + + client.On("RemoveSiemSettings", + mock.Anything, + appsec.RemoveSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: false, EnabledBotmanSiemEvents: false, FirewallPolicyIds: []string(nil)}, + ).Return(&removeSiemSettingsResponse, nil) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("match by SiemSettings ID when SIEM exceptions are added with empty actions", func(t *testing.T) { + client := &appsec.Mock{} + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + ExpectError: regexp.MustCompile(`Error: Not enough list items`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("update after removing exceptions block", func(t *testing.T) { + client := &appsec.Mock{} + + updateSiemSettingsResponse := appsec.UpdateSiemSettingsResponse{} + err := json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &updateSiemSettingsResponse) + require.NoError(t, err) + + updateSiemSettingsResponseNoExceptions := appsec.UpdateSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettings.json"), &updateSiemSettingsResponseNoExceptions) + require.NoError(t, err) + + getSiemSettingsResponse := appsec.GetSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &getSiemSettingsResponse) + require.NoError(t, err) + + getSiemSettingsResponseNoExceptions := appsec.GetSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettings.json"), &getSiemSettingsResponseNoExceptions) + require.NoError(t, err) + + removeSiemSettingsResponse := appsec.RemoveSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &removeSiemSettingsResponse) + require.NoError(t, err) + + config := appsec.GetConfigurationResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResConfiguration/LatestConfiguration.json"), &config) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&config, nil).Times(8) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponse, nil).Times(2) + + client.On("UpdateSiemSettings", + mock.Anything, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, + Exceptions: []appsec.Exception{ + { + Protection: "rate", + ActionTypes: []string{"alert"}, + }, + }}, + ).Return(&updateSiemSettingsResponse, nil).Times(1) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponse, nil).Times(1) + + client.On("UpdateSiemSettings", + mock.Anything, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, Exceptions: []appsec.Exception{}}, + ).Return(&updateSiemSettingsResponseNoExceptions, nil).Times(1) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponseNoExceptions, nil).Times(2) + + client.On("RemoveSiemSettings", + mock.Anything, + appsec.RemoveSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: false, EnabledBotmanSiemEvents: false, FirewallPolicyIds: []string(nil)}, + ).Return(&removeSiemSettingsResponse, nil) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) } diff --git a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go index d54c3657e..aa16c4c7d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go index 3ab426ad3..fccba7898 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go index e25243e4b..fcaf0d006 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go index 4f35777e1..09cf756a0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go b/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go index f5fc76565..12cba1c4e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go +++ b/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go @@ -9,7 +9,7 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go b/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go index db5f7717a..7fc3d4c8b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_version_notes.go b/pkg/providers/appsec/resource_akamai_appsec_version_notes.go index 1faeab356..453f9777a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_version_notes.go +++ b/pkg/providers/appsec/resource_akamai_appsec_version_notes.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go b/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go index 176506dfd..43fb78c47 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go b/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go index 8beb5a89b..af58d8913 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go b/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go index 3445e40a3..4be97bc52 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go b/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go index 4e219be88..c9cba9781 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go index f95235531..c2dffa352 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go index 7e26e69a5..64dd2911a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go +++ b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go index 550ad7722..5b1e82712 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/templates.go b/pkg/providers/appsec/templates.go index e2d34d311..e7a0c7cbf 100644 --- a/pkg/providers/appsec/templates.go +++ b/pkg/providers/appsec/templates.go @@ -8,7 +8,7 @@ import ( "strings" "text/template" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/jedib0t/go-pretty/v6/table" ) diff --git a/pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json b/pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json new file mode 100644 index 000000000..87f8531da --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json @@ -0,0 +1,14 @@ +{ + "enableForAllPolicies": false, + "enableSiem": true, + "enabledBotmanSiemEvents": true, + "siemDefinitionId": 1, + "firewallPolicyIds": ["12345"], + "exceptions": [ + { + "actionTypes": [ + "alert" + ], + "protection": "rate" + }] +} \ No newline at end of file diff --git a/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf new file mode 100644 index 000000000..e0a553186 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf @@ -0,0 +1,18 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" + cache_enabled = false +} + +resource "akamai_appsec_siem_settings" "test" { + config_id = 43253 + enable_siem = true + enable_for_all_policies = false + enable_botman_siem = true + siem_id = 1 + security_policy_ids = ["12345"] + exceptions { + rate = ["alert"] + } + +} + diff --git a/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf new file mode 100644 index 000000000..074062113 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf @@ -0,0 +1,18 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" + cache_enabled = false +} + +resource "akamai_appsec_siem_settings" "test" { + config_id = 43253 + enable_siem = true + enable_for_all_policies = false + enable_botman_siem = true + siem_id = 1 + security_policy_ids = ["12345"] + exceptions { + rate = ["alert"] + bot_management = [] + } +} + diff --git a/pkg/providers/botman/cache.go b/pkg/providers/botman/cache.go index 02b3189e1..f46f290cd 100644 --- a/pkg/providers/botman/cache.go +++ b/pkg/providers/botman/cache.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go index 3abf4a51a..855e39e32 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go index 26aa2e916..5c7da7fe1 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go index eb78c4191..047537b5f 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go index f3a24ee7f..b53040ab9 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go index f082a6aa4..17551b4a6 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go index f485d6955..ab3371099 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go index 6d2804ba3..cec1076f8 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go index 627f08352..a13f2d30e 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go index 2948a0c30..7b5faecf5 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_category_exception.go b/pkg/providers/botman/data_akamai_botman_bot_category_exception.go index 329a6a120..81fcc737d 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_category_exception.go +++ b/pkg/providers/botman/data_akamai_botman_bot_category_exception.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go b/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go index 48a51550d..3c55d8d68 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection.go b/pkg/providers/botman/data_akamai_botman_bot_detection.go index cc508a594..36b4005d6 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection_action.go b/pkg/providers/botman/data_akamai_botman_bot_detection_action.go index ec3e5cc6c..4d4512f2c 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_action.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_action.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go b/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go index c44af60f8..a49bb6fd2 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection_test.go b/pkg/providers/botman/data_akamai_botman_bot_detection_test.go index da0828d0b..cc00a8bbf 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go index 7975203a1..6721afc4d 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go +++ b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go index 38d0a3069..b4cc13f92 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_management_settings.go b/pkg/providers/botman/data_akamai_botman_bot_management_settings.go index ed76cc249..24b9584b3 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_management_settings.go +++ b/pkg/providers/botman/data_akamai_botman_bot_management_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go b/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go index 272335b1f..cdb28f508 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_action.go b/pkg/providers/botman/data_akamai_botman_challenge_action.go index a9e1e9c14..4f5496a56 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_action.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_action_test.go b/pkg/providers/botman/data_akamai_botman_challenge_action_test.go index 718276d43..d1a43f1b8 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go index 7ce1726ab..07b789104 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go index 4703a1061..2cc412640 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go index 81df446c4..3805a8637 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go index 71bedf62b..b457dad5e 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_client_side_security.go b/pkg/providers/botman/data_akamai_botman_client_side_security.go index b80146ef9..2b67f1ec0 100644 --- a/pkg/providers/botman/data_akamai_botman_client_side_security.go +++ b/pkg/providers/botman/data_akamai_botman_client_side_security.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_client_side_security_test.go b/pkg/providers/botman/data_akamai_botman_client_side_security_test.go index e505ca011..ca5c0d550 100644 --- a/pkg/providers/botman/data_akamai_botman_client_side_security_test.go +++ b/pkg/providers/botman/data_akamai_botman_client_side_security_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_conditional_action.go b/pkg/providers/botman/data_akamai_botman_conditional_action.go index 7d9af97d7..d52d48ef9 100644 --- a/pkg/providers/botman/data_akamai_botman_conditional_action.go +++ b/pkg/providers/botman/data_akamai_botman_conditional_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_conditional_action_test.go b/pkg/providers/botman/data_akamai_botman_conditional_action_test.go index f096479d6..905fe1379 100644 --- a/pkg/providers/botman/data_akamai_botman_conditional_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_conditional_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go index b197799a9..0fe6097db 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go index 68a9a559d..d4683518d 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule.go index be9edb73f..1302a1345 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go index 0cc104333..a4b5015d4 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go index 0c72c30ff..214516849 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go index 8750fd849..ddca84913 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category.go index 2277afe26..d17f3409f 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go index cf55dee6a..eb80c75d3 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go index 7c0aff92c..d823f3f21 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go index 20fa1062e..486732960 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go index f0d1008eb..eae76bd0f 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go index 23e704157..7cf341fa9 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go index 182dcd04a..5ca9df4b7 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go index 0943327d4..04408aa66 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client.go b/pkg/providers/botman/data_akamai_botman_custom_client.go index bf8f4ea57..dd7f63138 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go b/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go index 4e1ff2de1..91326cfb1 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go b/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go index 35555a7d2..c2184c545 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client_test.go b/pkg/providers/botman/data_akamai_botman_custom_client_test.go index f45bcd2ef..3f1bdcc17 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_code.go b/pkg/providers/botman/data_akamai_botman_custom_code.go index cabce58e6..43fe46b61 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_code.go +++ b/pkg/providers/botman/data_akamai_botman_custom_code.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_code_test.go b/pkg/providers/botman/data_akamai_botman_custom_code_test.go index efff5f4ca..6369e51e7 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_code_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_code_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go b/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go index 790dd31ee..0c505401a 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go b/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go index 15fe9cbba..ea5106e4d 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_deny_action.go b/pkg/providers/botman/data_akamai_botman_custom_deny_action.go index b9dcb4211..0eb63fb11 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_deny_action.go +++ b/pkg/providers/botman/data_akamai_botman_custom_deny_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go b/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go index 60662baf3..e44c5a174 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_javascript_injection.go b/pkg/providers/botman/data_akamai_botman_javascript_injection.go index a90ee731a..75f037f40 100644 --- a/pkg/providers/botman/data_akamai_botman_javascript_injection.go +++ b/pkg/providers/botman/data_akamai_botman_javascript_injection.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go b/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go index 046a8222d..187f48843 100644 --- a/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go +++ b/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go index 3270fab58..017576361 100644 --- a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go index 2abbd003d..98aaeeec8 100644 --- a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go +++ b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_response_action.go b/pkg/providers/botman/data_akamai_botman_response_action.go index 0f7e02833..84e82fa9f 100644 --- a/pkg/providers/botman/data_akamai_botman_response_action.go +++ b/pkg/providers/botman/data_akamai_botman_response_action.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_response_action_test.go b/pkg/providers/botman/data_akamai_botman_response_action_test.go index 06313b324..fb8bbbbe2 100644 --- a/pkg/providers/botman/data_akamai_botman_response_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_response_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go b/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go index 2a2c694a3..39f8e0da0 100644 --- a/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go +++ b/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go b/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go index f2ab04cc4..5691152d1 100644 --- a/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go index ac72e8c1c..dddb7024f 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go index 27ac84a4a..32c32ab37 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go index 3b514c60d..02a508106 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go index e26bd5981..3aae5f391 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/provider.go b/pkg/providers/botman/provider.go index 56b081c3e..909979a6b 100644 --- a/pkg/providers/botman/provider.go +++ b/pkg/providers/botman/provider.go @@ -4,7 +4,7 @@ package botman import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" diff --git a/pkg/providers/botman/provider_test.go b/pkg/providers/botman/provider_test.go index c32a19fce..c62939ab0 100644 --- a/pkg/providers/botman/provider_test.go +++ b/pkg/providers/botman/provider_test.go @@ -7,7 +7,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go index 00bfc5f3e..2b688340b 100644 --- a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go +++ b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go index a21a3596e..10c61238b 100644 --- a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go index bc3bd9c95..b45bd9791 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go index 35f143ab5..3fea428b2 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go b/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go index 458f45c47..40f66ad4e 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go b/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go index 4fe13310c..6822644aa 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go b/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go index 1525b9d06..01c615649 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go b/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go index 1d4f0c1f4..60156dc69 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go b/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go index 853af02cf..5584fc6b6 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go b/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go index 7f8e70c46..ffb81d678 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_action.go b/pkg/providers/botman/resource_akamai_botman_challenge_action.go index f89a53cd6..ba3f70094 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_action.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go b/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go index fbb3d7986..fbd04380f 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go index 790480eb0..44c7365c5 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go index 3978be2fa..886fe29f2 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go index a7d3d6a31..08f09ac30 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go index 3c536ddcb..6e37da9ba 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_client_side_security.go b/pkg/providers/botman/resource_akamai_botman_client_side_security.go index ba1fede3c..fe69aa0db 100644 --- a/pkg/providers/botman/resource_akamai_botman_client_side_security.go +++ b/pkg/providers/botman/resource_akamai_botman_client_side_security.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go b/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go index 94af3ddbb..d2a9e6fd0 100644 --- a/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go +++ b/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_conditional_action.go b/pkg/providers/botman/resource_akamai_botman_conditional_action.go index cce2dc185..710213b93 100644 --- a/pkg/providers/botman/resource_akamai_botman_conditional_action.go +++ b/pkg/providers/botman/resource_akamai_botman_conditional_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go b/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go index eb4891cbc..f319b9f0a 100644 --- a/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go index dd0476461..4458f0275 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go index 0b7f2c443..99e85fb27 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go index f3481e6f2..2c64a5258 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go index 5692c697e..dc749d734 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go index ccaad2c32..b4f7a3d87 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go index 945b68045..c712851f2 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go index 03edf2e63..9583ec61c 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go index c386b19f9..5367cab0e 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go index b709df334..f1db00f55 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go index dd9bf9943..d5102d4fe 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go index 09d53e42d..040874723 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go index 7eaf9029e..4d2a91cbb 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go index c779f666a..b42ccb997 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go index c01bc21e8..f3443c472 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client.go b/pkg/providers/botman/resource_akamai_botman_custom_client.go index 1d506e0ca..b2a3bd4d9 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go index ba320cd03..6b1f4d75d 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go index e9b4636b2..dc93d35fc 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client_test.go b/pkg/providers/botman/resource_akamai_botman_custom_client_test.go index a532abb44..0e9c5ecb9 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_code.go b/pkg/providers/botman/resource_akamai_botman_custom_code.go index a48ebf5d5..d15ee914e 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_code.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_code.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_code_test.go b/pkg/providers/botman/resource_akamai_botman_custom_code_test.go index 4fbc0d76a..2ee4399fe 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_code_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_code_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go index ba2270009..074bb09bf 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go index 2057479dc..727c58d8d 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go b/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go index ab6f7ec9f..b646ead95 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go b/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go index 81c54cfc8..643e078b9 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_javascript_injection.go b/pkg/providers/botman/resource_akamai_botman_javascript_injection.go index 285a0e2ac..c55cdd587 100644 --- a/pkg/providers/botman/resource_akamai_botman_javascript_injection.go +++ b/pkg/providers/botman/resource_akamai_botman_javascript_injection.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go b/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go index 45af0ce5b..c8349b4db 100644 --- a/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go +++ b/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go index c086d2858..9274b5a58 100644 --- a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go +++ b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go index 61a7276d8..c24fb440a 100644 --- a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go +++ b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go index 65e376c37..a54d0f633 100644 --- a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go +++ b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go index eedbcb72b..ae2bb739a 100644 --- a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go index df8fe4fec..8b5671e17 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go index 373f426ca..10f649bda 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go index 50d44e065..201f1210f 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go index 195d05570..f7718af09 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/clientlists/data_akamai_clientlist_lists.go b/pkg/providers/clientlists/data_akamai_clientlist_lists.go index f72b19235..bc6360f62 100644 --- a/pkg/providers/clientlists/data_akamai_clientlist_lists.go +++ b/pkg/providers/clientlists/data_akamai_clientlist_lists.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go b/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go index 8fe05d39d..3f3ad7b2e 100644 --- a/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go +++ b/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/clientlists/provider.go b/pkg/providers/clientlists/provider.go index 3ee537bc5..46984079e 100644 --- a/pkg/providers/clientlists/provider.go +++ b/pkg/providers/clientlists/provider.go @@ -4,7 +4,7 @@ package clientlists import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/clientlists/provider_test.go b/pkg/providers/clientlists/provider_test.go index 8e9e5be15..86ad0e338 100644 --- a/pkg/providers/clientlists/provider_test.go +++ b/pkg/providers/clientlists/provider_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list.go b/pkg/providers/clientlists/resource_akamai_clientlists_list.go index b2a0f8bdd..76405c5a3 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list.go @@ -8,7 +8,7 @@ import ( "reflect" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go index 65b4fe72a..299beb5af 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go index 266aae0d5..1a58dab1a 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go b/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go index 30bbbe960..61c2db74f 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go index bc4ef0dfd..569d20ba2 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go index d1ffafe48..fa7de6060 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go index 5c22f137c..6a84c3af2 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go index a38f238c9..c47810183 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go index 9b6f83517..eeac29306 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go index 27e815081..5d063d53e 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go index 83c8082b3..8f52454bb 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go index f5615462f..0ccbb1cd5 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cloudaccess/provider.go b/pkg/providers/cloudaccess/provider.go index 886baf7bf..d59076a1c 100644 --- a/pkg/providers/cloudaccess/provider.go +++ b/pkg/providers/cloudaccess/provider.go @@ -2,7 +2,7 @@ package cloudaccess import ( - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudaccess/provider_test.go b/pkg/providers/cloudaccess/provider_test.go index fa8ea09f9..280744f98 100644 --- a/pkg/providers/cloudaccess/provider_test.go +++ b/pkg/providers/cloudaccess/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go index d4f8ae466..0e2483004 100644 --- a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go +++ b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -963,21 +963,21 @@ func (m *KeyResourceModel) setCredentialsForAccessKeyCreation(useCredA bool) clo } func (m *KeyResourceModel) buildCreateKeyVersionRequest(useCredA bool) cloudaccess.CreateAccessKeyVersionRequest { - var bodyParams cloudaccess.CreateAccessKeyVersionBodyParams + var bodyParams cloudaccess.CreateAccessKeyVersionRequestBody if useCredA { - bodyParams = cloudaccess.CreateAccessKeyVersionBodyParams{ + bodyParams = cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: m.CredentialsA.CloudAccessKeyID.ValueString(), CloudSecretAccessKey: m.CredentialsA.CloudSecretAccessKey.ValueString(), } } else { - bodyParams = cloudaccess.CreateAccessKeyVersionBodyParams{ + bodyParams = cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: m.CredentialsB.CloudAccessKeyID.ValueString(), CloudSecretAccessKey: m.CredentialsB.CloudSecretAccessKey.ValueString(), } } return cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: m.AccessKeyUID.ValueInt64(), - BodyParams: bodyParams, + Body: bodyParams, } } diff --git a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go index 5d8c22934..23d1beedc 100644 --- a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go +++ b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -443,7 +443,7 @@ func TestAccessKeyResource(t *testing.T) { //create new version (no.3) m.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: resourceData.accessKeyData[0].accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: "test_key_id_3", CloudSecretAccessKey: "test_secret_3", }}).Return(&cloudaccess.CreateAccessKeyVersionResponse{RequestID: 321321, RetryAfter: 1000}, nil).Once() @@ -610,7 +610,7 @@ func TestAccessKeyResource(t *testing.T) { //create new version (no.3) m.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: resourceData.accessKeyData[0].accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: "test_key_id_3", CloudSecretAccessKey: "test_secret_3", }}).Return(&cloudaccess.CreateAccessKeyVersionResponse{RequestID: 321321, RetryAfter: 1000}, nil).Once() @@ -1377,7 +1377,7 @@ func TestAccessKeyResource(t *testing.T) { // fail and taint resource m.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: resourceData.accessKeyData[0].accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: resourceData.accessKeyData[0].credentialsB.cloudAccessKeyID, CloudSecretAccessKey: resourceData.accessKeyData[0].credentialsB.cloudSecretAccessKey, }}).Return(nil, cloudaccess.ErrCreateAccessKeyVersion).Once() @@ -1770,7 +1770,7 @@ func mockGetAccessKeyVersionStatus(client *cloudaccess.Mock, testData commonData func mockCreateAccessKeyVersion(client *cloudaccess.Mock, testData commonDataForAccessKey) *mock.Call { return client.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: testData.accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: testData.credentialsB.cloudAccessKeyID, CloudSecretAccessKey: testData.credentialsB.cloudSecretAccessKey, }}).Return(&cloudaccess.CreateAccessKeyVersionResponse{RequestID: 124, RetryAfter: 1000}, nil) diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go index e67c55f3d..9148b7653 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go index a5aef0417..8802cdc81 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go index efbb31055..319ec47c2 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go index 857670952..f83dd9358 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go index 2c83fd712..5b0913771 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go index c90704920..bfce95e5c 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go index d933b3e9a..54031add3 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go index 1ce886f52..7c4863da3 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go index a46b502ed..0ba7e3a20 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go index 1667d5ba3..14c3a6873 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go index e33d89aba..367f3b75f 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go index e35a397c2..8620ed48f 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go index da88021e8..aa908523e 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go index 8b4e0a7dc..ce1531991 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go index a32424ea2..4b5e140e0 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go index edd473f76..3630e1695 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/match_rules.go b/pkg/providers/cloudlets/match_rules.go index 778798c38..b461de770 100644 --- a/pkg/providers/cloudlets/match_rules.go +++ b/pkg/providers/cloudlets/match_rules.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/cloudlets/match_rules_test.go b/pkg/providers/cloudlets/match_rules_test.go index 0a2d602c9..91fbee552 100644 --- a/pkg/providers/cloudlets/match_rules_test.go +++ b/pkg/providers/cloudlets/match_rules_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/require" "github.com/tj/assert" diff --git a/pkg/providers/cloudlets/policy_version_test.go b/pkg/providers/cloudlets/policy_version_test.go index ddd0fc58c..3d353ed16 100644 --- a/pkg/providers/cloudlets/policy_version_test.go +++ b/pkg/providers/cloudlets/policy_version_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/cloudlets/policy_version_v2.go b/pkg/providers/cloudlets/policy_version_v2.go index b6027d109..0bfac4a34 100644 --- a/pkg/providers/cloudlets/policy_version_v2.go +++ b/pkg/providers/cloudlets/policy_version_v2.go @@ -3,7 +3,7 @@ package cloudlets import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" ) type v2VersionStrategy struct { diff --git a/pkg/providers/cloudlets/policy_version_v3.go b/pkg/providers/cloudlets/policy_version_v3.go index 63e81338b..7bb56f2ca 100644 --- a/pkg/providers/cloudlets/policy_version_v3.go +++ b/pkg/providers/cloudlets/policy_version_v3.go @@ -3,7 +3,7 @@ package cloudlets import ( "context" - cloudlets "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + cloudlets "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" ) type v3VersionStrategy struct { diff --git a/pkg/providers/cloudlets/provider.go b/pkg/providers/cloudlets/provider.go index 4820b8709..b5e77724f 100644 --- a/pkg/providers/cloudlets/provider.go +++ b/pkg/providers/cloudlets/provider.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" ) diff --git a/pkg/providers/cloudlets/provider_test.go b/pkg/providers/cloudlets/provider_test.go index 62c8a3995..110dcb0a2 100644 --- a/pkg/providers/cloudlets/provider_test.go +++ b/pkg/providers/cloudlets/provider_test.go @@ -4,10 +4,10 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" ) func TestMain(m *testing.M) { diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go index ab50e7caa..40cf37498 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ozzo "github.com/go-ozzo/ozzo-validation/v4" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go index 32bd866fe..4a4494320 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go index 136664c5a..d808a8951 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go index 80d04de78..fa0e1e12d 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go index 5da6246d0..a3c3cb633 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go @@ -10,9 +10,9 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go index e0cda453c..0e0144394 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go @@ -12,9 +12,9 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go index 2d01b0e55..773e2426c 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go index 6bd672448..344547772 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go @@ -8,7 +8,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go index e5ed14488..87c1fbea9 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go index 85f37ef1e..246e8f48c 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -1551,7 +1551,7 @@ func TestResourcePolicyV3(t *testing.T) { require.NoError(t, err) policyUpdate.GroupID = updatedGroup client.On("UpdatePolicy", mock.Anything, v3.UpdatePolicyRequest{ - BodyParams: v3.UpdatePolicyBodyParams{ + Body: v3.UpdatePolicyRequestBody{ GroupID: updatedGroup, }, PolicyID: policyUpdate.ID, @@ -2706,7 +2706,7 @@ func TestResourcePolicyV3(t *testing.T) { policy, version := expectCreatePolicy(t, client, 2, 123, matchRules, "test policy description") expectReadPolicy(t, client, policy, version, 3) client.On("UpdatePolicy", mock.Anything, v3.UpdatePolicyRequest{ - BodyParams: v3.UpdatePolicyBodyParams{ + Body: v3.UpdatePolicyRequestBody{ GroupID: 321, }, PolicyID: policy.ID, diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go index 710a8bcab..17ac81bcd 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go index 6abcf9802..5a7f1dcd0 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -77,7 +77,7 @@ func (strategy v3PolicyStrategy) updatePolicyVersion(ctx context.Context, d *sch func (strategy v3PolicyStrategy) updatePolicy(ctx context.Context, policyID, groupID int64, _ string) error { updatePolicyReq := v3.UpdatePolicyRequest{ PolicyID: policyID, - BodyParams: v3.UpdatePolicyBodyParams{ + Body: v3.UpdatePolicyRequestBody{ GroupID: groupID, }, } diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go index 7cf66fb53..ef83399d6 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/attr" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go index c85266cd4..8c23e8329 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go index f0b21d246..ec2c3a8c3 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go index 6187b4884..cd5394b95 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go index 8216a5f1c..9f23c0630 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go index 281c2ebde..0c59002c6 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go index 391f45ff3..ed31274f5 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go index fcf6a8d62..edf98916f 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go index 1dbb44cdf..d4cecfbc6 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go index 245a7decb..485db0868 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go index eb63fc2c4..aeaabd924 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go index c14f2861d..8d2580830 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/provider_test.go b/pkg/providers/cloudwrapper/provider_test.go index 5764867ff..063006af1 100644 --- a/pkg/providers/cloudwrapper/provider_test.go +++ b/pkg/providers/cloudwrapper/provider_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/akamai" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go index 655f0dae4..4806594bd 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/attr" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go index 4a5e6c932..5f3cf5781 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go index 7def24d00..1af20e7a9 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go index a20f080de..d648d7b3a 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/replacer" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" @@ -67,7 +67,7 @@ func (m *ConfigurationResourceModel) hasUnknown() bool { func (m *ConfigurationResourceModel) buildCreateRequest(ctx context.Context) cloudwrapper.CreateConfigurationRequest { return cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ CapacityAlertsThreshold: m.getCapacityAlertsThreshold(), Comments: m.Comments.ValueString(), ContractID: m.ContractID.ValueString(), @@ -84,7 +84,7 @@ func (m *ConfigurationResourceModel) buildCreateRequest(ctx context.Context) clo func (m *ConfigurationResourceModel) buildUpdateRequest(ctx context.Context) cloudwrapper.UpdateConfigurationRequest { return cloudwrapper.UpdateConfigurationRequest{ ConfigID: m.ID.ValueInt64(), - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ CapacityAlertsThreshold: m.getCapacityAlertsThreshold(), Comments: m.Comments.ValueString(), Locations: m.getLocationsReq(), diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go index 92e61f0a8..c9c0a489f 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jinzhu/copier" @@ -19,7 +19,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -78,7 +78,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -127,7 +127,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -176,7 +176,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -204,7 +204,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectDelete() configUpdate := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -259,7 +259,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -289,7 +289,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectDelete() configUpdate := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_234", Locations: []cloudwrapper.ConfigLocationReq{ @@ -346,7 +346,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -376,7 +376,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectDelete() configUpdate := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_234", Locations: []cloudwrapper.ConfigLocationReq{ @@ -433,7 +433,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -491,7 +491,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -521,7 +521,7 @@ func TestConfigurationResource(t *testing.T) { configUpdate := cloudwrapper.UpdateConfigurationRequest{ ConfigID: expecter.config.ConfigID, - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ CapacityAlertsThreshold: &capacityAlertsThreshold, Comments: "test", Locations: []cloudwrapper.ConfigLocationReq{ @@ -547,7 +547,7 @@ func TestConfigurationResource(t *testing.T) { configUpdate2 := cloudwrapper.UpdateConfigurationRequest{ ConfigID: expecter.config.ConfigID, - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ Comments: "test", Locations: []cloudwrapper.ConfigLocationReq{ { @@ -610,7 +610,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -674,7 +674,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -734,7 +734,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -782,7 +782,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectUpdate(cloudwrapper.UpdateConfigurationRequest{ ConfigID: 123, Activate: false, - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ Comments: "test", Locations: []cloudwrapper.ConfigLocationReq{ { @@ -833,7 +833,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -912,7 +912,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ diff --git a/pkg/providers/cps/data_akamai_cps_csr.go b/pkg/providers/cps/data_akamai_cps_csr.go index 1536d49da..e20d6a1ba 100644 --- a/pkg/providers/cps/data_akamai_cps_csr.go +++ b/pkg/providers/cps/data_akamai_cps_csr.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/data_akamai_cps_csr_test.go b/pkg/providers/cps/data_akamai_cps_csr_test.go index bebd98a95..44e2540ad 100644 --- a/pkg/providers/cps/data_akamai_cps_csr_test.go +++ b/pkg/providers/cps/data_akamai_cps_csr_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/data_akamai_cps_deployments.go b/pkg/providers/cps/data_akamai_cps_deployments.go index 6c150aea3..75d4bb8cc 100644 --- a/pkg/providers/cps/data_akamai_cps_deployments.go +++ b/pkg/providers/cps/data_akamai_cps_deployments.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/cps/data_akamai_cps_deployments_test.go b/pkg/providers/cps/data_akamai_cps_deployments_test.go index 6e100b3f9..e885608dc 100644 --- a/pkg/providers/cps/data_akamai_cps_deployments_test.go +++ b/pkg/providers/cps/data_akamai_cps_deployments_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cps/data_akamai_cps_enrollment.go b/pkg/providers/cps/data_akamai_cps_enrollment.go index 9728e21f4..cb3fb03d1 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollment.go +++ b/pkg/providers/cps/data_akamai_cps_enrollment.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" cpstools "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" diff --git a/pkg/providers/cps/data_akamai_cps_enrollment_test.go b/pkg/providers/cps/data_akamai_cps_enrollment_test.go index ff0969990..0c51a6d42 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollment_test.go +++ b/pkg/providers/cps/data_akamai_cps_enrollment_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/data_akamai_cps_enrollments.go b/pkg/providers/cps/data_akamai_cps_enrollments.go index ec41e8510..d9305ee40 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollments.go +++ b/pkg/providers/cps/data_akamai_cps_enrollments.go @@ -3,8 +3,8 @@ package cps import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" cpstools "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" diff --git a/pkg/providers/cps/data_akamai_cps_enrollments_test.go b/pkg/providers/cps/data_akamai_cps_enrollments_test.go index 88b229389..7ece70bf0 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollments_test.go +++ b/pkg/providers/cps/data_akamai_cps_enrollments_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/enrollments.go b/pkg/providers/cps/enrollments.go index 0dd339896..bb793569e 100644 --- a/pkg/providers/cps/enrollments.go +++ b/pkg/providers/cps/enrollments.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/enrollments_mocks.go b/pkg/providers/cps/enrollments_mocks.go index c57703e64..a6e5e31b0 100644 --- a/pkg/providers/cps/enrollments_mocks.go +++ b/pkg/providers/cps/enrollments_mocks.go @@ -1,6 +1,6 @@ package cps -import "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" +import "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" func mockLetsEncryptChallenges() *cps.Change { allowedInput := cps.AllowedInput{ diff --git a/pkg/providers/cps/enrollments_test.go b/pkg/providers/cps/enrollments_test.go index 722ded0dc..31f88ae9b 100644 --- a/pkg/providers/cps/enrollments_test.go +++ b/pkg/providers/cps/enrollments_test.go @@ -3,7 +3,7 @@ package cps import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/cps/provider.go b/pkg/providers/cps/provider.go index 759156a4c..a61f80898 100644 --- a/pkg/providers/cps/provider.go +++ b/pkg/providers/cps/provider.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" ) diff --git a/pkg/providers/cps/provider_test.go b/pkg/providers/cps/provider_test.go index 394c9e14e..67f029bb4 100644 --- a/pkg/providers/cps/provider_test.go +++ b/pkg/providers/cps/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go b/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go index 98dd00723..d860f5712 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go b/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go index e55b85385..355714fe0 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/resource_akamai_cps_dv_validation.go b/pkg/providers/cps/resource_akamai_cps_dv_validation.go index 08fbec155..9ffa53fbb 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_validation.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_validation.go @@ -7,8 +7,8 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go b/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go index 99a2a3bd7..8c2efb508 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go index 974e489e2..5304d16ef 100644 --- a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go +++ b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go index 635a23a3f..643f7b890 100644 --- a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go +++ b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/resource_akamai_cps_upload_certificate.go b/pkg/providers/cps/resource_akamai_cps_upload_certificate.go index 1d21b6080..d6b6cf2b3 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go index 1532c00d7..9321b2b6c 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go @@ -6,12 +6,12 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -1135,6 +1135,14 @@ func TestUpdateCPSUploadCertificate(t *testing.T) { func TestResourceUploadCertificateImport(t *testing.T) { id := 1 + checker := test.NewImportChecker(). + CheckEqual("certificate_ecdsa_pem", certECDSAForTests). + CheckEqual("trust_chain_ecdsa_pem", trustChainECDSAForTests). + CheckEqual("acknowledge_post_verification_warnings", "false"). + CheckEqual("wait_for_deployment", "false"). + CheckEqual("acknowledge_change_management", "false"). + CheckEqual("auto_approve_warnings.#", "0") + tests := map[string]struct { init func(*cps.Mock) expectedError *regexp.Regexp @@ -1145,20 +1153,10 @@ func TestResourceUploadCertificateImport(t *testing.T) { enrollment := cps.GetEnrollmentResponse{ ValidationType: "third-party", } - mockGetEnrollment(client, id, 2, &enrollment) mockGetChangeHistory(client, id, 2, &enrollment, ECDSA, certECDSAForTests, trustChainECDSAForTests) }, - stateCheck: func(s []*terraform.InstanceState) error { - state := s[0] - assertAttributeFor(state, t, "certificate_ecdsa_pem", certECDSAForTests) - assertAttributeFor(state, t, "trust_chain_ecdsa_pem", trustChainECDSAForTests) - assertAttributeFor(state, t, "acknowledge_post_verification_warnings", "false") - assertAttributeFor(state, t, "wait_for_deployment", "false") - assertAttributeFor(state, t, "acknowledge_change_management", "false") - assertAttributeFor(state, t, "auto_approve_warnings.#", "0") - return nil - }, + stateCheck: checker.Build(), }, "import error when validation type is not third_party": { init: func(client *cps.Mock) { @@ -1207,12 +1205,6 @@ func TestResourceUploadCertificateImport(t *testing.T) { } } -func assertAttributeFor(state *terraform.InstanceState, t *testing.T, key, value string) { - valueInState, exist := state.Attributes[key] - assert.True(t, exist, fmt.Sprintf("attribute '%s' was not present", key)) - assert.Equal(t, value, valueInState, fmt.Sprintf("attribute '%s' has incorrect value %s", key, valueInState)) -} - // copyEnrollmentWithEmptyPendingChanges returns enrollment after enrollment reaches "complete" state - it's pending changes disappear func copyEnrollmentWithEmptyPendingChanges(enrollment cps.GetEnrollmentResponse) *cps.GetEnrollmentResponse { enrollment.PendingChanges = []cps.PendingChange{} diff --git a/pkg/providers/cps/tools/enrollment.go b/pkg/providers/cps/tools/enrollment.go index c08596633..4b73e0ed7 100644 --- a/pkg/providers/cps/tools/enrollment.go +++ b/pkg/providers/cps/tools/enrollment.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/cps/tools/enrollment_test.go b/pkg/providers/cps/tools/enrollment_test.go index 91937747e..ddd1f0ee7 100644 --- a/pkg/providers/cps/tools/enrollment_test.go +++ b/pkg/providers/cps/tools/enrollment_test.go @@ -3,7 +3,7 @@ package tools import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/providers/datastream/connectors.go b/pkg/providers/datastream/connectors.go index a903a9a36..2c9202a3c 100644 --- a/pkg/providers/datastream/connectors.go +++ b/pkg/providers/datastream/connectors.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/datastream/connectors_test.go b/pkg/providers/datastream/connectors_test.go index f79576d96..0ddb60286 100644 --- a/pkg/providers/datastream/connectors_test.go +++ b/pkg/providers/datastream/connectors_test.go @@ -3,7 +3,7 @@ package datastream import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/datastream/data_akamai_datastream_activation_history.go b/pkg/providers/datastream/data_akamai_datastream_activation_history.go index ccfb27059..775256acc 100644 --- a/pkg/providers/datastream/data_akamai_datastream_activation_history.go +++ b/pkg/providers/datastream/data_akamai_datastream_activation_history.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" ) func dataAkamaiDatastreamActivationHistory() *schema.Resource { diff --git a/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go b/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go index 929030739..0038dbf2c 100644 --- a/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go +++ b/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go b/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go index b0f45290a..ddd0d4020 100644 --- a/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go +++ b/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go b/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go index d5e26b9f4..5bfc05c71 100644 --- a/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go +++ b/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/datastream/data_akamai_datastreams.go b/pkg/providers/datastream/data_akamai_datastreams.go index 3ec3ceaf5..85c6eee9f 100644 --- a/pkg/providers/datastream/data_akamai_datastreams.go +++ b/pkg/providers/datastream/data_akamai_datastreams.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/datastream/data_akamai_datastreams_test.go b/pkg/providers/datastream/data_akamai_datastreams_test.go index 12528dff8..fa49f64bf 100644 --- a/pkg/providers/datastream/data_akamai_datastreams_test.go +++ b/pkg/providers/datastream/data_akamai_datastreams_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/datastream/provider.go b/pkg/providers/datastream/provider.go index 627ec01c7..4226ee4b0 100644 --- a/pkg/providers/datastream/provider.go +++ b/pkg/providers/datastream/provider.go @@ -4,7 +4,7 @@ package datastream import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/datastream/provider_test.go b/pkg/providers/datastream/provider_test.go index 14cfe4791..62181dbc8 100644 --- a/pkg/providers/datastream/provider_test.go +++ b/pkg/providers/datastream/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/datastream/resource_akamai_datastream.go b/pkg/providers/datastream/resource_akamai_datastream.go index 92922aa21..d6d3b77ad 100644 --- a/pkg/providers/datastream/resource_akamai_datastream.go +++ b/pkg/providers/datastream/resource_akamai_datastream.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" @@ -888,7 +888,7 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } } - emailIDs := InterfaceSliceToStringSlice(emailIDsList) + emailIDs := tf.InterfaceSliceToStringSlice(emailIDsList) if len(emailIDs) == 0 { emailIDs = nil @@ -1185,7 +1185,7 @@ func updateStream(ctx context.Context, client datastream.DS, logger log.Interfac return err } } - emailIDs := InterfaceSliceToStringSlice(emailIDsList) + emailIDs := tf.InterfaceSliceToStringSlice(emailIDsList) propertyIDsList, err := tf.GetListValue("properties", d) diff --git a/pkg/providers/datastream/resource_akamai_datastream_test.go b/pkg/providers/datastream/resource_akamai_datastream_test.go index d47b8736c..9f7550e76 100644 --- a/pkg/providers/datastream/resource_akamai_datastream_test.go +++ b/pkg/providers/datastream/resource_akamai_datastream_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/datastream/stream.go b/pkg/providers/datastream/stream.go index 63956ff75..48aae93d7 100644 --- a/pkg/providers/datastream/stream.go +++ b/pkg/providers/datastream/stream.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -105,15 +105,6 @@ func DatasetFieldListToDatasetFields(list []interface{}) []datastream.DatasetFie return datasetFields } -// InterfaceSliceToStringSlice converts schema.Set to slice of string -func InterfaceSliceToStringSlice(list []interface{}) []string { - stringList := make([]string, len(list)) - for i, v := range list { - stringList[i] = v.(string) - } - return stringList -} - // DataSetFieldsToList converts slice of dataSetFields to slice of ints func DataSetFieldsToList(dataSetFields []datastream.DataSetField) []int { diff --git a/pkg/providers/datastream/stream_test.go b/pkg/providers/datastream/stream_test.go index 8f43570dc..dd264e324 100644 --- a/pkg/providers/datastream/stream_test.go +++ b/pkg/providers/datastream/stream_test.go @@ -6,7 +6,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tj/assert" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -198,7 +199,7 @@ func TestInterfaceSliceToStringSlice(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { - assert.Equal(t, test.expected, InterfaceSliceToStringSlice(test.input)) + assert.Equal(t, test.expected, tf.InterfaceSliceToStringSlice(test.input)) }) } } diff --git a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go index 2fbf774ce..9baa3a422 100644 --- a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go +++ b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go index 7aff7c065..64276daf2 100644 --- a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go +++ b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/dns/data_authorities_set.go b/pkg/providers/dns/data_authorities_set.go index 04fa16cf3..7132e5bce 100644 --- a/pkg/providers/dns/data_authorities_set.go +++ b/pkg/providers/dns/data_authorities_set.go @@ -6,7 +6,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -49,7 +50,9 @@ func dataSourceAuthoritiesSetRead(ctx context.Context, d *schema.ResourceData, m logger.WithField("contractid", contractID).Debug("Start Searching for authority records") - ns, err := inst.Client(meta).GetNameServerRecordList(ctx, contractID) + ns, err := inst.Client(meta).GetNameServerRecordList(ctx, dns.GetNameServerRecordListRequest{ + ContractIDs: contractID, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, diff --git a/pkg/providers/dns/data_authorities_set_test.go b/pkg/providers/dns/data_authorities_set_test.go index bb1ce65af..11216197e 100644 --- a/pkg/providers/dns/data_authorities_set_test.go +++ b/pkg/providers/dns/data_authorities_set_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -23,7 +23,7 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { client.On("GetNameServerRecordList", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), + mock.AnythingOfType("dns.GetNameServerRecordListRequest"), ).Return(authorities, nil) useClient(client, func() { @@ -71,7 +71,7 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { client.On("GetNameServerRecordList", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), + mock.AnythingOfType("dns.GetNameServerRecordListRequest"), ).Return(nil, errors.New("invalid contract")) useClient(client, func() { diff --git a/pkg/providers/dns/data_dns_record_set.go b/pkg/providers/dns/data_dns_record_set.go index cb4cd5e95..a59893720 100644 --- a/pkg/providers/dns/data_dns_record_set.go +++ b/pkg/providers/dns/data_dns_record_set.go @@ -5,11 +5,11 @@ import ( "fmt" "sort" - "github.com/apex/log" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -72,7 +72,11 @@ func dataSourceDNSRecordSetRead(ctx context.Context, d *schema.ResourceData, m i }).Debug("Start Searching for records") // Warning or Errors can be collected in a slice type var diags diag.Diagnostics - rdata, err := inst.Client(meta).GetRdata(ctx, zone, host, recordType) + rdata, err := inst.Client(meta).GetRdata(ctx, dns.GetRdataRequest{ + Name: zone, + Zone: host, + RecordType: recordType, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, diff --git a/pkg/providers/dns/data_dns_record_set_test.go b/pkg/providers/dns/data_dns_record_set_test.go index 5b00190ed..3e85b7a67 100644 --- a/pkg/providers/dns/data_dns_record_set_test.go +++ b/pkg/providers/dns/data_dns_record_set_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -22,9 +22,7 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { client.On("GetRdata", mock.Anything, // ctx is irrelevant for this test - "exampleterraform.io", - "exampleterraform.io", - "A", + mock.AnythingOfType("dns.GetRdataRequest"), ).Return(rdata, nil) useClient(client, func() { @@ -57,9 +55,7 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { client.On("GetRdata", mock.Anything, // ctx is irrelevant for this test - "exampleterraform.io", - "exampleterraform.io", - "TXT", + dns.GetRdataRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, ).Return(rdata, nil) useClient(client, func() { @@ -87,9 +83,7 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { client.On("GetRdata", mock.Anything, // ctx is irrelevant for this test - "exampleterraform.io", - "exampleterraform.io", - "A", + mock.AnythingOfType("dns.GetRdataRequest"), ).Return(nil, errors.New("invalid zone")) useClient(client, func() { diff --git a/pkg/providers/dns/provider.go b/pkg/providers/dns/provider.go index 47f8e222c..7e1051644 100644 --- a/pkg/providers/dns/provider.go +++ b/pkg/providers/dns/provider.go @@ -4,7 +4,7 @@ package dns import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/dns/provider_test.go b/pkg/providers/dns/provider_test.go index 49fb59aba..8192225d7 100644 --- a/pkg/providers/dns/provider_test.go +++ b/pkg/providers/dns/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/dns/resource_akamai_dns_record.go b/pkg/providers/dns/resource_akamai_dns_record.go index 4268acb13..bf1b63fa3 100644 --- a/pkg/providers/dns/resource_akamai_dns_record.go +++ b/pkg/providers/dns/resource_akamai_dns_record.go @@ -16,14 +16,13 @@ import ( "sync" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/dns/internal/txtrecord" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/dns/internal/txtrecord" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -599,7 +598,11 @@ func getRecordLock(recordType string) *sync.Mutex { func bumpSoaSerial(ctx context.Context, d *schema.ResourceData, meta meta.Meta, zone, host string, logger log.Interface) (*dns.RecordBody, error) { // Get SOA Record - recordset, err := inst.Client(meta).GetRecord(ctx, zone, host, "SOA") + recordset, err := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: "SOA", + }) if err != nil { return nil, fmt.Errorf("error looking up SOA record for %s: %w", host, err) } @@ -620,18 +623,31 @@ func bumpSoaSerial(ctx context.Context, d *schema.ResourceData, meta meta.Meta, } // Record op function -func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBody, zone string, rlock bool) error { +func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBody, zone string, rlock []bool) error { var e error switch fn { case "Create": - e = inst.Client(meta).CreateRecord(ctx, rec, zone, rlock) + e = inst.Client(meta).CreateRecord(ctx, dns.CreateRecordRequest{ + Zone: zone, + Record: rec, + RecLock: rlock, + }) case "Update": - e = inst.Client(meta).UpdateRecord(ctx, rec, zone, rlock) + e = inst.Client(meta).UpdateRecord(ctx, dns.UpdateRecordRequest{ + Zone: zone, + Record: rec, + RecLock: rlock, + }) case "Delete": - e = inst.Client(meta).DeleteRecord(ctx, rec, zone, rlock) + e = inst.Client(meta).DeleteRecord(ctx, dns.DeleteRecordRequest{ + Zone: zone, + Name: rec.Name, + RecordType: rec.RecordType, + RecLock: rlock, + }) default: e = fmt.Errorf("Invalid operation [%s]", fn) @@ -640,7 +656,7 @@ func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBod return e } -func executeRecordFunction(ctx context.Context, meta meta.Meta, name string, d *schema.ResourceData, fn string, rec *dns.RecordBody, zone, host, recordType string, logger log.Interface, rlock bool) error { +func executeRecordFunction(ctx context.Context, meta meta.Meta, name string, d *schema.ResourceData, fn string, rec *dns.RecordBody, zone, host, recordType string, logger log.Interface, rlock []bool) error { logger.Debugf("executeRecordFunction - zone: %s, host: %s, recordtype: %s", zone, host, recordType) // DNS API can have Concurrency issues @@ -733,7 +749,11 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte if recordType == RRTypeSoa { logger.Debug("Attempting to create a SOA record") // A default SOA is created automagically when the primary zone is created ... - if _, err := inst.Client(meta).GetRecord(ctx, zone, host, recordType); err == nil { + if _, err := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }); err == nil { // Record exists serial, err := tf.GetIntValue("serial", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { @@ -771,7 +791,11 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte // First try to get the zone from the API logger.Debugf("Searching for records [%s]", zone) rdata := make([]string, 0) - recordSet, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + recordSet, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -790,7 +814,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte // record not found/404 we will create a new logger.Debug("Creating new record") // Save the zone to the API - e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -801,7 +825,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte } else { logger.Debug("Updating record") if len(rdata) > 0 { - e = executeRecordFunction(ctx, meta, "CREATE", d, "Update", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "CREATE", d, "Update", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -811,7 +835,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte } } else { logger.Debug("Saving record") - e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -903,7 +927,11 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte if recordType == RRTypeSoa { // need to get current serial and increment as part of update - record, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + record, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -942,7 +970,11 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte // First try to get the zone from the API logger.Debugf("UPDATE Searching for records [%s]", zone) rdata := make([]string, 0, 0) - recordset, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + recordset, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -970,13 +1002,13 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte logger.Errorf("UPDATE [ERROR] %s", e.Error()) logger.Debugf("UPDATE Creating new record") // Save the zone to the API - e = executeRecordFunction(ctx, meta, "UPDATE", d, "Create", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "UPDATE", d, "Create", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return diag.FromErr(e) } } else { logger.Debug("UPDATE Updating record") - e = executeRecordFunction(ctx, meta, "UPDATE", d, "Update", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "UPDATE", d, "Update", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return diag.FromErr(e) } @@ -1060,7 +1092,11 @@ func resourceDNSRecordRead(ctx context.Context, d *schema.ResourceData, m interf "recordtype": recordType, }).Info("READ Searching for zone records") - record, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + record, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -1255,7 +1291,11 @@ func resourceDNSRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.R // Get recordset logger.Debugf("Searching for zone Recordset. %s", idParts) - recordset, e := inst.Client(meta).GetRecord(ctx, zone, recordName, recordType) + recordset, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: recordName, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -1367,7 +1407,7 @@ func resourceDNSRecordDelete(ctx context.Context, d *schema.ResourceData, m inte // Warning: Delete will expunge the ENTIRE Recordset regardless of whether user thought they were removing an instance - if err := executeRecordFunction(ctx, meta, "DELETE", d, "Delete", &recordcreate, zone, host, recordType, logger, false); err != nil { + if err := executeRecordFunction(ctx, meta, "DELETE", d, "Delete", &recordcreate, zone, host, recordType, logger, []bool{false}); err != nil { return diag.FromErr(err) } d.SetId("") @@ -1555,7 +1595,11 @@ func newRecordCreate(ctx context.Context, meta meta.Meta, d *schema.ResourceData return dns.RecordBody{}, err } logger.Debugf("MX record targets to process: %v", target) - recordset, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + recordset, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) rdata := make([]string, 0, 0) if e != nil { logger.Debugf("MX Get Error Type: %T", e) diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index 4994337f5..66518e1e1 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -21,8 +21,6 @@ import ( func TestResDnsRecord(t *testing.T) { dnsClient := dns.Client(session.Must(session.New())) - var rec *dns.RecordBody - notFound := &dns.Error{ StatusCode: http.StatusNotFound, } @@ -31,60 +29,92 @@ func TestResDnsRecord(t *testing.T) { t.Run("lifecycle test", func(t *testing.T) { client := &dns.Mock{} - getCall := client.On("GetRecord", + // read + client.On("GetRecord", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), - ).Return(nil, notFound) + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(nil, notFound).Once() + + // create + client.On("CreateRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.CreateRecordRequest"), + ).Return(nil).Once() - parseCall := client.On("ParseRData", + // read + client.On("GetRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ + Name: "", + RecordType: "", + TTL: 0, + Active: false, + Target: nil, + }, nil).Once() + + retCreate := dnsClient.ParseRData(context.Background(), "A", []string{"10.0.0.2", "10.0.0.3"}) + + client.On("ParseRData", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("[]string"), - ).Return(nil) + ).Return(retCreate).Times(3) - procCall := client.On("ProcessRdata", + client.On("ProcessRdata", mock.Anything, // ctx is irrelevant for this test mock.AnythingOfType("[]string"), mock.AnythingOfType("string"), - ).Return(nil, nil) + ).Return([]string{"A"}, nil).Times(4) - updateArguments := func(args mock.Arguments) { - rec = args.Get(1).(*dns.RecordBody) - getCall.ReturnArguments = mock.Arguments{rec, nil} - parseCall.ReturnArguments = mock.Arguments{ - dnsClient.ParseRData(context.Background(), rec.RecordType, rec.Target), - } - procCall.ReturnArguments = mock.Arguments{rec.Target, nil} - } + client.On("GetRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ + Name: "", + RecordType: "", + TTL: 0, + Active: false, + Target: nil, + }, nil).Times(3) - client.On("CreateRecord", + // update + client.On("UpdateRecord", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), + mock.AnythingOfType("dns.UpdateRecordRequest"), + ).Return(nil).Once() + + // read + client.On("GetRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ + Name: "", + RecordType: "", + TTL: 0, + Active: false, + Target: nil, + }, nil).Times(2) + + retUpdate := dnsClient.ParseRData(context.Background(), "A", []string{"10.0.0.4", "10.0.0.5"}) + + client.On("ParseRData", mock.Anything, - ).Return(nil).Run(func(args mock.Arguments) { - updateArguments(args) - }) + mock.AnythingOfType("string"), + mock.AnythingOfType("[]string"), + ).Return(retUpdate).Times(2) - client.On("UpdateRecord", + client.On("ProcessRdata", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*dns.RecordBody"), + mock.AnythingOfType("[]string"), mock.AnythingOfType("string"), - mock.Anything, - ).Return(nil).Run(func(args mock.Arguments) { - updateArguments(args) - }) + ).Return([]string{"A"}, nil).Times(2) + // delete client.On("DeleteRecord", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), - ).Return(nil).Run(func(mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{nil, notFound} - }) + mock.AnythingOfType("dns.DeleteRecordRequest"), + ).Return(nil).Once() dataSourceName := "akamai_dns_record.a_record" @@ -119,30 +149,18 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", + mock.AnythingOfType("dns.GetRecordRequest"), ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "exampleterraform.io", - RecordType: "TXT", - TTL: 300, - Active: false, - Target: []string{target1, target2}, - }, - "exampleterraform.io", - []bool{false}, + mock.AnythingOfType("dns.CreateRecordRequest"), ).Return(nil) client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -166,10 +184,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -179,9 +195,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + mock.AnythingOfType("dns.DeleteRecordRequest"), ).Return(nil) resourceName := "akamai_dns_record.txt_record" @@ -220,30 +234,28 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "exampleterraform.io", - RecordType: "TXT", - TTL: 300, - Active: false, - Target: []string{normalizedTarget1, normalizedTarget2, normalizedTarget3}, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "exampleterraform.io", + RecordType: "TXT", + TTL: 300, + Active: false, + Target: []string{normalizedTarget1, normalizedTarget2, normalizedTarget3}, + }, + Zone: "exampleterraform.io", + RecLock: []bool{false}, }, - "exampleterraform.io", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -267,10 +279,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -280,9 +290,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.txt_record" @@ -317,30 +325,28 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "origin.example.org", - RecordType: "SRV", - TTL: 300, - Active: false, - Target: []string{targetBig, targetSmall, targetTiny}, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "origin.example.org", + RecordType: "SRV", + TTL: 300, + Active: false, + Target: []string{targetBig, targetSmall, targetTiny}, + }, + Zone: "origin.org", + RecLock: []bool{false}, }, - "origin.org", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -366,10 +372,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -379,9 +383,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.srv_record" @@ -415,30 +417,28 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "origin.example.org", - RecordType: "SRV", - TTL: 300, - Active: false, - Target: []string{targetBig, targetSmall, targetTiny}, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "origin.example.org", + RecordType: "SRV", + TTL: 300, + Active: false, + Target: []string{targetBig, targetSmall, targetTiny}, + }, + Zone: "origin.org", + RecLock: []bool{false}, }, - "origin.org", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -464,10 +464,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -477,9 +475,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.srv_record" @@ -530,30 +526,28 @@ func TestResDnsRecord(t *testing.T) { targetReceived := []string{"2001:db8:0:0:0:0:0:68", "::ffff:192.0.2.1"} client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "AAAA", + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "exampleterraform.io", - RecordType: "AAAA", - TTL: 300, - Active: false, - Target: targetSent, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "exampleterraform.io", + RecordType: "AAAA", + TTL: 300, + Active: false, + Target: targetSent, + }, + Zone: "exampleterraform.io", + RecLock: []bool{false}, }, - "exampleterraform.io", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "AAAA", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "AAAA", TTL: 300, @@ -577,10 +571,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "AAAA", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "AAAA", TTL: 300, @@ -590,9 +582,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.aaaa_record" @@ -659,42 +649,55 @@ func TestMXRecord(t *testing.T) { } dnsClient := dns.Client(session.Must(session.New())) name, zone, mx := "exampleterraform.io", "exampleterraform.io", "MX" + getRecordRequest := dns.GetRecordRequest{ + Zone: zone, + Name: name, + RecordType: mx} mockCreate := func(d *dns.Mock, realClient dns.DNS, createdRecord *dns.RecordBody) { - d.On("GetRecord", mock.Anything, zone, name, mx). + d.On("GetRecord", mock.Anything, getRecordRequest). Return(nil, notFound).Twice() - d.On("CreateRecord", mock.Anything, - createdRecord, zone, []bool{false}). + d.On("CreateRecord", mock.Anything, dns.CreateRecordRequest{ + Record: createdRecord, + Zone: zone, + RecLock: []bool{false}}). Return(nil).Once() } mockRead := func(d *dns.Mock, realClient dns.DNS, createdRecord *dns.RecordBody) { - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(createdRecord, nil).Once() + response := (*dns.GetRecordResponse)(createdRecord) + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ProcessRdata", mock.Anything, createdRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), createdRecord.Target, mx)).Once() - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(createdRecord, nil).Once() + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ParseRData", mock.Anything, mx, createdRecord.Target). Return(realClient.ParseRData(context.Background(), mx, createdRecord.Target)).Once() d.On("ProcessRdata", mock.Anything, createdRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), createdRecord.Target, mx)).Once() } mockUpdate := func(d *dns.Mock, realClient dns.DNS, previousRecord *dns.RecordBody, updatedRecord *dns.RecordBody) { - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(previousRecord, nil).Once() + response := (*dns.GetRecordResponse)(previousRecord) + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ProcessRdata", mock.Anything, previousRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), previousRecord.Target, mx)).Once() - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(previousRecord, nil).Once() + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ProcessRdata", mock.Anything, previousRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), previousRecord.Target, mx)).Once() - d.On("UpdateRecord", mock.Anything, - updatedRecord, zone, []bool{false}). + d.On("UpdateRecord", mock.Anything, dns.UpdateRecordRequest{ + Record: updatedRecord, + Zone: zone, + RecLock: []bool{false}}). Return(nil) } mockDelete := func(d *dns.Mock, createdRecord *dns.RecordBody) { - d.On("DeleteRecord", mock.Anything, - createdRecord, zone, []bool{false}). + d.On("DeleteRecord", mock.Anything, dns.DeleteRecordRequest{ + Zone: zone, + Name: createdRecord.Name, + RecordType: createdRecord.RecordType, + RecLock: []bool{false}}). Return(nil) } diff --git a/pkg/providers/dns/resource_akamai_dns_zone.go b/pkg/providers/dns/resource_akamai_dns_zone.go index eb9931895..779c437cc 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone.go +++ b/pkg/providers/dns/resource_akamai_dns_zone.go @@ -10,13 +10,11 @@ import ( "strings" "time" - "github.com/apex/log" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/apex/log" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -185,7 +183,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte } // First try to get the zone from the API logger.Debugf("Searching for zone [%s]", hostname) - zone, e := inst.Client(meta).GetZone(ctx, hostname) + zone, e := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e == nil { // Not a good idea to overwrite an existing zone. Needs to be imported. @@ -208,7 +208,11 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte // no existing zone. logger.Debugf("Creating new zone: %v", zoneCreate) - e = inst.Client(meta).CreateZone(ctx, zoneCreate, zoneQueryString, true) + e = inst.Client(meta).CreateZone(ctx, dns.CreateZoneRequest{ + CreateZone: zoneCreate, + ZoneQueryString: zoneQueryString, + ClearConn: []bool{true}, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -219,7 +223,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte if strings.ToUpper(zoneType) == "PRIMARY" { time.Sleep(2 * time.Second) // Indirectly create NS and SOA records - e = inst.Client(meta).SaveChangelist(ctx, zoneCreate) + e = inst.Client(meta).SaveChangeList(ctx, dns.SaveChangeListRequest{ + Zone: zoneCreate.Zone, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -228,7 +234,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte }) } time.Sleep(time.Second) - e = inst.Client(meta).SubmitChangelist(ctx, zoneCreate) + e = inst.Client(meta).SubmitChangeList(ctx, dns.SubmitChangeListRequest{ + Zone: zoneCreate.Zone, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -237,7 +245,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte }) } } - zone, e = inst.Client(meta).GetZone(ctx, hostname) + zone, e = inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -283,7 +293,9 @@ func resourceDNSv2ZoneRead(ctx context.Context, d *schema.ResourceData, m interf } // find the zone first logger.Debugf("Searching for zone [%s]", hostname) - zone, e := inst.Client(meta).GetZone(ctx, hostname) + zone, e := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e != nil { apiError, ok := e.(*dns.Error) if ok && apiError.StatusCode == http.StatusNotFound { @@ -315,7 +327,9 @@ func resourceDNSv2ZoneRead(ctx context.Context, d *schema.ResourceData, m interf }) } // Need updated state - zone, err = inst.Client(meta).GetZone(ctx, hostname) + zone, err = inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -358,22 +372,15 @@ func resourceDNSv2ZoneUpdate(ctx context.Context, d *schema.ResourceData, m inte if err != nil { return diag.FromErr(err) } - contract, err := tf.GetStringValue("contract", d) - if err != nil { - return diag.FromErr(err) - } - group, err := tf.GetStringValue("group", d) - if err != nil { - return diag.FromErr(err) - } zoneType, err := tf.GetStringValue("type", d) if err != nil { return diag.FromErr(err) } - zoneQueryString := dns.ZoneQueryString{Contract: contract, Group: group} logger.Debugf("Searching for zone [%s]", hostname) - zone, e := inst.Client(meta).GetZone(ctx, hostname) + zone, e := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok && apiError.StatusCode != http.StatusOK { @@ -396,7 +403,9 @@ func resourceDNSv2ZoneUpdate(ctx context.Context, d *schema.ResourceData, m inte } // Save the zone to the API logger.Debugf("Saving zone %v", zoneCreate) - e = inst.Client(meta).UpdateZone(ctx, zoneCreate, zoneQueryString) + e = inst.Client(meta).UpdateZone(ctx, dns.UpdateZoneRequest{ + CreateZone: zoneCreate, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -429,7 +438,9 @@ func resourceDNSv2ZoneImport(d *schema.ResourceData, m interface{}) ([]*schema.R // find the zone first logger.Debugf("Searching for zone [%s]", hostname) - zone, err := inst.Client(meta).GetZone(ctx, hostname) + zone, err := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if err != nil { return nil, err } @@ -441,7 +452,9 @@ func resourceDNSv2ZoneImport(d *schema.ResourceData, m interface{}) ([]*schema.R return nil, err } // Need updated state - zone, err = inst.Client(meta).GetZone(ctx, hostname) + zone, err = inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if err != nil { return nil, err } @@ -492,7 +505,7 @@ func validateZoneType(v interface{}, _ cty.Path) diag.Diagnostics { } // populate zone state based on API response. -func populateDNSv2ZoneState(d *schema.ResourceData, zoneresp *dns.ZoneResponse) error { +func populateDNSv2ZoneState(d *schema.ResourceData, zoneresp *dns.GetZoneResponse) error { if err := d.Set("contract", zoneresp.ContractID); err != nil { return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) @@ -664,13 +677,16 @@ func checkDNSv2Zone(d tf.ResourceDataFetcher) error { } // Util func to create SOA and NS records -func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.ZoneResponse, logger log.Interface) error { +func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.GetZoneResponse, logger log.Interface) error { logger.Debugf("Checking SOA and NS records exist for zone %s", zone.Zone) - var resp *dns.RecordSetResponse + var resp *dns.GetRecordSetsResponse var err error if zone.ActivationState != "NEW" { // See if SOA and NS recs exist already. Both or none. - resp, err = inst.Client(meta).GetRecordSets(ctx, zone.Zone, dns.RecordSetQueryArgs{Types: "SOA,NS"}) + resp, err = inst.Client(meta).GetRecordSets(ctx, dns.GetRecordSetsRequest{ + Zone: zone.Zone, + QueryArgs: &dns.RecordSetQueryArgs{Types: "SOA,NS"}, + }) if err != nil { return err } @@ -680,7 +696,9 @@ func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.Zon } logger.Warnf("SOA and NS records don't exist. Creating ...") - nameservers, err := inst.Client(meta).GetNameServerRecordList(ctx, zone.ContractID) + nameservers, err := inst.Client(meta).GetNameServerRecordList(ctx, dns.GetNameServerRecordListRequest{ + ContractIDs: zone.ContractID, + }) if err != nil { return err } @@ -692,7 +710,11 @@ func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.Zon rs.RecordSets = append(rs.RecordSets, createNSRecord(zone.Zone, nameservers, logger)) // create recordSets - err = inst.Client(meta).CreateRecordSets(ctx, rs, zone.Zone, true) + err = inst.Client(meta).CreateRecordSets(ctx, dns.CreateRecordSetsRequest{ + Zone: zone.Zone, + RecordSets: rs, + RecLock: []bool{true}, + }) return err } diff --git a/pkg/providers/dns/resource_akamai_dns_zone_test.go b/pkg/providers/dns/resource_akamai_dns_zone_test.go index 9b240356c..37ca83f88 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone_test.go +++ b/pkg/providers/dns/resource_akamai_dns_zone_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -14,7 +14,7 @@ import ( ) func TestResDNSZone(t *testing.T) { - zone := &dns.ZoneResponse{ + zone := &dns.GetZoneResponse{ ContractID: "ctr1", Zone: "primaryexampleterraform.io", Type: "primary", @@ -22,7 +22,9 @@ func TestResDNSZone(t *testing.T) { SignAndServe: false, ActivationState: "PENDING", } - recordSetsResp := &dns.RecordSetResponse{RecordSets: make([]dns.RecordSet, 2, 2)} + recordSetsResp := &dns.GetRecordSetsResponse{ + RecordSets: make([]dns.RecordSet, 2, 2), + } t.Run("when group is not provided and there is no group for the user ", func(t *testing.T) { client := &dns.Mock{} @@ -79,34 +81,31 @@ func TestResDNSZone(t *testing.T) { getCall := client.On("GetZone", mock.Anything, - zone.Zone, + mock.AnythingOfType("dns.GetZoneRequest"), ).Return(nil, &dns.Error{ StatusCode: http.StatusNotFound, }) client.On("CreateZone", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), - mock.AnythingOfType("dns.ZoneQueryString"), - true, + mock.AnythingOfType("dns.CreateZoneRequest"), ).Return(nil).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{zone, nil} }) - client.On("SaveChangelist", + client.On("SaveChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SaveChangeListRequest"), ).Return(nil) - client.On("SubmitChangelist", + client.On("SubmitChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SubmitChangeListRequest"), ).Return(nil) client.On("GetRecordSets", mock.Anything, - zone.Zone, - mock.AnythingOfType("[]dns.RecordSetQueryArgs"), + mock.AnythingOfType("dns.GetRecordSetsRequest"), ).Return(recordSetsResp, nil) dataSourceName := "akamai_dns_zone.test_without_group" @@ -196,42 +195,38 @@ func TestResDNSZone(t *testing.T) { getCall := client.On("GetZone", mock.Anything, - zone.Zone, + mock.AnythingOfType("dns.GetZoneRequest"), ).Return(nil, &dns.Error{ StatusCode: http.StatusNotFound, }) client.On("CreateZone", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), - mock.AnythingOfType("dns.ZoneQueryString"), - true, + mock.AnythingOfType("dns.CreateZoneRequest"), ).Return(nil).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{zone, nil} }) client.On("UpdateZone", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), - mock.AnythingOfType("dns.ZoneQueryString"), + mock.AnythingOfType("dns.UpdateZoneRequest"), ).Return(nil).Run(func(args mock.Arguments) { zone.Comment = "This is an updated test primary zone" }) - client.On("SaveChangelist", + client.On("SaveChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SaveChangeListRequest"), ).Return(nil) - client.On("SubmitChangelist", + client.On("SubmitChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SubmitChangeListRequest"), ).Return(nil) client.On("GetRecordSets", mock.Anything, - zone.Zone, - mock.AnythingOfType("[]dns.RecordSetQueryArgs"), + mock.AnythingOfType("dns.GetRecordSetsRequest"), ).Return(recordSetsResp, nil) dataSourceName := "akamai_dns_zone.primary_test_zone" diff --git a/pkg/providers/edgeworkers/bundle_hash.go b/pkg/providers/edgeworkers/bundle_hash.go index 7b04843eb..1b0734cfb 100644 --- a/pkg/providers/edgeworkers/bundle_hash.go +++ b/pkg/providers/edgeworkers/bundle_hash.go @@ -8,7 +8,7 @@ import ( "io" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" ) type bundleFile struct { diff --git a/pkg/providers/edgeworkers/bundle_hash_test.go b/pkg/providers/edgeworkers/bundle_hash_test.go index ee0ae929c..a14de62ee 100644 --- a/pkg/providers/edgeworkers/bundle_hash_test.go +++ b/pkg/providers/edgeworkers/bundle_hash_test.go @@ -7,7 +7,7 @@ import ( "io" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go index 32ddae962..7e93d97b6 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go index a4a59b54e..19ff09b4f 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go b/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go index 6b30789ab..f370ef95d 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go b/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go index a441a2cf1..4b551e1e3 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker.go b/pkg/providers/edgeworkers/data_akamai_edgeworker.go index ada40cd81..08067f334 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go index b912abc93..61a58158c 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go index a80f31bc4..bf62e47fe 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go index 78c649b1f..f59dd1dee 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go index 7a016c639..4f44b77a5 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go index 1d614e8f1..bdbbee0bd 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/provider.go b/pkg/providers/edgeworkers/provider.go index 6f09bff54..de57385b9 100644 --- a/pkg/providers/edgeworkers/provider.go +++ b/pkg/providers/edgeworkers/provider.go @@ -4,7 +4,7 @@ package edgeworkers import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/edgeworkers/provider_test.go b/pkg/providers/edgeworkers/provider_test.go index f3193de45..6edf0a48e 100644 --- a/pkg/providers/edgeworkers/provider_test.go +++ b/pkg/providers/edgeworkers/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv.go b/pkg/providers/edgeworkers/resource_akamai_edgekv.go index 7cd88a75d..a40efe59d 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go index 1e1717176..23208fe60 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go index 5674f6fe1..77d6e2df3 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go index ac62ed9a0..c9e29cb1a 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go index fabf16cf7..46e518093 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go @@ -14,8 +14,8 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" @@ -318,14 +318,14 @@ func resourceEdgeWorkerUpdate(ctx context.Context, d *schema.ResourceData, m int if err != nil { return diag.FromErr(err) } - edgeWorkerIDBodyReq := edgeworkers.EdgeWorkerIDBodyRequest{ + edgeWorkerIDBodyReq := edgeworkers.EdgeWorkerIDRequestBody{ Name: name, GroupID: groupIDNum, ResourceTierID: resourceTierID, } _, err = client.UpdateEdgeWorkerID(ctx, edgeworkers.UpdateEdgeWorkerIDRequest{ - EdgeWorkerIDBodyRequest: edgeWorkerIDBodyReq, - EdgeWorkerID: edgeWorkerIDReq, + Body: edgeWorkerIDBodyReq, + EdgeWorkerID: edgeWorkerIDReq, }) if err != nil { return diag.FromErr(err) diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go index bdecb17bb..2621fe92a 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -172,7 +172,7 @@ func TestResourceEdgeWorkersEdgeWorker(t *testing.T) { EdgeWorkerID: edgeWorkerID, } updateEdgeWorkerID := edgeworkers.UpdateEdgeWorkerIDRequest{ - EdgeWorkerIDBodyRequest: edgeworkers.EdgeWorkerIDBodyRequest{ + Body: edgeworkers.EdgeWorkerIDRequestBody{ Name: name, GroupID: groupID, ResourceTierID: resourceTierID, @@ -209,7 +209,7 @@ func TestResourceEdgeWorkersEdgeWorker(t *testing.T) { EdgeWorkerID: edgeWorkerID, } updateEdgeWorkerID := edgeworkers.UpdateEdgeWorkerIDRequest{ - EdgeWorkerIDBodyRequest: edgeworkers.EdgeWorkerIDBodyRequest{ + Body: edgeworkers.EdgeWorkerIDRequestBody{ Name: name, GroupID: groupID, ResourceTierID: resourceTierID, diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go index dfdf2d9a5..0c54c8f53 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go index f8e5d68fa..a0a4153b9 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_asmap.go b/pkg/providers/gtm/data_akamai_gtm_asmap.go index c5eb90f7f..d73f4aeb9 100644 --- a/pkg/providers/gtm/data_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/data_akamai_gtm_asmap.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -145,7 +145,10 @@ func (d *asMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, } client := Client(d.meta) - asMap, err := client.GetASMap(ctx, data.Name.ValueString(), data.Domain.ValueString()) + asMap, err := client.GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: data.Name.ValueString(), + DomainName: data.Domain.ValueString(), + }) if err != nil { resp.Diagnostics.AddError("fetching GTM ASMap failed: ", err.Error()) return @@ -157,7 +160,7 @@ func (d *asMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, } -func (m *asMapDataSourceModel) setAttributes(asMap *gtm.ASMap) { +func (m *asMapDataSourceModel) setAttributes(asMap *gtm.GetASMapResponse) { m.Name = types.StringValue(asMap.Name) m.DefaultDatacenter = newDefaultDatacenter(*asMap.DefaultDatacenter) m.setAssignments(asMap.Assignments) @@ -165,7 +168,7 @@ func (m *asMapDataSourceModel) setAttributes(asMap *gtm.ASMap) { m.ID = types.StringValue("gtm_asmap") } -func (m *asMapDataSourceModel) setAssignments(assignments []*gtm.ASAssignment) { +func (m *asMapDataSourceModel) setAssignments(assignments []gtm.ASAssignment) { toBaseTypesInt64Slice := func(n []int64) []basetypes.Int64Value { out := make([]basetypes.Int64Value, 0, len(n)) for _, number := range n { diff --git a/pkg/providers/gtm/data_akamai_gtm_asmap_test.go b/pkg/providers/gtm/data_akamai_gtm_asmap_test.go index 41f22fb4e..02c47656f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_asmap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_asmap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -21,13 +21,16 @@ func TestDataGTMASMap(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetASMap", mock.Anything, "map1", "test.domain.net").Return(>m.ASMap{ + m.On("GetASMap", mock.Anything, gtm.GetASMapRequest{ + ASMapName: "map1", + DomainName: "test.domain.net", + }).Return(>m.GetASMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestDefaultDatacenterNickname", DatacenterID: 1, }, - Assignments: []*gtm.ASAssignment{{ + Assignments: []gtm.ASAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestAssignmentNickname", DatacenterID: 1, @@ -38,7 +41,7 @@ func TestDataGTMASMap(t *testing.T) { 3, }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Href: "href.test", Rel: "TestRel", }}, @@ -71,7 +74,10 @@ func TestDataGTMASMap(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetASMap", mock.Anything, "map1", "test.domain.net").Return( + m.On("GetASMap", mock.Anything, gtm.GetASMapRequest{ + ASMapName: "map1", + DomainName: "test.domain.net", + }).Return( nil, fmt.Errorf("test error")) }, expectError: regexp.MustCompile("test error"), @@ -79,17 +85,21 @@ func TestDataGTMASMap(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetASMap", mock.Anything, "map1", "test.domain.net").Return(>m.ASMap{ + m.On("GetASMap", mock.Anything, gtm.GetASMapRequest{ + ASMapName: "map1", + DomainName: "test.domain.net", + }).Return(>m.GetASMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestDefaultDatacenterNickname", DatacenterID: 1, }, - Assignments: []*gtm.ASAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.ASAssignment{}, + Links: []gtm.Link{{ Href: "href.test", Rel: "TestRel", - }}, + }, + }, }, nil) }, diff --git a/pkg/providers/gtm/data_akamai_gtm_cidrmap.go b/pkg/providers/gtm/data_akamai_gtm_cidrmap.go index ed504b0d0..db8ecf393 100644 --- a/pkg/providers/gtm/data_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/data_akamai_gtm_cidrmap.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -139,7 +139,10 @@ func (d *cidrMapDataSource) Read(ctx context.Context, req datasource.ReadRequest } client := Client(d.meta) - cidrMap, err := client.GetCIDRMap(ctx, data.Name.ValueString(), data.Domain.ValueString()) + cidrMap, err := client.GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: data.Domain.ValueString(), + MapName: data.Name.ValueString(), + }) if err != nil { resp.Diagnostics.AddError("fetching GTM CIDRmap failed: ", err.Error()) return @@ -154,7 +157,7 @@ func (d *cidrMapDataSource) Read(ctx context.Context, req datasource.ReadRequest resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (m *cidrMapDataSourceModel) setAttributes(ctx context.Context, cidrMap *gtm.CIDRMap) diag.Diagnostics { +func (m *cidrMapDataSourceModel) setAttributes(ctx context.Context, cidrMap *gtm.GetCIDRMapResponse) diag.Diagnostics { m.Name = types.StringValue(cidrMap.Name) m.DefaultDatacenter = newDefaultDatacenter(*cidrMap.DefaultDatacenter) m.Links = getLinks(cidrMap.Links) @@ -167,7 +170,7 @@ func (m *cidrMapDataSourceModel) setAttributes(ctx context.Context, cidrMap *gtm return nil } -func (m *cidrMapDataSourceModel) setAssignments(ctx context.Context, assignments []*gtm.CIDRAssignment) diag.Diagnostics { +func (m *cidrMapDataSourceModel) setAssignments(ctx context.Context, assignments []gtm.CIDRAssignment) diag.Diagnostics { for _, a := range assignments { blocks, diags := types.SetValueFrom(ctx, types.StringType, a.Blocks) if diags.HasError() { diff --git a/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go index 3b2f3faa8..3953feb03 100644 --- a/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -21,13 +21,16 @@ func TestDataGTMCIDRmap(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetCIDRMap", mock.Anything, "mapTest", "test.cidrmap.domain.net").Return(>m.CIDRMap{ + m.On("GetCIDRMap", mock.Anything, gtm.GetCIDRMapRequest{ + MapName: "mapTest", + DomainName: "test.cidrmap.domain.net", + }).Return(>m.GetCIDRMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.CIDRAssignment{{ + Assignments: []gtm.CIDRAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments", DatacenterID: 1, @@ -37,7 +40,7 @@ func TestDataGTMCIDRmap(t *testing.T) { "test2", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, @@ -69,7 +72,10 @@ func TestDataGTMCIDRmap(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetCIDRMap", mock.Anything, "mapTest", "test.cidrmap.domain.net").Return( + m.On("GetCIDRMap", mock.Anything, gtm.GetCIDRMapRequest{ + MapName: "mapTest", + DomainName: "test.cidrmap.domain.net", + }).Return( nil, fmt.Errorf("error")) }, expectError: regexp.MustCompile("error"), @@ -77,14 +83,17 @@ func TestDataGTMCIDRmap(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetCIDRMap", mock.Anything, "mapTest", "test.cidrmap.domain.net").Return(>m.CIDRMap{ + m.On("GetCIDRMap", mock.Anything, gtm.GetCIDRMapRequest{ + MapName: "mapTest", + DomainName: "test.cidrmap.domain.net", + }).Return(>m.GetCIDRMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.CIDRAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.CIDRAssignment{}, + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_datacenter.go index 553e29103..acbbdcb8f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -159,7 +159,10 @@ func dataGTMDatacenterRead(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("could not get 'datacenter_id' attribute: %s", err) } - dc, err := client.GetDatacenter(ctx, dcID, domain) + dc, err := client.GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { return diag.Errorf("could not get datacenter: %s", err) } diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go index 1b9c84eb5..8692ea6a8 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -42,7 +42,10 @@ func TestDataGTMDatacenter(t *testing.T) { }, "error - GetDatacenter fail": { init: func(_ *testing.T, m *gtm.Mock, data testDataForGTMDatacenter) { - m.On("GetDatacenter", mock.Anything, data.datacenterID, data.domain).Return( + m.On("GetDatacenter", mock.Anything, gtm.GetDatacenterRequest{ + DatacenterID: data.datacenterID, + DomainName: data.domain, + }).Return( nil, fmt.Errorf("GetDatacenter error")).Once() }, mockData: testGTMDatacenter, @@ -138,7 +141,7 @@ type testDataForGTMDatacenter struct { serverMonitorPool string cloudServerTargeting bool cloudServerHostHeaderOverride bool - links []*gtm.Link + links []gtm.Link } var ( @@ -162,7 +165,10 @@ var ( StateOrProvince: data.stateOrProvince, Virtual: data.virtual, } - client.On("GetDatacenter", mock.Anything, data.datacenterID, data.domain).Return(&dc, nil).Times(timesToRun) + client.On("GetDatacenter", mock.Anything, gtm.GetDatacenterRequest{ + DatacenterID: data.datacenterID, + DomainName: data.domain, + }).Return(&dc, nil).Times(timesToRun) } testGTMDatacenter = testDataForGTMDatacenter{ @@ -186,7 +192,7 @@ var ( serverMonitorPool: "serverMonitorPool", cloudServerTargeting: true, cloudServerHostHeaderOverride: true, - links: []*gtm.Link{ + links: []gtm.Link{ { Rel: "rel1", Href: "href1", diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters.go b/pkg/providers/gtm/data_akamai_gtm_datacenters.go index fe767d684..0e3c32b86 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters.go @@ -3,7 +3,8 @@ package gtm import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -161,14 +162,14 @@ func dataGTMDatacentersRead(ctx context.Context, d *schema.ResourceData, m inter return diag.FromErr(err) } - datacenters, err := client.ListDatacenters(ctx, domain) + datacenters, err := client.ListDatacenters(ctx, gtm.ListDatacentersRequest{DomainName: domain}) if err != nil { return diag.FromErr(err) } datacentersAttrs := make([]interface{}, len(datacenters)) for i, dc := range datacenters { - dcAttrs := getDatacenterAttributes(dc) + dcAttrs := getDatacenterAttributes(&dc) dcAttrs["datacenter_id"] = dc.DatacenterID datacentersAttrs[i] = dcAttrs } diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go index 6092b5147..5e00e9fdc 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -42,7 +42,9 @@ func TestDataGTMDatacenters(t *testing.T) { }, "error - ListDatacenters fail": { init: func(t *testing.T, m *gtm.Mock, data testDataForGTMDatacenters) { - m.On("ListDatacenters", mock.Anything, data.domain).Return( + m.On("ListDatacenters", mock.Anything, gtm.ListDatacentersRequest{ + DomainName: data.domain, + }).Return( nil, fmt.Errorf("ListDatacenters error")).Once() }, mockData: testGTMDatacenters, @@ -148,10 +150,10 @@ var ( // mockListDatacenters mocks ListDatacenters call with provided data mockListDatacenters = func(t *testing.T, client *gtm.Mock, data testDataForGTMDatacenters, timesToRun int) { - var dcs []*gtm.Datacenter + var dcs []gtm.Datacenter for _, data := range data.datacenters { - dc := >m.Datacenter{ + dc := gtm.Datacenter{ City: data.city, CloneOf: data.cloneOf, CloudServerHostHeaderOverride: data.cloudServerHostHeaderOverride, @@ -172,6 +174,8 @@ var ( dcs = append(dcs, dc) } - client.On("ListDatacenters", mock.Anything, data.domain).Return(dcs, nil).Times(timesToRun) + client.On("ListDatacenters", mock.Anything, gtm.ListDatacentersRequest{ + DomainName: data.domain, + }).Return(dcs, nil).Times(timesToRun) } ) diff --git a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go index ee983598e..98967b6a0 100644 --- a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go @@ -4,9 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go b/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go index 423fe225a..574d4a70e 100644 --- a/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go @@ -3,7 +3,7 @@ package gtm import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_domain.go b/pkg/providers/gtm/data_akamai_gtm_domain.go index bc7c67b4b..77cf71b96 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domain.go +++ b/pkg/providers/gtm/data_akamai_gtm_domain.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -1208,7 +1208,9 @@ func (d *domainDataSource) Read(ctx context.Context, request datasource.ReadRequ } client := Client(d.meta) - domain, err := client.GetDomain(ctx, data.Name.ValueString()) + domain, err := client.GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: data.Name.ValueString(), + }) if err != nil { response.Diagnostics.AddError("fetching domain failed", err.Error()) return @@ -1222,7 +1224,7 @@ func (d *domainDataSource) Read(ctx context.Context, request datasource.ReadRequ response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func populateDomain(ctx context.Context, domain *gtm.Domain) (*domainDataSourceModel, diag.Diagnostics) { +func populateDomain(ctx context.Context, domain *gtm.GetDomainResponse) (*domainDataSourceModel, diag.Diagnostics) { emailNotificationList, diags := types.ListValueFrom(ctx, types.StringType, domain.EmailNotificationList) if diags.HasError() { return nil, diags @@ -1290,7 +1292,7 @@ func populateDomain(ctx context.Context, domain *gtm.Domain) (*domainDataSourceM return domainModel, nil } -func getLinks(links []*gtm.Link) []link { +func getLinks(links []gtm.Link) []link { var result []link if links != nil { result = make([]link, len(links)) @@ -1304,7 +1306,7 @@ func getLinks(links []*gtm.Link) []link { return result } -func getASMaps(maps []*gtm.ASMap) []asMap { +func getASMaps(maps []gtm.ASMap) []asMap { var result []asMap for _, am := range maps { asMapInstance := asMap{ @@ -1321,7 +1323,7 @@ func getASMaps(maps []*gtm.ASMap) []asMap { if am.Assignments != nil { asMapInstance.Assignments = make([]asMapAssignment, len(am.Assignments)) for i, asg := range am.Assignments { - asMapInstance.Assignments[i] = populateASMapAssignment(asg) + asMapInstance.Assignments[i] = populateASMapAssignment(&asg) } } result = append(result, asMapInstance) @@ -1329,7 +1331,7 @@ func getASMaps(maps []*gtm.ASMap) []asMap { return result } -func getCIDRMaps(ctx context.Context, maps []*gtm.CIDRMap) ([]cidrMap, diag.Diagnostics) { +func getCIDRMaps(ctx context.Context, maps []gtm.CIDRMap) ([]cidrMap, diag.Diagnostics) { var result []cidrMap for _, cm := range maps { cidrMapInstance := cidrMap{ @@ -1347,7 +1349,7 @@ func getCIDRMaps(ctx context.Context, maps []*gtm.CIDRMap) ([]cidrMap, diag.Diag if cm.Assignments != nil { cidrMapInstance.Assignments = make([]cidrMapAssignment, len(cm.Assignments)) for i, asg := range cm.Assignments { - popCIDRMapAssignment, diags := populateCIDRMapAssignment(ctx, asg) + popCIDRMapAssignment, diags := populateCIDRMapAssignment(ctx, &asg) if diags.HasError() { return nil, diags } @@ -1359,7 +1361,7 @@ func getCIDRMaps(ctx context.Context, maps []*gtm.CIDRMap) ([]cidrMap, diag.Diag return result, nil } -func getGeographicMaps(ctx context.Context, maps []*gtm.GeoMap) ([]geographicMap, diag.Diagnostics) { +func getGeographicMaps(ctx context.Context, maps []gtm.GeoMap) ([]geographicMap, diag.Diagnostics) { var result []geographicMap for _, gm := range maps { geoMapInstance := geographicMap{ @@ -1377,7 +1379,7 @@ func getGeographicMaps(ctx context.Context, maps []*gtm.GeoMap) ([]geographicMap if gm.Assignments != nil { geoMapInstance.Assignments = make([]geographicMapAssignment, len(gm.Assignments)) for i, asg := range gm.Assignments { - popGeoMap, diags := populateGeographicMapAssignment(ctx, asg) + popGeoMap, diags := populateGeographicMapAssignment(ctx, &asg) if diags.HasError() { return nil, diags } @@ -1389,7 +1391,7 @@ func getGeographicMaps(ctx context.Context, maps []*gtm.GeoMap) ([]geographicMap return result, nil } -func getDatacenters(ctx context.Context, datacenters []*gtm.Datacenter) ([]datacenter, diag.Diagnostics) { +func getDatacenters(ctx context.Context, datacenters []gtm.Datacenter) ([]datacenter, diag.Diagnostics) { var result []datacenter for _, dc := range datacenters { dataCenterInstance := datacenter{ @@ -1426,7 +1428,7 @@ func getDatacenters(ctx context.Context, datacenters []*gtm.Datacenter) ([]datac return result, nil } -func getProperties(ctx context.Context, properties []*gtm.Property) ([]property, diag.Diagnostics) { +func getProperties(ctx context.Context, properties []gtm.Property) ([]property, diag.Diagnostics) { var result []property for _, prop := range properties { propertyInstance := property{ @@ -1516,8 +1518,8 @@ func getStatus(st *gtm.ResponseStatus) *status { PassingValidation: types.BoolValue(st.PassingValidation), } if st.Links != nil { - statusInstance.Links = make([]link, len(*st.Links)) - for i, l := range *st.Links { + statusInstance.Links = make([]link, len(st.Links)) + for i, l := range st.Links { statusInstance.Links[i] = link{ Rel: types.StringValue(l.Rel), Href: types.StringValue(l.Href), @@ -1527,7 +1529,7 @@ func getStatus(st *gtm.ResponseStatus) *status { return &statusInstance } -func getResources(resources []*gtm.Resource) []domainResource { +func getResources(resources []gtm.Resource) []domainResource { var result []domainResource for _, res := range resources { resource := domainResource{ @@ -1574,7 +1576,7 @@ func getResources(resources []*gtm.Resource) []domainResource { return result } -func populateLivenessTest(lt *gtm.LivenessTest) (livenessTest, diag.Diagnostics) { +func populateLivenessTest(lt gtm.LivenessTest) (livenessTest, diag.Diagnostics) { altCACerts, diags := types.ListValueFrom(context.TODO(), types.StringType, lt.AlternateCACertificates) if diags.HasError() { return livenessTest{}, diags @@ -1616,7 +1618,7 @@ func populateLivenessTest(lt *gtm.LivenessTest) (livenessTest, diag.Diagnostics) return ltModel, diags } -func populateHTTPHeaders(headers []*gtm.HTTPHeader) []httpHeader { +func populateHTTPHeaders(headers []gtm.HTTPHeader) []httpHeader { result := make([]httpHeader, len(headers)) for i, h := range headers { result[i] = httpHeader{ @@ -1627,7 +1629,7 @@ func populateHTTPHeaders(headers []*gtm.HTTPHeader) []httpHeader { return result } -func populateStaticRRSet(ctx context.Context, s *gtm.StaticRRSet) (staticRRSet, diag.Diagnostics) { +func populateStaticRRSet(ctx context.Context, s gtm.StaticRRSet) (staticRRSet, diag.Diagnostics) { Rdata, diags := types.ListValueFrom(ctx, types.StringType, s.Rdata) if diags.HasError() { return staticRRSet{}, diags @@ -1639,7 +1641,7 @@ func populateStaticRRSet(ctx context.Context, s *gtm.StaticRRSet) (staticRRSet, }, diags } -func populateLinks(links []*gtm.Link) []link { +func populateLinks(links []gtm.Link) []link { result := make([]link, len(links)) for i, l := range links { result[i] = link{ @@ -1650,7 +1652,7 @@ func populateLinks(links []*gtm.Link) []link { return result } -func populateTrafficTarget(ctx context.Context, t *gtm.TrafficTarget) (trafficTarget, diag.Diagnostics) { +func populateTrafficTarget(ctx context.Context, t gtm.TrafficTarget) (trafficTarget, diag.Diagnostics) { servers, diags := types.ListValueFrom(ctx, types.StringType, t.Servers) if diags.HasError() { return trafficTarget{}, diags diff --git a/pkg/providers/gtm/data_akamai_gtm_domain_test.go b/pkg/providers/gtm/data_akamai_gtm_domain_test.go index 07688d3b8..1f2cc82bb 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domain_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_domain_test.go @@ -5,9 +5,8 @@ import ( "regexp" "testing" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -24,7 +23,9 @@ func TestDataGtmDomain(t *testing.T) { "success - response is ok": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetDomain", mock.Anything, "test.cli.devexp-terraform.akadns.net").Return(>m.Domain{ + m.On("GetDomain", mock.Anything, gtm.GetDomainRequest{ + DomainName: "test.cli.devexp-terraform.akadns.net", + }).Return(>m.GetDomainResponse{ Name: "test.cli.devexp-terraform.akadns.net", CNameCoalescingEnabled: false, DefaultErrorPenalty: 75, @@ -47,7 +48,7 @@ func TestDataGtmDomain(t *testing.T) { PropagationStatus: "DENIED", PropagationStatusDate: "2023-01-25T10:21:00.000+00:00", }, - Resources: []*gtm.Resource{{ + Resources: []gtm.Resource{{ AggregationType: "latest", Description: "terraform test resource", Type: "XML load object via HTTP", @@ -55,12 +56,12 @@ func TestDataGtmDomain(t *testing.T) { UpperBound: 100, }, }, - ASMaps: []*gtm.ASMap{{ + ASMaps: []gtm.ASMap{{ DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 3133, Nickname: "Default (all others)", }, - Assignments: []*gtm.ASAssignment{{ + Assignments: []gtm.ASAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "New Zone 1", DatacenterID: 3133, @@ -72,18 +73,18 @@ func TestDataGtmDomain(t *testing.T) { }, }}, Name: "New Map 1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/as-maps/DevExpAutomatedTest_6Qil38", }}, }, }, - CIDRMaps: []*gtm.CIDRMap{{ + CIDRMaps: []gtm.CIDRMap{{ DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 3133, Nickname: "All Other CIDR Blocks", }, - Assignments: []*gtm.CIDRAssignment{{ + Assignments: []gtm.CIDRAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "New Zone 1", DatacenterID: 3133, @@ -93,18 +94,18 @@ func TestDataGtmDomain(t *testing.T) { }, }}, Name: "New Map 1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/cidr-maps/New%20Map%201", }}, }, }, - GeographicMaps: []*gtm.GeoMap{{ + GeographicMaps: []gtm.GeoMap{{ DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 3131, Nickname: "terraform_datacenter_test", }, - Assignments: []*gtm.GeoAssignment{{ + Assignments: []gtm.GeoAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "terraform_datacenter_test_1", DatacenterID: 3133, @@ -114,31 +115,31 @@ func TestDataGtmDomain(t *testing.T) { }, }}, Name: "tfexample_geo_2", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/geographic-maps/tfexample_geo_2", }}, }, }, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "properties", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/properties", }, { Rel: "resources", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/resources"}, }, - Properties: []*gtm.Property{{ + Properties: []gtm.Property{{ BalanceByDownloadScore: false, DynamicTTL: 60, GhostDemandReporting: false, HandoutMode: "Normal", LastModified: "2023-01-25T09:58:09.000+00:00", Name: "property", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/properties/property", Rel: "self", }}, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { AnswersRequired: false, DisableNonstandardPortWarning: false, @@ -156,7 +157,7 @@ func TestDataGtmDomain(t *testing.T) { TestObjectProtocol: "HTTP", }, }, - TrafficTargets: []*gtm.TrafficTarget{{ + TrafficTargets: []gtm.TrafficTarget{{ DatacenterID: 3131, Enabled: true, Servers: []string{ @@ -257,7 +258,9 @@ func TestDataGtmDomain(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetDomain", mock.Anything, "test.cli.devexp-terraform.akadns.net").Return(nil, fmt.Errorf("oops")) + m.On("GetDomain", mock.Anything, gtm.GetDomainRequest{ + DomainName: "test.cli.devexp-terraform.akadns.net", + }).Return(nil, fmt.Errorf("oops")) }, expectError: regexp.MustCompile("oops"), }, diff --git a/pkg/providers/gtm/data_akamai_gtm_domains.go b/pkg/providers/gtm/data_akamai_gtm_domains.go index 1da3f6c08..769b8a231 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domains.go +++ b/pkg/providers/gtm/data_akamai_gtm_domains.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -175,7 +175,7 @@ func (d *domainsDataSource) Read(ctx context.Context, request datasource.ReadReq response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func getDomains(domainList []*gtm.DomainItem) []domain { +func getDomains(domainList []gtm.DomainItem) []domain { var result []domain for _, dom := range domainList { domain := domain{ diff --git a/pkg/providers/gtm/data_akamai_gtm_domains_test.go b/pkg/providers/gtm/data_akamai_gtm_domains_test.go index 483f20a12..0bb43808d 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domains_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_domains_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -22,7 +22,7 @@ func TestDataGTMDomains(t *testing.T) { "success - response is ok": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListDomains", mock.Anything).Return([]*gtm.DomainItem{ + m.On("ListDomains", mock.Anything).Return([]gtm.DomainItem{ { Name: "test1.terraformtesting.net", LastModified: "2023-02-01T09:36:28.000+00:00", @@ -33,7 +33,7 @@ func TestDataGTMDomains(t *testing.T) { SignAndServe: false, Status: "2023-02-01 09:47 GMT: Current configuration has been propagated to all GTM nameservers", AcgID: "TestACGID-1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test-domain.net/config-gtm/v1/domains/test1.terraformtesting.net", }, @@ -49,7 +49,7 @@ func TestDataGTMDomains(t *testing.T) { SignAndServe: false, Status: "2023-12-21 08:37 GMT: Current configuration has been propagated to all GTM nameservers", AcgID: "TestACGID-1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test-domain.net/config-gtm/v1/domains/test2.terraformtesting.net", }, @@ -65,7 +65,7 @@ func TestDataGTMDomains(t *testing.T) { SignAndServe: false, Status: "2023-12-22 08:46 GMT: Current configuration has been propagated to all GTM nameservers", AcgID: "TestACGID-1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test-domain.net/config-gtm/v1/domains/test3.terraformtesting.net", }, @@ -85,7 +85,7 @@ func TestDataGTMDomains(t *testing.T) { "no domains found": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListDomains", mock.Anything).Return([]*gtm.DomainItem{}, nil) + m.On("ListDomains", mock.Anything).Return([]gtm.DomainItem{}, nil) }, }, "error response from api": { diff --git a/pkg/providers/gtm/data_akamai_gtm_geomap.go b/pkg/providers/gtm/data_akamai_gtm_geomap.go index 4a3d709e1..4d7661d99 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomap.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -138,7 +138,9 @@ func (d *geoMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, } client := Client(d.meta) - geoMap, err := client.GetGeoMap(ctx, data.Name.ValueString(), data.Domain.ValueString()) + geoMap, err := client.GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: data.Name.ValueString(), + DomainName: data.Domain.ValueString()}) if err != nil { resp.Diagnostics.AddError("fetching GTM Geographic map failed: ", err.Error()) return @@ -153,7 +155,7 @@ func (d *geoMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (m *geoMapDataSourceModel) setAttributes(ctx context.Context, geoMap *gtm.GeoMap) diag.Diagnostics { +func (m *geoMapDataSourceModel) setAttributes(ctx context.Context, geoMap *gtm.GetGeoMapResponse) diag.Diagnostics { m.Name = types.StringValue(geoMap.Name) m.DefaultDatacenter = newDefaultDatacenter(*geoMap.DefaultDatacenter) m.Links = getLinks(geoMap.Links) @@ -166,7 +168,7 @@ func (m *geoMapDataSourceModel) setAttributes(ctx context.Context, geoMap *gtm.G return nil } -func (m *geoMapDataSourceModel) setAssignments(ctx context.Context, assignments []*gtm.GeoAssignment) diag.Diagnostics { +func (m *geoMapDataSourceModel) setAssignments(ctx context.Context, assignments []gtm.GeoAssignment) diag.Diagnostics { for _, a := range assignments { countries, diags := types.SetValueFrom(ctx, types.StringType, a.Countries) if diags.HasError() { diff --git a/pkg/providers/gtm/data_akamai_gtm_geomap_test.go b/pkg/providers/gtm/data_akamai_gtm_geomap_test.go index 8040ba238..c98813682 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomap_test.go @@ -5,13 +5,18 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" ) func TestDataGTMGeoMap(t *testing.T) { + getGeoMapRequest := gtm.GetGeoMapRequest{ + MapName: "mapTest", + DomainName: "test.geomap.domain.net"} + anyContext := mock.AnythingOfType("*context.valueCtx") + tests := map[string]struct { givenTF string init func(mock *gtm.Mock) @@ -21,14 +26,14 @@ func TestDataGTMGeoMap(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetGeoMap", mock.AnythingOfType("*context.valueCtx"), "mapTest", "test.geomap.domain.net").Return( - >m.GeoMap{ + m.On("GetGeoMap", anyContext, getGeoMapRequest).Return( + >m.GetGeoMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{{ + Assignments: []gtm.GeoAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments", DatacenterID: 2, @@ -38,7 +43,7 @@ func TestDataGTMGeoMap(t *testing.T) { "US", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, @@ -70,7 +75,7 @@ func TestDataGTMGeoMap(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetGeoMap", mock.AnythingOfType("*context.valueCtx"), "mapTest", "test.geomap.domain.net").Return( + m.On("GetGeoMap", anyContext, getGeoMapRequest).Return( nil, fmt.Errorf("API error")) }, expectError: regexp.MustCompile("API error"), @@ -78,15 +83,15 @@ func TestDataGTMGeoMap(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetGeoMap", mock.AnythingOfType("*context.valueCtx"), "mapTest", "test.geomap.domain.net").Return( - >m.GeoMap{ + m.On("GetGeoMap", anyContext, getGeoMapRequest).Return( + >m.GetGeoMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.GeoAssignment{}, + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, diff --git a/pkg/providers/gtm/data_akamai_gtm_geomaps.go b/pkg/providers/gtm/data_akamai_gtm_geomaps.go index 0dd04067a..92f150057 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomaps.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomaps.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -141,7 +142,8 @@ func (d *geoMapsDataSource) Read(ctx context.Context, req datasource.ReadRequest } client := Client(d.meta) - geoMaps, err := client.ListGeoMaps(ctx, data.Domain.ValueString()) + geoMaps, err := client.ListGeoMaps(ctx, gtm.ListGeoMapsRequest{ + DomainName: data.Domain.ValueString()}) if err != nil { resp.Diagnostics.AddError("fetching GTM Geographic maps failed: ", err.Error()) return diff --git a/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go b/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go index 2f6f36e83..172f194bd 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go @@ -5,13 +5,17 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" ) func TestDataGTMGeoMaps(t *testing.T) { + listGeoMapsRequest := gtm.ListGeoMapsRequest{ + DomainName: "test.geomaps.domain.net"} + anyContext := mock.AnythingOfType("*context.valueCtx") + tests := map[string]struct { givenTF string init func(mock *gtm.Mock) @@ -21,15 +25,15 @@ func TestDataGTMGeoMaps(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListGeoMaps", mock.AnythingOfType("*context.valueCtx"), "test.geomaps.domain.net").Return( - []*gtm.GeoMap{ + m.On("ListGeoMaps", anyContext, listGeoMapsRequest).Return( + []gtm.GeoMap{ { Name: "TestName1", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname1", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{{ + Assignments: []gtm.GeoAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments1", DatacenterID: 2, @@ -39,7 +43,7 @@ func TestDataGTMGeoMaps(t *testing.T) { "US", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel1", Href: "TestHref1", }}, @@ -50,7 +54,7 @@ func TestDataGTMGeoMaps(t *testing.T) { Nickname: "TestNickname2", DatacenterID: 3, }, - Assignments: []*gtm.GeoAssignment{ + Assignments: []gtm.GeoAssignment{ { DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments2", @@ -71,7 +75,7 @@ func TestDataGTMGeoMaps(t *testing.T) { "IT", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel2", Href: "TestHref2", }}, @@ -113,7 +117,7 @@ func TestDataGTMGeoMaps(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListGeoMaps", mock.AnythingOfType("*context.valueCtx"), "test.geomaps.domain.net").Return( + m.On("ListGeoMaps", anyContext, listGeoMapsRequest).Return( nil, fmt.Errorf("API error")) }, expectError: regexp.MustCompile("API error"), @@ -121,15 +125,15 @@ func TestDataGTMGeoMaps(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListGeoMaps", mock.AnythingOfType("*context.valueCtx"), "test.geomaps.domain.net").Return( - []*gtm.GeoMap{{ + m.On("ListGeoMaps", anyContext, listGeoMapsRequest).Return( + []gtm.GeoMap{{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.GeoAssignment{}, + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, diff --git a/pkg/providers/gtm/data_akamai_gtm_resource.go b/pkg/providers/gtm/data_akamai_gtm_resource.go index 1c4bf2d3b..859325fd8 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resource.go +++ b/pkg/providers/gtm/data_akamai_gtm_resource.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -195,7 +195,10 @@ func (d *resourceDataSource) Read(ctx context.Context, request datasource.ReadRe } client := Client(d.meta) - resource, err := client.GetResource(ctx, data.ResourceName.ValueString(), data.Domain.ValueString()) + resource, err := client.GetResource(ctx, gtm.GetResourceRequest{ + DomainName: data.Domain.ValueString(), + ResourceName: data.ResourceName.ValueString(), + }) if err != nil { response.Diagnostics.AddError("fetching GTM resource failed:", err.Error()) return @@ -206,7 +209,7 @@ func (d *resourceDataSource) Read(ctx context.Context, request datasource.ReadRe response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func (m *resourceDataSourceModel) setAttributes(resource *gtm.Resource) { +func (m *resourceDataSourceModel) setAttributes(resource *gtm.GetResourceResponse) { m.AggregationType = types.StringValue(resource.AggregationType) m.ConstrainedProperty = types.StringValue(resource.ConstrainedProperty) @@ -224,7 +227,7 @@ func (m *resourceDataSourceModel) setAttributes(resource *gtm.Resource) { m.ID = types.StringValue(resource.Name) } -func (m *resourceDataSourceModel) setResourceInstances(resourceInstances []*gtm.ResourceInstance) { +func (m *resourceDataSourceModel) setResourceInstances(resourceInstances []gtm.ResourceInstance) { for _, res := range resourceInstances { resourceInstanceObject := resourceInstance{ diff --git a/pkg/providers/gtm/data_akamai_gtm_resource_test.go b/pkg/providers/gtm/data_akamai_gtm_resource_test.go index 04a22adad..569ffff4f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resource_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_resource_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -22,7 +22,10 @@ func TestDataGTMResource(t *testing.T) { "happy path - GTM data resource should be returned": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetResource", mock.Anything, "resource1", "test.domain.net").Return(>m.Resource{ + m.On("GetResource", mock.Anything, gtm.GetResourceRequest{ + ResourceName: "resource1", + DomainName: "test.domain.net", + }).Return(>m.GetResourceResponse{ Type: "XML load object via HTTP", LeastSquaresDecay: 0, Description: "terraform test resource", @@ -32,13 +35,13 @@ func TestDataGTMResource(t *testing.T) { Name: "property", MaxUMultiplicativeIncrement: 0, DecayRate: 0, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/" + "test.cli.domain.net/resources/resource1", }, }, - ResourceInstances: []*gtm.ResourceInstance{{ + ResourceInstances: []gtm.ResourceInstance{{ DatacenterID: 3131, UseDefaultLoadObject: false, LoadObject: gtm.LoadObject{ @@ -71,7 +74,10 @@ func TestDataGTMResource(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetResource", mock.Anything, "resource1", "test.domain.net").Return( + m.On("GetResource", mock.Anything, gtm.GetResourceRequest{ + ResourceName: "resource1", + DomainName: "test.domain.net", + }).Return( nil, fmt.Errorf("oops")) }, expectError: regexp.MustCompile("oops"), diff --git a/pkg/providers/gtm/data_akamai_gtm_resources.go b/pkg/providers/gtm/data_akamai_gtm_resources.go index 7199dfc1c..b7287adcd 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resources.go +++ b/pkg/providers/gtm/data_akamai_gtm_resources.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -147,7 +148,9 @@ func (d *resourcesDataSource) Read(ctx context.Context, request datasource.ReadR } client := Client(d.meta) - resources, err := client.ListResources(ctx, data.Domain.ValueString()) + resources, err := client.ListResources(ctx, gtm.ListResourcesRequest{ + DomainName: data.Domain.ValueString(), + }) if err != nil { response.Diagnostics.AddError("fetching GTM resources failed:", err.Error()) return diff --git a/pkg/providers/gtm/data_akamai_gtm_resources_test.go b/pkg/providers/gtm/data_akamai_gtm_resources_test.go index 5e24c8a16..92d10cc13 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resources_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_resources_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -22,7 +22,10 @@ func TestDataGTMResources(t *testing.T) { "happy path - GTM data resources should be returned": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListResources", mock.Anything, "test.domain.net").Return([]*gtm.Resource{ + m.On("ListResources", mock.Anything, + gtm.ListResourcesRequest{ + DomainName: "test.domain.net", + }).Return([]gtm.Resource{ { Type: "XML load object via HTTP", LeastSquaresDecay: 0, @@ -33,13 +36,13 @@ func TestDataGTMResources(t *testing.T) { Name: "property1", MaxUMultiplicativeIncrement: 0, DecayRate: 0, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test.domain1.net/config-gtm/v1/domains/" + "test.cli.domain.net/resources/resource1", }, }, - ResourceInstances: []*gtm.ResourceInstance{{ + ResourceInstances: []gtm.ResourceInstance{{ DatacenterID: 3131, UseDefaultLoadObject: false, LoadObject: gtm.LoadObject{ @@ -60,13 +63,13 @@ func TestDataGTMResources(t *testing.T) { Name: "property2", MaxUMultiplicativeIncrement: 0, DecayRate: 0, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self1", Href: "https://test.domain1.net/config-gtm/v1/domains/" + "test.cli.domain.net/resources/resource2", }, }, - ResourceInstances: []*gtm.ResourceInstance{{ + ResourceInstances: []gtm.ResourceInstance{{ DatacenterID: 3132, UseDefaultLoadObject: false, LoadObject: gtm.LoadObject{ @@ -95,7 +98,9 @@ func TestDataGTMResources(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListResources", mock.Anything, "test.domain.net").Return( + m.On("ListResources", mock.Anything, gtm.ListResourcesRequest{ + DomainName: "test.domain.net", + }).Return( nil, fmt.Errorf("oops")) }, expectError: regexp.MustCompile("oops"), diff --git a/pkg/providers/gtm/provider.go b/pkg/providers/gtm/provider.go index c4fa5bba0..704cfddb1 100644 --- a/pkg/providers/gtm/provider.go +++ b/pkg/providers/gtm/provider.go @@ -2,7 +2,7 @@ package gtm import ( - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/gtm/provider_test.go b/pkg/providers/gtm/provider_test.go index 31d3b3921..edb946c4b 100644 --- a/pkg/providers/gtm/provider_test.go +++ b/pkg/providers/gtm/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap.go b/pkg/providers/gtm/resource_akamai_gtm_asmap.go index 347fbc97c..9610639f6 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap.go @@ -6,8 +6,8 @@ import ( "net/http" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -102,7 +102,10 @@ func validateDefaultDC(ctx context.Context, meta meta.Meta, ddcField []interface if !ok || dcID == 0 { return fmt.Errorf("default Datacenter ID invalid") } - dc, err := Client(meta).GetDatacenter(ctx, dcID, domain) + dc, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DomainName: domain, + DatacenterID: dcID, + }) if dc == nil { if err != nil { apiError, ok := err.(*gtm.Error) @@ -170,7 +173,10 @@ func resourceGTMv1ASMapCreate(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("Proposed New asMap: [%v]", newAS) - cStatus, err := Client(meta).CreateASMap(ctx, newAS, domain) + cStatus, err := Client(meta).CreateASMap(ctx, gtm.CreateASMapRequest{ + ASMap: newAS, + DomainName: domain, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -231,7 +237,10 @@ func resourceGTMv1ASMapRead(ctx context.Context, d *schema.ResourceData, m inter if err != nil { return diag.FromErr(err) } - as, err := Client(meta).GetASMap(ctx, asMap, domain) + as, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("asMap Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -263,7 +272,10 @@ func resourceGTMv1ASMapUpdate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } // Get existingASmap - existAs, err := Client(meta).GetASMap(ctx, asMap, domain) + existAs, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("asMap Update read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -273,9 +285,13 @@ func resourceGTMv1ASMapUpdate(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("asMap BEFORE: %v", existAs) - populateASMapObject(d, existAs, m) + newAs := createASMapStruct(existAs) + populateASMapObject(d, newAs, m) logger.Debugf("asMap PROPOSED: %v", existAs) - uStat, err := Client(meta).UpdateASMap(ctx, existAs, domain) + uStat, err := Client(meta).UpdateASMap(ctx, gtm.UpdateASMapRequest{ + ASMap: newAs, + DomainName: domain, + }) if err != nil { logger.Errorf("asMap pdate: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -285,10 +301,10 @@ func resourceGTMv1ASMapUpdate(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("asMap Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -332,7 +348,10 @@ func resourceGTMv1ASMapImport(ctx context.Context, d *schema.ResourceData, m int if err != nil { return []*schema.ResourceData{d}, err } - as, err := Client(meta).GetASMap(ctx, asMap, domain) + as, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { return nil, err } @@ -366,7 +385,10 @@ func resourceGTMv1ASMapDelete(ctx context.Context, d *schema.ResourceData, m int logger.Errorf("[ERROR] ASMap Delete: %s", err.Error()) return diag.FromErr(err) } - existAs, err := Client(meta).GetASMap(ctx, asMap, domain) + existAs, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("ASMap Delete: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -375,8 +397,12 @@ func resourceGTMv1ASMapDelete(ctx context.Context, d *schema.ResourceData, m int Detail: err.Error(), }) } - logger.Debugf("Deleting ASmap: %v", existAs) - uStat, err := Client(meta).DeleteASMap(ctx, existAs, domain) + newAs := createASMapStruct(existAs) + logger.Debugf("Deleting ASmap: %v", newAs) + uStat, err := Client(meta).DeleteASMap(ctx, gtm.DeleteASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("ASMap Delete: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -386,10 +412,10 @@ func resourceGTMv1ASMapDelete(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("asMap Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -429,8 +455,7 @@ func populateNewASMapObject(d *schema.ResourceData, m interface{}) (*gtm.ASMap, asObj := >m.ASMap{ Name: asMapName, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]*gtm.ASAssignment, 1), - Links: make([]*gtm.Link, 1), + Assignments: make([]gtm.ASAssignment, 1), } populateASMapObject(d, asObj, m) @@ -448,7 +473,7 @@ func populateASMapObject(d *schema.ResourceData, as *gtm.ASMap, m interface{}) { } // Populate Terraform state from provided ASMap object -func populateTerraformASMapState(d *schema.ResourceData, as *gtm.ASMap, m interface{}) { +func populateTerraformASMapState(d *schema.ResourceData, as *gtm.GetASMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASMapState") @@ -469,7 +494,7 @@ func populateASAssignmentsObject(d *schema.ResourceData, as *gtm.ASMap, m interf if asAssignmentsList, err := tf.GetListValue("assignment", d); err != nil { logger.Errorf("Assignment not set: %s", err.Error()) } else { - asAssignmentsObjList := make([]*gtm.ASAssignment, len(asAssignmentsList)) // create new object list + asAssignmentsObjList := make([]gtm.ASAssignment, len(asAssignmentsList)) // create new object list for i, v := range asAssignmentsList { asMap := v.(map[string]interface{}) asAssignment := gtm.ASAssignment{} @@ -486,14 +511,14 @@ func populateASAssignmentsObject(d *schema.ResourceData, as *gtm.ASMap, m interf } asAssignment.ASNumbers = ls } - asAssignmentsObjList[i] = &asAssignment + asAssignmentsObjList[i] = asAssignment } as.Assignments = asAssignmentsObjList } } // create and populate Terraform asMap assignments schema -func populateTerraformASAssignmentsState(d *schema.ResourceData, asm *gtm.ASMap, m interface{}) { +func populateTerraformASAssignmentsState(d *schema.ResourceData, asm *gtm.GetASMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASAssignmentsState") @@ -539,7 +564,7 @@ func populateASDefaultDCObject(d *schema.ResourceData, as *gtm.ASMap, m interfac } // create and populate Terraform asMap default_datacenter schema -func populateTerraformASDefaultDCState(d *schema.ResourceData, as *gtm.ASMap, m interface{}) { +func populateTerraformASDefaultDCState(d *schema.ResourceData, as *gtm.GetASMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASDefaultDCState") @@ -664,6 +689,19 @@ func asNumbersEqual(old, new interface{}) bool { return true } +// createASMapStruct converts response from GetASMapResponse into ASMap +func createASMapStruct(asmap *gtm.GetASMapResponse) *gtm.ASMap { + if asmap != nil { + return >m.ASMap{ + DefaultDatacenter: asmap.DefaultDatacenter, + Assignments: asmap.Assignments, + Name: asmap.Name, + Links: asmap.Links, + } + } + return nil +} + // resolveAttrName resolves specific assignment attribute, based on a resource func resolveAttrName(list []interface{}) (string, error) { if len(list) == 0 { diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go index 0a0f45a7c..27b27060b 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -20,49 +20,52 @@ func TestResGTMASMap(t *testing.T) { getCall := client.On("GetASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetASMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.ASMapResponse{} - resp.Resource = &asmap - resp.Status = &pendingResponseStatus + resp := asmap client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(>m.ASMapResponse{ - Resource: &asmap, - Status: >m.ResponseStatus{}, + mock.AnythingOfType("gtm.CreateASMapRequest"), + ).Return(>m.CreateASMapResponse{ + Resource: asMapCreate.Resource, + Status: asMapCreate.Status, }, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{resp.Resource, nil} + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetASMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetASMapRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.UpdateASMapRequest"), + ).Return(updateASMapResponseStatus, nil) + + client.On("GetASMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetASMapRequest"), + ).Return(&asMapUpdate, nil).Times(3) client.On("DeleteASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteASMapRequest"), + ).Return(deleteASMapResponseStatus, nil) dataSourceName := "akamai_gtm_asmap.tfexample_as_1" @@ -96,16 +99,14 @@ func TestResGTMASMap(t *testing.T) { client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateASMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -126,21 +127,17 @@ func TestResGTMASMap(t *testing.T) { t.Run("create asmap denied", func(t *testing.T) { client := >m.Mock{} - asmap, dc := getASMapTestData() - - dr := gtm.ASMapResponse{} - dr.Resource = &asmap + dr := gtm.CreateASMapResponse{} + dr.Resource = asMapCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateASMapRequest"), ).Return(&dr, nil) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -165,35 +162,31 @@ func TestResGTMASMap(t *testing.T) { client.On("GetDatacenter", mock.Anything, - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("CreateASMap", mock.Anything, - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(>m.ASMapResponse{ - Resource: &asmap, - Status: >m.ResponseStatus{}, + mock.AnythingOfType("gtm.CreateASMapRequest"), + ).Return(>m.CreateASMapResponse{ + Resource: asMapCreate.Resource, + Status: asMapCreate.Status, }, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("GetASMap", mock.Anything, - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetASMapRequest"), ).Return(&asmap, nil) client.On("DeleteASMap", mock.Anything, - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteASMapRequest"), + ).Return(deleteASMapResponseStatus, nil) dataSourceName := "akamai_gtm_asmap.tfexample_as_1" @@ -320,60 +313,161 @@ func TestGTMASMapOrder(t *testing.T) { // getASMapMocks mocks creation and deletion of a resource func getASMapMocks() *gtm.Mock { - asmap, dc := getASMapTestData() - client := >m.Mock{} mockGetAsMap := client.On("GetASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetASMapRequest"), ).Return(nil, >m.Error{StatusCode: http.StatusNotFound}) - resp := gtm.ASMapResponse{} - resp.Resource = &asMapDiffOrder - resp.Status = &pendingResponseStatus + resp := asMapDiffOrder client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(>m.ASMapResponse{ - Resource: &asmap, - Status: >m.ResponseStatus{}, + mock.AnythingOfType("gtm.CreateASMapRequest"), + ).Return(>m.CreateASMapResponse{ + Resource: asMapCreate.Resource, + Status: asMapCreate.Status, }, nil).Run(func(args mock.Arguments) { - mockGetAsMap.ReturnArguments = mock.Arguments{resp.Resource, nil} + mockGetAsMap.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), + mock.AnythingOfType("gtm.DeleteASMapRequest"), mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + ).Return(deleteASMapResponseStatus, nil) return client } var ( + updateASMapResponseStatus = >m.UpdateASMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + deleteASMapResponseStatus = >m.DeleteASMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + getDomainStatusResponseStatus = >m.GetDomainStatusResponse{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + } + + asMapCreate = gtm.CreateASMapResponse{ + Resource: >m.ASMap{ + Name: "tfexample_as_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.ASAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + ASNumbers: []int64{12222, 16702, 17334}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + ASNumbers: []int64{12229, 16703, 17335}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + asMapUpdate = gtm.GetASMapResponse{ + Name: "tfexample_as_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.ASAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + ASNumbers: []int64{12223, 16701, 17333}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3133, + Nickname: "tfexample_dc_3", + }, + ASNumbers: []int64{12228, 16704, 17336}, + }, + }, + } + // asMapDiffOrder represents AsMap structure with values used in tests of the order of assignments and as_numbers - asMapDiffOrder = gtm.ASMap{ + asMapDiffOrder = gtm.GetASMapResponse{ Name: "tfexample_as_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.ASAssignment{ + Assignments: []gtm.ASAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -399,14 +493,14 @@ var ( } ) -func getASMapTestData() (gtm.ASMap, gtm.Datacenter) { - asmap := gtm.ASMap{ +func getASMapTestData() (gtm.GetASMapResponse, gtm.Datacenter) { + asmap := gtm.GetASMapResponse{ Name: "tfexample_as_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.ASAssignment{ + Assignments: []gtm.ASAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go index d4c868905..39af4f338 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go @@ -4,11 +4,10 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -117,7 +116,10 @@ func resourceGTMv1CIDRMapCreate(ctx context.Context, d *schema.ResourceData, m i newCidr := populateNewCIDRMapObject(meta, d, m) logger.Debugf("Proposed New CidrMap: [%v]", newCidr) - cStatus, err := Client(meta).CreateCIDRMap(ctx, newCidr, domain) + cStatus, err := Client(meta).CreateCIDRMap(ctx, gtm.CreateCIDRMapRequest{ + CIDR: newCidr, + DomainName: domain, + }) if err != nil { logger.Errorf("cidrMap Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -180,7 +182,10 @@ func resourceGTMv1CIDRMapRead(ctx context.Context, d *schema.ResourceData, m int logger.Errorf("Invalid cidrMap ID: %s", d.Id()) return diag.FromErr(err) } - cidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + cidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { logger.Errorf("cidrMap Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -212,7 +217,10 @@ func resourceGTMv1CIDRMapUpdate(ctx context.Context, d *schema.ResourceData, m i return diag.FromErr(err) } // Get existingCidrMap - existCidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + existCidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { logger.Errorf("cidrMap Update read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -221,10 +229,14 @@ func resourceGTMv1CIDRMapUpdate(ctx context.Context, d *schema.ResourceData, m i Detail: err.Error(), }) } - logger.Debugf("Updating cidrMap BEFORE: %v", existCidr) - populateCIDRMapObject(d, existCidr, m) + newCidr := createCIDRMapStruct(existCidr) + logger.Debugf("Updating cidrMap BEFORE: %v", newCidr) + populateCIDRMapObject(d, newCidr, m) logger.Debugf("Updating cidrMap PROPOSED: %v", existCidr) - uStat, err := Client(meta).UpdateCIDRMap(ctx, existCidr, domain) + uStat, err := Client(meta).UpdateCIDRMap(ctx, gtm.UpdateCIDRMapRequest{ + CIDR: newCidr, + DomainName: domain, + }) if err != nil { logger.Errorf("cidrMap Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -234,10 +246,10 @@ func resourceGTMv1CIDRMapUpdate(ctx context.Context, d *schema.ResourceData, m i }) } logger.Debugf("CidrMap Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -281,7 +293,10 @@ func resourceGTMv1CIDRMapImport(d *schema.ResourceData, m interface{}) ([]*schem if err != nil { return []*schema.ResourceData{d}, err } - cidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + cidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { return nil, err } @@ -315,7 +330,10 @@ func resourceGTMv1CIDRMapDelete(ctx context.Context, d *schema.ResourceData, m i logger.Errorf("Invalid cidrMap ID: %s", d.Id()) return diag.FromErr(err) } - existCidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + existCidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { logger.Errorf("CidrMapDelete cidrMap doesn't exist: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -324,8 +342,12 @@ func resourceGTMv1CIDRMapDelete(ctx context.Context, d *schema.ResourceData, m i Detail: err.Error(), }) } - logger.Debugf("Deleting cidrMap: %v", existCidr) - uStat, err := Client(meta).DeleteCIDRMap(ctx, existCidr, domain) + newCidr := createCIDRMapStruct(existCidr) + logger.Debugf("Deleting cidrMap: %v", newCidr) + uStat, err := Client(meta).DeleteCIDRMap(ctx, gtm.DeleteCIDRMapRequest{ + MapName: cidrMap, + DomainName: domain, + }) if err != nil { logger.Errorf("cidrMap Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -335,10 +357,10 @@ func resourceGTMv1CIDRMapDelete(ctx context.Context, d *schema.ResourceData, m i }) } logger.Debugf("cidrMap Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -380,8 +402,6 @@ func populateNewCIDRMapObject(meta meta.Meta, d *schema.ResourceData, m interfac cidrObj := >m.CIDRMap{ Name: cidrMapName, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]*gtm.CIDRAssignment, 0), - Links: make([]*gtm.Link, 1), } populateCIDRMapObject(d, cidrObj, m) @@ -398,7 +418,7 @@ func populateCIDRMapObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m interfac } // Populate Terraform state from provided CIDRMap object -func populateTerraformCIDRMapState(d *schema.ResourceData, cidr *gtm.CIDRMap, m interface{}) { +func populateTerraformCIDRMapState(d *schema.ResourceData, cidr *gtm.GetCIDRMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrMapState") @@ -418,7 +438,7 @@ func populateCIDRAssignmentsObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m // pull apart List if cassgns := d.Get("assignment"); cassgns != nil { cidrAssignmentsList := cassgns.([]interface{}) - cidrAssignmentsObjList := make([]*gtm.CIDRAssignment, len(cidrAssignmentsList)) // create new object list + cidrAssignmentsObjList := make([]gtm.CIDRAssignment, len(cidrAssignmentsList)) // create new object list for i, v := range cidrAssignmentsList { cidrMap := v.(map[string]interface{}) cidrAssignment := gtm.CIDRAssignment{} @@ -435,18 +455,18 @@ func populateCIDRAssignmentsObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m } cidrAssignment.Blocks = ls } - cidrAssignmentsObjList[i] = &cidrAssignment + cidrAssignmentsObjList[i] = cidrAssignment } cidr.Assignments = cidrAssignmentsObjList } } // create and populate Terraform cidrMap assignments schema -func populateTerraformCIDRAssignmentsState(d *schema.ResourceData, cidr *gtm.CIDRMap, m interface{}) { +func populateTerraformCIDRAssignmentsState(d *schema.ResourceData, cidr *gtm.GetCIDRMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrAssignmentsState") - objectInventory := make(map[int]*gtm.CIDRAssignment, len(cidr.Assignments)) + objectInventory := make(map[int]gtm.CIDRAssignment, len(cidr.Assignments)) if len(cidr.Assignments) > 0 { for _, aObj := range cidr.Assignments { objectInventory[aObj.DatacenterID] = aObj @@ -460,7 +480,7 @@ func populateTerraformCIDRAssignmentsState(d *schema.ResourceData, cidr *gtm.CID a := aMap.(map[string]interface{}) objIndex := a["datacenter_id"].(int) aObject := objectInventory[objIndex] - if aObject == nil { + if &aObject == nil { logger.Warnf("Cidr Assignment %d NOT FOUND in returned GTM Object", a["datacenter_id"]) continue } @@ -514,7 +534,7 @@ func populateCIDRDefaultDCObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m in } // create and populate Terraform cidrMap default_datacenter schema -func populateTerraformCIDRDefaultDCState(d *schema.ResourceData, cidr *gtm.CIDRMap, m interface{}) { +func populateTerraformCIDRDefaultDCState(d *schema.ResourceData, cidr *gtm.GetCIDRMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCIDRDefaultDCState") @@ -529,6 +549,19 @@ func populateTerraformCIDRDefaultDCState(d *schema.ResourceData, cidr *gtm.CIDRM } } +// createCIDRMapStruct converts response from GetCIDRMapResponse into CIDRMap +func createCIDRMapStruct(cidr *gtm.GetCIDRMapResponse) *gtm.CIDRMap { + if cidr != nil { + return >m.CIDRMap{ + DefaultDatacenter: cidr.DefaultDatacenter, + Assignments: cidr.Assignments, + Name: cidr.Name, + Links: cidr.Links, + } + } + return nil +} + // blocksEqual checks whether blocks are equal func blocksEqual(old, new interface{}) bool { logger := logger.Get("Akamai GTM", "blocksEqual") diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go index 5f6600176..8ed53f841 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -19,45 +19,51 @@ func TestResGTMCIDRMap(t *testing.T) { getCall := client.On("GetCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetCIDRMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.CIDRMapResponse{} - resp.Resource = &cidr - resp.Status = &pendingResponseStatus + resp := cidr client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{resp.Resource, nil} + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), + ).Return(>m.CreateCIDRMapResponse{ + Resource: cidrCreate.Resource, + Status: cidrCreate.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetCIDRMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetCIDRMapRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.UpdateCIDRMapRequest"), + ).Return(updateCIDRMapResponseStatus, nil) + + client.On("GetCIDRMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetCIDRMapRequest"), + ).Return(&cidrUpdate, nil).Times(3) client.On("DeleteCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteCIDRMapRequest"), + ).Return(deleteCIDRMapResponseStatus, nil) dataSourceName := "akamai_gtm_cidrmap.tfexample_cidrmap_1" @@ -89,16 +95,14 @@ func TestResGTMCIDRMap(t *testing.T) { client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -119,19 +123,17 @@ func TestResGTMCIDRMap(t *testing.T) { t.Run("create cidrmap denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.CIDRMapResponse{} - dr.Resource = &cidr + dr := gtm.CreateCIDRMapResponse{} + dr.Resource = cidrCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), ).Return(&dr, nil) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -252,52 +254,49 @@ func getCIDRMapMocks() *gtm.Mock { mockGetCIDRMap := client.On("GetCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetCIDRMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.CIDRMapResponse{} - resp.Resource = &cidrMapDiffOrder - resp.Status = &pendingResponseStatus + resp := cidrMapDiffOrder client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - mockGetCIDRMap.ReturnArguments = mock.Arguments{resp.Resource, nil} + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), + ).Return(>m.CreateCIDRMapResponse{ + Resource: cidrCreate.Resource, + Status: cidrCreate.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetCIDRMap.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteCIDRMapRequest"), + ).Return(deleteCIDRMapResponseStatus, nil) return client } var ( // cidrMapDiffOrder is a gtm.CidrMap structure used in tests of order of assignments and block in gtm_cidrmap resource - cidrMapDiffOrder = gtm.CIDRMap{ + cidrMapDiffOrder = gtm.GetCIDRMapResponse{ Name: "tfexample_cidrmap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.CIDRAssignment{ + Assignments: []gtm.CIDRAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -322,13 +321,45 @@ var ( }, } - cidr = gtm.CIDRMap{ + cidrCreate = gtm.CreateCIDRMapResponse{ + Resource: >m.CIDRMap{ + Name: "tfexample_cidrmap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.CIDRAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + Blocks: []string{"1.2.3.9/24"}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + cidr = gtm.GetCIDRMapResponse{ Name: "tfexample_cidrmap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.CIDRAssignment{ + Assignments: []gtm.CIDRAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -338,4 +369,53 @@ var ( }, }, } + + cidrUpdate = gtm.GetCIDRMapResponse{ + Name: "tfexample_cidrmap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.CIDRAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + Blocks: []string{"1.2.3.9/16"}, + }, + }, + } + + updateCIDRMapResponseStatus = >m.UpdateCIDRMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deleteCIDRMapResponseStatus = >m.DeleteCIDRMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go index df415cbfc..5096cb6d9 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go @@ -8,9 +8,8 @@ import ( "strings" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -188,7 +187,10 @@ func resourceGTMv1DatacenterCreate(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } logger.Debugf("Proposed New Datacenter: [%v]", newDC) - cStatus, err := Client(meta).CreateDatacenter(ctx, newDC, domain) + cStatus, err := Client(meta).CreateDatacenter(ctx, gtm.CreateDatacenterRequest{ + DomainName: domain, + Datacenter: newDC, + }) if err != nil { logger.Errorf("Datacenter Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -259,7 +261,10 @@ func resourceGTMv1DatacenterRead(ctx context.Context, d *schema.ResourceData, m Detail: err.Error(), }) } - dc, err := Client(meta).GetDatacenter(ctx, dcID, domain) + dc, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -296,7 +301,10 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, }) } // Get existing datacenter - existDC, err := Client(meta).GetDatacenter(ctx, dcID, domain) + existDC, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -310,7 +318,10 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } logger.Debugf("Updating Datacenter PROPOSED: %v", existDC) - uStat, err := Client(meta).UpdateDatacenter(ctx, existDC, domain) + uStat, err := Client(meta).UpdateDatacenter(ctx, gtm.UpdateDatacenterRequest{ + Datacenter: existDC, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -320,8 +331,8 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, }) } logger.Debugf("Datacenter Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) } @@ -363,7 +374,10 @@ func resourceGTMv1DatacenterImport(d *schema.ResourceData, m interface{}) ([]*sc if err != nil { return nil, fmt.Errorf("Invalid Datacenter resource ID") } - dc, err := Client(meta).GetDatacenter(ctx, dcID, domain) + dc, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Import error: %s", err.Error()) return nil, err @@ -402,7 +416,10 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, }) } // Get existing datacenter - existDC, err := Client(meta).GetDatacenter(ctx, dcID, domain) + existDC, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("DatacenterDelete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -412,7 +429,10 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, }) } logger.Debugf("Deleting Datacenter: %v", existDC) - uStat, err := Client(meta).DeleteDatacenter(ctx, existDC, domain) + uStat, err := Client(meta).DeleteDatacenter(ctx, gtm.DeleteDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -422,11 +442,11 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, }) } logger.Debugf("Datacenter Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go index c1f0b32f1..a9ae175cb 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -20,10 +20,10 @@ var dc = gtm.Datacenter{ DefaultLoadObject: >m.LoadObject{ LoadObject: "/test", LoadObjectPort: 80, - LoadServers: make([]string, 0), + LoadServers: []string{"1.2.3.4", "1.2.3.9"}, }, Latitude: 64.808, - Links: []*gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/datacenters/3132", Rel: "self", @@ -42,41 +42,36 @@ func TestResGTMDatacenter(t *testing.T) { getCall := client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.DatacenterResponse{} - resp.Resource = &dc - resp.Status = &pendingResponseStatus + resp := dc client.On("CreateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Datacenter), nil} + mock.AnythingOfType("gtm.CreateDatacenterRequest"), + ).Return(>m.CreateDatacenterResponse{ + Resource: &dc, + Status: &pendingResponseStatus, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Datacenter), nil} - }) + mock.AnythingOfType("gtm.UpdateDatacenterRequest"), + ).Return(updateDatacenterResponseStatus, nil) client.On("DeleteDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDatacenterRequest"), + ).Return(deleteDatacenterResponseStatus, nil) dataSourceName := "akamai_gtm_datacenter.tfexample_dc_1" @@ -110,8 +105,7 @@ func TestResGTMDatacenter(t *testing.T) { client.On("CreateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateDatacenterRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -134,13 +128,12 @@ func TestResGTMDatacenter(t *testing.T) { t.Run("create datacenter denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.DatacenterResponse{} + dr := gtm.CreateDatacenterResponse{} dr.Resource = &dc dr.Status = &deniedResponseStatus client.On("CreateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateDatacenterRequest"), ).Return(&dr, nil) useClient(client, func() { @@ -158,3 +151,37 @@ func TestResGTMDatacenter(t *testing.T) { client.AssertExpectations(t) }) } + +var ( + updateDatacenterResponseStatus = >m.UpdateDatacenterResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deleteDatacenterResponseStatus = >m.DeleteDatacenterResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } +) diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain.go b/pkg/providers/gtm/resource_akamai_gtm_domain.go index 881442e1c..935ffcf33 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -192,16 +192,16 @@ func resourceGTMv1Domain() *schema.Resource { } // GetQueryArgs retrieves optional query args. contractId, groupId [and accountSwitchKey] supported. -func GetQueryArgs(d *schema.ResourceData) (map[string]string, error) { +func GetQueryArgs(d *schema.ResourceData) (*gtm.DomainQueryArgs, error) { - qArgs := make(map[string]string) + qArgs := gtm.DomainQueryArgs{} contractName, err := tf.GetStringValue("contract", d) if err != nil { return nil, fmt.Errorf("contract not present in resource data: %v", err.Error()) } contract := strings.TrimPrefix(contractName, "ctr_") if contract != "" && len(contract) > 0 { - qArgs["contractId"] = contract + qArgs.ContractID = contract } groupName, err := tf.GetStringValue("group", d) if err != nil { @@ -209,10 +209,10 @@ func GetQueryArgs(d *schema.ResourceData) (map[string]string, error) { } groupID := strings.TrimPrefix(groupName, "grp_") if groupID != "" && len(groupID) > 0 { - qArgs["gid"] = groupID + qArgs.GroupID = groupID } - return qArgs, nil + return &qArgs, nil } // Create a new GTM Domain @@ -246,7 +246,10 @@ func resourceGTMv1DomainCreate(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - cStatus, err := Client(meta).CreateDomain(ctx, newDom, queryArgs) + cStatus, err := Client(meta).CreateDomain(ctx, gtm.CreateDomainRequest{ + Domain: newDom, + QueryArgs: queryArgs, + }) if err != nil { // Errored. Let's see if special hack if !HashiAcc { @@ -330,7 +333,9 @@ func resourceGTMv1DomainRead(ctx context.Context, d *schema.ResourceData, m inte logger.Debugf("Reading Domain: %s", d.Id()) var diags diag.Diagnostics // retrieve the domain - dom, err := Client(meta).GetDomain(ctx, d.Id()) + dom, err := Client(meta).GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: d.Id(), + }) if err != nil { logger.Errorf("Domain Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -357,7 +362,9 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in logger.Debugf("Updating Domain: %s", d.Id()) var diags diag.Diagnostics // Get existing domain - existDom, err := Client(meta).GetDomain(ctx, d.Id()) + existDom, err := Client(meta).GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: d.Id(), + }) if err != nil { logger.Errorf("Domain Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -367,11 +374,12 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("Updating Domain BEFORE: %v", existDom) - err = populateDomainObject(d, existDom, m) + newDom := createDomainStruct(existDom) + err = populateDomainObject(d, newDom, m) if err != nil { return diag.FromErr(err) } - logger.Debugf("Updating Domain PROPOSED: %v", existDom) + logger.Debugf("Updating Domain PROPOSED: %v", newDom) //existDom := populateNewDomainObject(d) args, err := GetQueryArgs(d) if err != nil { @@ -382,7 +390,11 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - uStat, err := Client(meta).UpdateDomain(ctx, existDom, args) + + uStat, err := Client(meta).UpdateDomain(ctx, gtm.UpdateDomainRequest{ + Domain: newDom, + QueryArgs: args, + }) if err != nil { logger.Errorf("Domain Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -392,11 +404,11 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -441,7 +453,9 @@ func resourceGTMv1DomainDelete(ctx context.Context, d *schema.ResourceData, m in logger.Debugf("Deleting GTM Domain: %s", d.Id()) var diags diag.Diagnostics // Get existing domain - existDom, err := Client(meta).GetDomain(ctx, d.Id()) + existDom, err := Client(meta).GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: d.Id(), + }) if err != nil { logger.Errorf("Domain Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -450,7 +464,10 @@ func resourceGTMv1DomainDelete(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - uStat, err := Client(meta).DeleteDomain(ctx, existDom) + logger.Debugf("Deleting Domain: %v", existDom) + uStat, err := Client(meta).DeleteDomain(ctx, gtm.DeleteDomainRequest{ + DomainName: d.Id(), + }) if err != nil { // Errored. Let's see if special hack if !HashiAcc { @@ -748,7 +765,7 @@ func populateDomainObject(d *schema.ResourceData, dom *gtm.Domain, m interface{} } // Populate Terraform state from provided Domain object -func populateTerraformState(d *schema.ResourceData, dom *gtm.Domain, m interface{}) { +func populateTerraformState(d *schema.ResourceData, dom *gtm.GetDomainResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformState") @@ -800,6 +817,58 @@ func populateTerraformState(d *schema.ResourceData, dom *gtm.Domain, m interface } } +// createDomainStruct converts response from GetDomainResponse into Domain +func createDomainStruct(domain *gtm.GetDomainResponse) *gtm.Domain { + if domain != nil { + return >m.Domain{ + Name: domain.Name, + Type: domain.Type, + ASMaps: domain.ASMaps, + Resources: domain.Resources, + DefaultUnreachableThreshold: domain.DefaultUnreachableThreshold, + EmailNotificationList: domain.EmailNotificationList, + MinPingableRegionFraction: domain.MinPingableRegionFraction, + DefaultTimeoutPenalty: domain.DefaultTimeoutPenalty, + Datacenters: domain.Datacenters, + ServermonitorLivenessCount: domain.ServermonitorLivenessCount, + RoundRobinPrefix: domain.RoundRobinPrefix, + ServermonitorLoadCount: domain.ServermonitorLoadCount, + PingInterval: domain.PingInterval, + MaxTTL: domain.MaxTTL, + LoadImbalancePercentage: domain.LoadImbalancePercentage, + DefaultHealthMax: domain.DefaultHealthMax, + LastModified: domain.LastModified, + Status: domain.Status, + MapUpdateInterval: domain.MapUpdateInterval, + MaxProperties: domain.MaxProperties, + MaxResources: domain.MaxResources, + DefaultSSLClientPrivateKey: domain.DefaultSSLClientPrivateKey, + DefaultErrorPenalty: domain.DefaultErrorPenalty, + Links: domain.Links, + Properties: domain.Properties, + MaxTestTimeout: domain.MaxTestTimeout, + CNameCoalescingEnabled: domain.CNameCoalescingEnabled, + DefaultHealthMultiplier: domain.DefaultHealthMultiplier, + ServermonitorPool: domain.ServermonitorPool, + LoadFeedback: domain.LoadFeedback, + MinTTL: domain.MinTTL, + GeographicMaps: domain.GeographicMaps, + CIDRMaps: domain.CIDRMaps, + DefaultMaxUnreachablePenalty: domain.DefaultMaxUnreachablePenalty, + DefaultHealthThreshold: domain.DefaultHealthThreshold, + LastModifiedBy: domain.LastModifiedBy, + ModificationComments: domain.ModificationComments, + MinTestInterval: domain.MinTestInterval, + PingPacketSize: domain.PingPacketSize, + DefaultSSLClientCertificate: domain.DefaultSSLClientCertificate, + EndUserMappingEnabled: domain.EndUserMappingEnabled, + SignAndServe: domain.SignAndServe, + SignAndServeAlgorithm: domain.SignAndServeAlgorithm, + } + } + return nil +} + // Util function to wait for change deployment. return true if complete. false if not - error or nil (timeout) func waitForCompletion(ctx context.Context, domain string, m interface{}) (bool, error) { meta := meta.Must(m) @@ -816,7 +885,9 @@ func waitForCompletion(ctx context.Context, domain string, m interface{}) (bool, logger.Debugf("WAIT: Sleep Interval [%v]", sleepInterval/time.Second) logger.Debugf("WAIT: Sleep Timeout [%v]", sleepTimeout/time.Second) for { - propStat, err := Client(meta).GetDomainStatus(ctx, domain) + propStat, err := Client(meta).GetDomainStatus(ctx, gtm.GetDomainStatusRequest{ + DomainName: domain, + }) if err != nil { return false, fmt.Errorf("GetDomainStatus error: %s", err.Error()) } diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go index 8a16a73a3..07c7a0631 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go @@ -5,9 +5,8 @@ import ( "regexp" "testing" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -20,39 +19,52 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - dr := gtm.DomainResponse{} - dr.Resource = &testDomain - dr.Status = &pendingResponseStatus + dr := testCreateDomain client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testCreateDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) + client.On("GetDomain", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetDomainRequest"), + ).Return(&testCreateDomain, nil).Times(3) + client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} - }) + gtm.UpdateDomainRequest{ + Domain: testUpdateDomain, + QueryArgs: >m.DomainQueryArgs{ + ContractID: "1-2ABCDEF", + GroupID: "123ABC", + }, + }, + ).Return(&updateDomainResponseStatus, nil) + + client.On("GetDomain", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetDomainRequest"), + ).Return(&testUpdateGetDomain, nil).Times(3) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -90,31 +102,31 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &testDomainWithSignAndServe - dr.Status = &pendingResponseStatus + dr := testDomainWithSignAndServe client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testGetDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -142,31 +154,31 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &testDomain - dr.Status = &pendingResponseStatus + dr := testGetDomain client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testGetDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -198,8 +210,7 @@ func TestResGTMDomain(t *testing.T) { client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), + mock.AnythingOfType("gtm.CreateDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -222,13 +233,12 @@ func TestResGTMDomain(t *testing.T) { t.Run("create domain denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.DomainResponse{} - dr.Resource = &testDomain + dr := gtm.CreateDomainResponse{} + dr.Resource = testDomain dr.Status = &deniedResponseStatus client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), + mock.AnythingOfType("gtm.CreateDomainRequest"), ).Return(&dr, nil) useClient(client, func() { @@ -251,31 +261,31 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &testDomain - dr.Status = &pendingResponseStatus + dr := testGetDomain client.On("CreateDomain", mock.Anything, - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testGetDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Times(2) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil).Times(2) client.On("DeleteDomain", mock.Anything, - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -360,38 +370,38 @@ func getGTMDomainMocks() *gtm.Mock { mockGetDomain := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &domainWithOrderedEmails - dr.Status = &pendingResponseStatus + dr := domainWithOrderedEmails client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - mockGetDomain.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: domainWithOrderedEmailsDomain, + Status: domainWithOrderedEmails.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetDomain.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) return client } var ( // datacenters is gtm.Datacenter structure used in tests - datacenters = []*gtm.Datacenter{ + datacenters = []gtm.Datacenter{ { City: "Snæfellsjökull", CloudServerTargeting: false, @@ -404,7 +414,7 @@ var ( LoadServers: make([]string, 0), }, Latitude: 64.808, - Links: []*gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/datacenters/3132", Rel: "self", @@ -418,7 +428,7 @@ var ( } // links is gtm.link structure used in tests - links = []*gtm.Link{ + links = []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net", Rel: "self", @@ -446,7 +456,7 @@ var ( } // properties is gtm.Property structure used in tests - properties = []*gtm.Property{ + properties = []gtm.Property{ { BackupCName: "", BackupIP: "", @@ -462,13 +472,13 @@ var ( HealthThreshold: 0, IPv6: false, LastModified: "2019-04-25T14:53:12.000+00:00", - Links: []*gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/properties/test_property", Rel: "self", }, }, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { DisableNonstandardPortWarning: false, HTTPError3xx: true, @@ -496,7 +506,7 @@ var ( StaticTTL: 600, StickinessBonusConstant: 0, StickinessBonusPercentage: 50, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -518,7 +528,7 @@ var ( // testStatus is gtm.ResponseStatus structure used in tests testStatus = >m.ResponseStatus{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", @@ -530,8 +540,27 @@ var ( PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", } + domainWithOrderedEmailsDomain = >m.Domain{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: []string{"email1@nomail.com", "email2@nomail.com", "email3@nomail.com"}, + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 10.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + // domainWithOrderedEmails is a gtm.Domain structure used in testing of email_notification_order list - domainWithOrderedEmails = gtm.Domain{ + domainWithOrderedEmails = gtm.GetDomainResponse{ Datacenters: datacenters, DefaultErrorPenalty: 75, DefaultSSLClientCertificate: "", @@ -550,7 +579,83 @@ var ( Type: "weighted", } - testDomain = gtm.Domain{ + testDomain = >m.Domain{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 10.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testUpdateGetDomain = gtm.GetDomainResponse{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 20.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testUpdateDomain = >m.Domain{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 20.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testGetDomain = gtm.GetDomainResponse{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 10.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testCreateDomain = gtm.GetDomainResponse{ Datacenters: datacenters, DefaultErrorPenalty: 75, DefaultSSLClientCertificate: "", @@ -569,7 +674,7 @@ var ( Type: "weighted", } - testDomainWithSignAndServe = gtm.Domain{ + testDomainWithSignAndServe = gtm.GetDomainResponse{ Datacenters: datacenters, DefaultErrorPenalty: 75, DefaultSSLClientCertificate: "", @@ -592,7 +697,7 @@ var ( deniedResponseStatus = gtm.ResponseStatus{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", @@ -606,7 +711,7 @@ var ( pendingResponseStatus = gtm.ResponseStatus{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", @@ -618,9 +723,25 @@ var ( PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", } - completeResponseStatus = gtm.ResponseStatus{ + updateDomainResponseStatus = gtm.UpdateDomainResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deleteDomainResponseStatus = gtm.DeleteDomainResponse{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap.go b/pkg/providers/gtm/resource_akamai_gtm_geomap.go index 0313252ca..dd3b8962d 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap.go @@ -5,11 +5,10 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -128,7 +127,10 @@ func resourceGTMv1GeoMapCreate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("Proposed New geoMap: [%v]", newGeo) - cStatus, err := Client(meta).CreateGeoMap(ctx, newGeo, domain) + cStatus, err := Client(meta).CreateGeoMap(ctx, gtm.CreateGeoMapRequest{ + GeoMap: newGeo, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -193,7 +195,10 @@ func resourceGTMv1GeoMapRead(ctx context.Context, d *schema.ResourceData, m inte logger.Errorf("Invalid geoMap ID") return diag.FromErr(err) } - geo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + geo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -231,7 +236,10 @@ func resourceGTMv1GeoMapUpdate(ctx context.Context, d *schema.ResourceData, m in return diag.FromErr(err) } // Get existingGeoMap - existGeo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + existGeo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -240,10 +248,14 @@ func resourceGTMv1GeoMapUpdate(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - logger.Debugf("Updating geoMap BEFORE: %v", existGeo) - populateGeoMapObject(d, existGeo, m) + newGeo := createGeoMapStruct(existGeo) + logger.Debugf("Updating geoMap BEFORE: %v", newGeo) + populateGeoMapObject(d, newGeo, m) logger.Debugf("Updating geoMap PROPOSED: %v", existGeo) - uStat, err := Client(meta).UpdateGeoMap(ctx, existGeo, domain) + uStat, err := Client(meta).UpdateGeoMap(ctx, gtm.UpdateGeoMapRequest{ + GeoMap: newGeo, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -253,11 +265,11 @@ func resourceGTMv1GeoMapUpdate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("geoMap Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -304,7 +316,10 @@ func resourceGTMv1GeoMapImport(d *schema.ResourceData, m interface{}) ([]*schema if err != nil { return []*schema.ResourceData{d}, err } - geo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + geo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { return nil, err } @@ -344,7 +359,10 @@ func resourceGTMv1GeoMapDelete(ctx context.Context, d *schema.ResourceData, m in logger.Errorf("Invalid geoMap ID: %s", d.Id()) return diag.FromErr(err) } - existGeo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + existGeo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -353,8 +371,12 @@ func resourceGTMv1GeoMapDelete(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - logger.Debugf("Deleting geoMap: %v", existGeo) - uStat, err := Client(meta).DeleteGeoMap(ctx, existGeo, domain) + newGeo := createGeoMapStruct(existGeo) + logger.Debugf("Deleting geoMap: %v", newGeo) + uStat, err := Client(meta).DeleteGeoMap(ctx, gtm.DeleteGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -364,11 +386,11 @@ func resourceGTMv1GeoMapDelete(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("geoMap Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -409,8 +431,6 @@ func populateNewGeoMapObject(d *schema.ResourceData, m interface{}) (*gtm.GeoMap geoObj := >m.GeoMap{ Name: name, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]*gtm.GeoAssignment, 1), - Links: make([]*gtm.Link, 1), } populateGeoMapObject(d, geoObj, m) @@ -427,7 +447,7 @@ func populateGeoMapObject(d *schema.ResourceData, geo *gtm.GeoMap, m interface{} } // Populate Terraform state from provided GeoMap object -func populateTerraformGeoMapState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) error { +func populateTerraformGeoMapState(d *schema.ResourceData, geo *gtm.GetGeoMapResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoMapState") @@ -449,7 +469,7 @@ func populateGeoAssignmentsObject(d *schema.ResourceData, geo *gtm.GeoMap, m int // pull apart List geoAssignmentsList, err := tf.GetListValue("assignment", d) if err == nil { - geoAssignmentsObjList := make([]*gtm.GeoAssignment, len(geoAssignmentsList)) // create new object list + geoAssignmentsObjList := make([]gtm.GeoAssignment, len(geoAssignmentsList)) // create new object list for i, v := range geoAssignmentsList { geoMap, ok := v.(map[string]interface{}) if !ok { @@ -470,18 +490,18 @@ func populateGeoAssignmentsObject(d *schema.ResourceData, geo *gtm.GeoMap, m int } geoAssignment.Countries = ls } - geoAssignmentsObjList[i] = &geoAssignment + geoAssignmentsObjList[i] = geoAssignment } geo.Assignments = geoAssignmentsObjList } } // create and populate Terraform geoMap assignments schema -func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) error { +func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GetGeoMapResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoAssignmentsState") - objectInventory := make(map[int]*gtm.GeoAssignment, len(geo.Assignments)) + objectInventory := make(map[int]gtm.GeoAssignment, len(geo.Assignments)) if len(geo.Assignments) > 0 { for _, aObj := range geo.Assignments { objectInventory[aObj.DatacenterID] = aObj @@ -495,7 +515,7 @@ func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GeoMa a := aMap.(map[string]interface{}) objIndex := a["datacenter_id"].(int) aObject := objectInventory[objIndex] - if aObject == nil { + if &aObject == nil { logger.Warnf("Geo Assignment %d NOT FOUND in returned GTM Object", a["datacenter_id"]) continue } @@ -552,7 +572,7 @@ func populateGeoDefaultDCObject(d *schema.ResourceData, geo *gtm.GeoMap, m inter } // create and populate Terraform geoMap default_datacenter schema -func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) error { +func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GetGeoMapResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoDefault") @@ -569,6 +589,19 @@ func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GeoMap, return nil } +// createGeoMapStruct converts response from GetGeoMapResponse into GeoMap +func createGeoMapStruct(geo *gtm.GetGeoMapResponse) *gtm.GeoMap { + if geo != nil { + return >m.GeoMap{ + DefaultDatacenter: geo.DefaultDatacenter, + Assignments: geo.Assignments, + Name: geo.Name, + Links: geo.Links, + } + } + return nil +} + // countriesEqual checks whether countries are equal func countriesEqual(old, new interface{}) bool { logger := logger.Get("Akamai GTM", "countriesEqual") diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go index f211c6bf0..a0e58e808 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -13,8 +13,8 @@ import ( func TestResGTMGeoMap(t *testing.T) { dc := gtm.Datacenter{ - DatacenterID: geo.DefaultDatacenter.DatacenterID, - Nickname: geo.DefaultDatacenter.Nickname, + DatacenterID: geomap.DefaultDatacenter.DatacenterID, + Nickname: geomap.DefaultDatacenter.Nickname, } t.Run("create geomap", func(t *testing.T) { @@ -22,47 +22,51 @@ func TestResGTMGeoMap(t *testing.T) { getCall := client.On("GetGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetGeoMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.GeoMapResponse{} - resp.Resource = &geo - resp.Status = &pendingResponseStatus + resp := geomap client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.GeoMap), nil} + mock.AnythingOfType("gtm.CreateGeoMapRequest"), + ).Return(>m.CreateGeoMapResponse{ + Resource: geoMapCreate.Resource, + Status: geoMapCreate.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetGeoMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetGeoMapRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.GeoMap), nil} - }) + mock.AnythingOfType("gtm.UpdateGeoMapRequest"), + ).Return(updateGeoMapResponseStatus, nil) + + client.On("GetGeoMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetGeoMapRequest"), + ).Return(&geomapUpdate, nil).Times(3) client.On("DeleteGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteGeoMapRequest"), + ).Return(deleteGeoMapResponseStatus, nil) dataSourceName := "akamai_gtm_geomap.tfexample_geomap_1" @@ -94,16 +98,14 @@ func TestResGTMGeoMap(t *testing.T) { client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateGeoMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -124,19 +126,17 @@ func TestResGTMGeoMap(t *testing.T) { t.Run("create geomap denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.GeoMapResponse{} - dr.Resource = &geo + dr := gtm.CreateGeoMapResponse{} + dr.Resource = geoMapCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateGeoMapRequest"), ).Return(&dr, nil) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -250,52 +250,49 @@ func getGeoMapMocks() *gtm.Mock { mockGetGeoMap := client.On("GetGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetGeoMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.GeoMapResponse{} - resp.Resource = &geoDiffOrder - resp.Status = &pendingResponseStatus + resp := geoDiffOrder client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - mockGetGeoMap.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.GeoMap), nil} + mock.AnythingOfType("gtm.CreateGeoMapRequest"), + ).Return(>m.CreateGeoMapResponse{ + Resource: geoMapCreateDiif.Resource, + Status: geoMapCreateDiif.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetGeoMap.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteGeoMapRequest"), + ).Return(deleteGeoMapResponseStatus, nil) return client } var ( // geoDiffOrder is gtm.GeoMap structure used in testing of the assignments order - geoDiffOrder = gtm.GeoMap{ + geoDiffOrder = gtm.GetGeoMapResponse{ Name: "tfexample_geomap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.GeoAssignment{ + Assignments: []gtm.GeoAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -320,13 +317,59 @@ var ( }, } - geo = gtm.GeoMap{ + geoMapCreateDiif = gtm.CreateGeoMapResponse{ + Resource: >m.GeoMap{ + Name: "tfexample_geomap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.GeoAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + Countries: []string{"GB", "PL", "US", "FR"}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + Countries: []string{"GB", "AU"}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3133, + Nickname: "tfexample_dc_3", + }, + Countries: []string{"GB", "BG", "CN", "MC", "TR"}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + geomap = gtm.GetGeoMapResponse{ Name: "tfexample_geomap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.GeoAssignment{ + Assignments: []gtm.GeoAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -336,4 +379,84 @@ var ( }, }, } + + geomapUpdate = gtm.GetGeoMapResponse{ + Name: "tfexample_geomap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.GeoAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + Countries: []string{"US"}, + }, + }, + } + + geoMapCreate = gtm.CreateGeoMapResponse{ + Resource: >m.GeoMap{ + Name: "tfexample_geomap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.GeoAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + Countries: []string{"GB"}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + updateGeoMapResponseStatus = >m.UpdateGeoMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + deleteGeoMapResponseStatus = >m.DeleteGeoMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 2d09c4fc0..97a05aca7 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -7,13 +7,15 @@ import ( "reflect" "sort" "strings" + "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/apex/log" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -539,7 +541,10 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } logger.Debugf("Proposed New Property: [%v]", newProp) - cStatus, err := Client(meta).CreateProperty(ctx, newProp, domain) + cStatus, err := createPropertyWithRetry(ctx, meta, logger, gtm.CreatePropertyRequest{ + Property: newProp, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Create failed: CreateProperty error: %s", err.Error()) return diag.Errorf("property Create failed: CreateProperty error: %s", err.Error()) @@ -578,6 +583,47 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m } +func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Interface, createPropertyRequest gtm.CreatePropertyRequest) (*gtm.CreatePropertyResponse, error) { + // Initial backoff interval + retryInterval := time.Second * 10 + // Maximum retry interval + maxRetryTimeout := time.Minute * 10 + + for { + // Attempt to create the property + cStatus, err := Client(meta).CreateProperty(ctx, createPropertyRequest) + if err == nil { + // Success, return the created property + return cStatus, nil + } + + logger.Errorf("Property Create failed: CreateProperty error: %s", err.Error()) + + // If the error is not "no datacenter is assigned to map target (all others)", return immediately + if !errors.Is(err, gtm.ErrNoDatacenterAssignedToMap) { + return nil, fmt.Errorf("property Create failed: error: %s", err) + } + + select { + case <-time.After(retryInterval): + // exponential backoff + retryInterval = 2 * retryInterval + if retryInterval > maxRetryTimeout { + retryInterval = maxRetryTimeout + } + logger.Debugf("Retrying property creation after %s", retryInterval) + case <-ctx.Done(): + // Handle context timeout or cancellation + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + return nil, fmt.Errorf("timeout waiting for property creation: last error: %s", err) + } + if errors.Is(ctx.Err(), context.Canceled) { + return nil, fmt.Errorf("operation canceled while creating property, last error: %s", err) + } + } + } +} + // Only ever save data from the tf config in the tf state file, to help with // api issues. See func unmarshalResourceData for more info. func resourceGTMv1PropertyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { @@ -595,7 +641,10 @@ func resourceGTMv1PropertyRead(ctx context.Context, d *schema.ResourceData, m in if err != nil { return diag.FromErr(err) } - prop, err := Client(meta).GetProperty(ctx, property, domain) + prop, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if errors.Is(err, gtm.ErrNotFound) { d.SetId("") return nil @@ -626,26 +675,33 @@ func resourceGTMv1PropertyUpdate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } // Get existing property - existProp, err := Client(meta).GetProperty(ctx, property, domain) + existProp, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Update failed: GetProperty error: %s", err.Error()) return diag.Errorf("property Update failed: GetProperty error: %s", err.Error()) } + newProp := createPropertyStruct(existProp) logger.Debugf("Updating Property BEFORE: %v", existProp) - err = populatePropertyObject(d, existProp, m) + err = populatePropertyObject(d, newProp, m) if err != nil { return diag.FromErr(err) } logger.Debugf("Updating Property PROPOSED: %v", existProp) - uStat, err := Client(meta).UpdateProperty(ctx, existProp, domain) + uStat, err := Client(meta).UpdateProperty(ctx, gtm.UpdatePropertyRequest{ + Property: newProp, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Update failed: UpdateProperty error: %s", err.Error()) return diag.Errorf("property Update failed: UpdateProperty error: %s", err.Error()) } logger.Debugf("Property Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Debugf(uStat.Message) - return diag.FromErr(fmt.Errorf(uStat.Message)) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Debugf(uStat.Status.Message) + return diag.FromErr(fmt.Errorf(uStat.Status.Message)) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -686,7 +742,10 @@ func resourceGTMv1PropertyImport(d *schema.ResourceData, m interface{}) ([]*sche if err != nil { return []*schema.ResourceData{d}, err } - prop, err := Client(meta).GetProperty(ctx, property, domain) + prop, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { return nil, fmt.Errorf("property Import failed: GetProperty error: %s", err.Error()) } @@ -719,21 +778,28 @@ func resourceGTMv1PropertyDelete(ctx context.Context, d *schema.ResourceData, m if err != nil { return diag.FromErr(err) } - existProp, err := Client(meta).GetProperty(ctx, property, domain) + existProp, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Delete failed: GetProperty error: %s", err.Error()) return diag.Errorf("property Delete failed: GetProperty error: %s", err.Error()) } - logger.Debugf("Deleting Property: %v", existProp) - uStat, err := Client(meta).DeleteProperty(ctx, existProp, domain) + newProp := createPropertyStruct(existProp) + logger.Debugf("Deleting Property: %v", newProp) + uStat, err := Client(meta).DeleteProperty(ctx, gtm.DeletePropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Delete failed: DeleteProperty error: %s", err.Error()) return diag.Errorf("property Delete failed: DeleteProperty error: %s", err.Error()) } logger.Debugf("Property Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) - return diag.FromErr(fmt.Errorf(uStat.Message)) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) + return diag.FromErr(fmt.Errorf(uStat.Status.Message)) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -977,8 +1043,8 @@ func populateNewPropertyObject(d *schema.ResourceData, m interface{}) (*gtm.Prop } propObj := >m.Property{ Name: name, - TrafficTargets: make([]*gtm.TrafficTarget, 0), - LivenessTests: make([]*gtm.LivenessTest, 0), + TrafficTargets: make([]gtm.TrafficTarget, 0), + LivenessTests: make([]gtm.LivenessTest, 0), } err = populatePropertyObject(d, propObj, m) @@ -987,7 +1053,7 @@ func populateNewPropertyObject(d *schema.ResourceData, m interface{}) (*gtm.Prop } // Populate Terraform state from provided Property object -func populateTerraformPropertyState(d *schema.ResourceData, prop *gtm.Property, m interface{}) { +func populateTerraformPropertyState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformPropertyState") @@ -1053,10 +1119,10 @@ func populateTrafficTargetObject(d *schema.ResourceData, prop *gtm.Property, m i // pull apart List traffTargList, err := tf.GetInterfaceArrayValue("traffic_target", d) if err == nil { - trafficObjList := make([]*gtm.TrafficTarget, len(traffTargList)) // create new object list + trafficObjList := make([]gtm.TrafficTarget, len(traffTargList)) // create new object list for i, v := range traffTargList { ttMap := v.(map[string]interface{}) - trafficTarget := >m.TrafficTarget{} + trafficTarget := gtm.TrafficTarget{} trafficTarget.DatacenterID = ttMap["datacenter_id"].(int) trafficTarget.Precedence = ptr.To(ttMap["precedence"].(int)) trafficTarget.Enabled = ttMap["enabled"].(bool) @@ -1078,11 +1144,11 @@ func populateTrafficTargetObject(d *schema.ResourceData, prop *gtm.Property, m i } // create and populate Terraform traffic_targets schema -func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.Property, m interface{}) error { +func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformTrafficTargetState") - objectInventory := make(map[int]*gtm.TrafficTarget, len(prop.TrafficTargets)) + objectInventory := make(map[int]gtm.TrafficTarget, len(prop.TrafficTargets)) if len(prop.TrafficTargets) > 0 { for _, aObj := range prop.TrafficTargets { objectInventory[aObj.DatacenterID] = aObj @@ -1097,7 +1163,7 @@ func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.Prope tt := ttMap.(map[string]interface{}) objIndex := tt["datacenter_id"].(int) ttObject := objectInventory[objIndex] - if ttObject == nil { + if &ttObject == nil { logger.Warnf("Property TrafficTarget %d NOT FOUND in returned GTM Object", tt["datacenter_id"]) continue } @@ -1139,10 +1205,10 @@ func populateStaticRRSetObject(d *schema.ResourceData, prop *gtm.Property) { // pull apart List staticSetList, err := tf.GetInterfaceArrayValue("static_rr_set", d) if err == nil { - staticObjList := make([]*gtm.StaticRRSet, len(staticSetList)) // create new object list + staticObjList := make([]gtm.StaticRRSet, len(staticSetList)) // create new object list for i, v := range staticSetList { recMap := v.(map[string]interface{}) - record := >m.StaticRRSet{ + record := gtm.StaticRRSet{ TTL: recMap["ttl"].(int), Type: recMap["type"].(string), } @@ -1160,11 +1226,11 @@ func populateStaticRRSetObject(d *schema.ResourceData, prop *gtm.Property) { } // create and populate Terraform static_rr_sets schema -func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.Property, m interface{}) error { +func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformStaticRRSetState") - objectInventory := make(map[string]*gtm.StaticRRSet, len(prop.StaticRRSets)) + objectInventory := make(map[string]gtm.StaticRRSet, len(prop.StaticRRSets)) if len(prop.StaticRRSets) > 0 { for _, aObj := range prop.StaticRRSets { objectInventory[aObj.Type] = aObj @@ -1179,7 +1245,7 @@ func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.Propert rr := rrMap.(map[string]interface{}) objIndex := rr["type"].(string) rrObject := objectInventory[objIndex] - if rrObject == nil { + if &rrObject == nil { logger.Warnf("Property StaticRRSet %s NOT FOUND in returned GTM Object", rr["type"]) continue } @@ -1210,11 +1276,11 @@ func populateLivenessTestObject(d *schema.ResourceData, prop *gtm.Property) { liveTestList, err := tf.GetInterfaceArrayValue("liveness_test", d) if err == nil { - liveTestObjList := make([]*gtm.LivenessTest, len(liveTestList)) // create new object list + liveTestObjList := make([]gtm.LivenessTest, len(liveTestList)) // create new object list for i, l := range liveTestList { v := l.(map[string]interface{}) - lt := >m.LivenessTest{ + lt := gtm.LivenessTest{ Name: v["name"].(string), TestObjectProtocol: v["test_object_protocol"].(string), TestInterval: v["test_interval"].(int), @@ -1248,10 +1314,10 @@ func populateLivenessTestObject(d *schema.ResourceData, prop *gtm.Property) { } httpHeaderList := v["http_header"].([]interface{}) if httpHeaderList != nil { - headerObjList := make([]*gtm.HTTPHeader, len(httpHeaderList)) // create new object list + headerObjList := make([]gtm.HTTPHeader, len(httpHeaderList)) // create new object list for i, h := range httpHeaderList { recMap := h.(map[string]interface{}) - record := >m.HTTPHeader{ + record := gtm.HTTPHeader{ Name: recMap["name"].(string), Value: recMap["value"].(string), } @@ -1274,11 +1340,11 @@ func populateLivenessTestObject(d *schema.ResourceData, prop *gtm.Property) { } // create and populate Terraform liveness_test schema -func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.Property, m interface{}) error { +func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformLivenessTestState") - objectInventory := make(map[string]*gtm.LivenessTest, len(prop.LivenessTests)) + objectInventory := make(map[string]gtm.LivenessTest, len(prop.LivenessTests)) if len(prop.LivenessTests) > 0 { for _, aObj := range prop.LivenessTests { objectInventory[aObj.Name] = aObj @@ -1293,7 +1359,7 @@ func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.Proper lt := ltMap.(map[string]interface{}) objIndex := lt["name"].(string) ltObject := objectInventory[objIndex] - if ltObject == nil { + if <Object == nil { logger.Warnf("Property LivenessTest %s NOT FOUND in returned GTM Object", lt["name"]) continue } @@ -1487,6 +1553,49 @@ func trafficTargetDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { return true } +// createPropertyStruct converts response from GetPropertyResponse into Property +func createPropertyStruct(prop *gtm.GetPropertyResponse) *gtm.Property { + if prop != nil { + return >m.Property{ + Name: prop.CName, + Type: prop.Type, + IPv6: prop.IPv6, + ScoreAggregationType: prop.ScoreAggregationType, + StickinessBonusPercentage: prop.StickinessBonusPercentage, + StickinessBonusConstant: prop.StickinessBonusConstant, + HealthThreshold: prop.HealthThreshold, + UseComputedTargets: prop.UseComputedTargets, + BackupIP: prop.BackupIP, + BalanceByDownloadScore: prop.BalanceByDownloadScore, + StaticTTL: prop.StaticTTL, + StaticRRSets: prop.StaticRRSets, + LastModified: prop.LastModified, + UnreachableThreshold: prop.UnreachableThreshold, + MinLiveFraction: prop.MinLiveFraction, + HealthMultiplier: prop.HealthMultiplier, + DynamicTTL: prop.DynamicTTL, + MaxUnreachablePenalty: prop.MaxUnreachablePenalty, + MapName: prop.Name, + HandoutLimit: prop.HandoutLimit, + HandoutMode: prop.HandoutMode, + FailoverDelay: prop.FailoverDelay, + BackupCName: prop.BackupIP, + FailbackDelay: prop.FailbackDelay, + LoadImbalancePercentage: prop.LoadImbalancePercentage, + HealthMax: prop.HealthMax, + GhostDemandReporting: prop.GhostDemandReporting, + Comments: prop.Comments, + CName: prop.CName, + WeightedHashBitsForIPv4: prop.WeightedHashBitsForIPv4, + WeightedHashBitsForIPv6: prop.WeightedHashBitsForIPv6, + TrafficTargets: prop.TrafficTargets, + Links: prop.Links, + LivenessTests: prop.LivenessTests, + } + } + return nil +} + func livenessTestsDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { oldLTests, newLTests := d.GetChange("liveness_test") oldLivenessTest := oldLTests.([]any) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 22d4bb320..0756dfe94 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -1,11 +1,12 @@ package gtm import ( + "context" "net/http" "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -14,8 +15,39 @@ import ( var ( propertyResourceName = "akamai_gtm_property.tfexample_prop_1" - propertyName = "tfexample_prop_1" updatedPropertyName = "tfexample_prop_1-updated" + + updatePropertyResponseStatus = >m.UpdatePropertyResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deletePropertyResponseStatus = >m.DeletePropertyResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) func TestResGTMProperty(t *testing.T) { @@ -27,16 +59,16 @@ func TestResGTMProperty(t *testing.T) { "create property": { property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getBasicProperty(), gtmTestDomain) + mockCreateProperty(m, getBasicProperty()) // read - mockGetProperty(m, getBasicProperty(), propertyName, gtmTestDomain, 4) + mockGetProperty(m, getBasicPropertyResponse(), 4) // update - mockUpdateProperty(m, getUpdatedProperty(), gtmTestDomain) + mockUpdateProperty(m) // read - mockGetDomainStatus(m, gtmTestDomain, 2) - mockGetProperty(m, getUpdatedProperty(), propertyName, gtmTestDomain, 3) + mockGetDomainStatus(m, 2) + mockGetProperty(m, getBasicPropertyResponseUpdate(), 3) // delete - mockDeleteProperty(m, getUpdatedProperty(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -74,11 +106,11 @@ func TestResGTMProperty(t *testing.T) { "create property with additional liveness test fields": { property: getBasicPropertyWithLivenessTests(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getBasicPropertyWithLivenessTests(), gtmTestDomain) + mockCreateProperty(m, getBasicPropertyWithLivenessTests()) // read - mockGetProperty(m, getBasicPropertyWithLivenessTests(), propertyName, gtmTestDomain, 3) + mockGetProperty(m, getBasicPropertyResponseWithLivenessTests(), 3) // delete - mockDeleteProperty(m, getBasicPropertyWithLivenessTests(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -104,8 +136,7 @@ func TestResGTMProperty(t *testing.T) { // bad request status code returned m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -117,19 +148,104 @@ func TestResGTMProperty(t *testing.T) { }, }, }, + "create property with retry on Property Validation Failure - no datacenter is assigned to map target": { + property: getBasicProperty(), + init: func(t *testing.T, m *gtm.Mock) { + // Simulate a retry scenario + m.On("CreateProperty", + mock.Anything, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, + ).Return(nil, >m.Error{ + Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", + StatusCode: http.StatusBadRequest, + Title: "Property Validation Failure", + Detail: "Invalid configuration for property \"tfexample_prop_1\": no datacenter is assigned to map target (all others)", + }).Once() + + // Simulate successful property creation on the second attempt + mockCreateProperty(m, getBasicProperty()) + mockGetProperty(m, getBasicPropertyResponse(), 3) + mockDeleteProperty(m) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResGtmProperty/create_basic.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(propertyResourceName, "name", "tfexample_prop_1"), + resource.TestCheckResourceAttr(propertyResourceName, "type", "weighted-round-robin"), + resource.TestCheckResourceAttr(propertyResourceName, "weighted_hash_bits_for_ipv4", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "weighted_hash_bits_for_ipv6", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.http_method", ""), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.http_request_body", ""), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.alternate_ca_certificates.#", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.pre_2023_security_posture", "false"), + resource.TestCheckResourceAttr(propertyResourceName, "traffic_target.0.precedence", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "id", "gtm_terra_testdomain.akadns.net:tfexample_prop_1"), + ), + }, + }, + }, + "create property with retry on Property Validation Failure - other errors": { + property: getBasicProperty(), + init: func(t *testing.T, m *gtm.Mock) { + // Simulate a retry scenario + m.On("CreateProperty", + mock.Anything, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, + ).Return(nil, >m.Error{ + Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", + StatusCode: http.StatusBadRequest, + Title: "Property Validation Failure", + Detail: "Invalid configuration for property \"tfexample_prop_1\": no targets found", + }).Once() + + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResGtmProperty/create_basic.tf"), + ExpectError: regexp.MustCompile("CreateProperty error: property Create failed: error: API error"), + }, + }, + }, + "create property with retry - context canceled": { + property: getBasicProperty(), + init: func(t *testing.T, m *gtm.Mock) { + // Simulate a retry scenario + m.On("CreateProperty", + mock.Anything, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, + ).Return(nil, >m.Error{ + Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", + StatusCode: http.StatusBadRequest, + Title: "Property Validation Failure", + Detail: "Invalid configuration for property \"tfexample_prop_1\": no datacenter is assigned to map target (all others)", + }).Once() + + // Simulate context cancellation on the second attempt + m.On("CreateProperty", + mock.Anything, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, + ).Return(nil, context.Canceled).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResGtmProperty/create_basic.tf"), + ExpectError: regexp.MustCompile("CreateProperty error: property Create failed: error: context canceled"), + }, + }, + }, "create property denied": { property: nil, init: func(t *testing.T, m *gtm.Mock) { // create // denied response status returned - deniedResponse := gtm.PropertyResponse{ + deniedResponse := gtm.CreatePropertyResponse{ Resource: getBasicProperty(), Status: &deniedResponseStatus, } m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(&deniedResponse, nil).Once() }, steps: []resource.TestStep{ @@ -143,18 +259,20 @@ func TestResGTMProperty(t *testing.T) { property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { // create 1st property - mockCreateProperty(m, getBasicProperty(), gtmTestDomain) + mockCreateProperty(m, getBasicProperty()) // read - mockGetProperty(m, getBasicProperty(), propertyName, gtmTestDomain, 4) + mockGetProperty(m, getBasicPropertyResponse(), 4) // force new -> delete 1st property and recreate 2nd with updated name - mockDeleteProperty(m, getBasicProperty(), gtmTestDomain) + mockDeleteProperty(m) propertyWithUpdatedName := getBasicProperty() propertyWithUpdatedName.Name = updatedPropertyName - mockCreateProperty(m, propertyWithUpdatedName, gtmTestDomain) + propertyResponseWithUpdatedName := getBasicPropertyResponse() + propertyResponseWithUpdatedName.Name = updatedPropertyName + mockCreateProperty(m, propertyWithUpdatedName) // read - mockGetProperty(m, propertyWithUpdatedName, updatedPropertyName, gtmTestDomain, 3) + mockGetProperty(m, propertyResponseWithUpdatedName, 3) // delete - mockDeleteProperty(m, propertyWithUpdatedName, gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -195,11 +313,14 @@ func TestResGTMProperty(t *testing.T) { propertyWithLivenessTest := getBasicProperty() propertyWithLivenessTest.LivenessTests[0].TestObject = "" propertyWithLivenessTest.LivenessTests[0].TestObjectProtocol = "SNMP" - mockCreateProperty(m, propertyWithLivenessTest, gtmTestDomain) + propertyResponseWithLivenessTest := getBasicPropertyResponse() + propertyResponseWithLivenessTest.LivenessTests[0].TestObject = "" + propertyResponseWithLivenessTest.LivenessTests[0].TestObjectProtocol = "SNMP" + mockCreateProperty(m, propertyWithLivenessTest) // read - mockGetProperty(m, propertyWithLivenessTest, propertyName, gtmTestDomain, 3) + mockGetProperty(m, propertyResponseWithLivenessTest, 3) // delete - mockDeleteProperty(m, propertyWithLivenessTest, gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -239,11 +360,11 @@ func TestResGTMProperty(t *testing.T) { "create property with 'ranked-failover' type and allow single empty precedence value": { property: getRankedFailoverPropertyWithPrecedence(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence()) // read - mockGetProperty(m, getRankedFailoverPropertyWithPrecedence(), propertyName, gtmTestDomain, 3) + mockGetProperty(m, getRankedFailoverPropertyResponseWithPrecedence(), 3) // delete - mockDeleteProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -266,11 +387,11 @@ func TestResGTMProperty(t *testing.T) { "create property with 'ranked-failover' type and 0 set as precedence value": { property: getRankedFailoverPropertyWithPrecedence(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence()) // read - mockGetProperty(m, getRankedFailoverPropertyWithPrecedence(), propertyName, gtmTestDomain, 3) + mockGetProperty(m, getRankedFailoverPropertyResponseWithPrecedence(), 3) // delete - mockDeleteProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -343,7 +464,7 @@ func TestResourceGTMTrafficTargetOrder(t *testing.T) { planOnly bool }{ "second apply - no diff": { - client: getMocks(), + client: getMocksSecondApply(), pathForCreate: "testdata/TestResGtmProperty/create_multiple_traffic_targets.tf", pathForUpdate: "testdata/TestResGtmProperty/create_multiple_traffic_targets.tf", nonEmptyPlan: false, @@ -357,7 +478,7 @@ func TestResourceGTMTrafficTargetOrder(t *testing.T) { planOnly: true, }, "re-ordered traffic target with no datacenter_id - no diff": { - client: getMocks(), + client: getMocksWithoutDatacenterID(), pathForCreate: "testdata/TestResGtmProperty/traffic_target/no_datacenter_id.tf", pathForUpdate: "testdata/TestResGtmProperty/traffic_target/no_datacenter_id_diff_order.tf", nonEmptyPlan: false, @@ -457,7 +578,75 @@ func getRankedFailoverPropertyWithPrecedence() *gtm.Property { DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ + { + DisableNonstandardPortWarning: false, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(10), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "ranked-failover", + } +} + +// getRankedFailoverPropertyResponseWithPrecedence gets the property values taken from `create_ranked_failover_precedence.tf` +func getRankedFailoverPropertyResponseWithPrecedence() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ { DisableNonstandardPortWarning: false, Name: "lt5", @@ -466,7 +655,7 @@ func getRankedFailoverPropertyWithPrecedence() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", @@ -481,19 +670,19 @@ func getRankedFailoverPropertyWithPrecedence() *gtm.Property { TestObject: "/junk", TestObjectPort: 80, PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, + HTTPHeaders: []gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -527,14 +716,14 @@ func getRankedFailoverPropertyNoPrecedence() *gtm.Property { HandoutLimit: 5, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -568,77 +757,77 @@ func TestResourceGTMLivenessTestOrder(t *testing.T) { planOnly bool }{ "second apply - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", nonEmptyPlan: false, planOnly: true, }, "re-ordered liveness test - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_liveness_tests_order.tf", nonEmptyPlan: false, planOnly: true, }, "remove liveness test - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/remove_liveness_test.tf", nonEmptyPlan: true, planOnly: true, }, "add liveness test - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/add_liveness_tests.tf", nonEmptyPlan: true, planOnly: true, }, "re-ordered liveness test and re-ordered http headers - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_lt_and_header_order.tf", nonEmptyPlan: false, planOnly: true, }, "change of 'timeout' field - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/change_timeout.tf", nonEmptyPlan: true, planOnly: true, }, "change of 'timeout' field and reorder of liveness tests - diff_(messy)": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/change_timeout_reorder_lt.tf", nonEmptyPlan: true, planOnly: true, }, "re-ordered liveness test and change http headers - diff_(messy)": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_lt_order_and_header_change.tf", nonEmptyPlan: true, planOnly: true, }, "change http headers - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/change_header.tf", nonEmptyPlan: true, planOnly: true, }, "value added to http header - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/http_header_without_value.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", nonEmptyPlan: true, planOnly: true, }, "re-ordered liveness test and alternate ca certificates - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests_with_ca_cert.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_lt_and_ca_certificate_order.tf", nonEmptyPlan: false, @@ -678,7 +867,7 @@ func getUpdatedProperty() *gtm.Property { DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { Name: "lt5", TestInterval: 50, @@ -686,7 +875,7 @@ func getUpdatedProperty() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", @@ -701,19 +890,19 @@ func getUpdatedProperty() *gtm.Property { TestObject: "/junk", TestObjectPort: 80, PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, + HTTPHeaders: []gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3132, Enabled: true, @@ -729,54 +918,123 @@ func getUpdatedProperty() *gtm.Property { } } -// getBasicProperty gets the property values taken from `create_basic.tf` -func getBasicProperty() *gtm.Property { - return >m.Property{ +// getBasicPropertyResponseDiff gets the property values taken from `create_basic.tf` +func getBasicPropertyResponseDiff() gtm.GetPropertyResponse { + return gtm.GetPropertyResponse{ DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { - Name: "lt5", - TestInterval: 40, - TestObject: "/junk", - TestObjectPort: 1, - TestObjectProtocol: "HTTP", - TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", }, }, }, - { - Name: "lt2", - TestInterval: 30, - TestObjectProtocol: "HTTP", - TestTimeout: 20, - TestObject: "/junk", - TestObjectPort: 80, - PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, - }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + TrafficTargets: []gtm.TrafficTarget{ { - Type: "MX", - TTL: 300, - Rdata: []string{"100 test_e"}, + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyCopy gets the property values taken from `create_basic.tf` +func getBasicPropertyDiff() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, HandoutCName: "test", Servers: []string{ - "1.2.3.9", + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", }, Weight: 200.0, Precedence: ptr.To(0), @@ -786,13 +1044,13 @@ func getBasicProperty() *gtm.Property { } } -// getBasicPropertyWithLivenessTests gets the property values taken from `create_basic_additional_liveness_tests.tf` -func getBasicPropertyWithLivenessTests() *gtm.Property { +// getBasicProperty gets the property values taken from `create_basic.tf` +func getBasicProperty() *gtm.Property { return >m.Property{ DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { Name: "lt5", TestInterval: 40, @@ -800,16 +1058,12 @@ func getBasicPropertyWithLivenessTests() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", }, }, - HTTPMethod: ptr.To("GET"), - HTTPRequestBody: ptr.To("Body"), - Pre2023SecurityPosture: true, - AlternateCACertificates: []string{"test1"}, }, { Name: "lt2", @@ -819,19 +1073,19 @@ func getBasicPropertyWithLivenessTests() *gtm.Property { TestObject: "/junk", TestObjectPort: 80, PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, + HTTPHeaders: []gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -847,70 +1101,620 @@ func getBasicPropertyWithLivenessTests() *gtm.Property { } } -// getMocks is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs -func getMocks() *gtm.Mock { - client := new(gtm.Mock) - - // read - getPropertyCall := client.On("GetProperty", mock.Anything, "tfexample_prop_1", gtmTestDomain). - Return(nil, >m.Error{StatusCode: http.StatusNotFound}) - // create - // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock - // each one and for those test it's not important, since we are only checking the diff - client.On("CreateProperty", mock.Anything, mock.AnythingOfType("*gtm.Property"), mock.AnythingOfType("string")).Return(>m.PropertyResponse{ - Resource: getBasicProperty(), - Status: &pendingResponseStatus, - }, nil).Run(func(args mock.Arguments) { - getPropertyCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Property), nil} - }) +// getBasicPropertySecondApply gets the property values taken from `create_multiple_traffic_targets.tf` +func getBasicPropertySecondApply() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + }, + Weight: 200, + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200, + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200, + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseSecondApply gets the property values taken from `create_multiple_traffic_targets.tf` +func getBasicPropertyResponseSecondApply() gtm.GetPropertyResponse { + return gtm.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + }, + Weight: 200, + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200, + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200, + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponse gets the property values taken from `create_basic.tf` +func getBasicPropertyResponse() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseUpdate gets the property values taken from `update_basic.tf` +func getBasicPropertyResponseUpdate() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 50, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyWithoutDatacenterID gets the property values without DatacenterID +func getBasicPropertyWithoutDatacenterID() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseWithoutDatacenterID gets the property values without DatacenterID +func getBasicPropertyResponseWithoutDatacenterID() gtm.GetPropertyResponse { + return gtm.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyWithLivenessTests gets the property values taken from `create_basic_additional_liveness_tests.tf` +func getBasicPropertyWithLivenessTests() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + HTTPMethod: ptr.To("GET"), + HTTPRequestBody: ptr.To("Body"), + Pre2023SecurityPosture: true, + AlternateCACertificates: []string{"test1"}, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseWithLivenessTests gets the property values taken from `create_basic_additional_liveness_tests.tf` +func getBasicPropertyResponseWithLivenessTests() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + HTTPMethod: ptr.To("GET"), + HTTPRequestBody: ptr.To("Body"), + Pre2023SecurityPosture: true, + AlternateCACertificates: []string{"test1"}, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getMocksForLivenessTest is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocksForLivenessTest() *gtm.Mock { + client := new(gtm.Mock) + + // read + getPropertyCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}) + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + mockCreateProperty(client, getBasicProperty()). + Run(func(args mock.Arguments) { + arg := (*gtm.GetPropertyResponse)(args.Get(1).(gtm.CreatePropertyRequest).Property) + getPropertyCall.ReturnArguments = mock.Arguments{arg, nil} + }) + + // delete + mockDeleteProperty(client) + + return client +} + +// getMocks is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocks() *gtm.Mock { + client := new(gtm.Mock) + + // read + getCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}).Once() + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + resp := getBasicPropertyResponseDiff() + mockCreateProperty(client, getBasicPropertyDiff()).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} + }) + + // read + client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(&resp, nil).Times(3) + + // delete + client.On("DeleteProperty", + mock.Anything, + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil) + + return client +} + +// getMocksNoDatacenterId is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocksWithoutDatacenterID() *gtm.Mock { + client := new(gtm.Mock) + + // read + getCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}).Once() + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + resp := getBasicPropertyResponseWithoutDatacenterID() + mockCreateProperty(client, getBasicPropertyWithoutDatacenterID()).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} + }) + + // read + client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(&resp, nil).Times(3) + + // delete + client.On("DeleteProperty", + mock.Anything, + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil) + + return client +} + +// getMocksSecondApply is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocksSecondApply() *gtm.Mock { + client := new(gtm.Mock) + + // read + getCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}).Once() + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + resp := getBasicPropertyResponseSecondApply() + mockCreateProperty(client, getBasicPropertySecondApply()).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} + }) + + // read + client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(&resp, nil).Times(3) + // delete client.On("DeleteProperty", mock.Anything, - mock.AnythingOfType("*gtm.Property"), - "gtm_terra_testdomain.akadns.net", - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil) return client } -func mockCreateProperty(client *gtm.Mock, property *gtm.Property, domain string) { - resp := gtm.PropertyResponse{} +func mockCreateProperty(client *gtm.Mock, property *gtm.Property) *mock.Call { + resp := gtm.CreatePropertyResponse{} resp.Resource = property resp.Status = &pendingResponseStatus - client.On("CreateProperty", + return client.On("CreateProperty", mock.Anything, - property, - domain, + mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(&resp, nil).Once() } -func mockGetProperty(client *gtm.Mock, property *gtm.Property, propertyName, domain string, times int) { +func mockGetProperty(client *gtm.Mock, property *gtm.GetPropertyResponse, times int) { client.On("GetProperty", mock.Anything, - propertyName, - domain, + mock.AnythingOfType("gtm.GetPropertyRequest"), ).Return(property, nil).Times(times) } -func mockUpdateProperty(client *gtm.Mock, property *gtm.Property, domain string) { +func mockUpdateProperty(client *gtm.Mock) { client.On("UpdateProperty", mock.Anything, - property, - domain, - ).Return(&completeResponseStatus, nil).Once() + mock.AnythingOfType("gtm.UpdatePropertyRequest"), + ).Return(updatePropertyResponseStatus, nil).Once() } -func mockGetDomainStatus(client *gtm.Mock, domain string, times int) { +func mockGetDomainStatus(client *gtm.Mock, times int) { client.On("GetDomainStatus", mock.Anything, - domain, - ).Return(&completeResponseStatus, nil).Times(times) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil).Times(times) } -func mockDeleteProperty(client *gtm.Mock, property *gtm.Property, domain string) { +func mockDeleteProperty(client *gtm.Mock) { client.On("DeleteProperty", mock.Anything, - property, - domain, - ).Return(&completeResponseStatus, nil).Once() + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil).Once() } diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource.go b/pkg/providers/gtm/resource_akamai_gtm_resource.go index cba5470a0..1a0c48fc4 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource.go @@ -6,8 +6,8 @@ import ( "fmt" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -142,7 +142,10 @@ func resourceGTMv1ResourceCreate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } logger.Debugf("Proposed New Resource: [%v]", newRsrc) - cStatus, err := Client(meta).CreateResource(ctx, newRsrc, domain) + cStatus, err := Client(meta).CreateResource(ctx, gtm.CreateResourceRequest{ + Resource: newRsrc, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -209,7 +212,10 @@ func resourceGTMv1ResourceRead(ctx context.Context, d *schema.ResourceData, m in logger.Errorf("Invalid resource Resource ID") return diag.FromErr(err) } - rsrc, err := Client(meta).GetResource(ctx, resource, domain) + rsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -248,7 +254,10 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } // Get existing property - existRsrc, err := Client(meta).GetResource(ctx, resource, domain) + existRsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -257,12 +266,16 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m Detail: err.Error(), }) } + newRsrc := createResourceStruct(existRsrc) logger.Debugf("Updating Resource BEFORE: %v", existRsrc) - if err := populateResourceObject(d, existRsrc, m); err != nil { + if err := populateResourceObject(d, newRsrc, m); err != nil { return diag.FromErr(err) } logger.Debugf("Updating Resource PROPOSED: %v", existRsrc) - uStat, err := Client(meta).UpdateResource(ctx, existRsrc, domain) + uStat, err := Client(meta).UpdateResource(ctx, gtm.UpdateResourceRequest{ + Resource: newRsrc, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -272,11 +285,11 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m }) } logger.Debugf("Resource Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -323,11 +336,13 @@ func resourceGTMv1ResourceImport(d *schema.ResourceData, m interface{}) ([]*sche if err != nil { return []*schema.ResourceData{d}, err } - rsrc, err := Client(meta).GetResource(ctx, resource, domain) + rsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { return nil, err } - err = d.Set("domain", domain) if err != nil { return nil, err @@ -367,7 +382,10 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m logger.Errorf("Invalid resource ID") return diag.FromErr(err) } - existRsrc, err := Client(meta).GetResource(ctx, resource, domain) + existRsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Delete Read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -376,8 +394,12 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m Detail: err.Error(), }) } - logger.Debugf("Deleting Resource: %v", existRsrc) - uStat, err := Client(meta).DeleteResource(ctx, existRsrc, domain) + newRsrc := createResourceStruct(existRsrc) + logger.Debugf("Deleting Resource: %v", newRsrc) + uStat, err := Client(meta).DeleteResource(ctx, gtm.DeleteResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -387,11 +409,11 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m }) } logger.Debugf("Resource Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -432,7 +454,7 @@ func populateNewResourceObject(d *schema.ResourceData, m interface{}) (*gtm.Reso } rsrcObj := >m.Resource{ Name: name, - ResourceInstances: make([]*gtm.ResourceInstance, 0), + ResourceInstances: make([]gtm.ResourceInstance, 0), } err = populateResourceObject(d, rsrcObj, m) @@ -543,14 +565,14 @@ func populateResourceObject(d *schema.ResourceData, rsrc *gtm.Resource, m interf if _, ok := d.GetOk("resource_instance"); ok { populateResourceInstancesObject(meta, d, rsrc) } else if d.HasChange("resource_instance") { - rsrc.ResourceInstances = make([]*gtm.ResourceInstance, 0) + rsrc.ResourceInstances = make([]gtm.ResourceInstance, 0) } return nil } // Populate Terraform state from provided Resource object -func populateTerraformResourceState(d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) error { +func populateTerraformResourceState(d *schema.ResourceData, rsrc *gtm.GetResourceResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformResourceState") @@ -586,10 +608,10 @@ func populateResourceInstancesObject(meta meta.Meta, d *schema.ResourceData, rsr // pull apart List rsrcInstances, err := tf.GetListValue("resource_instance", d) if err == nil { - rsrcInstanceObjList := make([]*gtm.ResourceInstance, len(rsrcInstances)) // create new object list + rsrcInstanceObjList := make([]gtm.ResourceInstance, len(rsrcInstances)) // create new object list for i, v := range rsrcInstances { riMap := v.(map[string]interface{}) - rsrcInstance := >m.ResourceInstance{DatacenterID: riMap["datacenter_id"].(int)} + rsrcInstance := gtm.ResourceInstance{DatacenterID: riMap["datacenter_id"].(int)} rsrcInstance.UseDefaultLoadObject = riMap["use_default_load_object"].(bool) if riMap["load_servers"] != nil { loadServers, ok := riMap["load_servers"].(*schema.Set) @@ -611,11 +633,11 @@ func populateResourceInstancesObject(meta meta.Meta, d *schema.ResourceData, rsr } // create and populate Terraform resource_instances schema -func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) error { +func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.GetResourceResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformResourceInstancesState") - riObjectInventory := make(map[int]*gtm.ResourceInstance, len(rsrc.ResourceInstances)) + riObjectInventory := make(map[int]gtm.ResourceInstance, len(rsrc.ResourceInstances)) if len(rsrc.ResourceInstances) > 0 { for _, riObj := range rsrc.ResourceInstances { riObjectInventory[riObj.DatacenterID] = riObj @@ -629,7 +651,7 @@ func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.R ri := riMap.(map[string]interface{}) objIndex := ri["datacenter_id"].(int) riObject := riObjectInventory[objIndex] - if riObject == nil { + if &riObject == nil { logger.Warnf("Resource_instance %d NOT FOUND in returned GTM Object", ri["datacenter_id"]) continue } @@ -715,6 +737,29 @@ func resourceInstanceDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { return true } +// createResourceStruct converts response from GetResourceResponse into Resource +func createResourceStruct(res *gtm.GetResourceResponse) *gtm.Resource { + if res != nil { + return >m.Resource{ + Type: res.Type, + HostHeader: res.HostHeader, + LeastSquaresDecay: res.LeastSquaresDecay, + Description: res.Description, + LeaderString: res.LeaderString, + ConstrainedProperty: res.ConstrainedProperty, + ResourceInstances: res.ResourceInstances, + AggregationType: res.AggregationType, + Links: res.Links, + LoadImbalancePercentage: res.LoadImbalancePercentage, + UpperBound: res.UpperBound, + Name: res.Name, + MaxUMultiplicativeIncrement: res.MaxUMultiplicativeIncrement, + DecayRate: res.DecayRate, + } + } + return nil +} + // loadServersEqual checks whether load_servers are equal func loadServersEqual(oldVal, newVal interface{}) bool { logger := logger.Get("Akamai GTM", "loadServersEqual") diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go index 22490a62d..48987ecd1 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -18,41 +18,46 @@ func TestResGTMResource(t *testing.T) { getCall := client.On("GetResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetResourceRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.ResourceResponse{} - resp.Resource = &rsrc - resp.Status = &pendingResponseStatus + resp := rsrc client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Resource), nil} + mock.AnythingOfType("gtm.CreateResourceRequest"), + ).Return(>m.CreateResourceResponse{ + Resource: rsrcCreate.Resource, + Status: rsrcCreate.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetResource", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetResourceRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Resource), nil} - }) + mock.AnythingOfType("gtm.UpdateResourceRequest"), + ).Return(updateResourceResponseStatus, nil) + + client.On("GetResource", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetResourceRequest"), + ).Return(&rsrcUpdate, nil).Times(3) client.On("DeleteResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteResourceRequest"), + ).Return(deleteResourceResponseStatus, nil) dataSourceName := "akamai_gtm_resource.tfexample_resource_1" @@ -86,8 +91,7 @@ func TestResGTMResource(t *testing.T) { client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateResourceRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -110,13 +114,12 @@ func TestResGTMResource(t *testing.T) { t.Run("create resource denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.ResourceResponse{} - dr.Resource = &rsrc + dr := gtm.CreateResourceResponse{} + dr.Resource = rsrcCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateResourceRequest"), ).Return(&dr, nil) useClient(client, func() { @@ -216,39 +219,37 @@ func getGTMResourceMocks() *gtm.Mock { mockGetResource := client.On("GetResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetResourceRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.ResourceResponse{} - resp.Resource = &resourceForOrderTests - resp.Status = &pendingResponseStatus + resp := resourceForOrderTests client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - mockGetResource.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Resource), nil} + mock.AnythingOfType("gtm.CreateResourceRequest"), + ).Return(>m.CreateResourceResponse{ + Resource: rsrcCreate.Resource, + Status: rsrcCreate.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetResource.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("DeleteResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteResourceRequest"), + ).Return(deleteResourceResponseStatus, nil) return client } var ( // resourceForOrderTests is a gtm.Resource structure used in testing the order of resource_instance - resourceForOrderTests = gtm.Resource{ + resourceForOrderTests = gtm.GetResourceResponse{ Name: "tfexample_resource_1", AggregationType: "latest", Type: "XML load object via HTTP", - ResourceInstances: []*gtm.ResourceInstance{ + ResourceInstances: []gtm.ResourceInstance{ { DatacenterID: 3131, UseDefaultLoadObject: false, @@ -270,11 +271,84 @@ var ( }, } - rsrc = gtm.Resource{ + rsrcCreateForOrder = gtm.CreateResourceResponse{ + Resource: >m.Resource{ + Name: "tfexample_resource_1", + AggregationType: "latest", + Type: "XML load object via HTTP", + ResourceInstances: []gtm.ResourceInstance{ + { + DatacenterID: 3131, + UseDefaultLoadObject: false, + LoadObject: gtm.LoadObject{ + LoadObject: "/test1", + LoadServers: []string{"1.2.3.4", "1.2.3.5", "1.2.3.6"}, + LoadObjectPort: 80, + }, + }, + { + DatacenterID: 3132, + UseDefaultLoadObject: false, + LoadObject: gtm.LoadObject{ + LoadObject: "/test2", + LoadServers: []string{"1.2.3.7", "1.2.3.8", "1.2.3.9", "1.2.3.10"}, + LoadObjectPort: 80, + }, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + rsrcCreate = gtm.CreateResourceResponse{ + Resource: >m.Resource{ + Name: "tfexample_resource_1", + AggregationType: "latest", + Type: "XML load object via HTTP", + ResourceInstances: []gtm.ResourceInstance{ + { + DatacenterID: 3131, + UseDefaultLoadObject: false, + LoadObject: gtm.LoadObject{ + LoadObject: "/test1", + LoadServers: []string{"1.2.3.4"}, + LoadObjectPort: 80, + }, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + rsrc = gtm.GetResourceResponse{ Name: "tfexample_resource_1", AggregationType: "latest", Type: "XML load object via HTTP", - ResourceInstances: []*gtm.ResourceInstance{ + ResourceInstances: []gtm.ResourceInstance{ { DatacenterID: 3131, UseDefaultLoadObject: false, @@ -286,4 +360,51 @@ var ( }, }, } + + rsrcUpdate = gtm.GetResourceResponse{ + Name: "tfexample_resource_1", + AggregationType: "latest", + Type: "XML load object via HTTP", + ResourceInstances: []gtm.ResourceInstance{ + { + DatacenterID: 3132, + LoadObject: gtm.LoadObject{ + LoadObject: "/test2", + LoadServers: []string{"1.2.3.5"}, + LoadObjectPort: 80, + }, + }, + }, + } + + updateResourceResponseStatus = >m.UpdateResourceResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + deleteResourceResponseStatus = >m.DeleteResourceResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) diff --git a/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf b/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf index a12de3e20..1d697a840 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf @@ -10,6 +10,10 @@ resource "akamai_gtm_datacenter" "tfexample_dc_1" { domain = local.gtmTestDomain nickname = "tfexample_dc_1" wait_on_complete = false + city = "Snæfellsjökull" + country = "IS" + latitude = "64.808" + longitude = "-23.776" default_load_object { load_object = "/test" load_object_port = 80 diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf index c9058f31a..26ce3b3bb 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 } diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf index 778e19a6b..5a6861ce1 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 sign_and_serve = true diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf index 4d467beac..4254e7522 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 email_notification_list = ["email1@nomail.com", "email2@nomail.com", "email3@nomail.com"] diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf index 2382e5b3e..23c3cd36e 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 email_notification_list = ["email3@nomail.com", "email1@nomail.com", "email2@nomail.com"] diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf index 4f6d71ed9..1c7b29be2 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 20.0 } diff --git a/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf b/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf index a1dfcdb99..ff828fac7 100644 --- a/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf @@ -20,7 +20,6 @@ resource "akamai_gtm_property" "tfexample_prop_1" { servers = ["1.2.3.9"] handout_cname = "test" } - liveness_test { name = "lt5" test_interval = 40 diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups.go b/pkg/providers/iam/data_akamai_iam_accessible_groups.go new file mode 100644 index 000000000..ecbde906b --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups.go @@ -0,0 +1,224 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &accessibleGroupsDataSource{} + _ datasource.DataSourceWithConfigure = &accessibleGroupsDataSource{} +) + +type ( + accessibleGroupsDataSource struct { + meta meta.Meta + } + + accessibleGroupsModel struct { + Username types.String `tfsdk:"username"` + AccessibleGroups []accessibleGroupModel `tfsdk:"accessible_groups"` + } + + accessibleGroupModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + RoleDescription types.String `tfsdk:"role_description"` + RoleID types.Int64 `tfsdk:"role_id"` + RoleName types.String `tfsdk:"role_name"` + SubGroups []accessibleSubgroupModel `tfsdk:"sub_groups"` + } + + accessibleSubgroupModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + ParentGroupID types.Int64 `tfsdk:"parent_group_id"` + SubGroups []accessibleSubgroupModel `tfsdk:"sub_groups"` + } +) + +// NewAccessibleGroupsDataSource returns new accessible groups data source. +func NewAccessibleGroupsDataSource() datasource.DataSource { + return &accessibleGroupsDataSource{} +} + +func (a *accessibleGroupsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_accessible_groups" +} + +func (a *accessibleGroupsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + a.meta = meta.Must(req.ProviderData) +} + +func (a *accessibleGroupsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "username": schema.StringAttribute{ + Required: true, + Description: "User's username for which the accessible groups will be listed.", + }, + "accessible_groups": schema.ListNestedAttribute{ + Description: "List of accessible groups for the user", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "sub_groups": schema.ListNestedAttribute{ + Computed: true, + Description: "Children of the parent group.", + // Schema effectively must be +1 size nested, to support correctly marshalling of last level (null of type []accessibleSubgroupModel onto `sub_groups`) + NestedObject: a.subgroupsSchema(maxSupportedGroupNesting + 1), + }, + }, + }, + }, + }, + } +} + +func (a *accessibleGroupsDataSource) subgroupsSchema(remainingNesting int) schema.NestedAttributeObject { + subgroupSchema := schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "parent_group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for the parent group.", + }, + }, + } + + var subgroupsAttribute schema.Attribute + if remainingNesting > 0 { + subgroupsAttribute = schema.ListNestedAttribute{ + Computed: true, + Description: fmt.Sprintf("Children of the parent group. Current maximal depth of subgroups is %d.", maxSupportedGroupNesting), + NestedObject: a.subgroupsSchema(remainingNesting - 1), + } + subgroupSchema.Attributes["sub_groups"] = subgroupsAttribute + } + + return subgroupSchema +} + +func (a *accessibleGroupsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Accessible Groups Datasource Read") + + var data accessibleGroupsModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + client := inst.Client(a.meta) + groups, err := client.ListAccessibleGroups(ctx, iam.ListAccessibleGroupsRequest{UserName: data.Username.ValueString()}) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Accessible Groups failed", err.Error()) + return + } + + newData, diags := a.convertAccessibleGroups(groups, data) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + resp.Diagnostics.Append(resp.State.Set(ctx, newData)...) +} + +func (a *accessibleGroupsDataSource) convertAccessibleGroups(groups iam.ListAccessibleGroupsResponse, data accessibleGroupsModel) (*accessibleGroupsModel, diag.Diagnostics) { + data.AccessibleGroups = []accessibleGroupModel{} + for _, group := range groups { + newGroup := accessibleGroupModel{ + GroupID: types.Int64Value(group.GroupID), + GroupName: types.StringValue(group.GroupName), + IsBlocked: types.BoolValue(group.IsBlocked), + RoleDescription: types.StringValue(group.RoleDescription), + RoleID: types.Int64Value(group.RoleID), + RoleName: types.StringValue(group.RoleName), + } + + subgroups, diags := a.convertAccessibleSubgroups(group.SubGroups, maxSupportedGroupNesting) + if diags.HasError() { + return nil, diags + } + newGroup.SubGroups = subgroups + + data.AccessibleGroups = append(data.AccessibleGroups, newGroup) + + } + return &data, nil +} + +func (a *accessibleGroupsDataSource) convertAccessibleSubgroups(subgroups []iam.AccessibleSubGroup, remainingNesting int) ([]accessibleSubgroupModel, diag.Diagnostics) { + var groups []accessibleSubgroupModel + + for _, subgroup := range subgroups { + newSubgroup := accessibleSubgroupModel{ + GroupID: types.Int64Value(subgroup.GroupID), + GroupName: types.StringValue(subgroup.GroupName), + ParentGroupID: types.Int64Value(subgroup.ParentGroupID), + } + if remainingNesting > 1 { + newSubgroups, diags := a.convertAccessibleSubgroups(subgroup.SubGroups, remainingNesting-1) + if diags.HasError() { + return nil, diags + } + newSubgroup.SubGroups = newSubgroups + } else if subgroup.SubGroups != nil && len(subgroup.SubGroups) > 0 { // We already processed the last level (remainingNesting = 1). If it still has subgroups, we cannot handle it + return nil, diag.Diagnostics{diag.NewErrorDiagnostic("unsupported subgroup depth", + fmt.Sprintf("Subgroup %d contains more subgroups and exceed total supported limit of nesting %d.", subgroup.GroupID, maxSupportedGroupNesting))} + } + groups = append(groups, newSubgroup) + } + + return groups, nil +} diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go new file mode 100644 index 000000000..a0b1bef5a --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go @@ -0,0 +1,215 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestAccessibleGroups(t *testing.T) { + mockPositiveCase := func(client *iam.Mock, returnedGroups iam.ListAccessibleGroupsResponse, times int) *mock.Call { + return client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(returnedGroups, nil).Times(times) + } + + generateCheckForGroup := func(path, groupID, groupName, isBlocked, roleDescription, roleID, roleName, subGroupsNumber string) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_id", path), groupID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_name", path), groupName), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.is_blocked", path), isBlocked), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.role_description", path), roleDescription), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.role_id", path), roleID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.role_name", path), roleName), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.sub_groups.#", path), subGroupsNumber), + ) + } + + generateCheckForSubGroup := func(path, groupID, groupName, parentGroupID, subGroupsNumber string) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_id", path), groupID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_name", path), groupName), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.parent_group_id", path), parentGroupID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.sub_groups.#", path), subGroupsNumber), + ) + } + + generateSubGroups := func(maxDepth, parentGroupID int64) []iam.AccessibleSubGroup { + var childSubgroups []iam.AccessibleSubGroup + + for groupID := maxDepth; groupID > 1; groupID-- { + currentSubgroups := iam.AccessibleSubGroup{ + GroupID: groupID, + GroupName: fmt.Sprintf("group%d", groupID), + ParentGroupID: groupID - 1, + SubGroups: childSubgroups, + } + childSubgroups = []iam.AccessibleSubGroup{currentSubgroups} + } + return []iam.AccessibleSubGroup{ + { + GroupID: 1, + GroupName: "group1", + ParentGroupID: parentGroupID, + SubGroups: childSubgroups, + }, + } + } + + generateIntermediateChecksForGeneratedSubGroup := func(min, max int) resource.TestCheckFunc { + var testCases []resource.TestCheckFunc + + for i := min; i < max; i++ { + testCases = append(testCases, generateCheckForSubGroup(fmt.Sprintf("accessible_groups.0%s", strings.Repeat(".sub_groups.0", i)), strconv.Itoa(i), fmt.Sprintf("group%d", i), strconv.Itoa(i-1), "1")) + } + + return resource.ComposeAggregateTestCheckFunc(testCases...) + } + + tests := map[string]struct { + init func(mock *iam.Mock) + config string + expectedError *regexp.Regexp + expectedChecks resource.TestCheckFunc + }{ + "normal case - all fields": { + init: func(client *iam.Mock) { + returnedGroups := []iam.AccessibleGroup{ + { + GroupID: 123, + GroupName: "first_group", + RoleID: 456, + RoleName: "admin", + RoleDescription: "admin description", + IsBlocked: true, + }, + { + GroupID: 321, + GroupName: "second_group", + RoleID: 654, + RoleName: "group1", + RoleDescription: "group1 description", + IsBlocked: false, + SubGroups: []iam.AccessibleSubGroup{ + { + GroupID: 234, + GroupName: "name2", + ParentGroupID: 321, + SubGroups: []iam.AccessibleSubGroup{ + { + GroupID: 345, + GroupName: "name3", + ParentGroupID: 234, + SubGroups: []iam.AccessibleSubGroup{}, + }, + }, + }, + }, + }, + } + mockPositiveCase(client, returnedGroups, 3) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "username", "user1"), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "accessible_groups.#", "2"), + generateCheckForGroup("accessible_groups.0", "123", "first_group", "true", "admin description", "456", "admin", "0"), + generateCheckForGroup("accessible_groups.1", "321", "second_group", "false", "group1 description", "654", "group1", "1"), + generateCheckForSubGroup("accessible_groups.1.sub_groups.0", "234", "name2", "321", "1"), + generateCheckForSubGroup("accessible_groups.1.sub_groups.0.sub_groups.0", "345", "name3", "234", "0"), + ), + }, + "normal case - max depth": { + init: func(client *iam.Mock) { + returnedGroups := []iam.AccessibleGroup{ + { + GroupID: 123, + GroupName: "root group", + RoleID: 321, + RoleName: "role321", + RoleDescription: "role321 description", + IsBlocked: false, + SubGroups: generateSubGroups(50, 123), + }, + } + mockPositiveCase(client, returnedGroups, 3) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "username", "user1"), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "accessible_groups.#", "1"), + generateCheckForSubGroup(fmt.Sprintf("accessible_groups.0%s", strings.Repeat(".sub_groups.0", 1)), "1", "group1", "123", "1"), + generateIntermediateChecksForGeneratedSubGroup(2, 50), + generateCheckForSubGroup(fmt.Sprintf("accessible_groups.0%s", strings.Repeat(".sub_groups.0", 50)), "50", "group50", "49", "0"), + ), + }, + "normal case - empty response": { + init: func(client *iam.Mock) { + mockPositiveCase(client, []iam.AccessibleGroup{}, 3) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "username", "user1"), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "accessible_groups.#", "0"), + ), + }, + "error - too deep nesting": { + init: func(client *iam.Mock) { + returnedGroups := []iam.AccessibleGroup{ + { + GroupID: 123, + GroupName: "root group", + RoleID: 321, + RoleName: "role321", + RoleDescription: "role321 description", + IsBlocked: false, + SubGroups: generateSubGroups(51, 123), + }, + } + mockPositiveCase(client, returnedGroups, 1) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedError: regexp.MustCompile("unsupported subgroup depth"), + }, + "error - api failed": { + init: func(client *iam.Mock) { + client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(nil, errors.New("api failed")).Times(1) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedError: regexp.MustCompile("api failed"), + }, + "error - missing username": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataAccessibleGroups/no-username.tf", + expectedError: regexp.MustCompile("Missing required argument"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + tc.init(client) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.config), + Check: tc.expectedChecks, + ExpectError: tc.expectedError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go new file mode 100644 index 000000000..5ef862ca8 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go @@ -0,0 +1,124 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &accountSwitchKeysDataSource{} + _ datasource.DataSourceWithConfigure = &accountSwitchKeysDataSource{} +) + +type ( + accountSwitchKeysDataSource struct { + meta meta.Meta + } + + accountSwitchKeysModel struct { + ClientID types.String `tfsdk:"client_id"` + Filter types.String `tfsdk:"filter"` + AccountSwitchKeys []accountSwitchKey `tfsdk:"account_switch_keys"` + } + + accountSwitchKey struct { + AccountName types.String `tfsdk:"account_name"` + AccountSwitchKey types.String `tfsdk:"account_switch_key"` + } +) + +// NewAccountSwitchKeysDataSource returns a new account switch keys data source. +func NewAccountSwitchKeysDataSource() datasource.DataSource { + return &accountSwitchKeysDataSource{} +} + +func (d *accountSwitchKeysDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_account_switch_keys" +} + +func (d *accountSwitchKeysDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *accountSwitchKeysDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management account switch keys", + Attributes: map[string]schema.Attribute{ + "client_id": schema.StringAttribute{ + Optional: true, + Description: "Unique identifier for each API client. If not provided it assumes your client id.", + }, + "filter": schema.StringAttribute{ + Optional: true, + Description: "Filters results by accountId or accountName. Enter at least three characters to filter the results by substring.", + Validators: []validator.String{stringvalidator.LengthAtLeast(3)}, + }, + "account_switch_keys": schema.ListNestedAttribute{ + Description: "List of account switch keys and account names available to the client.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the account.", + }, + "account_switch_key": schema.StringAttribute{ + Computed: true, + Description: "The identifier for an account other than your API client's default.", + }, + }, + }, + }, + }, + } +} + +func (d *accountSwitchKeysDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Account Switch Keys DataSource Read") + + var data accountSwitchKeysModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + accountSwitchKeysResponse, err := client.ListAccountSwitchKeys(ctx, iam.ListAccountSwitchKeysRequest{ + ClientID: data.ClientID.ValueString(), + Search: data.Filter.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Account Switch Keys Failed", err.Error()) + return + } + + keys := make([]accountSwitchKey, 0, len(accountSwitchKeysResponse)) + for _, key := range accountSwitchKeysResponse { + switchKey := accountSwitchKey{ + AccountName: types.StringValue(key.AccountName), + AccountSwitchKey: types.StringValue(key.AccountSwitchKey), + } + keys = append(keys, switchKey) + } + data.AccountSwitchKeys = keys + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go new file mode 100644 index 000000000..ac19acb12 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go @@ -0,0 +1,110 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestAccountSwitchKeys(t *testing.T) { + expectListAccountSwitchKeys := func(client *iam.Mock, clientID string, filter string, timesToRun int) { + accountSwitchKeysResponse := iam.ListAccountSwitchKeysResponse{ + { + AccountName: "Internet Company", + AccountSwitchKey: "1-EFGH", + }, + { + AccountName: "Internet Company", + AccountSwitchKey: "1-ABCD:Z-XYZ", + }, + { + AccountName: "Digital Company", + AccountSwitchKey: "1-ABCD:Z-PQR", + }, + } + client.On("ListAccountSwitchKeys", mock.Anything, iam.ListAccountSwitchKeysRequest{ + ClientID: clientID, + Search: filter, + }).Return(accountSwitchKeysResponse, nil).Times(timesToRun) + } + + expectListAccountSwitchKeysWithError := func(client *iam.Mock, timesToRun int) { + client.On("ListAccountSwitchKeys", mock.Anything, iam.ListAccountSwitchKeysRequest{ + ClientID: "", + Search: "", + }).Return(nil, fmt.Errorf("list account switch keys failed")).Times(timesToRun) + } + + tests := map[string]struct { + givenTF string + init func(*iam.Mock) + error *regexp.Regexp + }{ + "happy path": { + givenTF: "default.tf", + init: func(m *iam.Mock) { + expectListAccountSwitchKeys(m, "", "", 3) + }, + }, + "happy path with correct filter": { + givenTF: "default_correct_filter.tf", + init: func(m *iam.Mock) { + expectListAccountSwitchKeys(m, "XYZ", "ABC", 3) + }, + }, + "incorrect filter": { + givenTF: "incorrect_filter.tf", + error: regexp.MustCompile("Attribute filter string length must be at least 3, got: 2"), + }, + "error listing account switch keys": { + givenTF: "default.tf", + init: func(m *iam.Mock) { + expectListAccountSwitchKeysWithError(m, 1) + }, + error: regexp.MustCompile("list account switch keys failed"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(client) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataAccountSwitchKeys/%s", tc.givenTF)), + Check: checkAccountSwitchKeysAttrs(), + ExpectError: tc.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkAccountSwitchKeysAttrs() resource.TestCheckFunc { + var checkFuncs []resource.TestCheckFunc + + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.#", "3")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.0.account_name", "Internet Company")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.0.account_switch_key", "1-EFGH")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.1.account_name", "Internet Company")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.1.account_switch_key", "1-ABCD:Z-XYZ")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.2.account_name", "Digital Company")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.2.account_switch_key", "1-ABCD:Z-PQR")) + + return resource.ComposeAggregateTestCheckFunc(checkFuncs...) +} diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis.go b/pkg/providers/iam/data_akamai_iam_allowed_apis.go new file mode 100644 index 000000000..cdcff6ea3 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis.go @@ -0,0 +1,179 @@ +package iam + +import ( + "context" + "errors" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &allowedAPIsDataSource{} + _ datasource.DataSourceWithConfigure = &allowedAPIsDataSource{} + + // ErrIAMListAllowedAPIs is returned when ListAllowedAPIs fails. + ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") +) + +type ( + allowedAPIsDataSource struct { + meta meta.Meta + } + + allowedAPIsModel struct { + Username types.String `tfsdk:"username"` + ClientType types.String `tfsdk:"client_type"` + AllowAccountSwitch types.Bool `tfsdk:"allow_account_switch"` + AllowedAPIs []apiModel `tfsdk:"allowed_apis"` + } + + apiModel struct { + AccessLevels []types.String `tfsdk:"access_levels"` + APIID types.Int64 `tfsdk:"api_id"` + APIName types.String `tfsdk:"api_name"` + Description types.String `tfsdk:"description"` + DocumentationURL types.String `tfsdk:"documentation_url"` + Endpoint types.String `tfsdk:"endpoint"` + HasAccess types.Bool `tfsdk:"has_access"` + ServiceProviderID types.Int64 `tfsdk:"service_provider_id"` + } +) + +// NewAllowedAPIsDataSource returns a new iam allowed APIs data source +func NewAllowedAPIsDataSource() datasource.DataSource { + return &allowedAPIsDataSource{} +} + +func (d *allowedAPIsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_allowed_apis" +} + +func (d *allowedAPIsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *allowedAPIsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management allowed APIs", + Attributes: map[string]schema.Attribute{ + "username": schema.StringAttribute{ + Required: true, + Description: "Unique username for each user.", + }, + "client_type": schema.StringAttribute{ + Optional: true, + Description: "Filters data by client type, either USER_CLIENT, SERVICE_ACCOUNT, or default CLIENT.", + }, + "allow_account_switch": schema.BoolAttribute{ + Optional: true, + Description: "Includes account a user can switch to, false by default.", + }, + "allowed_apis": schema.ListNestedAttribute{ + Description: "List of available APIs for the user.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "access_levels": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + Description: "API access levels, possible values are READ-ONLY and READ-WRITE.", + }, + "api_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each API.", + }, + "api_name": schema.StringAttribute{ + Computed: true, + Description: "Name of the API.", + }, + "description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the API.", + }, + "documentation_url": schema.StringAttribute{ + Computed: true, + Description: "Link to more information about the API.", + }, + "endpoint": schema.StringAttribute{ + Computed: true, + Description: "Specifies where the API can access resources.", + }, + "has_access": schema.BoolAttribute{ + Computed: true, + Description: "Confirms access to the API.", + }, + "service_provider_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for the API's service provider.", + }, + }, + }, + }, + }, + } +} + +func (d *allowedAPIsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Allowed APIs DataSource Read") + + var data allowedAPIsModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + apis, err := client.ListAllowedAPIs(ctx, iam.ListAllowedAPIsRequest{ + UserName: data.Username.ValueString(), + ClientType: iam.ClientType(data.ClientType.ValueString()), + AllowAccountSwitch: data.AllowAccountSwitch.ValueBool(), + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMListAllowedAPIs), err.Error()) + return + } + + data.read(apis) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (d *allowedAPIsModel) read(allowedAPIs iam.ListAllowedAPIsResponse) { + var apis []apiModel + for _, api := range allowedAPIs { + accessLevels := make([]types.String, 0, len(api.AccessLevels)) + for _, accessLevel := range api.AccessLevels { + accessLevels = append(accessLevels, types.StringValue(string(accessLevel))) + } + + a := apiModel{ + AccessLevels: accessLevels, + APIID: types.Int64Value(api.APIID), + APIName: types.StringValue(api.APIName), + Description: types.StringValue(api.Description), + DocumentationURL: types.StringValue(api.DocumentationURL), + Endpoint: types.StringValue(api.Endpoint), + HasAccess: types.BoolValue(api.HasAccess), + ServiceProviderID: types.Int64Value(api.ServiceProviderID), + } + apis = append(apis, a) + } + + d.AllowedAPIs = apis +} diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go new file mode 100644 index 000000000..0850d5d47 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go @@ -0,0 +1,212 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForAllowedAPIs struct { + username string + clientType *string + allowAccountSwitch *bool + allowedAPIs []apiData + } + + apiData struct { + accessLevels []iam.AccessLevel + apiID int64 + apiName string + description string + documentationURL string + endpoint string + hasAccess bool + serviceProviderID int64 + } +) + +var ( + basicTestDataForAllowedAPIs = testDataForAllowedAPIs{ + username: "test", + clientType: ptr.To("CLIENT"), + allowAccountSwitch: ptr.To(true), + allowedAPIs: []apiData{{ + accessLevels: []iam.AccessLevel{ + iam.ReadWriteLevel}, + apiID: 146, + apiName: "Property Manager (PAPI)", + description: "Property Manager (PAPI). PAPI requires access to Edge Hostnames. Please edit your authorizations to add HAPI to your API Client.", + documentationURL: "https://developer.akamai.com/api/luna/papi/overview.html", + endpoint: "/papi", + hasAccess: true, + serviceProviderID: 1, + }, { + accessLevels: []iam.AccessLevel{ + iam.ReadOnlyLevel, + iam.ReadWriteLevel}, + apiID: 11, + apiName: "Event Center", + description: "Event Center", + documentationURL: "https://developer.akamai.com/api/luna/events/overview.html", + endpoint: "/events", + hasAccess: true, + serviceProviderID: 1, + }}, + } + basicTestDataForAllowedAPIsNoOptional = testDataForAllowedAPIs{ + username: "test", + allowedAPIs: []apiData{{ + accessLevels: []iam.AccessLevel{ + iam.ReadWriteLevel}, + apiID: 146, + apiName: "Property Manager (PAPI)", + description: "Property Manager (PAPI). PAPI requires access to Edge Hostnames. Please edit your authorizations to add HAPI to your API Client.", + documentationURL: "https://developer.akamai.com/api/luna/papi/overview.html", + endpoint: "/papi", + hasAccess: true, + serviceProviderID: 1, + }, { + accessLevels: []iam.AccessLevel{ + iam.ReadOnlyLevel, + iam.ReadWriteLevel}, + apiID: 11, + apiName: "Event Center", + description: "Event Center", + documentationURL: "https://developer.akamai.com/api/luna/events/overview.html", + endpoint: "/events", + hasAccess: true, + serviceProviderID: 1, + }}, + } +) + +func TestDataAllowedAPIs(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForAllowedAPIs) + mockData testDataForAllowedAPIs + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataAllowedAPIs/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { + expectFullListAllowedAPIs(t, m, testData, 3) + }, + mockData: basicTestDataForAllowedAPIs, + }, + "happy path no optional values": { + configPath: "testdata/TestDataAllowedAPIs/default_no_optional.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { + expectFullListAllowedAPIs(t, m, testData, 3) + }, + mockData: basicTestDataForAllowedAPIsNoOptional, + }, + "error - ListAllowedAPIs call failed": { + configPath: "testdata/TestDataAllowedAPIs/default_no_optional.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { + listAllowedAPIsReq := iam.ListAllowedAPIsRequest{UserName: testData.username} + + m.On("ListAllowedAPIs", mock.Anything, listAllowedAPIsReq).Return(nil, errors.New("test error")) + }, + error: regexp.MustCompile("test error"), + mockData: basicTestDataForAllowedAPIsNoOptional, + }, + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client, tc.mockData) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkAllowedAPIsAttrs(tc.mockData), + ExpectError: tc.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func expectFullListAllowedAPIs(_ *testing.T, client *iam.Mock, data testDataForAllowedAPIs, timesToRun int) { + listAllowedAPIsReq := iam.ListAllowedAPIsRequest{ + UserName: data.username, + } + if data.clientType != nil { + listAllowedAPIsReq.ClientType = iam.ClientType(*data.clientType) + } + if data.allowAccountSwitch != nil { + listAllowedAPIsReq.AllowAccountSwitch = *data.allowAccountSwitch + } + + listAllowedAPIsRes := iam.ListAllowedAPIsResponse{} + + for _, api := range data.allowedAPIs { + + listAllowedAPIsRes = append(listAllowedAPIsRes, iam.AllowedAPI{ + AccessLevels: api.accessLevels, + APIID: api.apiID, + APIName: api.apiName, + Description: api.description, + DocumentationURL: api.documentationURL, + Endpoint: api.endpoint, + HasAccess: api.hasAccess, + ServiceProviderID: api.serviceProviderID, + }) + } + + client.On("ListAllowedAPIs", mock.Anything, listAllowedAPIsReq).Return(listAllowedAPIsRes, nil).Times(timesToRun) +} + +func checkAllowedAPIsAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { + name := "data.akamai_iam_allowed_apis.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "username", data.username), + } + + if data.clientType != nil { + resource.TestCheckResourceAttr(name, "client_type", *data.clientType) + } else { + resource.TestCheckNoResourceAttr(name, "client_type") + } + + if data.allowAccountSwitch != nil { + resource.TestCheckResourceAttr(name, "allow_account_switch", strconv.FormatBool(*data.allowAccountSwitch)) + } else { + resource.TestCheckNoResourceAttr(name, "allow_account_switch") + } + + for i, api := range data.allowedAPIs { + for j, accessLevel := range api.accessLevels { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.access_levels.%d", i, j), string(accessLevel))) + } + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.api_id", i), strconv.FormatInt(api.apiID, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.api_name", i), api.apiName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.description", i), api.description)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.documentation_url", i), api.documentationURL)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.endpoint", i), api.endpoint)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.has_access", i), strconv.FormatBool(api.hasAccess))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.service_provider_id", i), strconv.FormatInt(api.serviceProviderID, 10))) + + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users.go b/pkg/providers/iam/data_akamai_iam_authorized_users.go new file mode 100644 index 000000000..34ad39950 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_authorized_users.go @@ -0,0 +1,132 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &authorizedUsersDataSource{} + _ datasource.DataSourceWithConfigure = &authorizedUsersDataSource{} +) + +type ( + authorizedUsersDataSource struct { + meta meta.Meta + } + + authorizedUsersModel struct { + AuthorizedUsers []authorizedUserModel `tfsdk:"authorized_users"` + } + + authorizedUserModel struct { + Email types.String `tfsdk:"email"` + Username types.String `tfsdk:"username"` + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + } +) + +// NewAuthorizedUsersDataSource returns the list of authorized API client users. +func NewAuthorizedUsersDataSource() datasource.DataSource { + return &authorizedUsersDataSource{} +} + +func (a *authorizedUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_authorized_users" +} + +func (a *authorizedUsersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + a.meta = meta.Must(req.ProviderData) +} + +func (a *authorizedUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "List of authorized API client users", + Attributes: map[string]schema.Attribute{ + "authorized_users": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + "username": schema.StringAttribute{ + Computed: true, + Description: "The user's Control Center sign-in name.", + }, + }, + }, + }, + }, + } +} + +func (a *authorizedUsersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Authorized Users DataSource Read") + + var data authorizedUsersModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(a.meta) + + users, err := client.ListAuthorizedUsers(ctx) + if err != nil { + resp.Diagnostics.AddError("Failed to fetch authorized users:", err.Error()) + return + } + + data.read(users) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (d *authorizedUsersModel) read(authorisedUsers iam.ListAuthorizedUsersResponse) { + var users []authorizedUserModel + for _, u := range authorisedUsers { + authorizedUser := authorizedUserModel{ + Email: types.StringValue(u.Email), + Username: types.StringValue(u.Username), + FirstName: types.StringValue(u.FirstName), + LastName: types.StringValue(u.LastName), + UIIdentityID: types.StringValue(u.UIIdentityID), + } + + users = append(users, authorizedUser) + } + + d.AuthorizedUsers = users +} diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go new file mode 100644 index 000000000..a1a21fe5c --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go @@ -0,0 +1,131 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForAuthorizedUsers struct { + authorizedUsers []userData + } + + userData struct { + Email string + Username string + FirstName string + LastName string + UIIdentityID string + } +) + +var ( + basicTestDataForAuthorizedUsers = testDataForAuthorizedUsers{ + authorizedUsers: []userData{ + { + Email: "user1@example.com", + Username: "user1", + FirstName: "John", + LastName: "Doe", + UIIdentityID: "U-I-DYS45", + }, + { + Email: "user2@example.com", + Username: "user2", + FirstName: "Jane", + LastName: "Smith", + UIIdentityID: "B-P-2XYC01", + }, + }, + } +) + +func TestAuthorizedUsers(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForAuthorizedUsers) + mockData testDataForAuthorizedUsers + error *regexp.Regexp + }{ + "success path": { + configPath: "testdata/TestAuthorizedUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAuthorizedUsers) { + expectFullListAuthorizedUsers(t, m, testData, 3) + }, + mockData: basicTestDataForAuthorizedUsers, + }, + "fail path": { + configPath: "testdata/TestAuthorizedUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAuthorizedUsers) { + m.On("ListAuthorizedUsers", mock.Anything).Return(iam.ListAuthorizedUsersResponse{}, errors.New("could not get authorized users")) + }, + error: regexp.MustCompile(`could not get authorized users`), + mockData: basicTestDataForAuthorizedUsers, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client, tc.mockData) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkAuthorizedUsersAttrs(tc.mockData), + ExpectError: tc.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func expectFullListAuthorizedUsers(_ *testing.T, client *iam.Mock, data testDataForAuthorizedUsers, timesToRun int) { + listAuthorizedUsersRes := iam.ListAuthorizedUsersResponse{} + + for _, user := range data.authorizedUsers { + listAuthorizedUsersRes = append(listAuthorizedUsersRes, iam.AuthorizedUser{ + Email: user.Email, + Username: user.Username, + FirstName: user.FirstName, + LastName: user.LastName, + UIIdentityID: user.UIIdentityID, + }) + } + + client.On("ListAuthorizedUsers", mock.Anything).Return(listAuthorizedUsersRes, nil).Times(timesToRun) +} + +func checkAuthorizedUsersAttrs(data testDataForAuthorizedUsers) resource.TestCheckFunc { + name := "data.akamai_iam_authorized_users.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "authorized_users.#", strconv.Itoa(len(data.authorizedUsers))), + } + + for i, user := range data.authorizedUsers { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.ui_identity_id", i), user.UIIdentityID)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.email", i), user.Email)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.first_name", i), user.FirstName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.last_name", i), user.LastName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.username", i), user.Username)) + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties.go b/pkg/providers/iam/data_akamai_iam_blocked_properties.go new file mode 100644 index 000000000..cf5b50c45 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties.go @@ -0,0 +1,152 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &blockedPropertiesDataSource{} + _ datasource.DataSourceWithConfigure = &blockedPropertiesDataSource{} +) + +// NewBlockedPropertiesDataSource returns all the properties that are blocked for a certain user in a group. +func NewBlockedPropertiesDataSource() datasource.DataSource { + return &blockedPropertiesDataSource{} +} + +type ( + blockedPropertiesDataSource struct { + meta meta.Meta + } + + blockedPropertiesModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + ContractID types.String `tfsdk:"contract_id"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + BlockedProperties []blockedPropertyIDsModel `tfsdk:"blocked_properties"` + } + + blockedPropertyIDsModel struct { + PropertyID types.String `tfsdk:"property_id"` + AssetID types.Int64 `tfsdk:"asset_id"` + } +) + +func (d *blockedPropertiesDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_blocked_properties" +} + +func (d *blockedPropertiesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Blocked Properties data source.", + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each group.", + }, + "contract_id": schema.StringAttribute{ + Required: true, + Description: "Contract ID for which block properties are retrieved.", + }, + "ui_identity_id": schema.StringAttribute{ + Required: true, + Description: "Unique identifier for each user.", + }, + "blocked_properties": schema.ListNestedAttribute{ + Computed: true, + Description: "The list of blocked properties.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "property_id": schema.StringAttribute{ + Computed: true, + Description: "PAPI's blocked property ID.", + }, + "asset_id": schema.Int64Attribute{ + Computed: true, + Description: "IAM's blocked property ID.", + }, + }, + }, + }, + }, + } +} + +func (d *blockedPropertiesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + d.meta = meta.Must(req.ProviderData) +} + +func (d *blockedPropertiesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Blocked Properties DataSource Read") + + var data blockedPropertiesModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + + client := inst.Client(d.meta) + papiClient := inst.PapiClient(d.meta) + + listBlockedPropertiesResp, err := client.ListBlockedProperties(ctx, iam.ListBlockedPropertiesRequest{ + IdentityID: data.UIIdentityID.ValueString(), + GroupID: data.GroupID.ValueInt64(), + }) + if err != nil { + resp.Diagnostics.AddError("fetching iam blocked properties failed", err.Error()) + return + } + + var blockedProperties []blockedPropertyIDsModel + groupID := str.AddPrefix(data.GroupID.String(), "grp_") + + for _, prop := range listBlockedPropertiesResp { + req := iam.MapPropertyIDToNameRequest{ + GroupID: data.GroupID.ValueInt64(), + PropertyID: prop, + } + papiPropertyName, err := client.MapPropertyIDToName(ctx, req) + if err != nil { + resp.Diagnostics.AddError("fetching PAPI propertyName failed", err.Error()) + return + } + papiPropertyID, err := papiClient.MapPropertyNameToID(ctx, papi.MapPropertyNameToIDRequest{ + GroupID: groupID, + ContractID: data.ContractID.ValueString(), + Name: *papiPropertyName, + }) + if err != nil { + resp.Diagnostics.AddError("fetching PAPI propertyID failed", err.Error()) + return + } + + blockedProperties = append(blockedProperties, blockedPropertyIDsModel{PropertyID: types.StringValue(*papiPropertyID), AssetID: types.Int64Value(prop)}) + } + + data.BlockedProperties = blockedProperties + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go new file mode 100644 index 000000000..1d92ee4db --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go @@ -0,0 +1,122 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestBlockedPropertiesDataSource(t *testing.T) { + propertyName1 := "example1.com" + propertyName2 := "example2.com" + propertyID1 := "prp_123456" + propertyID2 := "prp_456789" + + tests := map[string]struct { + givenTF string + init func(*iam.Mock, *papi.Mock) + expectedCheck resource.TestCheckFunc + expectError *regexp.Regexp + }{ + "happy path - blocked properties are returned": { + givenTF: "valid.tf", + init: func(im *iam.Mock, pm *papi.Mock) { + im.On("ListBlockedProperties", mock.Anything, iam.ListBlockedPropertiesRequest{ + IdentityID: "user123", + GroupID: 1, + }).Return([]int64{123, 456}, nil) + im.On("MapPropertyIDToName", mock.Anything, iam.MapPropertyIDToNameRequest{ + GroupID: 1, + PropertyID: 123, + }).Return(&propertyName1, nil) + pm.On("MapPropertyNameToID", mock.Anything, papi.MapPropertyNameToIDRequest{ + GroupID: "grp_1", + ContractID: "ctr_C-123", + Name: propertyName1, + }).Return(&propertyID1, nil) + im.On("MapPropertyIDToName", mock.Anything, iam.MapPropertyIDToNameRequest{ + GroupID: 1, + PropertyID: 456, + }).Return(&propertyName2, nil) + pm.On("MapPropertyNameToID", mock.Anything, papi.MapPropertyNameToIDRequest{ + GroupID: "grp_1", + ContractID: "ctr_C-123", + Name: propertyName2, + }).Return(&propertyID2, nil) + + }, + expectedCheck: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.#", "2"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.0.property_id", "prp_123456"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.0.asset_id", "123"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.1.property_id", "prp_456789"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.1.asset_id", "456"), + ), + expectError: nil, + }, + "happy path - no blocked properties are returned": { + givenTF: "valid.tf", + init: func(im *iam.Mock, pm *papi.Mock) { + im.On("ListBlockedProperties", mock.Anything, iam.ListBlockedPropertiesRequest{ + IdentityID: "user123", + GroupID: 1, + }).Return([]int64{}, nil) + }, + expectedCheck: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.#", "0"), + ), + expectError: nil, + }, + "error response from api": { + givenTF: "valid.tf", + init: func(im *iam.Mock, _ *papi.Mock) { + im.On("ListBlockedProperties", mock.Anything, iam.ListBlockedPropertiesRequest{ + IdentityID: "user123", + GroupID: 1, + }).Return(nil, fmt.Errorf("oops")) + }, + expectError: regexp.MustCompile("oops"), + }, + "missing required argument group_id": { + givenTF: "missing_group_id.tf", + expectError: regexp.MustCompile(`The argument "group_id" is required, but no definition was found`), + }, + "missing required argument contract_id": { + givenTF: "missing_contract_id.tf", + expectError: regexp.MustCompile(`The argument "contract_id" is required, but no definition was found`), + }, + "missing required argument ui_identity_id": { + givenTF: "missing_ui_identity_id.tf", + expectError: regexp.MustCompile(`The argument "ui_identity_id" is required, but no definition was found`), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + papiClient := &papi.Mock{} + + if tc.init != nil { + tc.init(client, papiClient) + } + useIAMandPAPIClient(client, papiClient, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataBlockedProperties/%s", tc.givenTF)), + Check: tc.expectedCheck, + ExpectError: tc.expectError, + }}, + }) + }) + client.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block.go b/pkg/providers/iam/data_akamai_iam_cidr_block.go new file mode 100644 index 000000000..f617b5c0c --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_cidr_block.go @@ -0,0 +1,170 @@ +package iam + +import ( + "context" + "errors" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &cidrBlockDataSource{} + _ datasource.DataSourceWithConfigure = &cidrBlockDataSource{} + + // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails. + ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") +) + +type ( + cidrBlockDataSource struct { + meta meta.Meta + } + + cidrBlockModel struct { + CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` + Actions *actions `tfsdk:"actions"` + CIDRBlock types.String `tfsdk:"cidr_block"` + Comments types.String `tfsdk:"comments"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + Enabled types.Bool `tfsdk:"enabled"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + } + + actions struct { + Delete types.Bool `tfsdk:"delete"` + Edit types.Bool `tfsdk:"edit"` + } +) + +// NewCIDRBlockDataSource returns a new iam CIDR block data source. +func NewCIDRBlockDataSource() datasource.DataSource { + return &cidrBlockDataSource{} +} + +func (d *cidrBlockDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_block" +} + +func (d *cidrBlockDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *cidrBlockDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management CIDR block.", + Attributes: map[string]schema.Attribute{ + "cidr_block_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each CIDR block.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block.", + }, + }, + }, + "cidr_block": schema.StringAttribute{ + Computed: true, + Description: "The value of an IP address or IP address range.", + }, + "comments": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + }, + "enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether the CIDR block is enabled.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + }, + }, + } +} + +func (d *cidrBlockDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM CIDR Block DataSource Read") + + var data cidrBlockModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + id := data.CIDRBlockID.ValueInt64() + cidrBlock, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ + CIDRBlockID: id, + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMGetCIDRBlock), err.Error()) + return + } + + data.read(cidrBlock) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (d *cidrBlockModel) read(cidrBlock *iam.GetCIDRBlockResponse) { + d.CIDRBlock = types.StringValue(cidrBlock.CIDRBlock) + d.CreatedBy = types.StringValue(cidrBlock.CreatedBy) + d.CreatedDate = types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)) + d.Enabled = types.BoolValue(cidrBlock.Enabled) + d.ModifiedBy = types.StringValue(cidrBlock.ModifiedBy) + d.ModifiedDate = types.StringValue(date.FormatRFC3339Nano(cidrBlock.ModifiedDate)) + + if cidrBlock.Actions != nil { + d.Actions = &actions{ + Delete: types.BoolValue(cidrBlock.Actions.Delete), + Edit: types.BoolValue(cidrBlock.Actions.Edit), + } + } + + if cidrBlock.Comments != nil { + d.Comments = types.StringValue(*cidrBlock.Comments) + } else { + d.Comments = types.StringNull() + } +} diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go new file mode 100644 index 000000000..aacb2f05c --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go @@ -0,0 +1,149 @@ +package iam + +import ( + "errors" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForCIDRBlock struct { + cidrBlockID int64 + actions *testActions + cidrBlock string + comments string + createdBy string + createdDate string + enabled bool + modifiedBy string + modifiedDate string + } + + testActions struct { + delete bool + edit bool + } +) + +var ( + basicTestDataForCIDRBlock = testDataForCIDRBlock{ + cidrBlockID: 2567, + actions: &testActions{ + delete: true, + edit: false, + }, + cidrBlock: "128.5.6.6/24", + comments: "APAC Region", + createdBy: "alfulani", + createdDate: "2017-07-27T18:11:25Z", + enabled: true, + modifiedBy: "alfulani", + modifiedDate: "2017-07-27T18:11:25Z", + } +) + +func TestDataCIDRBlock(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForCIDRBlock) + mockData testDataForCIDRBlock + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataCIDRBlock/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData testDataForCIDRBlock) { + expectGetCIDRBlock(t, m, mockData, 3) + }, + mockData: basicTestDataForCIDRBlock, + }, + "error - missing cidr_block_id": { + configPath: "testdata/TestDataCIDRBlock/missing_cidr_block_id.tf", + error: regexp.MustCompile("Missing required argument"), + mockData: basicTestDataForCIDRBlock, + }, + "error - GetCIDRBlock call failed ": { + configPath: "testdata/TestDataCIDRBlock/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData testDataForCIDRBlock) { + getCIDRBlockReq := iam.GetCIDRBlockRequest{CIDRBlockID: mockData.cidrBlockID, Actions: true} + m.On("GetCIDRBlock", mock.Anything, getCIDRBlockReq).Return(nil, errors.New("test error")) + }, + mockData: basicTestDataForCIDRBlock, + error: regexp.MustCompile("test error"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client, tc.mockData) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkCIDRBlockAttrs(), + ExpectError: tc.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkCIDRBlockAttrs() resource.TestCheckFunc { + name := "data.akamai_iam_cidr_block.test" + + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "cidr_block_id", "2567"), + resource.TestCheckResourceAttr(name, "cidr_block", "128.5.6.6/24"), + resource.TestCheckResourceAttr(name, "comments", "APAC Region"), + resource.TestCheckResourceAttr(name, "created_by", "alfulani"), + resource.TestCheckResourceAttr(name, "created_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "enabled", "true"), + resource.TestCheckResourceAttr(name, "modified_by", "alfulani"), + resource.TestCheckResourceAttr(name, "modified_date", "2017-07-27T18:11:25Z"), + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} + +func expectGetCIDRBlock(t *testing.T, client *iam.Mock, data testDataForCIDRBlock, timesToRun int) { + + getCIDRBlockReq := iam.GetCIDRBlockRequest{ + CIDRBlockID: data.cidrBlockID, + Actions: true, + } + + createdDate := test.NewTimeFromString(t, data.createdDate) + modifiedDate := test.NewTimeFromString(t, data.modifiedDate) + + getCIDRBlockResp := iam.GetCIDRBlockResponse{ + CIDRBlock: data.cidrBlock, + CIDRBlockID: data.cidrBlockID, + Comments: &data.comments, + CreatedBy: data.createdBy, + CreatedDate: createdDate, + Enabled: data.enabled, + ModifiedBy: data.modifiedBy, + ModifiedDate: modifiedDate, + } + if data.actions != nil { + getCIDRBlockResp.Actions = &iam.CIDRActions{ + Delete: data.actions.delete, + Edit: data.actions.edit, + } + } + + client.On("GetCIDRBlock", mock.Anything, getCIDRBlockReq).Return(&getCIDRBlockResp, nil).Times(timesToRun) +} diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go new file mode 100644 index 000000000..71be27ab5 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go @@ -0,0 +1,170 @@ +package iam + +import ( + "context" + "errors" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &cidrBlocksDataSource{} + _ datasource.DataSourceWithConfigure = &cidrBlocksDataSource{} + + // ErrIAMListCIDRBlocks is returned when ListCIDRBlocks fails. + ErrIAMListCIDRBlocks = errors.New("IAM list CIDR blocks failed") +) + +type ( + cidrBlocksDataSource struct { + meta meta.Meta + } + + cidrBlocksSourceModel struct { + CIDRBlocks []cidrBlockModel `tfsdk:"cidr_blocks"` + } +) + +// NewCIDRBlocksDataSource returns a new iam CIDR blocks data source. +func NewCIDRBlocksDataSource() datasource.DataSource { + return &cidrBlocksDataSource{} +} + +func (d *cidrBlocksDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_blocks" +} + +func (d *cidrBlocksDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *cidrBlocksDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management CIDR blocks.", + Attributes: map[string]schema.Attribute{ + "cidr_blocks": schema.ListNestedAttribute{ + Description: "List of CIDR blocks on account's allowlist.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block.", + }, + }, + }, + "cidr_block": schema.StringAttribute{ + Computed: true, + Description: "The value of an IP address or IP address range.", + }, + "cidr_block_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each CIDR block.", + }, + "comments": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + }, + "enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether the CIDR block is enabled.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + }, + }, + }, + }, + }, + } +} + +func (d *cidrBlocksDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM CIDR Blocks DataSource Read") + + var data cidrBlocksSourceModel + + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + cidrBlocks, err := client.ListCIDRBlocks(ctx, iam.ListCIDRBlocksRequest{ + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMListCIDRBlocks), err.Error()) + return + } + + data.read(cidrBlocks) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (d *cidrBlocksSourceModel) read(cidrBlocks iam.ListCIDRBlocksResponse) { + for _, cidrBlock := range cidrBlocks { + block := cidrBlockModel{ + CIDRBlock: types.StringValue(cidrBlock.CIDRBlock), + Enabled: types.BoolValue(cidrBlock.Enabled), + CIDRBlockID: types.Int64Value(cidrBlock.CIDRBlockID), + CreatedBy: types.StringValue(cidrBlock.CreatedBy), + CreatedDate: types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)), + ModifiedBy: types.StringValue(cidrBlock.ModifiedBy), + ModifiedDate: types.StringValue(date.FormatRFC3339Nano(cidrBlock.ModifiedDate)), + } + if cidrBlock.Actions != nil { + block.Actions = &actions{ + Delete: types.BoolValue(cidrBlock.Actions.Delete), + Edit: types.BoolValue(cidrBlock.Actions.Edit), + } + } + + if cidrBlock.Comments != nil { + block.Comments = types.StringValue(*cidrBlock.Comments) + } else { + block.Comments = types.StringNull() + } + + d.CIDRBlocks = append(d.CIDRBlocks, block) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go new file mode 100644 index 000000000..7d63cc88a --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go @@ -0,0 +1,114 @@ +package iam + +import ( + "errors" + "regexp" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestDataCIDRBlocks(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*iam.Mock) + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataCIDRBlocks/default.tf", + init: func(m *iam.Mock) { + listCIDRBlocksReq := iam.ListCIDRBlocksRequest{Actions: true} + listCIDRBlocksResp := iam.ListCIDRBlocksResponse{ + { + Actions: &iam.CIDRActions{ + Delete: true, + Edit: false, + }, + CIDRBlock: "128.5.6.6/24", + CIDRBlockID: 2567, + Comments: ptr.To("APAC Region"), + CreatedBy: "user1", + CreatedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + Enabled: true, + ModifiedBy: "user1", + ModifiedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + }, + { + Actions: &iam.CIDRActions{ + Delete: true, + Edit: false, + }, + CIDRBlock: "128.5.6.6/24", + CIDRBlockID: 6042, + Comments: ptr.To("East Coast Office"), + CreatedBy: "user2", + CreatedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + Enabled: true, + ModifiedBy: "user3", + ModifiedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + }, + } + m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(listCIDRBlocksResp, nil).Times(3) + }, + }, + "error - ListCIDRBlocks call failed ": { + configPath: "testdata/TestDataCIDRBlocks/default.tf", + init: func(m *iam.Mock) { + listCIDRBlocksReq := iam.ListCIDRBlocksRequest{Actions: true} + m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(nil, errors.New("test error")) + }, + error: regexp.MustCompile("test error"), + }, + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(client) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkCIDRBlocksAttrs(), + ExpectError: tc.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkCIDRBlocksAttrs() resource.TestCheckFunc { + name := "data.akamai_iam_cidr_blocks.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "cidr_blocks.#", "2"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.cidr_block_id", "2567"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.cidr_block", "128.5.6.6/24"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.comments", "APAC Region"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.created_by", "user1"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.created_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.enabled", "true"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.modified_by", "user1"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.modified_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.cidr_block_id", "6042"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.cidr_block", "128.5.6.6/24"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.comments", "East Coast Office"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.created_by", "user2"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.created_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.enabled", "true"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.modified_by", "user3"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.modified_date", "2017-07-27T18:11:25Z"), + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} diff --git a/pkg/providers/iam/data_akamai_iam_contact_types.go b/pkg/providers/iam/data_akamai_iam_contact_types.go index eb949d9cb..c9e80fc3c 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,13 +11,13 @@ import ( func dataSourceIAMContactTypes() *schema.Resource { return &schema.Resource{ - Description: "Retrieve all contact types that Akamai supports", + Description: "Retrieve all contact types that Akamai supports.", ReadContext: dataIAMContactTypesRead, Schema: map[string]*schema.Schema{ "contact_types": { Type: schema.TypeSet, Computed: true, - Description: "Supported contact types", + Description: "Supported contact types.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, @@ -38,7 +38,7 @@ func dataIAMContactTypesRead(ctx context.Context, d *schema.ResourceData, m inte return diag.FromErr(err) } - types := []interface{}{} + var types []interface{} for _, ct := range res { types = append(types, ct) } diff --git a/pkg/providers/iam/data_akamai_iam_contact_types_test.go b/pkg/providers/iam/data_akamai_iam_contact_types_test.go index f5b9a60ff..7eb8faefd 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types_test.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_countries.go b/pkg/providers/iam/data_akamai_iam_countries.go index b0ea4e5c5..6a23f3c42 100644 --- a/pkg/providers/iam/data_akamai_iam_countries.go +++ b/pkg/providers/iam/data_akamai_iam_countries.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,13 +11,13 @@ import ( func dataSourceIAMCountries() *schema.Resource { return &schema.Resource{ - Description: "List all the possible countries that Akamai supports", + Description: "List all the possible countries that Akamai supports.", ReadContext: dataIAMCountriesRead, Schema: map[string]*schema.Schema{ "countries": { Type: schema.TypeSet, Computed: true, - Description: "Supported countries", + Description: "Supported countries.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_countries_test.go b/pkg/providers/iam/data_akamai_iam_countries_test.go index fd50aa7e9..ea2624ba9 100644 --- a/pkg/providers/iam/data_akamai_iam_countries_test.go +++ b/pkg/providers/iam/data_akamai_iam_countries_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_grantable_roles.go b/pkg/providers/iam/data_akamai_iam_grantable_roles.go index 8cea4d54c..bac00f314 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -12,28 +12,28 @@ import ( func dataSourceIAMGrantableRoles() *schema.Resource { return &schema.Resource{ - Description: "Get roles for the current account and contract", + Description: "Get roles for the current account and contract.", ReadContext: dataIAMGrantableRolesRead, Schema: map[string]*schema.Schema{ "grantable_roles": { Type: schema.TypeList, Computed: true, - Description: "List of grantable roles", + Description: "List of grantable roles.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "granted_role_id": { Type: schema.TypeInt, - Description: "Granted role ID", + Description: "Granted role ID.", Computed: true, }, "name": { Type: schema.TypeString, - Description: "Granted role name", + Description: "Granted role name.", Computed: true, }, "description": { Type: schema.TypeString, - Description: "Granted role description", + Description: "Granted role description.", Computed: true, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go b/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go index c2fdc20d0..847dfe9a0 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_group.go b/pkg/providers/iam/data_akamai_iam_group.go new file mode 100644 index 000000000..9c8a047b0 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_group.go @@ -0,0 +1,199 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &groupDataSource{} + _ datasource.DataSourceWithConfigure = &groupDataSource{} +) + +const maxSupportedGroupNesting = 50 + +// NewGroupDataSource returns all the details for a group. +func NewGroupDataSource() datasource.DataSource { + return &groupDataSource{} +} + +type ( + groupDataSource struct { + meta meta.Meta + } + + groupModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + Actions *actions `tfsdk:"actions"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + ParentGroupID types.Int64 `tfsdk:"parent_group_id"` + SubGroups []groupModel `tfsdk:"sub_groups"` + } +) + +// groupSchemaAttributes returns the schema attributes for a group, with optional nesting for subgroups +func (d *groupDataSource) groupSchemaAttributes(remainingNesting int) map[string]schema.Attribute { + groupAttributes := map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the group.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the group was created.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the group.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the group was last updated.", + }, + "parent_group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for the parent group within the subgroup tree.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the group.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can remove the group from the account. You can't remove a group that contains resources or subgroups, or if users have roles on that group.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can modify the group.", + }, + }, + }, + } + + if remainingNesting > 0 { + groupAttributes["sub_groups"] = schema.ListNestedAttribute{ + Computed: true, + Description: fmt.Sprintf("Children of the parent group. Maximal depth of subgroups is %d.", maxSupportedGroupNesting), + NestedObject: schema.NestedAttributeObject{ + Attributes: d.groupSchemaAttributes(remainingNesting - 1), + }, + } + } + + return groupAttributes +} + +func (d *groupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "IAM Group data source.", + Attributes: d.groupSchemaAttributes(maxSupportedGroupNesting + 1), + } +} + +func (d *groupDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_group" +} + +func (d *groupDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + d.meta = meta.Must(req.ProviderData) +} + +func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Group DataSource Read") + + var data groupModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + + client := inst.Client(d.meta) + + getGroupResp, err := client.GetGroup(ctx, iam.GetGroupRequest{ + GroupID: data.GroupID.ValueInt64(), + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError("Fetching IAM group failed", err.Error()) + return + } + + groupData, diags := d.convertGroupData(getGroupResp, data, maxSupportedGroupNesting) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &groupData)...) +} + +// convertGroupData converts the response from the IAM client into the groupDataSourceModel structure +func (d *groupDataSource) convertGroupData(group *iam.Group, data groupModel, remainingNesting int) (groupModel, diag.Diagnostics) { + data.GroupName = types.StringValue(group.GroupName) + data.CreatedBy = types.StringValue(group.CreatedBy) + data.CreatedDate = types.StringValue(date.FormatRFC3339Nano(group.CreatedDate)) + data.ModifiedBy = types.StringValue(group.ModifiedBy) + data.ModifiedDate = types.StringValue(date.FormatRFC3339Nano(group.ModifiedDate)) + data.ParentGroupID = types.Int64Value(group.ParentGroupID) + data.GroupID = types.Int64Value(group.GroupID) + + if group.Actions != nil { + data.Actions = &actions{ + Delete: types.BoolValue(group.Actions.Delete), + Edit: types.BoolValue(group.Actions.Edit), + } + } + + var subGroups []groupModel + if remainingNesting > 1 { + for _, subGroup := range group.SubGroups { + subGroupData, diags := d.convertGroupData(&subGroup, groupModel{}, remainingNesting-1) + if diags.HasError() { + return groupModel{}, diags + } + subGroups = append(subGroups, subGroupData) + } + data.SubGroups = subGroups + } else if remainingNesting <= 1 && len(group.SubGroups) > 0 { + return groupModel{}, diag.Diagnostics{diag.NewErrorDiagnostic( + "unsupported subgroup depth", + fmt.Sprintf("Subgroup %d contains more subgroups and exceeds the total supported limit of nesting %d.", group.GroupID, maxSupportedGroupNesting), + )} + } + + return data, nil +} diff --git a/pkg/providers/iam/data_akamai_iam_group_test.go b/pkg/providers/iam/data_akamai_iam_group_test.go new file mode 100644 index 000000000..520adf006 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_group_test.go @@ -0,0 +1,163 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestGroupDataSource(t *testing.T) { + mockGetGroup := func(client *iam.Mock, group *iam.Group, times int) *mock.Call { + return client.On("GetGroup", mock.Anything, iam.GetGroupRequest{ + GroupID: 123, + Actions: true, + }).Return(group, nil).Times(times) + } + + tests := map[string]struct { + init func(mock *iam.Mock) + expectedError *regexp.Regexp + expectedChecks resource.TestCheckFunc + givenTF string + }{ + "normal case - all fields": { + init: func(client *iam.Mock) { + group := &iam.Group{ + GroupID: 123, + GroupName: "parent_group", + CreatedBy: "DevUser", + CreatedDate: test.NewTimeFromString(t, "2024-05-28T06:58:26Z"), + ModifiedBy: "TestUser", + ModifiedDate: test.NewTimeFromString(t, "2024-05-28T06:58:27Z"), + ParentGroupID: 0, + Actions: &iam.GroupActions{ + Delete: true, + Edit: true, + }, + SubGroups: []iam.Group{}, + } + mockGetGroup(client, group, 3) + }, + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_id", "123"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_name", "parent_group"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "created_by", "DevUser"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "modified_by", "TestUser"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "parent_group_id", "0"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "actions.edit", "true"), + ), + givenTF: "valid.tf", + }, + "normal case - nested subgroups": { + init: func(client *iam.Mock) { + group := &iam.Group{ + GroupID: 123, + GroupName: "parent_group", + CreatedBy: "DevUser", + CreatedDate: test.NewTimeFromString(t, "2024-05-28T06:58:26Z"), + ModifiedBy: "TestUser", + ModifiedDate: test.NewTimeFromString(t, "2024-05-28T06:58:27Z"), + ParentGroupID: 0, + SubGroups: []iam.Group{ + { + GroupID: 456, + GroupName: "child_group", + CreatedBy: "creator_child", + ModifiedBy: "modifier_child", + ParentGroupID: 123, + }, + }, + } + mockGetGroup(client, group, 3) + }, + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_id", "123"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_name", "parent_group"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.group_id", "456"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.group_name", "child_group"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.created_by", "creator_child"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.modified_by", "modifier_child"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.parent_group_id", "123"), + ), + givenTF: "valid.tf", + }, + "error - too deep nesting": { + init: func(client *iam.Mock) { + group := &iam.Group{ + GroupID: 123, + GroupName: "root_group", + CreatedBy: "DevUser", + ModifiedBy: "TestUser", + ParentGroupID: 0, + SubGroups: generateDeepSubGroups(51), + } + mockGetGroup(client, group, 1) + }, + expectedError: regexp.MustCompile("unsupported subgroup depth"), + givenTF: "valid.tf", + }, + "api failed": { + init: func(client *iam.Mock) { + client.On("GetGroup", mock.Anything, iam.GetGroupRequest{ + GroupID: 123, + Actions: true, + }).Return(nil, errors.New("api failed")).Once() + }, + expectedError: regexp.MustCompile("api failed"), + givenTF: "valid.tf", + }, + "missing group_id": { + init: func(client *iam.Mock) {}, + expectedError: regexp.MustCompile("The argument \"group_id\" is required, but no definition was found."), + givenTF: "missing_group_id.tf", + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + tc.init(client) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestDataGroup/%s", tc.givenTF), + Check: tc.expectedChecks, + ExpectError: tc.expectedError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } + +} + +func generateDeepSubGroups(depth int64) []iam.Group { + if depth == 0 { + return nil + } + + return []iam.Group{ + { + GroupID: depth, + GroupName: fmt.Sprintf("group%d", depth), + CreatedBy: "DevUser", + ModifiedBy: "TestUser", + ParentGroupID: depth - 1, + SubGroups: generateDeepSubGroups(depth - 1), + }, + } +} diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index df7dc79e8..45152aa5e 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -4,72 +4,72 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Resource schema for akamai_iam_groups data source func dataSourceIAMGroups() *schema.Resource { return &schema.Resource{ - Description: `List all groups in which you have a scope of "admin" for the current account and contract`, + Description: `List all groups in which you have a scope of "admin" for the current account and contract.`, ReadContext: dataIAMGroupsRead, Schema: map[string]*schema.Schema{ - "groups": nestedGroupsSchema(50), // Can handle groups with nesting up to 50 levels deep + "groups": nestedGroupsSchema(maxSupportedGroupNesting), // Can handle groups with nesting up to 50 levels deep }, } } // nestedGroupsSchema builds a nested groups schema to the given depth func nestedGroupsSchema(depth int) *schema.Schema { - schem := map[string]*schema.Schema{ + nestedSchema := map[string]*schema.Schema{ "name": { Type: schema.TypeString, - Description: "The group's name", + Description: "The group's name.", Computed: true, }, "group_id": { Type: schema.TypeString, - Description: "A unique identifier for each group", + Description: "A unique identifier for each group.", Computed: true, }, "parent_group_id": { Type: schema.TypeString, - Description: "Identifies the parent group to which a group belongs", + Description: "Identifies the parent group to which a group belongs.", Computed: true, }, "time_created": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the group was originally created", + Description: "ISO 8601 timestamp indicating when the group was originally created.", Computed: true, }, "time_modified": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the group was last updated", + Description: "ISO 8601 timestamp indicating when the group was last updated.", Computed: true, }, "modified_by": { Type: schema.TypeString, - Description: "The username or email of the last person to edit the group", + Description: "The username or email of the last person to edit the group.", Computed: true, }, "created_by": { Type: schema.TypeString, - Description: "The user name or email of the person who created the group", + Description: "The user name or email of the person who created the group.", Computed: true, }, } if depth > 1 { - schem["sub_groups"] = nestedGroupsSchema(depth - 1) + nestedSchema["sub_groups"] = nestedGroupsSchema(depth - 1) } return &schema.Schema{ Type: schema.TypeSet, Computed: true, - Elem: &schema.Resource{Schema: schem}, + Elem: &schema.Resource{Schema: nestedSchema}, } } @@ -115,8 +115,8 @@ func groupToState(g iam.Group) map[string]interface{} { m["name"] = g.GroupName m["group_id"] = strconv.FormatInt(g.GroupID, 10) m["parent_group_id"] = strconv.FormatInt(g.ParentGroupID, 10) - m["time_created"] = g.CreatedDate - m["time_modified"] = g.ModifiedDate + m["time_created"] = date.FormatRFC3339Nano(g.CreatedDate) + m["time_modified"] = date.FormatRFC3339Nano(g.ModifiedDate) m["modified_by"] = g.ModifiedBy m["created_by"] = g.CreatedBy diff --git a/pkg/providers/iam/data_akamai_iam_groups_test.go b/pkg/providers/iam/data_akamai_iam_groups_test.go index 1d788b168..da4461ba1 100644 --- a/pkg/providers/iam/data_akamai_iam_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_groups_test.go @@ -5,7 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -26,11 +27,11 @@ func TestDataGroups(t *testing.T) { { req := iam.ListGroupsRequest{} - group1 := makeGroup("test group 1", 101, 100, nil, nil) - group4 := makeGroup("test group 4", 104, 103, nil, nil) - group5 := makeGroup("test group 5", 105, 102, nil, nil) - group3 := makeGroup("test group 3", 103, 102, []iam.Group{group4}, nil) - group2 := makeGroup("test group 2", 102, 100, []iam.Group{group3, group5}, nil) + group1 := makeGroup(t, "test group 1", 101, 100, nil, nil) + group4 := makeGroup(t, "test group 4", 104, 103, nil, nil) + group5 := makeGroup(t, "test group 5", 105, 102, nil, nil) + group3 := makeGroup(t, "test group 3", 103, 102, []iam.Group{group4}, nil) + group2 := makeGroup(t, "test group 2", 102, 100, []iam.Group{group3, group5}, nil) res := []iam.Group{group1, group2, group3} client.On("ListGroups", mock.Anything, req).Return(res, nil) @@ -117,16 +118,16 @@ func groupsNestingDepth(res *schema.Resource) int { } // Convenience method to make a group -func makeGroup(Name string, GroupID, PGroupID int64, SubGroups []iam.Group, Actions *iam.GroupActions) iam.Group { +func makeGroup(t *testing.T, Name string, GroupID, PGroupID int64, SubGroups []iam.Group, Actions *iam.GroupActions) iam.Group { return iam.Group{ Actions: Actions, GroupName: Name, GroupID: GroupID, ParentGroupID: PGroupID, CreatedBy: "creator@akamai.net", - CreatedDate: "2020-01-01T00:00:00Z", + CreatedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), ModifiedBy: "modifier@akamai.net", - ModifiedDate: "2020-01-01T00:00:00Z", + ModifiedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), SubGroups: SubGroups, } } diff --git a/pkg/providers/iam/data_akamai_iam_password_policy.go b/pkg/providers/iam/data_akamai_iam_password_policy.go new file mode 100644 index 000000000..360613d83 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_password_policy.go @@ -0,0 +1,131 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &passwordPolicyDataSource{} + _ datasource.DataSourceWithConfigure = &passwordPolicyDataSource{} +) + +type ( + passwordPolicyDataSource struct { + meta meta.Meta + } + + passwordPolicyModel struct { + PwClass types.String `tfsdk:"pw_class"` + CaseDif types.Int64 `tfsdk:"case_dif"` + MaxRepeating types.Int64 `tfsdk:"max_repeating"` + MinDigits types.Int64 `tfsdk:"min_digits"` + MinLength types.Int64 `tfsdk:"min_length"` + MinLetters types.Int64 `tfsdk:"min_letters"` + MinNonAlpha types.Int64 `tfsdk:"min_non_alpha"` + MinReuse types.Int64 `tfsdk:"min_reuse"` + RotateFrequency types.Int64 `tfsdk:"rotate_frequency"` + } +) + +// NewPasswordPolicyDataSource returns a new password policy data source. +func NewPasswordPolicyDataSource() datasource.DataSource { + return &passwordPolicyDataSource{} +} + +func (d *passwordPolicyDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_password_policy" +} + +func (d *passwordPolicyDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *passwordPolicyDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management password policy.", + Attributes: map[string]schema.Attribute{ + "pw_class": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for a password policy.", + }, + "min_length": schema.Int64Attribute{ + Computed: true, + Description: "The minimum length of a password.", + }, + "min_letters": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of letters in a password.", + }, + "min_digits": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of digits in a password.", + }, + "case_dif": schema.Int64Attribute{ + Computed: true, + Description: "The number of characters that, at minimum, need to be in a different case.", + }, + "min_non_alpha": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of non-alphabetic characters in a password.", + }, + "max_repeating": schema.Int64Attribute{ + Computed: true, + Description: "The maximum allowed number of repeating characters.", + }, + "min_reuse": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of previous passwords to retain to prevent password reuse.", + }, + "rotate_frequency": schema.Int64Attribute{ + Computed: true, + Description: "The number of days a password is valid.", + }, + }, + } +} + +func (d *passwordPolicyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Password Policy DataSource Read") + + var data passwordPolicyModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + passwordPolicyResponse, err := client.GetPasswordPolicy(ctx) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Password Policy Failed", err.Error()) + return + } + + data.PwClass = types.StringValue(passwordPolicyResponse.PwClass) + data.CaseDif = types.Int64Value(passwordPolicyResponse.CaseDiff) + data.MaxRepeating = types.Int64Value(passwordPolicyResponse.MaxRepeating) + data.MinDigits = types.Int64Value(passwordPolicyResponse.MinDigits) + data.MinLength = types.Int64Value(passwordPolicyResponse.MinLength) + data.MinLetters = types.Int64Value(passwordPolicyResponse.MinLetters) + data.MinNonAlpha = types.Int64Value(passwordPolicyResponse.MinNonAlpha) + data.MinReuse = types.Int64Value(passwordPolicyResponse.MinReuse) + data.RotateFrequency = types.Int64Value(passwordPolicyResponse.RotateFrequency) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/iam/data_akamai_iam_password_policy_test.go b/pkg/providers/iam/data_akamai_iam_password_policy_test.go new file mode 100644 index 000000000..3cf73053a --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_password_policy_test.go @@ -0,0 +1,90 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestPasswordPolicy(t *testing.T) { + expectGetPasswordPolicy := func(client *iam.Mock, timesToRun int) { + passwordPolicyResponse := iam.GetPasswordPolicyResponse{ + CaseDiff: 0, + MaxRepeating: 2, + MinDigits: 1, + MinLength: 8, + MinLetters: 1, + MinNonAlpha: 0, + MinReuse: 4, + PwClass: "aka90", + RotateFrequency: 90, + } + client.On("GetPasswordPolicy", mock.Anything).Return(&passwordPolicyResponse, nil).Times(timesToRun) + } + + expectGetPasswordPolicyWithError := func(client *iam.Mock, timesToRun int) { + client.On("GetPasswordPolicy", mock.Anything).Return(nil, fmt.Errorf("get password policy failed")).Times(timesToRun) + } + + tests := map[string]struct { + init func(*iam.Mock) + error *regexp.Regexp + }{ + "happy path": { + init: func(m *iam.Mock) { + expectGetPasswordPolicy(m, 3) + }, + }, + "error listing password policy": { + init: func(m *iam.Mock) { + expectGetPasswordPolicyWithError(m, 1) + }, + error: regexp.MustCompile("get password policy failed"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(client) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestDataPasswordPolicy/default.tf"), + Check: checkPasswordPolicyAttrs(), + ExpectError: tc.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkPasswordPolicyAttrs() resource.TestCheckFunc { + var checkFuncs []resource.TestCheckFunc + + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "pw_class", "aka90")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "case_dif", "0")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "max_repeating", "2")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_digits", "1")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_length", "8")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_letters", "1")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_non_alpha", "0")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_reuse", "4")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "rotate_frequency", "90")) + + return resource.ComposeAggregateTestCheckFunc(checkFuncs...) +} diff --git a/pkg/providers/iam/data_akamai_iam_property_users.go b/pkg/providers/iam/data_akamai_iam_property_users.go new file mode 100644 index 000000000..d969ef3b8 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_property_users.go @@ -0,0 +1,172 @@ +package iam + +import ( + "context" + "fmt" + "regexp" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &propertyUsersDataSource{} + _ datasource.DataSourceWithConfigure = &propertyUsersDataSource{} +) + +type ( + propertyUsersDataSource struct { + meta meta.Meta + } + + propertyUsersModel struct { + AssetID types.String `tfsdk:"asset_id"` + UserType types.String `tfsdk:"user_type"` + Users []propertyUser `tfsdk:"users"` + } + + propertyUser struct { + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + UIUserName types.String `tfsdk:"ui_user_name"` + } +) + +// NewPropertyUsersDataSource returns a new iam property users data source. +func NewPropertyUsersDataSource() datasource.DataSource { + return &propertyUsersDataSource{} +} + +func (d *propertyUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_property_users" +} + +func (d *propertyUsersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *propertyUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management property users data source. Lists users for " + + "property or include.", + Attributes: map[string]schema.Attribute{ + "asset_id": schema.StringAttribute{ + Required: true, + Description: "IAM identifier of the property or include. The optional aid_ prefix " + + "is allowed.", + Validators: []validator.String{stringvalidator.RegexMatches( + regexp.MustCompile(`^(aid_)?\d+$`), + `must be a number with the optional "aid_" prefix`)}, + }, + "user_type": schema.StringAttribute{ + Optional: true, + Description: "Filters the list based on users' access to the property.", + Validators: []validator.String{stringvalidator.OneOf( + string(iam.PropertyUserTypeAll), + string(iam.PropertyUserTypeBlocked), + string(iam.PropertyUserTypeAssigned))}, + }, + "users": schema.ListNestedAttribute{ + Computed: true, + Description: "List of users accessing the property.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a property is blocked.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds " + + "to their Control Center profile or client ID. Also known " + + "as a contactId in other APIs.", + }, + "ui_user_name": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + }, + }, + }, + }, + } +} + +func (d *propertyUsersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Property Users DataSource Read") + + var data propertyUsersModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + id, err := str.GetIntID(data.AssetID.ValueString(), "aid_") + if err != nil { + resp.Diagnostics.AddError( + "Unable to read IAM Property Users DataSource", + fmt.Sprintf("Error occurred while parsing property id: %s. Error: %s", + data.AssetID.ValueString(), err.Error())) + return + } + + client := inst.Client(d.meta) + + users, err := client.ListUsersForProperty(ctx, iam.ListUsersForPropertyRequest{ + PropertyID: int64(id), + UserType: iam.PropertyUserType(data.UserType.ValueString()), + }) + if err != nil { + resp.Diagnostics.AddError( + "Unable to read IAM Property Users DataSource", + fmt.Sprintf( + "Error occurred while listing users for property: %s (user type: %s). Error: %s", + data.AssetID.ValueString(), data.UserType.ValueString(), err.Error())) + return + } + + for _, user := range users { + data.Users = append(data.Users, newPropertyUser(user)) + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func newPropertyUser(user iam.UsersForProperty) propertyUser { + return propertyUser{ + FirstName: types.StringValue(user.FirstName), + LastName: types.StringValue(user.LastName), + IsBlocked: types.BoolValue(user.IsBlocked), + UIIdentityID: types.StringValue(user.UIIdentityID), + UIUserName: types.StringValue(user.UIUserName), + } +} diff --git a/pkg/providers/iam/data_akamai_iam_property_users_test.go b/pkg/providers/iam/data_akamai_iam_property_users_test.go new file mode 100644 index 000000000..71fee6f67 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_property_users_test.go @@ -0,0 +1,204 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestDataPropertyUsers(t *testing.T) { + userJohn := iam.UsersForProperty{ + FirstName: "John", + LastName: "Smith", + IsBlocked: false, + UIIdentityID: "B-C-IP9IND", + UIUserName: "josmith", + } + + userJane := iam.UsersForProperty{ + FirstName: "Jane", + LastName: "Smith", + IsBlocked: false, + UIIdentityID: "B-C-AB1CDE", + UIUserName: "jasmith", + } + + blockedUserJudy := iam.UsersForProperty{ + FirstName: "Judy", + LastName: "Smith", + IsBlocked: true, + UIIdentityID: "B-C-FG2HIJ", + UIUserName: "jusmith", + } + + mockListUsersForProperty := func(iamMock *iam.Mock, req iam.ListUsersForPropertyRequest, + users ...iam.UsersForProperty) { + iamMock.On("ListUsersForProperty", mock.Anything, req). + Return((iam.ListUsersForPropertyResponse)(users), nil).Times(3) + } + + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock) + check resource.TestCheckFunc + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataPropertyUsers/basic.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + mockListUsersForProperty(iamMock, req, userJohn, userJane, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckNoResourceAttr("data.akamai_iam_property_users.test", "user_type"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "3"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.last_name", "Smith"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.1.is_blocked", "false"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.2.ui_identity_id", "B-C-FG2HIJ"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.2.ui_user_name", "jusmith")), + }, + "handling aid prefix": { + configPath: "testdata/TestDataPropertyUsers/aid_prefix.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + mockListUsersForProperty(iamMock, req, userJohn, userJane, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "aid_12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "3"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John")), + }, + "user filtering - two users assigned": { + configPath: "testdata/TestDataPropertyUsers/user_type_assigned.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + UserType: "assigned", + } + mockListUsersForProperty(iamMock, req, userJohn, userJane) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "user_type", "assigned"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "2"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.is_blocked", "false"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.1.first_name", "Jane"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.1.is_blocked", "false")), + }, + "user filtering - one user blocked": { + configPath: "testdata/TestDataPropertyUsers/user_type_blocked.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + UserType: "blocked", + } + mockListUsersForProperty(iamMock, req, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "user_type", "blocked"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "1"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "Judy"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.is_blocked", "true")), + }, + "user filtering - all users returned for all": { + configPath: "testdata/TestDataPropertyUsers/user_type_all.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + UserType: "all", + } + mockListUsersForProperty(iamMock, req, userJohn, userJane, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "user_type", "all"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "3"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.2.first_name", "Judy")), + }, + "no users returned": { + configPath: "testdata/TestDataPropertyUsers/basic.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + mockListUsersForProperty(iamMock, req) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckNoResourceAttr("data.akamai_iam_property_users.test", "user_type"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "0")), + }, + "missing property id": { + configPath: "testdata/TestDataPropertyUsers/missing_asset_id.tf", + error: regexp.MustCompile(`The argument "asset_id" is required, but no definition was found`), + }, + "empty property id": { + configPath: "testdata/TestDataPropertyUsers/empty_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "property id is not a number": { + configPath: "testdata/TestDataPropertyUsers/nan_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "property id has invalid prefix": { + configPath: "testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "property id has trailing text": { + configPath: "testdata/TestDataPropertyUsers/trailing_text_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "bad user type": { + configPath: "testdata/TestDataPropertyUsers/bad_user_type.tf", + error: regexp.MustCompile(`Attribute user_type value must be one of.+all.+blocked.+assigned`), + }, + "edgegrid error": { + configPath: "testdata/TestDataPropertyUsers/basic.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + iamMock.On("ListUsersForProperty", mock.Anything, req). + Return(nil, fmt.Errorf("list users failed")) + }, + error: regexp.MustCompile("list users failed"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + iamMock := iam.Mock{} + if tc.init != nil { + tc.init(t, &iamMock) + } + + useClient(&iamMock, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: tc.check, + ExpectError: tc.error, + }, + }, + }) + }) + iamMock.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_role.go b/pkg/providers/iam/data_akamai_iam_role.go new file mode 100644 index 000000000..2b29268b6 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_role.go @@ -0,0 +1,256 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &roleDataSource{} + _ datasource.DataSourceWithConfigure = &roleDataSource{} +) + +// NewRoleDataSource returns all the details for a role. +func NewRoleDataSource() datasource.DataSource { + return &roleDataSource{} +} + +type ( + roleDataSource struct { + meta meta.Meta + } + + roleModel struct { + RoleID types.Int64 `tfsdk:"role_id"` + Actions *actions `tfsdk:"actions"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + RoleDescription types.String `tfsdk:"role_description"` + RoleName types.String `tfsdk:"role_name"` + Type types.String `tfsdk:"type"` + GrantedRoles []grantedRole `tfsdk:"granted_roles"` + Users []user `tfsdk:"users"` + } + + grantedRole struct { + GrantedRoleID types.Int64 `tfsdk:"granted_role_id"` + GrantedRoleName types.String `tfsdk:"granted_role_name"` + GrantedRoleDescription types.String `tfsdk:"granted_role_description"` + } + + user struct { + AccountID types.String `tfsdk:"account_id"` + Email types.String `tfsdk:"email"` + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + LastLoginDate types.String `tfsdk:"last_login_date"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + } +) + +func (d *roleDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Role data source.", + Attributes: map[string]schema.Attribute{ + "role_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each role.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the granted role.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the granted role was originally created.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the granted role.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the granted role was last updated.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "type": schema.StringAttribute{ + Computed: true, + Description: "Whether it's a standard role defined by Akamai or a custom role created by a user of your account. You can't modify or delete a standard role.", + Validators: []validator.String{ + stringvalidator.OneOf("standard", "custom"), + }, + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the role.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can remove the role.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can modify the role.", + }, + }, + }, + "granted_roles": schema.ListNestedAttribute{ + Computed: true, + Description: "Granted roles for the account.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "granted_role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "granted_role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each granted role.", + }, + "granted_role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the granted role.", + }, + }, + }, + }, + "users": schema.ListNestedAttribute{ + Computed: true, + Description: "Users on the account who share the same role.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each account.", + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + }, + }, + }, + }, + } +} + +func (d *roleDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_role" +} + +func (d *roleDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + d.meta = meta.Must(req.ProviderData) +} + +func (d *roleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Role DataSource Read") + + var data roleModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + + client := inst.Client(d.meta) + + getRoleResp, err := client.GetRole(ctx, iam.GetRoleRequest{ + ID: data.RoleID.ValueInt64(), + Actions: true, + GrantedRoles: true, + Users: true, + }) + if err != nil { + resp.Diagnostics.AddError("fetching iam role failed", err.Error()) + return + } + + data.setAttributes(getRoleResp) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (m *roleModel) setAttributes(role *iam.Role) { + + m.CreatedBy = types.StringValue(role.CreatedBy) + m.CreatedDate = types.StringValue(date.FormatRFC3339Nano(role.CreatedDate)) + m.ModifiedBy = types.StringValue(role.ModifiedBy) + m.ModifiedDate = types.StringValue(date.FormatRFC3339Nano(role.ModifiedDate)) + m.RoleName = types.StringValue(role.RoleName) + m.RoleDescription = types.StringValue(role.RoleDescription) + m.Type = types.StringValue(string(role.RoleType)) + + if role.Actions != nil { + m.Actions = &actions{ + Delete: types.BoolValue(role.Actions.Delete), + Edit: types.BoolValue(role.Actions.Edit), + } + } + + for _, r := range role.GrantedRoles { + grantedRoleObject := grantedRole{ + GrantedRoleID: types.Int64Value(r.RoleID), + GrantedRoleName: types.StringValue(r.RoleName), + GrantedRoleDescription: types.StringValue(r.Description), + } + m.GrantedRoles = append(m.GrantedRoles, grantedRoleObject) + } + for _, u := range role.Users { + userObject := user{ + AccountID: types.StringValue(u.AccountID), + Email: types.StringValue(u.Email), + FirstName: types.StringValue(u.FirstName), + LastName: types.StringValue(u.LastName), + LastLoginDate: types.StringValue(u.LastLoginDate.String()), + UIIdentityID: types.StringValue(u.UIIdentityID), + } + + m.Users = append(m.Users, userObject) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_role_test.go b/pkg/providers/iam/data_akamai_iam_role_test.go new file mode 100644 index 000000000..7866ee9c2 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_role_test.go @@ -0,0 +1,144 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestRoleDataSource(t *testing.T) { + createdDate := time.Date(2017, time.July, 27, 18, 11, 25, 0, time.UTC) + modifiedDate := time.Date(2017, time.August, 27, 18, 11, 25, 0, time.UTC) + + tests := map[string]struct { + givenTF string + init func(*iam.Mock) + expectedAttributes map[string]string + expectedMissingAttributes []string + expectError *regexp.Regexp + }{ + "happy path - role is returned": { + givenTF: "valid.tf", + init: func(m *iam.Mock) { + m.On("GetRole", mock.Anything, iam.GetRoleRequest{ + ID: 12345, + Actions: true, + GrantedRoles: true, + Users: true, + }).Return(&iam.Role{ + RoleID: int64(12345), + RoleName: "example-role", + RoleDescription: "This is an example role.", + CreatedBy: "user@example.com", + CreatedDate: createdDate, + ModifiedBy: "admin@example.com", + ModifiedDate: modifiedDate, + RoleType: "custom", + Actions: &iam.RoleAction{ + Delete: true, + Edit: true, + }, + }, nil).Times(3) + }, + expectedAttributes: map[string]string{ + "role_id": "12345", + "role_name": "example-role", + "role_description": "This is an example role.", + "created_by": "user@example.com", + "created_date": "2017-07-27T18:11:25Z", + "modified_by": "admin@example.com", + "modified_date": "2017-08-27T18:11:25Z", + "type": "custom", + "actions.delete": "true", + "actions.edit": "true", + }, + expectError: nil, + }, + "happy path - role is returned, without dates": { + givenTF: "valid.tf", + init: func(m *iam.Mock) { + m.On("GetRole", mock.Anything, iam.GetRoleRequest{ + ID: 12345, + Actions: true, + GrantedRoles: true, + Users: true, + }).Return(&iam.Role{ + RoleID: int64(12345), + RoleName: "example-role", + RoleDescription: "This is an example role.", + CreatedBy: "user@example.com", + ModifiedBy: "admin@example.com", + RoleType: "custom", + Actions: &iam.RoleAction{ + Delete: true, + Edit: true, + }, + }, nil).Times(3) + }, + expectedAttributes: map[string]string{ + "role_id": "12345", + "role_name": "example-role", + "role_description": "This is an example role.", + "created_by": "user@example.com", + "created_date": "", + "modified_by": "admin@example.com", + "modified_date": "", + "type": "custom", + "actions.delete": "true", + "actions.edit": "true", + }, + expectError: nil, + }, + "error response from API": { + givenTF: "valid.tf", + init: func(m *iam.Mock) { + m.On("GetRole", mock.Anything, iam.GetRoleRequest{ + ID: 12345, + Actions: true, + GrantedRoles: true, + Users: true, + }).Return(nil, fmt.Errorf("API error")).Once() + }, + expectError: regexp.MustCompile("API error"), + }, + "missing required argument role_id": { + givenTF: "missing_role_id.tf", + expectError: regexp.MustCompile(`The argument "role_id" is required, but no definition was found`), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + + if tc.init != nil { + tc.init(client) + } + var checkFuncs []resource.TestCheckFunc + for k, v := range tc.expectedAttributes { + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_role.test", k, v)) + } + for _, v := range tc.expectedMissingAttributes { + checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("data.akamai_iam_role.test", v)) + } + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataRole/%s", tc.givenTF)), + Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), + ExpectError: tc.expectError, + }}, + }) + }) + client.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_roles.go b/pkg/providers/iam/data_akamai_iam_roles.go index a849239a5..76f985bb5 100644 --- a/pkg/providers/iam/data_akamai_iam_roles.go +++ b/pkg/providers/iam/data_akamai_iam_roles.go @@ -4,8 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -13,7 +14,7 @@ import ( func dataSourceIAMRoles() *schema.Resource { return &schema.Resource{ - Description: "Get roles for the current account and contract", + Description: "Get roles for the current account and contract.", ReadContext: dataIAMRolesRead, Schema: map[string]*schema.Schema{ // outputs @@ -24,42 +25,42 @@ func dataSourceIAMRoles() *schema.Resource { Schema: map[string]*schema.Schema{ "role_id": { Type: schema.TypeString, - Description: "A unique identifier for each role", + Description: "A unique identifier for each role.", Computed: true, }, "name": { Type: schema.TypeString, - Description: "The role's name", + Description: "The role's name.", Computed: true, }, "description": { Type: schema.TypeString, - Description: "The role's description", + Description: "The role's description.", Computed: true, }, "type": { Type: schema.TypeString, - Description: "Whether the role is a standard role or a custom role", + Description: "Whether the role is a standard role or a custom role.", Computed: true, }, "time_created": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the role was originally created", + Description: "ISO 8601 timestamp indicating when the role was originally created.", Computed: true, }, "time_modified": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the role was last updated", + Description: "ISO 8601 timestamp indicating when the role was last updated.", Computed: true, }, "modified_by": { Type: schema.TypeString, - Description: "The username or email of the last person to edit the role", + Description: "The username or email of the last person to edit the role.", Computed: true, }, "created_by": { Type: schema.TypeString, - Description: "The user name or email of the person who created the role", + Description: "The user name or email of the person who created the role.", Computed: true, }, }, @@ -109,8 +110,8 @@ func roleToState(r iam.Role) map[string]interface{} { m["name"] = r.RoleName m["description"] = r.RoleDescription m["type"] = string(r.RoleType) - m["time_created"] = r.CreatedDate - m["time_modified"] = r.ModifiedDate + m["time_created"] = date.FormatRFC3339Nano(r.CreatedDate) + m["time_modified"] = date.FormatRFC3339Nano(r.ModifiedDate) m["modified_by"] = r.ModifiedBy m["created_by"] = r.CreatedBy diff --git a/pkg/providers/iam/data_akamai_iam_roles_test.go b/pkg/providers/iam/data_akamai_iam_roles_test.go index d181214ca..dd4e0309c 100644 --- a/pkg/providers/iam/data_akamai_iam_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_roles_test.go @@ -5,7 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -21,9 +22,9 @@ func TestDataRoles(t *testing.T) { RoleDescription: "role description", RoleType: iam.RoleTypeStandard, CreatedBy: "creator@akamai.net", - CreatedDate: "2020-01-01T00:00:00Z", + CreatedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), ModifiedBy: "modifier@akamai.net", - ModifiedDate: "2020-01-01T00:00:00Z", + ModifiedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), }} req := iam.ListRolesRequest{} @@ -57,6 +58,49 @@ func TestDataRoles(t *testing.T) { client.AssertExpectations(t) }) + t.Run("happy path/no dates", func(t *testing.T) { + client := &iam.Mock{} + + roles := []iam.Role{{ + RoleName: "test role name", + RoleID: 100, + RoleDescription: "role description", + RoleType: iam.RoleTypeStandard, + CreatedBy: "creator@akamai.net", + ModifiedBy: "modifier@akamai.net", + }} + + req := iam.ListRolesRequest{} + + client.Test(testutils.TattleT{T: t}) + client.On("ListRoles", mock.Anything, req).Return(roles, nil) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestDataRoles/happy_path/no_args.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrSet("data.akamai_iam_roles.test", "id"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.name", "test role name"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.role_id", "100"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.description", "role description"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.type", string(iam.RoleTypeStandard)), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.time_created", ""), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.time_modified", ""), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.created_by", "creator@akamai.net"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.modified_by", "modifier@akamai.net"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + t.Run("fail path", func(t *testing.T) { req := iam.ListRolesRequest{} diff --git a/pkg/providers/iam/data_akamai_iam_states.go b/pkg/providers/iam/data_akamai_iam_states.go index 12b3342a3..bf4220cef 100644 --- a/pkg/providers/iam/data_akamai_iam_states.go +++ b/pkg/providers/iam/data_akamai_iam_states.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -12,18 +12,18 @@ import ( func dataSourceIAMStates() *schema.Resource { return &schema.Resource{ - Description: "List US states or Canadian provinces", + Description: "List US states or Canadian provinces.", ReadContext: dataIAMStatesRead, Schema: map[string]*schema.Schema{ "country": { Type: schema.TypeString, Required: true, - Description: "Specifies a US state or Canadian province", + Description: "Specifies a US state or Canadian province.", }, "states": { Type: schema.TypeSet, Computed: true, - Description: "Supported states", + Description: "Supported states.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_states_test.go b/pkg/providers/iam/data_akamai_iam_states_test.go index e9f2323c0..b2af348f9 100644 --- a/pkg/providers/iam/data_akamai_iam_states_test.go +++ b/pkg/providers/iam/data_akamai_iam_states_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_supported_langs.go b/pkg/providers/iam/data_akamai_iam_supported_langs.go index cbe1c984f..1a0e253b5 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,13 +11,13 @@ import ( func dataSourceIAMLanguages() *schema.Resource { return &schema.Resource{ - Description: "List all the possible languages Akamai supports", + Description: "List all the possible languages Akamai supports.", ReadContext: dataIAMLanguagesRead, Schema: map[string]*schema.Schema{ "languages": { Type: schema.TypeSet, Computed: true, - Description: "Languages supported by Akamai", + Description: "Languages supported by Akamai.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_supported_langs_test.go b/pkg/providers/iam/data_akamai_iam_supported_langs_test.go index 1ec1a02b5..cc88fda18 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs_test.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_timeout_policies.go b/pkg/providers/iam/data_akamai_iam_timeout_policies.go index 3fa7b1ee8..e2e26fa94 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -11,13 +11,13 @@ import ( func dataSourceIAMTimeoutPolicies() *schema.Resource { return &schema.Resource{ - Description: "Lists all session timeout policies Akamai supports", + Description: "Lists all session timeout policies Akamai supports.", ReadContext: dataIAMTimeoutPoliciesRead, Schema: map[string]*schema.Schema{ "policies": { Type: schema.TypeMap, Computed: true, - Description: "Session timeout policies", + Description: "Session timeout policies.", Elem: &schema.Schema{Type: schema.TypeInt}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go b/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go index 03ecacdc8..14a8c07a7 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_timezones.go b/pkg/providers/iam/data_akamai_iam_timezones.go index c5281e1b8..bcada811e 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones.go +++ b/pkg/providers/iam/data_akamai_iam_timezones.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -13,7 +13,7 @@ import ( func dataSourceIAMTimezones() *schema.Resource { return &schema.Resource{ - Description: "List all the possible time zones Akamai supports", + Description: "List all the possible time zones Akamai supports.", ReadContext: dataIAMTimezonesRead, Schema: map[string]*schema.Schema{ "timezones": { @@ -23,22 +23,22 @@ func dataSourceIAMTimezones() *schema.Resource { Schema: map[string]*schema.Schema{ "timezone": { Type: schema.TypeString, - Description: "The time zone ID", + Description: "The time zone ID.", Computed: true, }, "description": { Type: schema.TypeString, - Description: "The description of a time zone, including the GMT +/-", + Description: "The description of a time zone, including the GMT +/-.", Computed: true, }, "offset": { Type: schema.TypeString, - Description: "The time zone offset from GMT", + Description: "The time zone offset from GMT.", Computed: true, }, "posix": { Type: schema.TypeString, - Description: "The time zone posix", + Description: "The time zone posix.", Computed: true, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_timezones_test.go b/pkg/providers/iam/data_akamai_iam_timezones_test.go index da5316c72..0b65b60e0 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones_test.go +++ b/pkg/providers/iam/data_akamai_iam_timezones_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_user.go b/pkg/providers/iam/data_akamai_iam_user.go new file mode 100644 index 000000000..66d8617eb --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_user.go @@ -0,0 +1,494 @@ +package iam + +import ( + "context" + "errors" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &userDataSource{} + _ datasource.DataSourceWithConfigure = &userDataSource{} + + // ErrIAMGetUser is returned when GetUser fails. + ErrIAMGetUser = errors.New("IAM get user failed") +) + +type ( + userDataSource struct { + meta meta.Meta + } + + userModel struct { + UIIdentityID types.String `tfsdk:"ui_identity_id"` + AccountID types.String `tfsdk:"account_id"` + Actions *actionsModel `tfsdk:"actions"` + AdditionalAuthentication types.String `tfsdk:"additional_authentication"` + AdditionalAuthenticationConfigured types.Bool `tfsdk:"additional_authentication_configured"` + Address types.String `tfsdk:"address"` + AuthGrants []authGrantsModel `tfsdk:"auth_grants"` + City types.String `tfsdk:"city"` + ContactType types.String `tfsdk:"contact_type"` + Country types.String `tfsdk:"country"` + Email types.String `tfsdk:"email"` + EmailUpdatePending types.Bool `tfsdk:"email_update_pending"` + FirstName types.String `tfsdk:"first_name"` + IsLocked types.Bool `tfsdk:"is_locked"` + JobTitle types.String `tfsdk:"job_title"` + LastLoginDate types.String `tfsdk:"last_login_date"` + LastName types.String `tfsdk:"last_name"` + MobilePhone types.String `tfsdk:"mobile_phone"` + Notifications *notificationsModel `tfsdk:"notifications"` + PasswordExpiryDate types.String `tfsdk:"password_expiry_date"` + Phone types.String `tfsdk:"phone"` + PreferredLanguage types.String `tfsdk:"preferred_language"` + SecondaryEmail types.String `tfsdk:"secondary_email"` + SessionTimeout types.Int64 `tfsdk:"session_timeout"` + State types.String `tfsdk:"state"` + TFAConfigured types.Bool `tfsdk:"tfa_configured"` + TFAEnabled types.Bool `tfsdk:"tfa_enabled"` + TimeZone types.String `tfsdk:"time_zone"` + UIUserName types.String `tfsdk:"ui_user_name"` + ZIPCode types.String `tfsdk:"zip_code"` + } + + actionsModel struct { + Delete types.Bool `tfsdk:"delete"` + APIClient types.Bool `tfsdk:"api_client"` + Edit types.Bool `tfsdk:"edit"` + IsCloneable types.Bool `tfsdk:"is_cloneable"` + ResetPassword types.Bool `tfsdk:"reset_password"` + ThirdPartyAccess types.Bool `tfsdk:"third_party_access"` + } + + authGrantsModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + RoleDescription types.String `tfsdk:"role_description"` + RoleID types.Int64 `tfsdk:"role_id"` + RoleName types.String `tfsdk:"role_name"` + SubGroups []authGrantsModel `tfsdk:"sub_groups"` + } + + notificationsModel struct { + Options optionsModel `tfsdk:"options"` + EnableEmailNotifications types.Bool `tfsdk:"enable_email_notifications"` + } + + optionsModel struct { + APIClientCredentialExpiryNotification types.Bool `tfsdk:"api_client_credential_expiry_notification"` + NewUserNotification types.Bool `tfsdk:"new_user_notification"` + PasswordExpiry types.Bool `tfsdk:"password_expiry"` + Proactive []types.String `tfsdk:"proactive"` + Upgrade []types.String `tfsdk:"upgrade"` + } +) + +// NewUserDataSource returns a new iam user data source. +func NewUserDataSource() datasource.DataSource { + return &userDataSource{} +} + +func (d *userDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_user" +} + +func (d *userDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "IAM User Data Source.", + Attributes: map[string]schema.Attribute{ + "ui_identity_id": schema.StringAttribute{ + Required: true, + Description: "Unique identifier for each user.", + }, + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each account.", + }, + "actions": schema.SingleNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is deletable.", + }, + "api_client": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to create an API client.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is editable.", + }, + "is_cloneable": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to create a new user with permissions cloned from this user.", + }, + "reset_password": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to send a user a password by email or see a one-time token.", + }, + "third_party_access": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to manage extended access.", + }, + }, + }, + "additional_authentication": schema.StringAttribute{ + Computed: true, + Description: "Specifies the user's multi-factor authentication method, confirming their identity.", + }, + "additional_authentication_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user has multi-factor authentication configured.", + }, + "address": schema.StringAttribute{ + Computed: true, + Description: "The user's street address.", + }, + "auth_grants": schema.ListNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "sub_groups": nestedAuthGrant(maxSupportedGroupNesting), + }, + }, + }, + "city": schema.StringAttribute{ + Computed: true, + Description: "The user's city.", + }, + "contact_type": schema.StringAttribute{ + Computed: true, + Description: "User's contact type.", + }, + "country": schema.StringAttribute{ + Computed: true, + Description: "User's country.", + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "email_update_pending": schema.BoolAttribute{ + Computed: true, + Description: "Whether there are any pending changes to the email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "is_locked": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user's account is locked.", + }, + "job_title": schema.StringAttribute{ + Computed: true, + Description: "The user's position at the company.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "mobile_phone": schema.StringAttribute{ + Computed: true, + Description: "The user's mobile phone number, represented as a ten-digit integer within a string.", + }, + "notifications": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies email notifications the user receives for products.", + Attributes: map[string]schema.Attribute{ + "options": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "api_client_credential_expiry_notification": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user gets notifications for expiring API client credentials.", + }, + "new_user_notification": schema.BoolAttribute{ + Computed: true, + Description: "Whether group administrators get notifications when the user creates other new users.", + }, + "password_expiry": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user gets notifications for password expiration.", + }, + "proactive": schema.ListAttribute{ + Computed: true, + Description: "Products for which the user gets notifications for service issues.", + ElementType: types.StringType, + }, + "upgrade": schema.ListAttribute{ + Computed: true, + Description: "Products for which the user receives notifications for upgrades.", + ElementType: types.StringType, + }, + }, + }, + "enable_email_notifications": schema.BoolAttribute{ + Computed: true, + Description: "Enables email notifications.", + }, + }, + }, + "password_expiry_date": schema.StringAttribute{ + Computed: true, + Description: "The date a user's password expires.", + }, + "phone": schema.StringAttribute{ + Computed: true, + Description: "The user's main phone number.", + }, + "preferred_language": schema.StringAttribute{ + Computed: true, + Description: "The user's language.", + }, + "secondary_email": schema.StringAttribute{ + Computed: true, + Description: "The user's alternate email address.", + }, + "session_timeout": schema.Int64Attribute{ + Computed: true, + Description: "The number of seconds it takes for the user's Control Center session to time out after no activity.", + }, + "state": schema.StringAttribute{ + Computed: true, + Description: "The user's state or province if user's country is USA or Canada.", + }, + "tfa_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is configured.", + }, + "tfa_enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is enabled.", + }, + "time_zone": schema.StringAttribute{ + Computed: true, + Description: "The user's time zone.", + }, + "ui_user_name": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + "zip_code": schema.StringAttribute{ + Computed: true, + Description: "The user's postal code, represented as a string.", + }, + }, + } +} + +func nestedAuthGrant(depth int) *schema.ListNestedAttribute { + authGrant := schema.ListNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + }, + }, + } + if depth > 1 { + authGrant.NestedObject.Attributes["sub_groups"] = nestedAuthGrant(depth - 1) + } + return &authGrant +} + +func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM User DataSource Read") + + var data userModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + usr, err := client.GetUser(ctx, iam.GetUserRequest{ + IdentityID: data.UIIdentityID.ValueString(), + Actions: true, + AuthGrants: true, + Notifications: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMGetUser), err.Error()) + return + } + + if resp.Diagnostics.Append(data.setAttributes(usr)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + +} + +func (d *userModel) setAttributes(user *iam.User) diag.Diagnostics { + d.UIIdentityID = types.StringValue(user.IdentityID) + d.AccountID = types.StringValue(user.AccountID) + d.AdditionalAuthentication = types.StringValue(string(user.AdditionalAuthentication)) + d.AdditionalAuthenticationConfigured = types.BoolValue(user.AdditionalAuthenticationConfigured) + d.Address = types.StringValue(user.Address) + d.City = types.StringValue(user.City) + d.ContactType = types.StringValue(user.ContactType) + d.Country = types.StringValue(user.Country) + d.Email = types.StringValue(user.Email) + d.State = types.StringValue(user.State) + d.EmailUpdatePending = types.BoolValue(user.EmailUpdatePending) + d.FirstName = types.StringValue(user.FirstName) + d.IsLocked = types.BoolValue(user.IsLocked) + d.JobTitle = types.StringValue(user.JobTitle) + d.LastLoginDate = types.StringValue(date.FormatRFC3339Nano(user.LastLoginDate)) + d.LastName = types.StringValue(user.LastName) + d.MobilePhone = types.StringValue(user.MobilePhone) + d.PasswordExpiryDate = types.StringValue(date.FormatRFC3339Nano(user.PasswordExpiryDate)) + d.Phone = types.StringValue(user.Phone) + d.PreferredLanguage = types.StringValue(user.PreferredLanguage) + d.SecondaryEmail = types.StringValue(user.SecondaryEmail) + if user.SessionTimeOut != nil { + d.SessionTimeout = types.Int64Value(int64(*user.SessionTimeOut)) + } + d.TFAEnabled = types.BoolValue(user.TFAEnabled) + d.TFAConfigured = types.BoolValue(user.TFAConfigured) + d.TimeZone = types.StringValue(user.TimeZone) + d.UIUserName = types.StringValue(user.UserName) + d.ZIPCode = types.StringValue(user.ZipCode) + d.Notifications = ¬ificationsModel{ + Options: optionsModel{ + APIClientCredentialExpiryNotification: types.BoolValue(user.Notifications.Options.APIClientCredentialExpiry), + NewUserNotification: types.BoolValue(user.Notifications.Options.NewUser), + PasswordExpiry: types.BoolValue(user.Notifications.Options.PasswordExpiry), + }, + EnableEmailNotifications: types.BoolValue(user.Notifications.EnableEmail), + } + proactiveList := make([]types.String, 0, len(user.Notifications.Options.Proactive)) + for _, proactive := range user.Notifications.Options.Proactive { + proactiveList = append(proactiveList, types.StringValue(proactive)) + } + upgradeList := make([]types.String, 0, len(user.Notifications.Options.Upgrade)) + for _, upgrade := range user.Notifications.Options.Upgrade { + upgradeList = append(upgradeList, types.StringValue(upgrade)) + } + d.Notifications.Options.Proactive = proactiveList + d.Notifications.Options.Upgrade = upgradeList + d.Actions = &actionsModel{ + Delete: types.BoolValue(user.Actions.Delete), + APIClient: types.BoolValue(user.Actions.APIClient), + Edit: types.BoolValue(user.Actions.Edit), + IsCloneable: types.BoolValue(user.Actions.IsCloneable), + ResetPassword: types.BoolValue(user.Actions.ResetPassword), + ThirdPartyAccess: types.BoolValue(user.Actions.ThirdPartyAccess), + } + subGroups, diags := readAuthGrantSubGroups(user.AuthGrants, maxSupportedGroupNesting) + if diags.HasError() { + return diags + } + d.AuthGrants = subGroups + return nil +} + +func readAuthGrantSubGroups(authGrants []iam.AuthGrant, depth int) ([]authGrantsModel, diag.Diagnostics) { + authGrantModelList := make([]authGrantsModel, 0, len(authGrants)) + for _, authGrant := range authGrants { + grantModel := authGrantsModel{ + GroupID: types.Int64Value(authGrant.GroupID), + GroupName: types.StringValue(authGrant.GroupName), + IsBlocked: types.BoolValue(authGrant.IsBlocked), + RoleDescription: types.StringValue(authGrant.RoleDescription), + RoleName: types.StringValue(authGrant.RoleName), + } + if authGrant.RoleID != nil { + grantModel.RoleID = types.Int64Value(int64(*authGrant.RoleID)) + } + if depth > 1 { + grants, diags := readAuthGrantSubGroups(authGrant.Subgroups, depth-1) + if diags.HasError() { + return nil, diags + } + grantModel.SubGroups = grants + } else if depth == 1 && len(authGrant.Subgroups) > 0 { + return nil, diag.Diagnostics{diag.NewErrorDiagnostic("unsupported subgroup depth", + fmt.Sprintf("AuthGrant %d contains more subgroups and exceed total supported limit of nesting %d.", authGrant.GroupID, maxSupportedGroupNesting))} + } + authGrantModelList = append(authGrantModelList, grantModel) + } + return authGrantModelList, nil +} diff --git a/pkg/providers/iam/data_akamai_iam_user_test.go b/pkg/providers/iam/data_akamai_iam_user_test.go new file mode 100644 index 000000000..80731af68 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_user_test.go @@ -0,0 +1,527 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForUser struct { + uiIdentityID string + accountID string + additionalAuthentication string + additionalAuthenticationConfigured bool + address string + city string + contactType string + country string + email string + emailUpdatePending bool + firstName string + isLocked bool + jobTitle string + lastLoginDate time.Time + lastName string + mobilePhone string + passwordExpiryDate time.Time + phone string + preferredLanguage string + secondaryEmail string + sessionTimeout int64 + state string + tfaConfigured bool + tfaEnabled bool + timeZone string + uiUserName string + zipCode string + actions actionsData + authGrants []authGrantData + notifications notificationData + } + + actionsData struct { + delete bool + apiClient bool + edit bool + isCloneable bool + resetPassword bool + thirdPartyAccess bool + } + + authGrantData struct { + groupID int64 + groupName string + isBlocked bool + roleDescription string + roleID int64 + roleName string + subgroup []*authGrantData + } + + notificationData struct { + options optionsData + enableEmailNotifications bool + } + + optionsData struct { + apiClientCredentialExpiryNotification bool + newUserNotification bool + passwordExpiry bool + proactive []string + upgrade []string + } +) + +var ( + basicUserTestData = testDataForUser{ + uiIdentityID: "asd-12345", + uiUserName: "JoeDoeOh", + accountID: "acc-12345", + additionalAuthentication: "NONE", + additionalAuthenticationConfigured: true, + address: "test address 12", + city: "test city", + contactType: "test contact type", + country: "test country", + email: "email@test.com", + emailUpdatePending: true, + firstName: "Joe", + isLocked: true, + jobTitle: "Phd", + lastLoginDate: time.Date(2021, 1, 11, 7, 45, 18, 000, time.UTC), + lastName: "Doe", + mobilePhone: "123-456-789", + passwordExpiryDate: time.Date(2025, 1, 11, 7, 45, 18, 000, time.UTC), + phone: "987-654-321", + preferredLanguage: "English", + secondaryEmail: "seccondEmail@test.com", + sessionTimeout: 1000, + state: "CN", + tfaEnabled: true, + tfaConfigured: true, + timeZone: "UTC", + zipCode: "12-345", + actions: basicActionTestData, + notifications: basicNotificationTesData, + authGrants: append([]authGrantData{}, basicAuthGrantData), + } + basicUserTestDataMaxGroups = testDataForUser{ + uiIdentityID: "asd-12345", + uiUserName: "JoeDoeOh", + accountID: "acc-12345", + additionalAuthentication: "NONE", + additionalAuthenticationConfigured: true, + address: "test address 12", + city: "test city", + contactType: "test contact type", + country: "test country", + email: "email@test.com", + emailUpdatePending: true, + firstName: "Joe", + isLocked: true, + jobTitle: "Phd", + lastLoginDate: time.Date(2021, 1, 11, 7, 45, 18, 000, time.UTC), + lastName: "Doe", + mobilePhone: "123-456-789", + passwordExpiryDate: time.Date(2025, 1, 11, 7, 45, 18, 000, time.UTC), + phone: "987-654-321", + preferredLanguage: "English", + secondaryEmail: "seccondEmail@test.com", + sessionTimeout: 1000, + state: "CN", + tfaEnabled: true, + tfaConfigured: true, + timeZone: "UTC", + zipCode: "12-345", + actions: basicActionTestData, + notifications: basicNotificationTesData, + authGrants: append([]authGrantData{}, basicAuthGrantDataMaxSubgroup), + } + + basicActionTestData = actionsData{ + delete: true, + apiClient: true, + edit: true, + isCloneable: true, + resetPassword: true, + thirdPartyAccess: true, + } + + basicNotificationTesData = notificationData{ + enableEmailNotifications: true, + options: basicOptionsTestData, + } + + basicOptionsTestData = optionsData{ + apiClientCredentialExpiryNotification: true, + newUserNotification: true, + passwordExpiry: true, + proactive: []string{"EdgeScape"}, + upgrade: []string{"NetStorage"}, + } + + basicAuthGrantData = authGrantData{ + roleDescription: "testDesc", + roleName: "admin", + isBlocked: false, + roleID: 1234, + groupID: 1234, + groupName: "TestName", + } + + basicAuthGrantDataMaxSubgroup = authGrantData{ + roleDescription: "testDesc", + roleName: "admin", + isBlocked: false, + roleID: 1234, + groupID: 1234, + groupName: "TestName", + subgroup: generateMaxDepthSubGroupsAuthGrantData(maxSupportedGroupNesting), + } +) + +func TestDataUser(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForUser) + mockData testDataForUser + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForUser) { + expectGetUser(t, m, testData, 3) + }, + mockData: basicUserTestData, + }, + "happy path - max amount of sub groups": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForUser) { + expectGetUserMaxAuthGranSubGroups(t, m, testData, 3, maxSupportedGroupNesting) + }, + mockData: basicUserTestDataMaxGroups, + }, + "error - max amount of sub groups + 1": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForUser) { + expectGetUserMaxAuthGranSubGroups(t, m, testData, 1, maxSupportedGroupNesting+1) + }, + error: regexp.MustCompile("unsupported subgroup depth"), + mockData: basicUserTestDataMaxGroups, + }, + "error - missing cidr_block_id": { + configPath: "testdata/TestDataUser/missing_ui_identity.tf", + error: regexp.MustCompile("Missing required argument"), + mockData: basicUserTestData, + }, + "error - GetUser call failed": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, user testDataForUser) { + getUserReq := iam.GetUserRequest{IdentityID: user.uiIdentityID, Actions: true, AuthGrants: true, Notifications: true} + m.On("GetUser", mock.Anything, getUserReq).Return(nil, errors.New("test error")) + }, + error: regexp.MustCompile("test error"), + mockData: basicUserTestData, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.mockData) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkUserAttrs(test.mockData), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func expectGetUser(_ *testing.T, client *iam.Mock, data testDataForUser, times int) { + getUserReq := iam.GetUserRequest{ + IdentityID: data.uiIdentityID, + Actions: true, + AuthGrants: true, + Notifications: true, + } + + usr := iam.User{ + IdentityID: data.uiIdentityID, + IsLocked: data.isLocked, + LastLoginDate: data.lastLoginDate, + PasswordExpiryDate: data.passwordExpiryDate, + TFAConfigured: data.tfaConfigured, + EmailUpdatePending: data.emailUpdatePending, + AccountID: data.accountID, + AdditionalAuthenticationConfigured: data.additionalAuthenticationConfigured, + UserBasicInfo: iam.UserBasicInfo{ + FirstName: data.firstName, + LastName: data.lastName, + UserName: data.uiUserName, + Email: data.email, + Phone: data.phone, + TimeZone: data.timeZone, + JobTitle: data.jobTitle, + TFAEnabled: data.tfaEnabled, + SecondaryEmail: data.secondaryEmail, + MobilePhone: data.mobilePhone, + Address: data.address, + City: data.city, + State: data.state, + ZipCode: data.zipCode, + Country: data.country, + ContactType: data.contactType, + PreferredLanguage: data.preferredLanguage, + SessionTimeOut: ptr.To(int(data.sessionTimeout)), + AdditionalAuthentication: iam.Authentication(data.additionalAuthentication), + }, + Actions: &iam.UserActions{ + APIClient: data.actions.apiClient, + Delete: data.actions.delete, + Edit: data.actions.edit, + IsCloneable: data.actions.isCloneable, + ResetPassword: data.actions.resetPassword, + ThirdPartyAccess: data.actions.thirdPartyAccess, + }, + Notifications: iam.UserNotifications{ + Options: iam.UserNotificationOptions{ + NewUser: data.notifications.options.newUserNotification, + PasswordExpiry: data.notifications.options.passwordExpiry, + Proactive: data.notifications.options.proactive, + Upgrade: data.notifications.options.upgrade, + APIClientCredentialExpiry: data.notifications.options.apiClientCredentialExpiryNotification, + }, + EnableEmail: data.notifications.enableEmailNotifications, + }, + } + userAuthGrantList := make([]iam.AuthGrant, 0, len(data.authGrants)) + for _, authGrant := range data.authGrants { + userAuthGrant := iam.AuthGrant{ + GroupID: authGrant.groupID, + GroupName: authGrant.groupName, + IsBlocked: authGrant.isBlocked, + RoleDescription: authGrant.roleDescription, + RoleID: ptr.To(int(authGrant.roleID)), + RoleName: authGrant.roleName, + } + userAuthGrantList = append(userAuthGrantList, userAuthGrant) + } + usr.AuthGrants = userAuthGrantList + + client.On("GetUser", mock.Anything, getUserReq).Return(&usr, nil).Times(times) +} + +func expectGetUserMaxAuthGranSubGroups(_ *testing.T, client *iam.Mock, data testDataForUser, times, subGroupsDepth int) { + getUserReq := iam.GetUserRequest{ + IdentityID: data.uiIdentityID, + Actions: true, + AuthGrants: true, + Notifications: true, + } + + usr := iam.User{ + IdentityID: data.uiIdentityID, + IsLocked: data.isLocked, + LastLoginDate: data.lastLoginDate, + PasswordExpiryDate: data.passwordExpiryDate, + TFAConfigured: data.tfaConfigured, + EmailUpdatePending: data.emailUpdatePending, + AccountID: data.accountID, + AdditionalAuthenticationConfigured: data.additionalAuthenticationConfigured, + UserBasicInfo: iam.UserBasicInfo{ + FirstName: data.firstName, + LastName: data.lastName, + UserName: data.uiUserName, + Email: data.email, + Phone: data.phone, + TimeZone: data.timeZone, + JobTitle: data.jobTitle, + TFAEnabled: data.tfaEnabled, + SecondaryEmail: data.secondaryEmail, + MobilePhone: data.mobilePhone, + Address: data.address, + City: data.city, + State: data.state, + ZipCode: data.zipCode, + Country: data.country, + ContactType: data.contactType, + PreferredLanguage: data.preferredLanguage, + SessionTimeOut: ptr.To(int(data.sessionTimeout)), + AdditionalAuthentication: iam.Authentication(data.additionalAuthentication), + }, + Actions: &iam.UserActions{ + APIClient: data.actions.apiClient, + Delete: data.actions.delete, + Edit: data.actions.edit, + IsCloneable: data.actions.isCloneable, + ResetPassword: data.actions.resetPassword, + ThirdPartyAccess: data.actions.thirdPartyAccess, + }, + Notifications: iam.UserNotifications{ + Options: iam.UserNotificationOptions{ + NewUser: data.notifications.options.newUserNotification, + PasswordExpiry: data.notifications.options.passwordExpiry, + Proactive: data.notifications.options.proactive, + Upgrade: data.notifications.options.upgrade, + APIClientCredentialExpiry: data.notifications.options.apiClientCredentialExpiryNotification, + }, + EnableEmail: data.notifications.enableEmailNotifications, + }, + } + userAuthGrantList := make([]iam.AuthGrant, 0, len(data.authGrants)) + for _, authGrant := range data.authGrants { + userAuthGrant := iam.AuthGrant{ + GroupID: authGrant.groupID, + GroupName: authGrant.groupName, + IsBlocked: authGrant.isBlocked, + RoleDescription: authGrant.roleDescription, + RoleID: ptr.To(int(authGrant.roleID)), + RoleName: authGrant.roleName, + Subgroups: generateMaxDepthSubGroupsAPIResponse(subGroupsDepth), + } + userAuthGrantList = append(userAuthGrantList, userAuthGrant) + } + usr.AuthGrants = userAuthGrantList + + client.On("GetUser", mock.Anything, getUserReq).Return(&usr, nil).Times(times) +} + +func checkUserAttrs(data testDataForUser) resource.TestCheckFunc { + name := "data.akamai_iam_user.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "ui_identity_id", data.uiIdentityID), + } + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "account_id", data.accountID)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "additional_authentication", data.additionalAuthentication)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "additional_authentication_configured", strconv.FormatBool(data.additionalAuthenticationConfigured))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "address", data.address)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "city", data.city)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "contact_type", data.contactType)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "state", data.state)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "country", data.country)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "email", data.email)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "email_update_pending", strconv.FormatBool(data.emailUpdatePending))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "first_name", data.firstName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "is_locked", strconv.FormatBool(data.isLocked))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "job_title", data.jobTitle)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_login_date", date.FormatRFC3339Nano(data.lastLoginDate))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_name", data.lastName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "mobile_phone", data.mobilePhone)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "password_expiry_date", date.FormatRFC3339Nano(data.passwordExpiryDate))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "phone", data.phone)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "preferred_language", data.preferredLanguage)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "secondary_email", data.secondaryEmail)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "session_timeout", strconv.FormatInt(data.sessionTimeout, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "tfa_configured", strconv.FormatBool(data.tfaConfigured))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "tfa_enabled", strconv.FormatBool(data.tfaEnabled))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "time_zone", data.timeZone)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "ui_user_name", data.uiUserName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "zip_code", data.zipCode)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.delete", strconv.FormatBool(data.actions.delete))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.api_client", strconv.FormatBool(data.actions.apiClient))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.edit", strconv.FormatBool(data.actions.edit))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.is_cloneable", strconv.FormatBool(data.actions.isCloneable))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.reset_password", strconv.FormatBool(data.actions.resetPassword))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.third_party_access", strconv.FormatBool(data.actions.thirdPartyAccess))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "auth_grants.#", strconv.Itoa(1))) + for i, authGrant := range data.authGrants { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.group_id", i), strconv.FormatInt(authGrant.groupID, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.group_name", i), authGrant.groupName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.is_blocked", i), strconv.FormatBool(authGrant.isBlocked))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.role_id", i), strconv.FormatInt(authGrant.roleID, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.role_name", i), authGrant.roleName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.role_description", i), authGrant.roleDescription)) + if authGrant.subgroup != nil && len(authGrant.subgroup) > 0 { + checksFuncs = append(checksFuncs, generateAggregateTestCheckFuncsForMaxAuthGrantSubGroups(i, 2, maxSupportedGroupNesting)) + } + } + + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.enable_email_notifications", strconv.FormatBool(data.notifications.enableEmailNotifications))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.options.api_client_credential_expiry_notification", strconv.FormatBool(data.notifications.options.apiClientCredentialExpiryNotification))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.options.new_user_notification", strconv.FormatBool(data.notifications.options.newUserNotification))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.options.password_expiry", strconv.FormatBool(data.notifications.options.passwordExpiry))) + for i, proactiveElement := range data.notifications.options.proactive { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("notifications.options.proactive.%d", i), proactiveElement)) + } + for i, upgradeElement := range data.notifications.options.upgrade { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("notifications.options.upgrade.%d", i), upgradeElement)) + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} + +func generateMaxDepthSubGroupsAuthGrantData(depth int) []*authGrantData { + var subgroups []*authGrantData + for groupID := depth; groupID > 1; groupID-- { + + authGrant := authGrantData{ + groupID: int64(groupID), + groupName: fmt.Sprintf("group%d", groupID), + isBlocked: false, + roleID: int64(groupID), + roleName: fmt.Sprintf("role%d", groupID), + roleDescription: fmt.Sprintf("roleDesc%d", groupID), + subgroup: subgroups, + } + subgroups = append([]*authGrantData{}, &authGrant) + } + return subgroups +} + +func generateMaxDepthSubGroupsAPIResponse(depth int) []iam.AuthGrant { + var subgroups []iam.AuthGrant + for groupID := depth; groupID > 1; groupID-- { + + authGrant := iam.AuthGrant{ + GroupID: int64(groupID), + GroupName: fmt.Sprintf("group%d", groupID), + IsBlocked: false, + RoleID: ptr.To(groupID), + RoleName: fmt.Sprintf("role%d", groupID), + RoleDescription: fmt.Sprintf("roleDesc%d", groupID), + Subgroups: subgroups, + } + subgroups = []iam.AuthGrant{authGrant} + } + return subgroups +} + +func generateAggregateTestCheckFuncsForMaxAuthGrantSubGroups(authGrantElement, min, max int) resource.TestCheckFunc { + var testCases []resource.TestCheckFunc + path := "sub_groups.0" + for i := min; i < max; i++ { + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.group_id", authGrantElement, path), strconv.Itoa(i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.group_name", authGrantElement, path), fmt.Sprintf("group%d", i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.role_id", authGrantElement, path), strconv.Itoa(i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.role_name", authGrantElement, path), fmt.Sprintf("role%d", i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.role_description", authGrantElement, path), fmt.Sprintf("roleDesc%d", i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.is_blocked", authGrantElement, path), "false")) + path = path + ".sub_groups.0" + } + + return resource.ComposeAggregateTestCheckFunc(testCases...) +} diff --git a/pkg/providers/iam/data_akamai_iam_users.go b/pkg/providers/iam/data_akamai_iam_users.go new file mode 100644 index 000000000..1a8f96579 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users.go @@ -0,0 +1,298 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &usersDataSource{} + _ datasource.DataSourceWithConfigure = &usersDataSource{} +) + +type ( + usersDataSource struct { + meta meta.Meta + } + + usersModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + Users []userItem `tfsdk:"users"` + } + + userItem struct { + AccountID types.String `tfsdk:"account_id"` + Actions *userActions `tfsdk:"actions"` + AdditionalAuthentication types.String `tfsdk:"additional_authentication"` + AdditionalAuthenticationConfigured types.Bool `tfsdk:"additional_authentication_configured"` + AuthGrants []authGrantsModel `tfsdk:"auth_grants"` + Email types.String `tfsdk:"email"` + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + IsLocked types.Bool `tfsdk:"is_locked"` + LastLoginDate types.String `tfsdk:"last_login_date"` + TFAConfigured types.Bool `tfsdk:"tfa_configured"` + TFAEnabled types.Bool `tfsdk:"tfa_enabled"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + UIUserName types.String `tfsdk:"ui_user_name"` + } + + userActions struct { + Delete types.Bool `tfsdk:"delete"` + APIClient types.Bool `tfsdk:"api_client"` + CanEditMFA types.Bool `tfsdk:"can_edit_mfa"` + CanEditNone types.Bool `tfsdk:"can_edit_none"` + CanEditTFA types.Bool `tfsdk:"can_edit_tfa"` + Edit types.Bool `tfsdk:"edit"` + EditProfile types.Bool `tfsdk:"edit_profile"` + IsCloneable types.Bool `tfsdk:"is_cloneable"` + ResetPassword types.Bool `tfsdk:"reset_password"` + ThirdPartyAccess types.Bool `tfsdk:"third_party_access"` + } +) + +// NewUsersDataSource returns a new iam users data source. +func NewUsersDataSource() datasource.DataSource { + return &usersDataSource{} +} + +func (d *usersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_users" +} + +func (d *usersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +func (d *usersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management users.", + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Optional: true, + Description: "Filters users for a specific group.", + }, + "users": schema.ListNestedAttribute{ + Description: "List of users in the account.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier of the account.", + }, + "actions": schema.SingleNestedAttribute{ + Description: "Specifies permissions available to the user for this group.", + Computed: true, + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is deletable.", + }, + "api_client": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to create an API client.", + }, + "can_edit_mfa": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can turn their MFA setting on or off.", + }, + "can_edit_none": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can turn their None setting on or off.", + }, + "can_edit_tfa": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can turn their TFA setting on or off.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is editable.", + }, + "edit_profile": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can edit their user profile.", + }, + "is_cloneable": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to create a new user with permissions cloned from this user.", + }, + "reset_password": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to send a user a password by email or see a one-time token.", + }, + "third_party_access": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to manage extended access.", + }, + }, + }, + "additional_authentication": schema.StringAttribute{ + Computed: true, + Description: "Specifies the user's multi-factor authentication method, confirming their identity.", + }, + "additional_authentication_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user has multi-factor authentication configured.", + }, + "auth_grants": schema.ListNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "sub_groups": nestedAuthGrant(50), + }}, + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "is_locked": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user's account is locked.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "tfa_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is configured.", + }, + "tfa_enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is enabled.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + "ui_user_name": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + }, + }, + }}} +} + +func (d *usersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Users DataSource Read") + + var data usersModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + groupID := data.GroupID.ValueInt64Pointer() + + users, err := client.ListUsers(ctx, iam.ListUsersRequest{ + GroupID: groupID, + AuthGrants: true, + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError("list users failed: ", err.Error()) + return + } + + if resp.Diagnostics.Append(data.read(users)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (d *usersModel) read(users []iam.UserListItem) diag.Diagnostics { + for _, usr := range users { + authGrants, diags := readAuthGrantSubGroups(usr.AuthGrants, maxSupportedGroupNesting) + if diags.HasError() { + return diags + } + usrItem := userItem{ + AccountID: types.StringValue(usr.AccountID), + AdditionalAuthentication: types.StringValue(string(usr.AdditionalAuthentication)), + AdditionalAuthenticationConfigured: types.BoolValue(usr.AdditionalAuthenticationConfigured), + AuthGrants: authGrants, + Email: types.StringValue(usr.Email), + FirstName: types.StringValue(usr.FirstName), + IsLocked: types.BoolValue(usr.IsLocked), + LastName: types.StringValue(usr.LastName), + LastLoginDate: types.StringValue(date.FormatRFC3339Nano(usr.LastLoginDate)), + TFAConfigured: types.BoolValue(usr.TFAConfigured), + TFAEnabled: types.BoolValue(usr.TFAEnabled), + UIIdentityID: types.StringValue(usr.IdentityID), + UIUserName: types.StringValue(usr.UserName), + } + + if usr.Actions != nil { + usrItem.Actions = &userActions{ + Delete: types.BoolValue(usr.Actions.Delete), + APIClient: types.BoolValue(usr.Actions.APIClient), + CanEditMFA: types.BoolValue(usr.Actions.CanEditMFA), + CanEditNone: types.BoolValue(usr.Actions.CanEditNone), + CanEditTFA: types.BoolValue(usr.Actions.CanEditTFA), + Edit: types.BoolValue(usr.Actions.Edit), + EditProfile: types.BoolValue(usr.Actions.EditProfile), + IsCloneable: types.BoolValue(usr.Actions.IsCloneable), + ResetPassword: types.BoolValue(usr.Actions.ResetPassword), + ThirdPartyAccess: types.BoolValue(usr.Actions.ThirdPartyAccess), + } + } + d.Users = append(d.Users, usrItem) + } + return nil +} diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go new file mode 100644 index 000000000..980b7f054 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go @@ -0,0 +1,168 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &usersAffectedByMovingGroupDataSource{} + _ datasource.DataSourceWithConfigure = &usersAffectedByMovingGroupDataSource{} +) + +type ( + usersAffectedByMovingGroupDataSource struct { + meta meta.Meta + } + + usersAffectedByMovingGroupModel struct { + SourceGroupID types.Int64 `tfsdk:"source_group_id"` + DestinationGroupID types.Int64 `tfsdk:"destination_group_id"` + UserType types.String `tfsdk:"user_type"` + Users []userAffectedByMovingGroupModel `tfsdk:"users"` + } + + userAffectedByMovingGroupModel struct { + AccountID types.String `tfsdk:"account_id"` + Email types.String `tfsdk:"email"` + FirstName types.String `tfsdk:"first_name"` + LastLoginDate types.String `tfsdk:"last_login_date"` + LastName types.String `tfsdk:"last_name"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + UIUsername types.String `tfsdk:"ui_username"` + } +) + +// NewUsersAffectedByMovingGroupDataSource returns new users affected by moving group data source. +func NewUsersAffectedByMovingGroupDataSource() datasource.DataSource { + return &usersAffectedByMovingGroupDataSource{} +} + +func (a *usersAffectedByMovingGroupDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_users_affected_by_moving_group" +} + +func (a *usersAffectedByMovingGroupDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + a.meta = meta.Must(req.ProviderData) +} + +func (a *usersAffectedByMovingGroupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "source_group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for a group you want to move.", + }, + "destination_group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for a group you're putting the other group into.", + }, + "user_type": schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("lostAccess", "gainAccess", ""), + }, + Description: "Filters the list by users who have lostAccess or the reverse gainAccess.", + }, + "users": schema.ListNestedAttribute{ + Computed: true, + Description: "The list of affected users.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each account.", + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + "ui_username": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + }, + }, + }, + }, + } +} + +func (a *usersAffectedByMovingGroupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Users affected by moving group Datasource Read") + + var data usersAffectedByMovingGroupModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + client := inst.Client(a.meta) + users, err := client.ListAffectedUsers(ctx, iam.ListAffectedUsersRequest{ + SourceGroupID: data.SourceGroupID.ValueInt64(), + DestinationGroupID: data.DestinationGroupID.ValueInt64(), + UserType: data.UserType.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Users affected by moving group failed", err.Error()) + return + } + + data.Users = convertUsersAffectedByMove(users) + + resp.Diagnostics.Append(resp.State.Set(ctx, data)...) +} + +func convertUsersAffectedByMove(users []iam.GroupUser) []userAffectedByMovingGroupModel { + var convertedUsers []userAffectedByMovingGroupModel + for _, u := range users { + convertedUser := userAffectedByMovingGroupModel{ + AccountID: types.StringValue(u.AccountID), + Email: types.StringValue(u.Email), + FirstName: types.StringValue(u.FirstName), + LastName: types.StringValue(u.LastName), + UIIdentityID: types.StringValue(u.IdentityID), + UIUsername: types.StringValue(u.UserName), + LastLoginDate: types.StringValue(date.FormatRFC3339Nano(u.LastLoginDate)), + } + convertedUsers = append(convertedUsers, convertedUser) + } + return convertedUsers +} diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go new file mode 100644 index 000000000..4a9c173fb --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go @@ -0,0 +1,163 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestUsersAffectedByMovingGroup(t *testing.T) { + + mockListAffectedUsers := func(client *iam.Mock, userType string, users []iam.GroupUser) *mock.Call { + return client.On("ListAffectedUsers", mock.Anything, iam.ListAffectedUsersRequest{SourceGroupID: 123, DestinationGroupID: 321, UserType: userType}). + Return(users, nil).Times(3) + } + + generateExpectedGroup := func(path, accountID, email, firstName, lastName, userName, identityID string, lastLoginDate *string) resource.TestCheckFunc { + checks := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.account_id", path), accountID), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.email", path), email), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.first_name", path), firstName), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_name", path), lastName), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.ui_username", path), userName), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.ui_identity_id", path), identityID), + } + + if lastLoginDate != nil { + checks = append(checks, resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path), *lastLoginDate)) + } else { + checks = append(checks, resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path), "")) + } + + return resource.ComposeAggregateTestCheckFunc(checks...) + } + + tests := map[string]struct { + init func(mock *iam.Mock) + config string + expectedError *regexp.Regexp + expectedChecks resource.TestCheckFunc + }{ + "normal case - no filter": { + init: func(client *iam.Mock) { + mockListAffectedUsers(client, "", []iam.GroupUser{ + { + AccountID: "1-ABCD", + Email: "ab.cd@test.com", + FirstName: "ab", + LastName: "cd", + UserName: "abcd", + IdentityID: "F-CO-abcd", + }, + { + AccountID: "1-EFGH", + Email: "ef.gh@test.com", + FirstName: "ef", + LastName: "gh", + UserName: "efgh", + IdentityID: "F-CO-efgh", + LastLoginDate: test.NewTimeFromString(t, "2024-02-06T15:00:00.000Z"), + }, + }) + }, + config: "testdata/TestDataUsersAffected/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", "users.#", "2"), + generateExpectedGroup("users.0", "1-ABCD", "ab.cd@test.com", "ab", "cd", "abcd", "F-CO-abcd", nil), + generateExpectedGroup("users.1", "1-EFGH", "ef.gh@test.com", "ef", "gh", "efgh", "F-CO-efgh", ptr.To("2024-02-06T15:00:00Z")), + ), + }, + "normal case - only gained": { + init: func(client *iam.Mock) { + mockListAffectedUsers(client, "gainAccess", []iam.GroupUser{ + { + AccountID: "1-ABCD", + Email: "ab.cd@test.com", + FirstName: "ab", + LastName: "cd", + UserName: "abcd", + IdentityID: "F-CO-abcd", + }, + }) + }, + config: "testdata/TestDataUsersAffected/gained.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", "users.#", "1"), + generateExpectedGroup("users.0", "1-ABCD", "ab.cd@test.com", "ab", "cd", "abcd", "F-CO-abcd", nil), + ), + }, + "normal case - only lost": { + init: func(client *iam.Mock) { + mockListAffectedUsers(client, "lostAccess", []iam.GroupUser{ + { + AccountID: "1-EFGH", + Email: "ef.gh@test.com", + FirstName: "ef", + LastName: "gh", + UserName: "efgh", + IdentityID: "F-CO-efgh", + LastLoginDate: test.NewTimeFromString(t, "2024-02-06T15:00:00.000Z"), + }, + }) + }, + config: "testdata/TestDataUsersAffected/lost.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", "users.#", "1"), + generateExpectedGroup("users.0", "1-EFGH", "ef.gh@test.com", "ef", "gh", "efgh", "F-CO-efgh", ptr.To("2024-02-06T15:00:00Z")), + ), + }, + "validation - missing source": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataUsersAffected/missing-source.tf", + expectedError: regexp.MustCompile("Missing required argument(.|\n)*The argument \"source_group_id\" is required, but no definition was found."), + }, + "validation - missing destination": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataUsersAffected/missing-destination.tf", + expectedError: regexp.MustCompile("Missing required argument(.|\n)*The argument \"destination_group_id\" is required, but no definition was found."), + }, + "validation - incorrect user_type": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataUsersAffected/incorrect-usertype.tf", + expectedError: regexp.MustCompile("Invalid Attribute Value Match(.|\n)*Attribute user_type value must be one of: \\[\"lostAccess\" \"gainAccess\" \"\"]"), + }, + "api failed": { + init: func(client *iam.Mock) { + client.On("ListAffectedUsers", mock.Anything, iam.ListAffectedUsersRequest{SourceGroupID: 123, DestinationGroupID: 321, UserType: ""}). + Return(nil, errors.New("api failed")).Once() + }, + config: "testdata/TestDataUsersAffected/basic.tf", + expectedError: regexp.MustCompile("api failed"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + tc.init(client) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.config), + Check: tc.expectedChecks, + ExpectError: tc.expectedError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_users_test.go b/pkg/providers/iam/data_akamai_iam_users_test.go new file mode 100644 index 000000000..655a95e74 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users_test.go @@ -0,0 +1,265 @@ +package iam + +import ( + "errors" + "regexp" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +var ( + basicTestDataForUsers = []iam.UserListItem{{ + FirstName: "firstName1", + LastName: "lastName1", + UserName: "user1", + Email: "user1@example.com", + TFAEnabled: false, + IdentityID: "A-B-123456", + IsLocked: false, + LastLoginDate: time.Date(2017, time.July, 27, 18, 11, 25, 0, time.UTC), + TFAConfigured: false, + AccountID: "A-CCT3456", + Actions: &iam.UserActions{ + APIClient: true, + Delete: true, + Edit: true, + IsCloneable: true, + ResetPassword: true, + ThirdPartyAccess: true, + CanEditTFA: false, + CanEditMFA: false, + CanEditNone: false, + EditProfile: true, + }, + AuthGrants: []iam.AuthGrant{ + { + GroupID: 12345, + GroupName: "Internet Company", + IsBlocked: false, + RoleDescription: "Role giving admin access.", + RoleID: ptr.To(12), + RoleName: "admin", + Subgroups: []iam.AuthGrant{{ + GroupID: 1000, + GroupName: "sub group", + RoleID: ptr.To(1000), + RoleName: "sub group role", + }}, + }, + { + RoleID: ptr.To(100002), + RoleName: "Admin for Account Roles", + }, + }, + AdditionalAuthentication: "TFA", + AdditionalAuthenticationConfigured: false, + }, + { + FirstName: "firstName2", + LastName: "lastName2", + UserName: "user2", + Email: "user2@example.com", + TFAEnabled: false, + IdentityID: "B-B-123456", + IsLocked: false, + LastLoginDate: time.Time{}, + TFAConfigured: false, + AccountID: "B-CCT3456", + Actions: &iam.UserActions{ + APIClient: true, + Delete: true, + Edit: true, + IsCloneable: true, + ResetPassword: true, + ThirdPartyAccess: true, + CanEditTFA: false, + CanEditMFA: false, + CanEditNone: false, + EditProfile: true, + }, + AuthGrants: []iam.AuthGrant{ + { + RoleID: ptr.To(100002), + RoleName: "Admin for Account Roles", + }, + }, + AdditionalAuthentication: "TFA", + AdditionalAuthenticationConfigured: false, + }} +) + +func TestDataUsers(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, []iam.UserListItem, *int64) + mockData []iam.UserListItem + groupID *int64 + expectedError *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + expectListUsers(m, mockData, groupID, 3) + }, + mockData: basicTestDataForUsers, + }, + "happy path - no users": { + configPath: "testdata/TestDataUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + expectListUsers(m, mockData, groupID, 3) + }, + mockData: []iam.UserListItem{}, + }, + "happy path - groupID search": { + groupID: ptr.To(int64(12345)), + configPath: "testdata/TestDataUsers/groupIDSearch.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + expectListUsers(m, mockData, groupID, 3) + }, + mockData: basicTestDataForUsers, + }, + "error - list user fails": { + configPath: "testdata/TestDataUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + listUsersReq := iam.ListUsersRequest{GroupID: groupID, AuthGrants: true, Actions: true} + m.On("ListUsers", mock.Anything, listUsersReq).Return(nil, errors.New("test error")) + }, + expectedError: regexp.MustCompile("test error"), + mockData: basicTestDataForUsers, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client, tc.mockData, tc.groupID) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkUsersAttrs(tc.groupID, len(tc.mockData) == 0), + ExpectError: tc.expectedError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkUsersAttrs(groupID *int64, emptyReturn bool) resource.TestCheckFunc { + name := "data.akamai_iam_users.test" + + if emptyReturn { + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "users.#", "0"), + } + if groupID != nil { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "group_id", "12345")) + } else { + checksFuncs = append(checksFuncs, resource.TestCheckNoResourceAttr(name, "group_id")) + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) + } + + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "users.#", "2"), + resource.TestCheckResourceAttr(name, "users.0.account_id", "A-CCT3456"), + resource.TestCheckResourceAttr(name, "users.0.additional_authentication", "TFA"), + resource.TestCheckResourceAttr(name, "users.0.additional_authentication_configured", "false"), + resource.TestCheckResourceAttr(name, "users.0.email", "user1@example.com"), + resource.TestCheckResourceAttr(name, "users.0.first_name", "firstName1"), + resource.TestCheckResourceAttr(name, "users.0.is_locked", "false"), + resource.TestCheckResourceAttr(name, "users.0.last_login_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "users.0.last_name", "lastName1"), + resource.TestCheckResourceAttr(name, "users.0.tfa_configured", "false"), + resource.TestCheckResourceAttr(name, "users.0.tfa_enabled", "false"), + resource.TestCheckResourceAttr(name, "users.0.ui_identity_id", "A-B-123456"), + resource.TestCheckResourceAttr(name, "users.0.ui_user_name", "user1"), + resource.TestCheckResourceAttr(name, "users.0.actions.delete", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.api_client", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.can_edit_mfa", "false"), + resource.TestCheckResourceAttr(name, "users.0.actions.can_edit_none", "false"), + resource.TestCheckResourceAttr(name, "users.0.actions.can_edit_tfa", "false"), + resource.TestCheckResourceAttr(name, "users.0.actions.edit", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.edit_profile", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.is_cloneable", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.reset_password", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.third_party_access", "true"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.#", "2"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.group_id", "12345"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.group_name", "Internet Company"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.is_blocked", "false"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.role_description", "Role giving admin access."), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.role_id", "12"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.role_name", "admin"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.sub_groups.#", "1"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.group_id", "0"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.group_name", ""), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.is_blocked", "false"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.role_description", ""), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.role_id", "100002"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.role_name", "Admin for Account Roles"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.sub_groups.#", "0"), + + resource.TestCheckResourceAttr(name, "users.1.account_id", "B-CCT3456"), + resource.TestCheckResourceAttr(name, "users.1.additional_authentication", "TFA"), + resource.TestCheckResourceAttr(name, "users.1.additional_authentication_configured", "false"), + resource.TestCheckResourceAttr(name, "users.1.email", "user2@example.com"), + resource.TestCheckResourceAttr(name, "users.1.first_name", "firstName2"), + resource.TestCheckResourceAttr(name, "users.1.is_locked", "false"), + resource.TestCheckResourceAttr(name, "users.1.last_login_date", ""), + resource.TestCheckResourceAttr(name, "users.1.last_name", "lastName2"), + resource.TestCheckResourceAttr(name, "users.1.tfa_configured", "false"), + resource.TestCheckResourceAttr(name, "users.1.tfa_enabled", "false"), + resource.TestCheckResourceAttr(name, "users.1.ui_identity_id", "B-B-123456"), + resource.TestCheckResourceAttr(name, "users.1.ui_user_name", "user2"), + resource.TestCheckResourceAttr(name, "users.1.actions.delete", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.api_client", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.can_edit_mfa", "false"), + resource.TestCheckResourceAttr(name, "users.1.actions.can_edit_none", "false"), + resource.TestCheckResourceAttr(name, "users.1.actions.can_edit_tfa", "false"), + resource.TestCheckResourceAttr(name, "users.1.actions.edit", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.edit_profile", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.is_cloneable", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.reset_password", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.third_party_access", "true"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.#", "1"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.group_id", "0"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.group_name", ""), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.is_blocked", "false"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.role_description", ""), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.role_id", "100002"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.role_name", "Admin for Account Roles"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.sub_groups.#", "0"), + } + if groupID != nil { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "group_id", "12345")) + } else { + checksFuncs = append(checksFuncs, resource.TestCheckNoResourceAttr(name, "group_id")) + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} + +func expectListUsers(client *iam.Mock, mockData []iam.UserListItem, groupID *int64, timesToRun int) { + listUsersReq := iam.ListUsersRequest{ + GroupID: groupID, + AuthGrants: true, + Actions: true, + } + + client.On("ListUsers", mock.Anything, listUsersReq).Return(mockData, nil).Times(timesToRun) +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 01141e313..ee4a352e4 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -4,7 +4,8 @@ package iam import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -15,7 +16,8 @@ import ( type ( // Subprovider gathers IAM resources and data sources Subprovider struct { - client iam.IAM + client iam.IAM + papiClient papi.PAPI } option func(p *Subprovider) @@ -38,12 +40,6 @@ func NewSubprovider() *Subprovider { return inst } -func withClient(c iam.IAM) option { - return func(p *Subprovider) { - p.client = c - } -} - // Client returns the IAM interface func (p *Subprovider) Client(meta meta.Meta) iam.IAM { if p.client != nil { @@ -52,6 +48,14 @@ func (p *Subprovider) Client(meta meta.Meta) iam.IAM { return iam.Client(meta.Session()) } +// PapiClient returns the PAPI interface +func (p *Subprovider) PapiClient(meta meta.Meta) papi.PAPI { + if p.client != nil { + return p.papiClient + } + return papi.Client(meta.Session()) +} + // SDKResources returns the IAM resources implemented using terraform-plugin-sdk func (p *Subprovider) SDKResources() map[string]*schema.Resource { return map[string]*schema.Resource{ @@ -79,10 +83,28 @@ func (p *Subprovider) SDKDataSources() map[string]*schema.Resource { // FrameworkResources returns the IAM resources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkResources() []func() resource.Resource { - return []func() resource.Resource{} + return []func() resource.Resource{ + NewCIDRBlockResource, + NewIPAllowlistResource, + } } // FrameworkDataSources returns the IAM data sources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { - return []func() datasource.DataSource{} + return []func() datasource.DataSource{ + NewAccessibleGroupsDataSource, + NewAccountSwitchKeysDataSource, + NewAllowedAPIsDataSource, + NewAuthorizedUsersDataSource, + NewBlockedPropertiesDataSource, + NewCIDRBlockDataSource, + NewCIDRBlocksDataSource, + NewGroupDataSource, + NewPasswordPolicyDataSource, + NewPropertyUsersDataSource, + NewRoleDataSource, + NewUserDataSource, + NewUsersAffectedByMovingGroupDataSource, + NewUsersDataSource, + } } diff --git a/pkg/providers/iam/provider_test.go b/pkg/providers/iam/provider_test.go index 9651be230..bf3ba93d7 100644 --- a/pkg/providers/iam/provider_test.go +++ b/pkg/providers/iam/provider_test.go @@ -4,7 +4,8 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) @@ -22,7 +23,25 @@ func useClient(client iam.IAM, f func()) { inst.client = client defer func() { - inst.client = orig + client = orig + clientLock.Unlock() + }() + + f() +} + +// useClient swaps out the client on the global instance for the duration of the given func using both IAM and PAPI +func useIAMandPAPIClient(client iam.IAM, papiClient papi.PAPI, f func()) { + clientLock.Lock() + orig := inst.client + inst.client = client + + origPapi := inst.papiClient + inst.papiClient = papiClient + + defer func() { + client = orig + papiClient = origPapi clientLock.Unlock() }() diff --git a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go index d0efa325f..86c32be85 100644 --- a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go +++ b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -16,7 +16,7 @@ import ( func resourceIAMBlockedUserProperties() *schema.Resource { return &schema.Resource{ - Description: "Manage a user in your account", + Description: "Manage a user in your account.", CreateContext: resourceIAMBlockedUserPropertiesCreate, ReadContext: resourceIAMBlockedUserPropertiesRead, UpdateContext: resourceIAMBlockedUserPropertiesUpdate, @@ -28,20 +28,20 @@ func resourceIAMBlockedUserProperties() *schema.Resource { "identity_id": { Type: schema.TypeString, Required: true, - Description: "A unique identifier for a user's profile, which corresponds to a user's actual profile or client ID", + Description: "A unique identifier for a user's profile, which corresponds to a user's actual profile or client ID.", }, "group_id": { Type: schema.TypeInt, ForceNew: true, Required: true, - Description: "A unique identifier for a group", + Description: "A unique identifier for a group.", }, "blocked_properties": { Type: schema.TypeList, Required: true, MinItems: 1, Elem: &schema.Schema{Type: schema.TypeInt}, - Description: "List of properties to block for a user", + Description: "List of properties to block for a user.", }, }, } diff --git a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go index e162e98bd..f08ee9b70 100644 --- a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go +++ b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go @@ -5,7 +5,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -165,15 +165,15 @@ func TestResourceIAMBlockedUserProperties(t *testing.T) { }, }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) @@ -181,7 +181,6 @@ func TestResourceIAMBlockedUserProperties(t *testing.T) { } } -// read func expectListBlockedProperties(m *iam.Mock, request iam.ListBlockedPropertiesRequest, response []int64, err error) *mock.Call { on := m.On("ListBlockedProperties", mock.Anything, request) if err != nil { @@ -190,7 +189,6 @@ func expectListBlockedProperties(m *iam.Mock, request iam.ListBlockedPropertiesR return on.Return(response, nil) } -// create/update func expectUpdateBlockedProperties(m *iam.Mock, request iam.UpdateBlockedPropertiesRequest, response []int64, err error) *mock.Call { on := m.On("UpdateBlockedProperties", mock.Anything, request) if err != nil { diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block.go b/pkg/providers/iam/resource_akamai_iam_cidr_block.go new file mode 100644 index 000000000..78721b87b --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block.go @@ -0,0 +1,325 @@ +package iam + +import ( + "context" + "fmt" + "strconv" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &cidrBlockResource{} + _ resource.ResourceWithImportState = &cidrBlockResource{} +) + +type cidrBlockResource struct { + meta meta.Meta +} + +// NewCIDRBlockResource returns new akamai_iam_cidr_block resource. +func NewCIDRBlockResource() resource.Resource { return &cidrBlockResource{} } + +type cidrBlockResourceModel struct { + CIDR types.String `tfsdk:"cidr_block"` + Enabled types.Bool `tfsdk:"enabled"` + Comments types.String `tfsdk:"comments"` + Actions types.Object `tfsdk:"actions"` + CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` +} + +func (r *cidrBlockResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_block" +} + +func (r *cidrBlockResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "cidr_block": schema.StringAttribute{ + Required: true, + Description: "The value of an IP address or IP address range.", + }, + "enabled": schema.BoolAttribute{ + Required: true, + Description: "Enables the CIDR block on the account.", + }, + "comments": schema.StringAttribute{ + Optional: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block. You can't delete a CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block. You can't edit CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", + }, + }, + }, + "cidr_block_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each CIDR block.", + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.UseStateForUnknown(), + }, + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + }, + } +} + +func (r *cidrBlockResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + r.meta = meta.Must(req.ProviderData) +} + +func (r *cidrBlockResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating CIDR Block resource") + var plan cidrBlockResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.create(ctx, &plan); err != nil { + resp.Diagnostics.AddError("create cidr block failed", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *cidrBlockResource) create(ctx context.Context, plan *cidrBlockResourceModel) error { + client := inst.Client(r.meta) + + resp, err := client.CreateCIDRBlock(ctx, iam.CreateCIDRBlockRequest{ + CIDRBlock: plan.CIDR.ValueString(), + Comments: plan.Comments.ValueStringPointer(), + Enabled: plan.Enabled.ValueBool(), + }) + if err != nil { + return err + } + + // Use GetCIDRBlock to fetch current actions, as they are not present in the response from CreateCIDRBlock + cidr, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ + CIDRBlockID: resp.CIDRBlockID, + Actions: true, + }) + if err != nil { + return err + } + + plan.setData(cidr) + + return nil +} + +func (r *cidrBlockResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading CIDR Block Resource") + var state cidrBlockResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.read(ctx, &state); err != nil { + resp.Diagnostics.AddError("read cidr block error", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *cidrBlockResource) read(ctx context.Context, data *cidrBlockResourceModel) error { + client := inst.Client(r.meta) + + cidr, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ + CIDRBlockID: data.CIDRBlockID.ValueInt64(), + Actions: true, + }) + if err != nil { + return err + } + + data.setData(cidr) + + return nil +} + +func (r *cidrBlockResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating CIDR Block Resource") + var plan cidrBlockResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.update(ctx, &plan); err != nil { + resp.Diagnostics.AddError("update cidr block failed", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *cidrBlockResource) update(ctx context.Context, plan *cidrBlockResourceModel) error { + client := inst.Client(r.meta) + + _, err := client.UpdateCIDRBlock(ctx, iam.UpdateCIDRBlockRequest{ + CIDRBlockID: plan.CIDRBlockID.ValueInt64(), + Body: iam.UpdateCIDRBlockRequestBody{ + CIDRBlock: plan.CIDR.ValueString(), + Comments: plan.Comments.ValueStringPointer(), + Enabled: plan.Enabled.ValueBool(), + }, + }) + if err != nil { + return err + } + + return nil +} + +func (r *cidrBlockResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Deleting CIDR Block Resource") + + var state *cidrBlockResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + client := inst.Client(r.meta) + + if err := client.DeleteCIDRBlock(ctx, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: state.CIDRBlockID.ValueInt64(), + }); err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("delete cidr block %d failed", state.CIDRBlockID), err.Error()) + return + } + + resp.State.RemoveResource(ctx) +} + +func (r *cidrBlockResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing CIDR Block Resource") + + cidrBlockID, err := strconv.ParseInt(req.ID, 10, 64) + if err != nil { + resp.Diagnostics.AddError("could not convert import ID to int", err.Error()) + return + } + + data := &cidrBlockResourceModel{} + + // in import, we only need to set cidr block ID to allow read function to fill other attributes + data.CIDRBlockID = types.Int64Value(cidrBlockID) + // we also need to satisfy framework with a correct value for actions object + data.Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (m *cidrBlockResourceModel) setData(resp *iam.GetCIDRBlockResponse) { + if resp.Actions != nil { + m.Actions = getActionFor(resp.Actions.Edit, resp.Actions.Delete) + } else { + m.Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + } + m.CIDRBlockID = types.Int64Value(resp.CIDRBlockID) + m.ModifiedBy = types.StringValue(resp.ModifiedBy) + m.ModifiedDate = types.StringValue(resp.ModifiedDate.Format(time.RFC3339Nano)) + m.CreatedBy = types.StringValue(resp.CreatedBy) + m.CreatedDate = types.StringValue(resp.CreatedDate.Format(time.RFC3339Nano)) + m.CIDR = types.StringValue(resp.CIDRBlock) + m.Comments = types.StringPointerValue(resp.Comments) + m.Enabled = types.BoolValue(resp.Enabled) +} + +func getActionFor(editAction, deleteAction bool) basetypes.ObjectValue { + return types.ObjectValueMust( + map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }, + map[string]attr.Value{ + "edit": basetypes.NewBoolValue(editAction), + "delete": basetypes.NewBoolValue(deleteAction), + }, + ) +} diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go b/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go new file mode 100644 index 000000000..df64d2ee1 --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go @@ -0,0 +1,489 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/mock" +) + +type ( + commonDataForResource struct { + cidrBlock string + comments *string + enabled bool + actions *action + cidrBlockID int64 + createdBy string + createdDate string + modifiedBy string + modifiedDate string + } + + action struct { + deleteAction bool + editAction bool + } +) + +var ( + testCIDR = commonDataForResource{ + cidrBlock: "128.5.6.5/24", + enabled: true, + comments: ptr.To("test"), + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + } + + testCIDRNoComments = commonDataForResource{ + cidrBlock: "128.5.6.5/24", + enabled: false, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + } + + updatedCIDR = commonDataForResource{ + cidrBlock: "128.5.6.99/24", + enabled: false, + comments: ptr.To("test-updated"), + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + } +) + +func TestCIDRBlockResource(t *testing.T) { + t.Parallel() + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, commonDataForResource, commonDataForResource) + createData commonDataForResource + updateData commonDataForResource + steps []resource.TestStep + error *regexp.Regexp + }{ + "happy path - create with comment": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Twice() + // Delete + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + }, + }, + "happy path - create without comment": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Times(2) + // Delete + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDRNoComments, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create_without_comments.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckNoResourceAttr("akamai_iam_cidr_block.test", "comments"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "false"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + }, + }, + "happy path - update all fields": { + init: func(t *testing.T, m *iam.Mock, createData, updateData commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + mockGetCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Twice() + // Update + mockUpdateCIDRBlock(t, m, updateData) + // Read + mockGetCIDRBlock(t, m, updateData) + // Delete + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDR, + updateData: updatedCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/update.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test-updated"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.99/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "false"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + }, + }, + "validation error - missing cidr block": { + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/missing_cidr_block.tf"), + ExpectError: regexp.MustCompile(`The argument "cidr_block" is required, but no definition was found`), + }, + }, + }, + "validation error - missing enabled": { + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/missing_enabled.tf"), + ExpectError: regexp.MustCompile(`The argument "enabled" is required, but no definition was found`), + }, + }, + }, + "expect error - create": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ + CIDRBlock: createData.cidrBlock, + Comments: createData.comments, + Enabled: createData.enabled, + }).Return(nil, fmt.Errorf("create failed")).Once() + }, + createData: testCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + ExpectError: regexp.MustCompile(`create failed`), + }, + }, + }, + "expect error - delete": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Twice() + mockGetCIDRBlock(t, m, createData) + // Delete - error + m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: createData.cidrBlockID, + }).Return(iam.ErrDeleteCIDRBlock).Once() + // Delete - destroy + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/empty_config.tf"), + ExpectError: regexp.MustCompile(`Error: delete cidr block {2 1111} failed`), + }, + }, + }, + } + + for name, tc := range tests { + tc := tc + t.Run(name, func(t *testing.T) { + t.Parallel() + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client, tc.createData, tc.updateData) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: tc.steps, + }) + }) + client.AssertExpectations(t) + }) + } + +} + +func TestImportCIDRBlockResource(t *testing.T) { + tests := map[string]struct { + importID string + init func(*testing.T, *iam.Mock, commonDataForResource) + mockData commonDataForResource + expectError *regexp.Regexp + }{ + "happy path - import with comments": { + importID: "1111", + mockData: testCIDR, + init: func(t *testing.T, m *iam.Mock, data commonDataForResource) { + // Read + mockGetCIDRBlock(t, m, data) + }, + }, + "happy path - import without comments": { + importID: "1111", + mockData: testCIDRNoComments, + init: func(t *testing.T, m *iam.Mock, data commonDataForResource) { + // Read + mockGetCIDRBlock(t, m, data) + }, + }, + "expect error - wrong import ID": { + importID: "wrong format", + init: func(_ *testing.T, _ *iam.Mock, _ commonDataForResource) {}, + expectError: regexp.MustCompile(`Error: could not convert import ID to int`), + }, + "expect error - read": { + importID: "1111", + init: func(t *testing.T, m *iam.Mock, data commonDataForResource) { + m.On("GetCIDRBlock", mock.Anything, iam.GetCIDRBlockRequest{ + CIDRBlockID: data.cidrBlockID, + Actions: true, + }).Return(nil, fmt.Errorf("get failed")).Once() + }, + mockData: testCIDR, + expectError: regexp.MustCompile(`get failed`), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + tc.init(t, client, tc.mockData) + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + ImportStateCheck: checkImportCIDRBlock(tc.mockData), + ImportStateId: tc.importID, + ImportState: true, + ResourceName: "akamai_iam_cidr_block.test", + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/importable.tf"), + ExpectError: tc.expectError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkImportCIDRBlock(data commonDataForResource) resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + attr := make(map[string]string) + + if len(s) == 0 { + return errors.New("no instance found") + } + if len(s) != 1 { + return fmt.Errorf("expected one instance: %d", len(s)) + } + + if data.actions != nil { + attr["actions.delete"] = strconv.FormatBool(data.actions.deleteAction) + attr["actions.edit"] = strconv.FormatBool(data.actions.editAction) + } + if data.comments != nil { + attr["comments"] = *data.comments + } else { + attr["comments"] = "" + } + attr["cidr_block"] = data.cidrBlock + attr["enabled"] = strconv.FormatBool(data.enabled) + attr["cidr_block_id"] = strconv.FormatInt(data.cidrBlockID, 10) + attr["created_by"] = data.createdBy + attr["created_date"] = data.createdDate + attr["modified_by"] = data.modifiedBy + attr["modified_date"] = data.modifiedDate + + state := s[0].Attributes + + attributes := attr + + var invalidValues []string + for field, expectedVal := range attributes { + if state[field] != expectedVal { + invalidValues = append(invalidValues, fmt.Sprintf("field: %s, got: %s, expected: %s ", field, state[field], expectedVal)) + } + } + + if len(invalidValues) != 0 { + return fmt.Errorf(strings.Join(invalidValues, "\n")) + } + return nil + } +} + +func mockCreateCIDRBlock(t *testing.T, m *iam.Mock, testData commonDataForResource) *mock.Call { + var act *iam.CIDRActions + + if testData.actions != nil { + act = &iam.CIDRActions{ + Delete: testData.actions.deleteAction, + Edit: testData.actions.editAction, + } + } + + return m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ + CIDRBlock: testData.cidrBlock, + Comments: testData.comments, + Enabled: testData.enabled, + }).Return(&iam.CreateCIDRBlockResponse{ + Actions: act, + CIDRBlock: testData.cidrBlock, + CIDRBlockID: testData.cidrBlockID, + Comments: testData.comments, + CreatedBy: testData.createdBy, + CreatedDate: test.NewTimeFromString(t, testData.createdDate), + Enabled: testData.enabled, + ModifiedBy: testData.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, testData.modifiedDate), + }, nil).Once() +} + +func mockGetCIDRBlock(t *testing.T, m *iam.Mock, testData commonDataForResource) *mock.Call { + var act *iam.CIDRActions + + if testData.actions != nil { + act = &iam.CIDRActions{ + Delete: testData.actions.deleteAction, + Edit: testData.actions.editAction, + } + } + + return m.On("GetCIDRBlock", mock.Anything, iam.GetCIDRBlockRequest{ + CIDRBlockID: testData.cidrBlockID, + Actions: true, + }).Return(&iam.GetCIDRBlockResponse{ + Actions: act, + CIDRBlock: testData.cidrBlock, + CIDRBlockID: testData.cidrBlockID, + Comments: testData.comments, + CreatedBy: testData.createdBy, + CreatedDate: test.NewTimeFromString(t, testData.createdDate), + Enabled: testData.enabled, + ModifiedBy: testData.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, testData.modifiedDate), + }, nil).Once() +} + +func mockDeleteCIDRBlock(m *iam.Mock, testData commonDataForResource) *mock.Call { + return m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: testData.cidrBlockID, + }).Return(nil).Once() +} + +func mockUpdateCIDRBlock(t *testing.T, m *iam.Mock, testData commonDataForResource) *mock.Call { + var act *iam.CIDRActions + + if testData.actions != nil { + act = &iam.CIDRActions{ + Delete: testData.actions.deleteAction, + Edit: testData.actions.editAction, + } + } + + return m.On("UpdateCIDRBlock", mock.Anything, iam.UpdateCIDRBlockRequest{ + CIDRBlockID: testData.cidrBlockID, + Body: iam.UpdateCIDRBlockRequestBody{ + CIDRBlock: testData.cidrBlock, + Comments: testData.comments, + Enabled: testData.enabled, + }, + }).Return(&iam.UpdateCIDRBlockResponse{ + Actions: act, + CIDRBlock: testData.cidrBlock, + CIDRBlockID: testData.cidrBlockID, + Comments: testData.comments, + CreatedBy: testData.createdBy, + CreatedDate: test.NewTimeFromString(t, testData.createdDate), + Enabled: testData.enabled, + ModifiedBy: testData.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, testData.modifiedDate), + }, nil).Once() +} diff --git a/pkg/providers/iam/resource_akamai_iam_group.go b/pkg/providers/iam/resource_akamai_iam_group.go index 0b78047f6..d8c0eb2ca 100644 --- a/pkg/providers/iam/resource_akamai_iam_group.go +++ b/pkg/providers/iam/resource_akamai_iam_group.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -14,7 +14,7 @@ import ( func resourceIAMGroup() *schema.Resource { return &schema.Resource{ - Description: "Manage a group in your account", + Description: "Manage a group in your account.", CreateContext: resourceIAMGroupCreate, ReadContext: resourceIAMGroupRead, UpdateContext: resourceIAMGroupUpdate, @@ -26,18 +26,18 @@ func resourceIAMGroup() *schema.Resource { "parent_group_id": { Type: schema.TypeInt, Required: true, - Description: "Unique identifier for the parent group", + Description: "Unique identifier for the parent group.", }, "name": { Type: schema.TypeString, Required: true, - Description: "Human readable name for a group", + Description: "Human readable name for a group.", }, "sub_groups": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeInt}, Computed: true, - Description: "Subgroups IDs", + Description: "Subgroups IDs.", }, }, } diff --git a/pkg/providers/iam/resource_akamai_iam_group_test.go b/pkg/providers/iam/resource_akamai_iam_group_test.go index 26dac8031..bf38a6108 100644 --- a/pkg/providers/iam/resource_akamai_iam_group_test.go +++ b/pkg/providers/iam/resource_akamai_iam_group_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -137,15 +137,15 @@ func TestResourceGroup(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go new file mode 100644 index 000000000..c12e0887a --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go @@ -0,0 +1,200 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &ipAllowlistResource{} + _ resource.ResourceWithConfigure = &ipAllowlistResource{} + _ resource.ResourceWithImportState = &ipAllowlistResource{} +) + +type ipAllowlistResource struct { + meta meta.Meta +} + +// NewIPAllowlistResource returns new akamai_iam_ip_allowlist resource. +func NewIPAllowlistResource() resource.Resource { + return &ipAllowlistResource{} +} + +type ipAllowlistModel struct { + Enable types.Bool `tfsdk:"enable"` +} + +func (r *ipAllowlistResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "unexpected resource configure type", + fmt.Sprintf("expected meta.Meta, got: %T. please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + r.meta = meta.Must(req.ProviderData) +} + +func (r *ipAllowlistResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_iam_ip_allowlist" +} + +func (r *ipAllowlistResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "enable": schema.BoolAttribute{ + Required: true, + Description: "Whether to enable or disable the allowlist.", + }, + }, + } +} + +func (r *ipAllowlistResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating IP Allowlist resource") + var plan *ipAllowlistModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if plan.Enable.ValueBool() { + resp.Diagnostics.Append(r.enableIPAllowlist(ctx)...) + } else { + resp.Diagnostics.Append(r.disableIPAllowlist(ctx)...) + } + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *ipAllowlistResource) enableIPAllowlist(ctx context.Context) diag.Diagnostics { + var diags diag.Diagnostics + client := inst.Client(r.meta) + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + diags.AddError("cannot fetch IP Allowlist status", err.Error()) + return diags + } + if !status.Enabled { + err = client.EnableIPAllowlist(ctx) + if err != nil { + diags.AddError("enable ip allowlist fail", err.Error()) + return diags + } + } + return nil +} + +func (r *ipAllowlistResource) disableIPAllowlist(ctx context.Context) diag.Diagnostics { + var diags diag.Diagnostics + client := inst.Client(r.meta) + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + diags.AddError("cannot fetch IP Allowlist status", err.Error()) + return diags + } + if status.Enabled != false { + err = client.DisableIPAllowlist(ctx) + if err != nil { + diags.AddError("disable IP allowlist fail", err.Error()) + return diags + } + } + return nil +} + +func (r *ipAllowlistResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading IP Allowlist Resource") + var oldState *ipAllowlistModel + client := inst.Client(r.meta) + resp.Diagnostics.Append(req.State.Get(ctx, &oldState)...) + if resp.Diagnostics.HasError() { + return + } + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + resp.Diagnostics.AddError("cannot fetch IP Allowlist status", err.Error()) + return + } + + oldState.Enable = types.BoolValue(status.Enabled) + resp.Diagnostics.Append(resp.State.Set(ctx, &oldState)...) +} + +func (r *ipAllowlistResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating IP Allowlist Resource") + var diags diag.Diagnostics + var plan *ipAllowlistModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + if plan.Enable.ValueBool() { + diags.Append(r.enableIPAllowlist(ctx)...) + } else { + diags.Append(r.disableIPAllowlist(ctx)...) + } + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *ipAllowlistResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var plan *ipAllowlistModel + + // Read Terraform state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if plan.Enable.ValueBool() { + resp.Diagnostics.Append(r.disableIPAllowlist(ctx)...) + } + + if resp.Diagnostics.HasError() { + return + } + + // It can be only removed from state + resp.State.RemoveResource(ctx) +} + +func (r *ipAllowlistResource) ImportState(ctx context.Context, _ resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing IP Allowlist Resource") + client := inst.Client(r.meta) + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + resp.Diagnostics.AddError("cannot fetch IP Allowlist status", err.Error()) + return + } + var state = &ipAllowlistModel{} + state.Enable = types.BoolValue(status.Enabled) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go new file mode 100644 index 000000000..f5a2b86f3 --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go @@ -0,0 +1,281 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/mock" +) + +func TestIPAllowlistResource(t *testing.T) { + t.Parallel() + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock) + steps []resource.TestStep + error *regexp.Regexp + }{ + "create - enable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 2 read + mockReadIPAllowlistStatus(m, true) + // step 3 delete - remove resource form state and disable ip allowlist + mockReadIPAllowlistStatus(m, false) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }, + "create - disable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlist(m) + // step 2 read + mockReadIPAllowlistStatus(m, false) + // step 3 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + }, + }, + "create - already enabled on server": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - ip allowlist already enabled on server + mockReadIPAllowlistStatus(m, true) + // step 2 read + mockReadIPAllowlistStatus(m, true) + // step 3 delete - remove resource form state and disable ip allowlist + mockReadIPAllowlistStatus(m, false) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }, + "create - already disabled on server": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - ip allowlist already disabled on server + mockReadIPAllowlistStatus(m, false) + // step 2 read + mockReadIPAllowlistStatus(m, false) + // step 3 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + }, + }, + "update - enable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlist(m) + // step 2 refresh + mockReadIPAllowlistStatus(m, false) + mockReadIPAllowlistStatus(m, false) + // step 3 update + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 4 refresh + mockReadIPAllowlistStatus(m, true) + // step 5 delete - remove resource form state and disable ip allowlist + mockReadIPAllowlistStatus(m, false) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }, + "update - disable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 2 refresh + mockReadIPAllowlistStatus(m, true) + mockReadIPAllowlistStatus(m, true) + // step 3 update + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlist(m) + // step 4 refresh + mockReadIPAllowlistStatus(m, false) + // step 5 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + }, + }, + "error - enable error ip not on allowlist": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - error + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlistError(m) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + ExpectError: regexp.MustCompile("enable ip allowlist fail"), + }, + }, + }, + "error - disable error IP not on allowlist": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - error + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlistError(m) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + ExpectError: regexp.MustCompile("disable IP allowlist fail"), + }, + }, + }, + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: tc.steps, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func TestImportIPAllowlistResource(t *testing.T) { + tests := map[string]struct { + importID string + configPath string + init func(*testing.T, *iam.Mock) + mockData []commonDataForResource + stateCheck func(s []*terraform.InstanceState) error + }{ + "import": { + importID: " ", + init: func(t *testing.T, m *iam.Mock) { + // Import + mockReadIPAllowlistStatus(m, true).Twice() + }, + stateCheck: checkImportEnabledIPAllowlistForSpecificUser(), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(t, client) + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + ImportStateCheck: test.stateCheck, + ImportStateId: test.importID, + ImportState: true, + ResourceName: "akamai_iam_ip_allowlist.test", + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkImportEnabledIPAllowlistForSpecificUser() resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + if len(s) == 0 { + return errors.New("No Instance found") + } + if len(s) != 1 { + return fmt.Errorf("Expected one Instance: %d", len(s)) + } + + state := s[0].Attributes + + attributes := map[string]string{ + "enable": "true", + } + + invalidValues := []string{} + for field, expectedVal := range attributes { + if state[field] != expectedVal { + invalidValues = append(invalidValues, fmt.Sprintf("field: %s, got: %s, expected: %s ", field, state[field], expectedVal)) + } + } + return nil + } +} + +func mockEnableIPAllowlist(m *iam.Mock) *mock.Call { + return m.On("EnableIPAllowlist", mock.Anything).Return(nil).Once() +} + +func mockEnableIPAllowlistError(m *iam.Mock) *mock.Call { + return m.On("EnableIPAllowlist", mock.Anything).Return(iam.ErrEnableIPAllowlist).Once() +} + +func mockDisableIPAllowlist(m *iam.Mock) *mock.Call { + return m.On("DisableIPAllowlist", mock.Anything).Return(nil).Once() +} +func mockDisableIPAllowlistError(m *iam.Mock) *mock.Call { + return m.On("DisableIPAllowlist", mock.Anything).Return(iam.ErrDisableIPAllowlist).Once() +} + +func mockReadIPAllowlistStatus(m *iam.Mock, enabled bool) *mock.Call { + if enabled { + return m.On("GetIPAllowlistStatus", mock.Anything).Return(&iam.GetIPAllowlistStatusResponse{Enabled: true}, nil).Once() + } + return m.On("GetIPAllowlistStatus", mock.Anything).Return(&iam.GetIPAllowlistStatusResponse{Enabled: false}, nil).Once() +} diff --git a/pkg/providers/iam/resource_akamai_iam_role.go b/pkg/providers/iam/resource_akamai_iam_role.go index 0a1ef78c4..adae33a34 100644 --- a/pkg/providers/iam/resource_akamai_iam_role.go +++ b/pkg/providers/iam/resource_akamai_iam_role.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -25,12 +25,12 @@ func resourceIAMRole() *schema.Resource { "name": { Type: schema.TypeString, Required: true, - Description: "The name you supply for a role", + Description: "The name you supply for a role.", }, "description": { Type: schema.TypeString, Required: true, - Description: "The description for a role", + Description: "The description for a role.", }, "granted_roles": { Type: schema.TypeSet, @@ -38,13 +38,13 @@ func resourceIAMRole() *schema.Resource { Type: schema.TypeInt, }, Required: true, - Description: "The list of existing unique identifiers for the granted roles", + Description: "The list of existing unique identifiers for the granted roles.", }, "type": { Type: schema.TypeString, Computed: true, Optional: true, - Description: "The role type which indicates whether it's a standard role provided by Akamai or a custom role for the account", + Description: "The role type which indicates whether it's a standard role provided by Akamai or a custom role for the account.", }, }, } diff --git a/pkg/providers/iam/resource_akamai_iam_role_test.go b/pkg/providers/iam/resource_akamai_iam_role_test.go index 01008be1a..025361d60 100644 --- a/pkg/providers/iam/resource_akamai_iam_role_test.go +++ b/pkg/providers/iam/resource_akamai_iam_role_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 20ac511e3..4d3775b11 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -9,14 +9,16 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -25,11 +27,12 @@ var international = regexp.MustCompile(`^\+[02-9][\d\s\-]{0,40}$`) func resourceIAMUser() *schema.Resource { return &schema.Resource{ - Description: "Manage a user in your account", + Description: "Manage a user in your account.", CreateContext: resourceIAMUserCreate, ReadContext: resourceIAMUserRead, UpdateContext: resourceIAMUserUpdate, DeleteContext: resourceIAMUserDelete, + CustomizeDiff: customdiff.All(customizePasswordDiff, customizeNotificationDiff), Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -38,42 +41,47 @@ func resourceIAMUser() *schema.Resource { "first_name": { Type: schema.TypeString, Required: true, - Description: "The user's first name", + Description: "The user's first name.", }, "last_name": { Type: schema.TypeString, Required: true, - Description: "The user's surname", + Description: "The user's surname.", }, "email": { Type: schema.TypeString, Required: true, - Description: "The user's email address", + Description: "The user's email address.", StateFunc: stateEmail, DiffSuppressFunc: suppressEmail, }, "country": { Type: schema.TypeString, Required: true, - Description: "As part of the user's location, the value can be any that are available from the view-supported-countries operation", + Description: "As part of the user's location, the value can be any that are available from the view-supported-countries operation.", }, "phone": { Type: schema.TypeString, Optional: true, - Description: "The user's main phone number", + Description: "The user's main phone number.", DiffSuppressFunc: suppressPhone, StateFunc: statePhone, ValidateFunc: validatePhone, }, "enable_tfa": { Type: schema.TypeBool, - Required: true, - Description: "Indicates whether two-factor authentication is allowed", + Optional: true, + Description: "Indicates whether two-factor authentication is allowed.", + }, + "enable_mfa": { + Type: schema.TypeBool, + Optional: true, + Description: "Indicates whether multi-factor authentication is allowed.", }, "auth_grants_json": { Type: schema.TypeString, Required: true, - Description: "A user's per-group role assignments, in JSON form", + Description: "A user's per-group role assignments, in JSON form.", ValidateDiagFunc: validateAuthGrantsJS, DiffSuppressFunc: suppressAuthGrantsJS, StateFunc: stateAuthGrantsJS, @@ -84,30 +92,30 @@ func resourceIAMUser() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - Description: "To help characterize the user, the value can be any that are available from the view-contact-types operation", + Description: "To help characterize the user, the value can be any that are available from the view-contact-types operation.", }, "job_title": { Type: schema.TypeString, Optional: true, - Description: "The user's position at your company", + Description: "The user's position at your company.", }, "time_zone": { Type: schema.TypeString, Optional: true, Computed: true, - Description: "The user's time zone. The value can be any that are available from the view-time-zones operation", + Description: "The user's time zone. The value can be any that are available from the view-time-zones operation.", }, "secondary_email": { Type: schema.TypeString, Optional: true, - Description: "The user's secondary email address", + Description: "The user's secondary email address.", StateFunc: stateEmail, DiffSuppressFunc: suppressEmail, }, "mobile_phone": { Type: schema.TypeString, Optional: true, - Description: "The user's mobile phone number", + Description: "The user's mobile phone number.", DiffSuppressFunc: suppressPhone, StateFunc: statePhone, ValidateFunc: validatePhone, @@ -116,68 +124,123 @@ func resourceIAMUser() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - Description: "The user's street address", + Description: "The user's street address.", }, "city": { Type: schema.TypeString, Optional: true, - Description: "The user's city", + Description: "The user's city.", }, "state": { Type: schema.TypeString, Optional: true, - Description: "The user's state", + Description: "The user's state.", }, "zip_code": { Type: schema.TypeString, Optional: true, - Description: "The user's five-digit ZIP code", + Description: "The user's five-digit ZIP code.", }, "preferred_language": { Type: schema.TypeString, Optional: true, Computed: true, - Description: "The value can be any that are available from the view-languages operation", + Description: "The value can be any that are available from the view-languages operation.", }, "session_timeout": { Type: schema.TypeInt, Optional: true, Computed: true, - Description: "The number of seconds it takes for the user's Control Center session to time out if there hasn't been any activity", + Description: "The number of seconds it takes for the user's Control Center session to time out if there hasn't been any activity.", }, // Purely computed "user_name": { Type: schema.TypeString, Computed: true, - Description: "A user's `loginId`. Typically, a user's email address", + Description: "A user's `loginId`. Typically, a user's email address.", }, "last_login": { Type: schema.TypeString, Computed: true, - Description: "ISO 8601 timestamp indicating when the user last logged in", + Description: "ISO 8601 timestamp indicating when the user last logged in.", }, "password_expired_after": { Type: schema.TypeString, Computed: true, - Description: "The date a user's password expires", + Description: "The date a user's password expires.", }, "tfa_configured": { Type: schema.TypeBool, Computed: true, - Description: "Indicates whether two-factor authentication is configured", + Description: "Indicates whether two-factor authentication is configured.", }, "email_update_pending": { Type: schema.TypeBool, Computed: true, - Description: "Indicates whether email update is pending", + Description: "Indicates whether email update is pending.", }, "lock": { Type: schema.TypeBool, Optional: true, - Description: "Flag to block a user account", + Description: "Flag to block a user account.", Default: false, }, + "password": { + Type: schema.TypeString, + Description: "New password for a user.", + Optional: true, + Sensitive: true, + }, + "user_notifications": { + Type: schema.TypeList, + Optional: true, + Description: "Specifies email notifications the user receives for products.", + Computed: true, + MaxItems: 1, // Ensure only one notification configuration can be set + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "api_client_credential_expiry_notification": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Enables notifications for expiring API client credentials.", + }, + "new_user_notification": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Enables notifications for group administrators when the user creates other new users.", + }, + "password_expiry": { + Type: schema.TypeBool, + Required: true, + Description: "Enables notifications for expiring passwords.", + }, + "proactive": { + Type: schema.TypeList, + Required: true, + Description: "Products for which the user gets notifications for service issues.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "upgrade": { + Type: schema.TypeList, + Required: true, + Description: "Products for which the user receives notifications for upgrades.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "enable_email_notifications": { + Type: schema.TypeBool, + Required: true, + Description: "Enables email notifications.", + }, + }, + }, + }, }, } } @@ -200,24 +263,30 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf } } + authMethod, err := getAuthenticationMethod(d) + if err != nil { + return diag.FromErr(err) + } + basicUser := iam.UserBasicInfo{ - FirstName: d.Get("first_name").(string), - LastName: d.Get("last_name").(string), - UserName: d.Get("user_name").(string), - Email: d.Get("email").(string), - Phone: d.Get("phone").(string), - TimeZone: d.Get("time_zone").(string), - JobTitle: d.Get("job_title").(string), - TFAEnabled: d.Get("enable_tfa").(bool), - SecondaryEmail: d.Get("secondary_email").(string), - MobilePhone: d.Get("mobile_phone").(string), - Address: d.Get("address").(string), - City: d.Get("city").(string), - State: d.Get("state").(string), - ZipCode: d.Get("zip_code").(string), - Country: d.Get("country").(string), - ContactType: d.Get("contact_type").(string), - PreferredLanguage: d.Get("preferred_language").(string), + FirstName: d.Get("first_name").(string), + LastName: d.Get("last_name").(string), + UserName: d.Get("user_name").(string), + Email: d.Get("email").(string), + Phone: d.Get("phone").(string), + TimeZone: d.Get("time_zone").(string), + JobTitle: d.Get("job_title").(string), + TFAEnabled: d.Get("enable_tfa").(bool), + SecondaryEmail: d.Get("secondary_email").(string), + MobilePhone: d.Get("mobile_phone").(string), + Address: d.Get("address").(string), + City: d.Get("city").(string), + State: d.Get("state").(string), + ZipCode: d.Get("zip_code").(string), + Country: d.Get("country").(string), + ContactType: d.Get("contact_type").(string), + PreferredLanguage: d.Get("preferred_language").(string), + AdditionalAuthentication: iam.Authentication(authMethod), } if st, ok := d.GetOk("session_timeout"); ok { @@ -225,22 +294,34 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf basicUser.SessionTimeOut = &sessionTimeout } - user, err := client.CreateUser(ctx, iam.CreateUserRequest{ + userRequest := iam.CreateUserRequest{ UserBasicInfo: basicUser, AuthGrants: authGrants, SendEmail: true, - Notifications: iam.UserNotifications{ - Options: iam.UserNotificationOptions{ - Proactive: []string{}, - Upgrade: []string{}, - }, - }, - }) + } + + // Get user notifications if provided + userNotifications, err := getUserNotifications(d) + if err != nil { + return diag.FromErr(err) + } + + if userNotifications != nil { + userRequest.Notifications = userNotifications + } + + user, err := client.CreateUser(ctx, userRequest) if err != nil { logger.WithError(err).Errorf("failed to create user") return diag.Errorf("failed to create user: %s\n%s", err, resourceIAMUserErrorAdvice(err)) } + err = manageUserPassword(ctx, d, client, user.IdentityID) + if err != nil { + logger.WithError(err).Errorf("failed to set user password") + return diag.Errorf("failed to set user password: %s", err) + } + // lock the user's account lock, err := tf.GetBoolValue("lock", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { @@ -257,6 +338,72 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf return resourceIAMUserRead(ctx, d, m) } +func manageUserPassword(ctx context.Context, d *schema.ResourceData, client iam.IAM, ID string) error { + password, err := tf.GetStringValue("password", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return err + } + + if password != "" { + err = client.SetUserPassword(ctx, iam.SetUserPasswordRequest{ + IdentityID: ID, + NewPassword: password, + }) + if err != nil { + return err + } + } + return nil +} + +func extractUserNotificationsData(notificationsData interface{}) (*iam.UserNotifications, error) { + + notificationsList, ok := notificationsData.([]interface{}) + if !ok { + return nil, errors.New("user notifications data is not a valid list") + } + + itemMap, ok := notificationsList[0].(map[string]interface{}) + if !ok { + return nil, errors.New("user notifications data item is not a valid map") + } + + return &iam.UserNotifications{ + EnableEmail: itemMap["enable_email_notifications"].(bool), + Options: iam.UserNotificationOptions{ + APIClientCredentialExpiry: itemMap["api_client_credential_expiry_notification"].(bool), + NewUser: itemMap["new_user_notification"].(bool), + PasswordExpiry: itemMap["password_expiry"].(bool), + Proactive: tf.InterfaceSliceToStringSlice(itemMap["proactive"].([]interface{})), + Upgrade: tf.InterfaceSliceToStringSlice(itemMap["upgrade"].([]interface{})), + }, + }, nil +} + +func getUserNotifications(d *schema.ResourceData) (*iam.UserNotifications, error) { + notificationsData, err := tf.GetListValue("user_notifications", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return nil, err + } + return extractUserNotificationsData(notificationsData) +} + +func getAuthenticationMethod(d *schema.ResourceData) (string, error) { + enableTFA := d.Get("enable_tfa").(bool) + enableMFA := d.Get("enable_mfa").(bool) + + if enableTFA && enableMFA { + return "", errors.New("only one of 'enable_tfa' or 'enable_mfa' can be set") + } + + if enableTFA { + return "TFA", nil + } else if enableMFA { + return "MFA", nil + } + return "NONE", nil +} + func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMUserRead") @@ -266,8 +413,9 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac logger.Debug("Reading User") req := iam.GetUserRequest{ - IdentityID: d.Id(), - AuthGrants: true, + IdentityID: d.Id(), + AuthGrants: true, + Notifications: true, } user, err := client.GetUser(ctx, req) @@ -290,6 +438,18 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac } } + userNotifications := []interface{}{map[string]interface{}{ + "enable_email_notifications": user.Notifications.EnableEmail, + "api_client_credential_expiry_notification": user.Notifications.Options.APIClientCredentialExpiry, + "new_user_notification": user.Notifications.Options.NewUser, + "password_expiry": user.Notifications.Options.PasswordExpiry, + "proactive": user.Notifications.Options.Proactive, + "upgrade": user.Notifications.Options.Upgrade, + }, + } + + enableMFA := user.AdditionalAuthentication == "MFA" + err = tf.SetAttrs(d, map[string]interface{}{ "first_name": user.FirstName, "last_name": user.LastName, @@ -299,6 +459,7 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "time_zone": user.TimeZone, "job_title": user.JobTitle, "enable_tfa": user.TFAEnabled, + "enable_mfa": enableMFA, "secondary_email": user.SecondaryEmail, "mobile_phone": user.MobilePhone, "address": user.Address, @@ -308,13 +469,14 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "country": user.Country, "contact_type": user.ContactType, "preferred_language": user.PreferredLanguage, - "last_login": user.LastLoginDate, - "password_expired_after": user.PasswordExpiryDate, + "last_login": date.FormatRFC3339Nano(user.LastLoginDate), + "password_expired_after": date.FormatRFC3339Nano(user.PasswordExpiryDate), "tfa_configured": user.TFAConfigured, "email_update_pending": user.EmailUpdatePending, "session_timeout": *user.SessionTimeOut, "auth_grants_json": stateAuthGrantsJS(string(authGrantsJSON)), "lock": user.IsLocked, + "user_notifications": userNotifications, }) if err != nil { logger.WithError(err).Error("could not save attributes to state") @@ -349,6 +511,7 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf "time_zone", "job_title", "enable_tfa", + "enable_mfa", "secondary_email", "mobile_phone", "address", @@ -360,25 +523,32 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf "preferred_language", "session_timeout", ) + + authMethod, err := getAuthenticationMethod(d) + if err != nil { + return diag.FromErr(err) + } + if updateBasicInfo { basicUser := iam.UserBasicInfo{ - FirstName: d.Get("first_name").(string), - LastName: d.Get("last_name").(string), - UserName: d.Get("user_name").(string), - Email: d.Get("email").(string), - Phone: d.Get("phone").(string), - TimeZone: d.Get("time_zone").(string), - JobTitle: d.Get("job_title").(string), - TFAEnabled: d.Get("enable_tfa").(bool), - SecondaryEmail: d.Get("secondary_email").(string), - MobilePhone: d.Get("mobile_phone").(string), - Address: d.Get("address").(string), - City: d.Get("city").(string), - State: d.Get("state").(string), - ZipCode: d.Get("zip_code").(string), - Country: d.Get("country").(string), - ContactType: d.Get("contact_type").(string), - PreferredLanguage: d.Get("preferred_language").(string), + FirstName: d.Get("first_name").(string), + LastName: d.Get("last_name").(string), + UserName: d.Get("user_name").(string), + Email: d.Get("email").(string), + Phone: d.Get("phone").(string), + TimeZone: d.Get("time_zone").(string), + JobTitle: d.Get("job_title").(string), + TFAEnabled: d.Get("enable_tfa").(bool), + SecondaryEmail: d.Get("secondary_email").(string), + MobilePhone: d.Get("mobile_phone").(string), + Address: d.Get("address").(string), + City: d.Get("city").(string), + State: d.Get("state").(string), + ZipCode: d.Get("zip_code").(string), + Country: d.Get("country").(string), + ContactType: d.Get("contact_type").(string), + PreferredLanguage: d.Get("preferred_language").(string), + AdditionalAuthentication: iam.Authentication(authMethod), } if st, ok := d.GetOk("session_timeout"); ok { @@ -425,6 +595,41 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf needRead = true } + // user notifications + if d.HasChange("user_notifications") { + notificationsData, err := tf.GetListValue("user_notifications", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return diag.FromErr(err) + } + + userNotifications, err := extractUserNotificationsData(notificationsData) + if err != nil { + return diag.Errorf("failed to extract user notifications: %s", err) + } + + req := iam.UpdateUserNotificationsRequest{ + IdentityID: d.Id(), + Notifications: userNotifications, + } + + if _, err := client.UpdateUserNotifications(ctx, req); err != nil { + d.Partial(true) + logger.WithError(err).Errorf("failed to update user notifications") + return diag.Errorf("failed to update user notifications: %s", err) + } + needRead = true + } + + // password + if d.HasChange("password") { + err = manageUserPassword(ctx, d, client, d.Id()) + if err != nil { + logger.WithError(err).Errorf("failed to set user password") + return diag.Errorf("failed to set user password: %s", err) + } + needRead = true + } + // lock the user if d.HasChange("lock") { lock, err := tf.GetBoolValue("lock", d) @@ -620,3 +825,37 @@ func validatePhone(i interface{}, k string) (warnings []string, errors []error) return warnings, errors } + +func customizePasswordDiff(_ context.Context, d *schema.ResourceDiff, _ interface{}) error { + if d.HasChange("password") { + oldVal, newVal := d.GetChange("password") + oldPassword := oldVal.(string) + newPassword := newVal.(string) + if oldPassword != "" && newPassword == "" { + return fmt.Errorf("deleting the password field or setting the password to an empty string is not allowed") + } + } + return nil +} + +func customizeNotificationDiff(_ context.Context, d *schema.ResourceDiff, _ interface{}) error { + newValue := d.GetRawConfig() + if newValue.GetAttr("user_notifications").LengthInt() == 0 { + // Field is omitted, so apply the default configuration + defaultConfig := []interface{}{ + map[string]interface{}{ + "enable_email_notifications": true, + "api_client_credential_expiry_notification": false, + "new_user_notification": true, + "password_expiry": true, + "proactive": []interface{}{}, + "upgrade": []interface{}{}, + }, + } + if err := d.SetNew("user_notifications", defaultConfig); err != nil { + return fmt.Errorf("failed to set default notification configuration: %s", err) + } + } + + return nil +} diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index a42cb6c8c..60ce0f516 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -6,8 +6,10 @@ import ( "regexp" "strings" "testing" + "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -17,31 +19,43 @@ import ( func TestResourceUser(t *testing.T) { basicUserInfo := iam.UserBasicInfo{ - FirstName: "John", - LastName: "Smith", - Email: "jsmith@example.com", - Phone: "(111) 111-1111", - TFAEnabled: false, - Country: "country", + FirstName: "John", + LastName: "Smith", + Email: "jsmith@example.com", + Phone: "(111) 111-1111", + TFAEnabled: false, + Country: "country", + AdditionalAuthentication: "NONE", + } + + basicUserInfoWithMFA := iam.UserBasicInfo{ + FirstName: "John", + LastName: "Smith", + Email: "jsmith@example.com", + Phone: "(111) 111-1111", + TFAEnabled: false, + Country: "country", + AdditionalAuthentication: "MFA", } extendedUserInfo := iam.UserBasicInfo{ - FirstName: "John", - LastName: "Smith", - Email: "jsmith@example.com", - Phone: "(111) 111-1111", - TimeZone: "timezone", - JobTitle: "job title", - TFAEnabled: false, - SecondaryEmail: "secondary.email@example.com", - MobilePhone: "(222) 222-2222", - Address: "123 B Street", - City: "B-Town", - State: "state", - ZipCode: "zip", - Country: "country", - ContactType: "contact type", - PreferredLanguage: "language", - SessionTimeOut: ptr.To(2), + FirstName: "John", + LastName: "Smith", + Email: "jsmith@example.com", + Phone: "(111) 111-1111", + TimeZone: "timezone", + JobTitle: "job title", + TFAEnabled: false, + SecondaryEmail: "secondary.email@example.com", + MobilePhone: "(222) 222-2222", + Address: "123 B Street", + City: "B-Town", + State: "state", + ZipCode: "zip", + Country: "country", + ContactType: "contact type", + PreferredLanguage: "language", + SessionTimeOut: ptr.To(2), + AdditionalAuthentication: "NONE", } authGrantsCreate := []iam.AuthGrant{ @@ -99,14 +113,30 @@ func TestResourceUser(t *testing.T) { } notifications := iam.UserNotifications{ + EnableEmail: true, Options: iam.UserNotificationOptions{ - Proactive: []string{}, - Upgrade: []string{}, + NewUser: true, + PasswordExpiry: true, + Proactive: []string{}, + Upgrade: []string{}, + APIClientCredentialExpiry: false, }, } + + customNotifications := iam.UserNotifications{ + EnableEmail: true, + Options: iam.UserNotificationOptions{ + NewUser: true, + PasswordExpiry: true, + Proactive: []string{"EdgeScape"}, + Upgrade: []string{"NetStorage"}, + APIClientCredentialExpiry: true, + }, + } + id := "test_identity_id" - checkUserAttributes := func(user iam.User) resource.TestCheckFunc { + checkUserAttributes := func(user iam.User, checkPassword bool) resource.TestCheckFunc { if user.SessionTimeOut == nil { user.SessionTimeOut = ptr.To(0) } @@ -129,7 +159,7 @@ func TestResourceUser(t *testing.T) { authGrantsJSON = string(marshalledAuthGrants) } - return resource.ComposeAggregateTestCheckFunc( + checks := []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_iam_user.test", "id", "test_identity_id"), resource.TestCheckResourceAttr("akamai_iam_user.test", "first_name", user.FirstName), resource.TestCheckResourceAttr("akamai_iam_user.test", "last_name", user.LastName), @@ -137,6 +167,7 @@ func TestResourceUser(t *testing.T) { resource.TestCheckResourceAttr("akamai_iam_user.test", "country", user.Country), resource.TestCheckResourceAttr("akamai_iam_user.test", "phone", user.Phone), resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_tfa", fmt.Sprintf("%t", user.TFAEnabled)), + resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_mfa", fmt.Sprintf("%t", user.AdditionalAuthentication == "MFA")), resource.TestCheckResourceAttr("akamai_iam_user.test", "contact_type", user.ContactType), resource.TestCheckResourceAttr("akamai_iam_user.test", "user_name", user.UserName), resource.TestCheckResourceAttr("akamai_iam_user.test", "job_title", user.JobTitle), @@ -148,27 +179,82 @@ func TestResourceUser(t *testing.T) { resource.TestCheckResourceAttr("akamai_iam_user.test", "state", user.State), resource.TestCheckResourceAttr("akamai_iam_user.test", "zip_code", user.ZipCode), resource.TestCheckResourceAttr("akamai_iam_user.test", "preferred_language", user.PreferredLanguage), - resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", user.LastLoginDate), - resource.TestCheckResourceAttr("akamai_iam_user.test", "password_expired_after", user.PasswordExpiryDate), + resource.TestCheckResourceAttr("akamai_iam_user.test", "password_expired_after", user.PasswordExpiryDate.Format(time.RFC3339Nano)), resource.TestCheckResourceAttr("akamai_iam_user.test", "tfa_configured", fmt.Sprintf("%t", user.TFAConfigured)), resource.TestCheckResourceAttr("akamai_iam_user.test", "email_update_pending", fmt.Sprintf("%t", user.EmailUpdatePending)), resource.TestCheckResourceAttr("akamai_iam_user.test", "session_timeout", fmt.Sprintf("%d", *user.SessionTimeOut)), resource.TestCheckResourceAttr("akamai_iam_user.test", "auth_grants_json", authGrantsJSON), resource.TestCheckResourceAttr("akamai_iam_user.test", "lock", fmt.Sprintf("%t", user.IsLocked)), - ) + } + if user.LastLoginDate.IsZero() { + checks = append(checks, resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", "")) + } else { + checks = append(checks, resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", user.LastLoginDate.Format(time.RFC3339Nano))) + } + if checkPassword { + checks = append(checks, resource.TestCheckResourceAttrSet("akamai_iam_user.test", "password")) + } else { + checks = append(checks, resource.TestCheckNoResourceAttr("akamai_iam_user.test", "password")) + } + return resource.ComposeAggregateTestCheckFunc(checks...) + } + checkDefaultUserNotificationsAttributes := func(user iam.User) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.new_user_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.password_expiry", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.proactive.#", "0"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.upgrade.#", "0"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.api_client_credential_expiry_notification", "false"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true")) + } + + checkUserNotificationsAttributes := func(user iam.User) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.new_user_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.password_expiry", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.proactive.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.upgrade.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.api_client_credential_expiry_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true")) } userCreate := iam.User{ UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsCreate, Notifications: notifications, } + + userCreateNoLastLoginDate := iam.User{ + UserBasicInfo: basicUserInfo, + IdentityID: id, + IsLocked: false, + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), + TFAConfigured: true, + EmailUpdatePending: true, + AuthGrants: authGrantsCreate, + Notifications: notifications, + } + + userCreateWithNotification := iam.User{ + UserBasicInfo: basicUserInfoWithMFA, + IdentityID: id, + IsLocked: false, + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + TFAConfigured: true, + EmailUpdatePending: true, + AuthGrants: authGrantsCreate, + Notifications: customNotifications, + } basicUserInfoExtPhone := basicUserInfo basicUserInfoExtPhone.Phone = "(617) 444-3000 x2664" @@ -179,8 +265,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsSubgroupCreate, @@ -190,27 +276,33 @@ func TestResourceUser(t *testing.T) { userCreateRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, + } + + userCreateRequestWithNotifications := iam.CreateUserRequest{ + UserBasicInfo: basicUserInfoWithMFA, + AuthGrants: authGrantsCreateRequest, + Notifications: &customNotifications, } userCreateExtPhoneRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfoExtPhone, AuthGrants: authGrantsCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userSubgroupCreateRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsSubgroupCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userCreateLocked := iam.User{ UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: true, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsCreate, @@ -220,15 +312,15 @@ func TestResourceUser(t *testing.T) { userCreateLockedRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userUpdateInfo := iam.User{ UserBasicInfo: extendedUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsCreate, @@ -241,8 +333,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsUpdate, @@ -252,7 +344,7 @@ func TestResourceUser(t *testing.T) { userUpdateGrantsRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsUpdateRequest, - Notifications: notifications, + Notifications: ¬ifications, } authGrantsCreateWithIgnoredFields := []iam.AuthGrantRequest{ { @@ -282,10 +374,10 @@ func TestResourceUser(t *testing.T) { init func(*iam.Mock) steps []resource.TestStep }{ - "basic": { + "basic - default notification": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // delete @@ -294,14 +386,91 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), + }, + }, + }, + "basic - default notification, no last login date": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreateNoLastLoginDate, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreateNoLastLoginDate, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreateNoLastLoginDate, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateNoLastLoginDate, false), checkDefaultUserNotificationsAttributes(userCreateNoLastLoginDate)), + }, + }, + }, + "basic - custom notification": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequestWithNotifications, userCreateWithNotification, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreateWithNotification, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreateWithNotification, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateWithNotification, false), checkUserNotificationsAttributes(userCreateWithNotification)), + }, + }, + }, + "basic - custom notification - password_expiry field missing": { + init: func(m *iam.Mock) {}, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf"), + ExpectError: regexp.MustCompile("The argument \"password_expiry\" is required, but no definition was found."), + }, + }, + }, + "basic - custom notification - multiple user_notification blocks": { + init: func(m *iam.Mock) {}, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf"), + ExpectError: regexp.MustCompile("No more than 1 \"user_notifications\" blocks are allowed"), + }, + }, + }, + "basic - custom notification - enable_email_notifications missing": { + init: func(m *iam.Mock) {}, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf"), + ExpectError: regexp.MustCompile("The argument \"enable_email_notifications\" is required, but no definition was\nfound."), + }, + }, + }, + "basic - authentication method - NONE": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreate, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_tfa", fmt.Sprintf("%t", false)), + resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_mfa", fmt.Sprintf("%t", false))), }, }, }, "basic with extension phone number": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateExtPhoneRequest, userCreateExtPhone, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateExtPhoneRequest, userCreateExtPhone, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreateExtPhone, nil).Times(2) // delete @@ -310,14 +479,14 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_ext_phone.tf"), - Check: checkUserAttributes(userCreateExtPhone), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateExtPhone, false), checkDefaultUserNotificationsAttributes(userCreateExtPhone)), }, }, }, "basic lock": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateLockedRequest, userCreateLocked, true, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateLockedRequest, userCreateLocked, true, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Times(2) // delete @@ -326,7 +495,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_lock.tf"), - Check: checkUserAttributes(userCreateLocked), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, false), checkDefaultUserNotificationsAttributes(userCreateLocked)), }, }, }, @@ -342,7 +511,7 @@ func TestResourceUser(t *testing.T) { "basic error create": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, fmt.Errorf("error create"), nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, fmt.Errorf("error create"), nil, nil) }, steps: []resource.TestStep{ { @@ -351,10 +520,31 @@ func TestResourceUser(t *testing.T) { }, }, }, + "enable_tfa and enable_mfa set to true - error": { + init: func(m *iam.Mock) {}, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf"), + ExpectError: regexp.MustCompile("only one of 'enable_tfa' or 'enable_mfa' can be set"), + }, + }, + }, + "setting password- error": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, fmt.Errorf("error setting user password")) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + ExpectError: regexp.MustCompile("error setting user password"), + }, + }, + }, "basic no diff no update": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -366,18 +556,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: checkUserAttributes(userCreate, false), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: checkUserAttributes(userCreate, false), }, }, }, "update user info": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -392,18 +582,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_user_info.tf"), - Check: checkUserAttributes(userUpdateInfo), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateInfo, false), checkDefaultUserNotificationsAttributes(userUpdateInfo)), }, }, }, "update user info - lock - unlock": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Once() // plan @@ -422,22 +612,22 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_lock.tf"), - Check: checkUserAttributes(userCreateLocked), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, false), checkDefaultUserNotificationsAttributes(userCreateLocked)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, }, }, "update user info - error": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -451,7 +641,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_user_info.tf"), @@ -462,7 +652,7 @@ func TestResourceUser(t *testing.T) { "update user auth grants": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -477,18 +667,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_auth_grants.tf"), - Check: checkUserAttributes(userUpdateGrants), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateGrants, false), checkDefaultUserNotificationsAttributes(userUpdateGrants)), }, }, }, "update swap user auth grants subgroups": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userSubgroupCreateRequest, userSubgroupCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userSubgroupCreateRequest, userSubgroupCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userSubgroupCreate, nil).Times(2) // plan @@ -500,18 +690,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_grants.tf"), - Check: checkUserAttributes(userSubgroupCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userSubgroupCreate, false), checkDefaultUserNotificationsAttributes(userSubgroupCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_grants_swap.tf"), - Check: checkUserAttributes(userSubgroupCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userSubgroupCreate, false), checkDefaultUserNotificationsAttributes(userSubgroupCreate)), }, }, }, "update user auth grants with redundant fields": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateWithIgnoredFieldsRequest, userCreateWithIgnoredFields, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateWithIgnoredFieldsRequest, userCreateWithIgnoredFields, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreateWithIgnoredFieldsResponse, nil).Once() expectResourceIAMUserReadPhase(m, userCreateWithIgnoredFieldsResponse, nil).Once() @@ -525,18 +715,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_auth_grants.tf"), - Check: checkUserAttributes(userCreateWithIgnoredFieldsResponse), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateWithIgnoredFieldsResponse, false), checkDefaultUserNotificationsAttributes(userCreateWithIgnoredFieldsResponse)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_auth_grants.tf"), - Check: checkUserAttributes(userCreateWithIgnoredFieldsResponse), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateWithIgnoredFieldsResponse, false), checkDefaultUserNotificationsAttributes(userCreateWithIgnoredFieldsResponse)), }, }, }, "update user auth grants - an error": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -550,7 +740,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_auth_grants.tf"), @@ -561,7 +751,7 @@ func TestResourceUser(t *testing.T) { "basic import": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // import @@ -572,8 +762,8 @@ func TestResourceUser(t *testing.T) { }, steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/basic_import.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { ImportState: true, @@ -584,8 +774,7 @@ func TestResourceUser(t *testing.T) { }, }, "auth_grants_json should not panic when supplied interpolated string with unknown value": { - init: func(m *iam.Mock) { - }, + init: func(m *iam.Mock) {}, steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/auth_grants_interpolated.tf"), @@ -597,7 +786,7 @@ func TestResourceUser(t *testing.T) { "error updating email": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -609,7 +798,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: checkUserAttributes(userCreate, false), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_email.tf"), @@ -626,16 +815,140 @@ func TestResourceUser(t *testing.T) { }, }, }, + "create user with password and update user info and set new password": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + // update basic info + expectResourceIAMUserUpdateInfoAndPasswordPhase(m, userUpdateInfo.IdentityID, userUpdateInfo.UserBasicInfo, "NewPassword@123", nil).Once() + expectResourceIAMUserReadPhase(m, userUpdateInfo, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, true), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateInfo, true), checkDefaultUserNotificationsAttributes(userUpdateInfo)), + }, + }, + }, + "create user with password, set lock field as true and set new password": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateLockedRequest, userCreateLocked, true, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Once() + // update only the user password + expectPassword(m, userCreateLocked.IdentityID, "NewPassword@123", nil).Once() + expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreateLocked, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, true), checkDefaultUserNotificationsAttributes(userCreateLocked)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, true), checkDefaultUserNotificationsAttributes(userCreateLocked)), + }, + }, + }, + "create user with password and update user info and remove the password field": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, true), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password_without_password.tf"), + ExpectError: regexp.MustCompile("deleting the password field or setting the password to an empty string is not allowed"), + }, + }, + }, + "create user with password and update user info with the empty password field": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, true), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf"), + ExpectError: regexp.MustCompile("deleting the password field or setting the password to an empty string is not allowed"), + }, + }, + }, + "create without a password, later update user info and set a password": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + // update basic info + expectResourceIAMUserUpdateInfoAndPasswordPhase(m, userUpdateInfo.IdentityID, userUpdateInfo.UserBasicInfo, "NewPassword@123", nil).Once() + expectResourceIAMUserReadPhase(m, userUpdateInfo, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateInfo, true), checkDefaultUserNotificationsAttributes(userUpdateInfo)), + }, + }, + }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) @@ -644,7 +957,7 @@ func TestResourceUser(t *testing.T) { } // create -func expectResourceIAMUserCreatePhase(m *iam.Mock, request iam.CreateUserRequest, response iam.User, lock bool, creationError, lockError error) { +func expectResourceIAMUserCreatePhase(m *iam.Mock, request iam.CreateUserRequest, response iam.User, lock bool, setPassword bool, creationError, lockError error, setPasswordError error) { onCreation := m.On("CreateUser", mock.Anything, iam.CreateUserRequest{ UserBasicInfo: request.UserBasicInfo, AuthGrants: request.AuthGrants, @@ -663,6 +976,13 @@ func expectResourceIAMUserCreatePhase(m *iam.Mock, request iam.CreateUserRequest return } } + password := "Password@123" + if setPassword { + expectPassword(m, response.IdentityID, password, setPasswordError).Once() + if setPasswordError != nil { + return + } + } } func expectToggleLock(m *iam.Mock, identityID string, lock bool, err error) *mock.Call { @@ -672,11 +992,16 @@ func expectToggleLock(m *iam.Mock, identityID string, lock bool, err error) *moc return m.On("UnlockUser", mock.Anything, iam.UnlockUserRequest{IdentityID: identityID}).Return(err) } +func expectPassword(m *iam.Mock, identityID string, password string, err error) *mock.Call { + return m.On("SetUserPassword", mock.Anything, iam.SetUserPasswordRequest{IdentityID: identityID, NewPassword: password}).Return(err) +} + // read func expectResourceIAMUserReadPhase(m *iam.Mock, user iam.User, anError error) *mock.Call { on := m.On("GetUser", mock.Anything, iam.GetUserRequest{ - IdentityID: user.IdentityID, - AuthGrants: true, + IdentityID: user.IdentityID, + AuthGrants: true, + Notifications: true, }) if anError != nil { return on.Return(nil, anError).Once() @@ -696,6 +1021,20 @@ func expectResourceIAMUserInfoUpdatePhase(m *iam.Mock, id string, basicUserInfo return on.Return(&basicUserInfo, nil) } +func expectResourceIAMUserUpdateInfoAndPasswordPhase(m *iam.Mock, id string, basicUserInfo iam.UserBasicInfo, password string, anError error) *mock.Call { + on := m.On("UpdateUserInfo", mock.Anything, iam.UpdateUserInfoRequest{ + IdentityID: id, + User: basicUserInfo, + }) + + expectPassword(m, id, password, nil).Once() + + if anError != nil { + return on.Return(nil, anError).Once() + } + return on.Return(&basicUserInfo, nil) +} + // update auth grants func expectResourceIAMUserAuthGrantsUpdatePhase(m *iam.Mock, id string, authGrantsReqest []iam.AuthGrantRequest, authGrants []iam.AuthGrant, anError error) *mock.Call { on := m.On("UpdateUserAuthGrants", mock.Anything, iam.UpdateUserAuthGrantsRequest{ diff --git a/pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf b/pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf new file mode 100644 index 000000000..8aa70e27c --- /dev/null +++ b/pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_authorized_users" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf b/pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf new file mode 100644 index 000000000..e16c8194b --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_accessible_groups" "groups" { + username = "user1" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf b/pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf new file mode 100644 index 000000000..90cb348ba --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_accessible_groups" "groups" { +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf new file mode 100644 index 000000000..e02444370 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_account_switch_keys" "test" {} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf new file mode 100644 index 000000000..09c30eaae --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_account_switch_keys" "test" { + client_id = "XYZ" + filter = "ABC" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf new file mode 100644 index 000000000..07e280d0c --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_account_switch_keys" "test" { + filter = "AB" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf new file mode 100644 index 000000000..0ab5b8581 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_allowed_apis" "test" { + username = "test" + client_type = "CLIENT" + allow_account_switch = true +} diff --git a/pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf new file mode 100644 index 000000000..caeffaaed --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_allowed_apis" "test" { + username = "test" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf new file mode 100644 index 000000000..4522bddd8 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_blocked_properties" "test" { + group_id = 1 + ui_identity_id = "user123" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf new file mode 100644 index 000000000..db046023a --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_blocked_properties" "test" { + contract_id = "ctr_C-123" + ui_identity_id = "user123" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf new file mode 100644 index 000000000..5e1ac2018 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_blocked_properties" "test" { + group_id = 1 + contract_id = "ctr_C-123" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf new file mode 100644 index 000000000..7b660cd39 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf @@ -0,0 +1,10 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + + +data "akamai_iam_blocked_properties" "test" { + group_id = 1 + contract_id = "ctr_C-123" + ui_identity_id = "user123" +} diff --git a/pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf b/pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf new file mode 100644 index 000000000..8d68a5c28 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_cidr_block" "test" { + cidr_block_id = 2567 +} diff --git a/pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf b/pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf new file mode 100644 index 000000000..5d712d559 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_cidr_block" "test" { +} diff --git a/pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf b/pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf new file mode 100644 index 000000000..084f79804 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_cidr_blocks" "test" { +} diff --git a/pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf b/pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf new file mode 100644 index 000000000..1a14120bb --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_group" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataGroup/valid.tf b/pkg/providers/iam/testdata/TestDataGroup/valid.tf new file mode 100644 index 000000000..950ded310 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataGroup/valid.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_group" "test" { + group_id = 123 +} diff --git a/pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf b/pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf new file mode 100644 index 000000000..281287419 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_password_policy" "test" {} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf new file mode 100644 index 000000000..65f162a27 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "aid_12345" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf new file mode 100644 index 000000000..fff0350f9 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "raid_321" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf new file mode 100644 index 000000000..6139d8c9a --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "foo" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf new file mode 100644 index 000000000..d434c50cf --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf new file mode 100644 index 000000000..9bbece598 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf new file mode 100644 index 000000000..a4f60d6b7 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf new file mode 100644 index 000000000..308d8d81c --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "foobar" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf new file mode 100644 index 000000000..154bd5fa0 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "123foo" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf new file mode 100644 index 000000000..77e128ac3 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "all" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf new file mode 100644 index 000000000..5c60c1e27 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "assigned" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf new file mode 100644 index 000000000..92fdd17c6 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "blocked" +} diff --git a/pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf b/pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf new file mode 100644 index 000000000..eb4168a15 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + + +data "akamai_iam_role" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataRole/valid.tf b/pkg/providers/iam/testdata/TestDataRole/valid.tf new file mode 100644 index 000000000..8887458f2 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataRole/valid.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + + +data "akamai_iam_role" "test" { + role_id = 12345 +} diff --git a/pkg/providers/iam/testdata/TestDataUser/default.tf b/pkg/providers/iam/testdata/TestDataUser/default.tf new file mode 100644 index 000000000..a74248ff4 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUser/default.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_user" "test" { + ui_identity_id = "asd-12345" +} diff --git a/pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf b/pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf new file mode 100644 index 000000000..059b812cc --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_user" "test" { +} diff --git a/pkg/providers/iam/testdata/TestDataUsers/default.tf b/pkg/providers/iam/testdata/TestDataUsers/default.tf new file mode 100644 index 000000000..849e34e67 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsers/default.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users" "test" { +} diff --git a/pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf b/pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf new file mode 100644 index 000000000..bd7a462bd --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users" "test" { + group_id = 12345 +} diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf new file mode 100644 index 000000000..acdae832a --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf new file mode 100644 index 000000000..38217c5a9 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 + user_type = "gainAccess" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf new file mode 100644 index 000000000..8e3798d00 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 + user_type = "incorrect" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf new file mode 100644 index 000000000..23ae9931f --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 + user_type = "lostAccess" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf new file mode 100644 index 000000000..a70315e20 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf new file mode 100644 index 000000000..f13f24a02 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + destination_group_id = 321 +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/create.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/create.tf new file mode 100644 index 000000000..8c3382fc5 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/create.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.5/24" + comments = "test" + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf new file mode 100644 index 000000000..2d3295ba0 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.5/24" + enabled = false +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/empty_config.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/empty_config.tf new file mode 100644 index 000000000..e713fdeb3 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/empty_config.tf @@ -0,0 +1,3 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf new file mode 100644 index 000000000..2571b89ad --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.6/24" + comments = "test" + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf new file mode 100644 index 000000000..514145dbf --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.6/24" + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf new file mode 100644 index 000000000..af966e85f --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf new file mode 100644 index 000000000..6918c6a82 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.1.2.5/24" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/update.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/update.tf new file mode 100644 index 000000000..6640171bd --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/update.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.99/24" + comments = "test-updated" + enabled = false +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf b/pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf new file mode 100644 index 000000000..1f0c48566 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_ip_allowlist" "test" { + enable = false +} diff --git a/pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf b/pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf new file mode 100644 index 000000000..fa9ea229e --- /dev/null +++ b/pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_ip_allowlist" "test" { + enable = true +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf new file mode 100644 index 000000000..671007198 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf @@ -0,0 +1,14 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf index 5f448e0fb..671007198 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf @@ -3,12 +3,12 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf new file mode 100644 index 000000000..671007198 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf @@ -0,0 +1,14 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf index 6b10c7d9a..fc156d1b8 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf @@ -3,13 +3,12 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - lock = true - + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + lock = true auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf new file mode 100644 index 000000000..e913c9799 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf @@ -0,0 +1,26 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf new file mode 100644 index 000000000..035416472 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf @@ -0,0 +1,25 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf new file mode 100644 index 000000000..088be9bbb --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf @@ -0,0 +1,38 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + enable_email_notifications = true + } + user_notifications { + api_client_credential_expiry_notification = false + new_user_notification = true + password_expiry = false + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf new file mode 100644 index 000000000..ad4c96db8 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf @@ -0,0 +1,25 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + api_client_credential_expiry_notification = true + new_user_notification = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf new file mode 100644 index 000000000..279ec3db8 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + password = "Password@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf new file mode 100644 index 000000000..ce5381aed --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + lock = true + password = "Password@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf new file mode 100644 index 000000000..671007198 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf @@ -0,0 +1,14 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf new file mode 100644 index 000000000..d240d280d --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = true + enable_mfa = true + password = "Password@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf index 43462bdf1..8e84d49b1 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf @@ -3,12 +3,11 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false auth_grants_json = "[{\"groupId\":1,\"groupName\":\"other_group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf index e9071846e..2060c5efb 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf @@ -3,12 +3,12 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@update.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - + first_name = "John" + last_name = "Smith" + email = "jsmith@update.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + password = "Password@123" auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf new file mode 100644 index 000000000..03bfd98df --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf @@ -0,0 +1,26 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + enable_tfa = false + + contact_type = "contact type" + job_title = "job title" + time_zone = "timezone" + secondary_email = "secondary.email@example.com" + mobile_phone = "+49 98765 4321" + address = "123 B Street" + city = "B-Town" + state = "state" + zip_code = "zip" + preferred_language = "language" + session_timeout = 2 + password = "NewPassword@123" + + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf new file mode 100644 index 000000000..e3536775d --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + lock = true + password = "NewPassword@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf new file mode 100644 index 000000000..84337911a --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf @@ -0,0 +1,25 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + enable_tfa = false + + contact_type = "contact type" + job_title = "job title" + time_zone = "timezone" + secondary_email = "secondary.email@example.com" + mobile_phone = "+49 98765 4321" + address = "123 B Street" + city = "B-Town" + state = "state" + zip_code = "zip" + preferred_language = "language" + session_timeout = 2 + password = "" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf new file mode 100644 index 000000000..6179f3876 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf @@ -0,0 +1,25 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + enable_tfa = false + + contact_type = "contact type" + job_title = "job title" + time_zone = "timezone" + secondary_email = "secondary.email@example.com" + mobile_phone = "+49 98765 4321" + address = "123 B Street" + city = "B-Town" + state = "state" + zip_code = "zip" + preferred_language = "language" + session_timeout = 2 + + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/imaging/data_akamai_imaging_policy_image.go b/pkg/providers/imaging/data_akamai_imaging_policy_image.go index 513f29f38..bc9f0d36b 100644 --- a/pkg/providers/imaging/data_akamai_imaging_policy_image.go +++ b/pkg/providers/imaging/data_akamai_imaging_policy_image.go @@ -7,7 +7,7 @@ import ( "encoding/json" "io" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/imaging/imagewriter" diff --git a/pkg/providers/imaging/data_akamai_imaging_policy_video.go b/pkg/providers/imaging/data_akamai_imaging_policy_video.go index 72a5150ea..bf9862e0d 100644 --- a/pkg/providers/imaging/data_akamai_imaging_policy_video.go +++ b/pkg/providers/imaging/data_akamai_imaging_policy_video.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/imaging/videowriter" diff --git a/pkg/providers/imaging/imagewriter/convert-image.gen.go b/pkg/providers/imaging/imagewriter/convert-image.gen.go index e95316a09..39118e44d 100644 --- a/pkg/providers/imaging/imagewriter/convert-image.gen.go +++ b/pkg/providers/imaging/imagewriter/convert-image.gen.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/imaging/provider.go b/pkg/providers/imaging/provider.go index 3040aa9e8..1a86058b7 100644 --- a/pkg/providers/imaging/provider.go +++ b/pkg/providers/imaging/provider.go @@ -4,7 +4,7 @@ package imaging import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/imaging/provider_test.go b/pkg/providers/imaging/provider_test.go index 3dfd74400..c88dbff38 100644 --- a/pkg/providers/imaging/provider_test.go +++ b/pkg/providers/imaging/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_image.go b/pkg/providers/imaging/resource_akamai_imaging_policy_image.go index 08c7c6ee1..d4188b9f8 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_image.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_image.go @@ -10,8 +10,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go b/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go index 89836abb0..7cd8d5809 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_set.go b/pkg/providers/imaging/resource_akamai_imaging_policy_set.go index 5199da58f..0d927d4fd 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_set.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_set.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go b/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go index c08755eec..49c6c1680 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_video.go b/pkg/providers/imaging/resource_akamai_imaging_policy_video.go index 2c9538a1a..7a75ee82b 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_video.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_video.go @@ -10,8 +10,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go b/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go index b301b1cf0..d964448c0 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/imaging/videowriter/convert-video.gen.go b/pkg/providers/imaging/videowriter/convert-video.gen.go index 9490a3ba6..4bd609fa7 100644 --- a/pkg/providers/imaging/videowriter/convert-video.gen.go +++ b/pkg/providers/imaging/videowriter/convert-video.gen.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/networklists/data_akamai_network_network_lists.go b/pkg/providers/networklists/data_akamai_network_network_lists.go index f0509b466..c885bbe40 100644 --- a/pkg/providers/networklists/data_akamai_network_network_lists.go +++ b/pkg/providers/networklists/data_akamai_network_network_lists.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go b/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go index 231907a33..5810c1e13 100644 --- a/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go +++ b/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/provider.go b/pkg/providers/networklists/provider.go index ebe59f29c..1b527868e 100644 --- a/pkg/providers/networklists/provider.go +++ b/pkg/providers/networklists/provider.go @@ -4,7 +4,7 @@ package networklists import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" @@ -16,7 +16,7 @@ import ( type ( // Subprovider gathers networklists resources and data sources Subprovider struct { - client networklists.NTWRKLISTS + client networklists.NetworkList } option func(p *Subprovider) @@ -43,14 +43,14 @@ func NewSubprovider(opts ...option) *Subprovider { return inst } -func withClient(c networklists.NTWRKLISTS) option { +func withClient(c networklists.NetworkList) option { return func(p *Subprovider) { p.client = c } } -// Client returns the NTWRKLISTS interface -func (p *Subprovider) Client(meta meta.Meta) networklists.NTWRKLISTS { +// Client returns the NetworkList interface +func (p *Subprovider) Client(meta meta.Meta) networklists.NetworkList { if p.client != nil { return p.client } diff --git a/pkg/providers/networklists/provider_test.go b/pkg/providers/networklists/provider_test.go index 904b12db2..5fe1ee9fd 100644 --- a/pkg/providers/networklists/provider_test.go +++ b/pkg/providers/networklists/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) @@ -16,7 +16,7 @@ func TestMain(m *testing.M) { var clientLock sync.Mutex // useClient swaps out the client on the global instance for the duration of the given func -func useClient(client networklists.NTWRKLISTS, f func()) { +func useClient(client networklists.NetworkList, f func()) { clientLock.Lock() orig := inst.client inst.client = client diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations.go b/pkg/providers/networklists/resource_akamai_networklist_activations.go index 804e6eca8..9b48a4a26 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_activations.go +++ b/pkg/providers/networklists/resource_akamai_networklist_activations.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/go-hclog" @@ -134,7 +134,7 @@ func resourceActivationsCreate(ctx context.Context, d *schema.ResourceData, m in return resourceActivationsRead(ctx, d, m) } -func createActivation(ctx context.Context, client networklists.NTWRKLISTS, params networklists.CreateActivationsRequest) (*networklists.CreateActivationsResponse, diag.Diagnostics) { +func createActivation(ctx context.Context, client networklists.NetworkList, params networklists.CreateActivationsRequest) (*networklists.CreateActivationsResponse, diag.Diagnostics) { createNetworkListActivationMutex.Lock() defer func() { createNetworkListActivationMutex.Unlock() @@ -263,7 +263,7 @@ func resourceActivationsDelete(_ context.Context, _ *schema.ResourceData, m inte } } -func lookupActivation(ctx context.Context, client networklists.NTWRKLISTS, query networklists.GetActivationRequest) (*networklists.GetActivationResponse, error) { +func lookupActivation(ctx context.Context, client networklists.NetworkList, query networklists.GetActivationRequest) (*networklists.GetActivationResponse, error) { activation, err := client.GetActivation(ctx, query) if err != nil { return nil, err @@ -278,7 +278,7 @@ func suppressFieldsForNetworkListActivation(_, oldValue, newValue string, d *sch return true } -func pollActivation(ctx context.Context, client networklists.NTWRKLISTS, activationStatus string, activationID int) error { +func pollActivation(ctx context.Context, client networklists.NetworkList, activationStatus string, activationID int) error { retriesMax := 5 retries5xx := 0 diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations_test.go b/pkg/providers/networklists/resource_akamai_networklist_activations_test.go index 6321fe0f9..81e7ac509 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_activations_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_activations_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list.go b/pkg/providers/networklists/resource_akamai_networklist_network_list.go index be3d91ae2..547f75039 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list.go @@ -7,7 +7,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go index 9d9bc4866..10ce3e305 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go index fe93f21b1..7b640535d 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go index 0e3e4c2ae..6fc958ff7 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go index 23c3bf211..a79c1595f 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go index dfc701bc5..60ae47e04 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_contracts.go b/pkg/providers/property/data_akamai_contracts.go index 638d7a6a8..3f4b837db 100644 --- a/pkg/providers/property/data_akamai_contracts.go +++ b/pkg/providers/property/data_akamai_contracts.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/data_akamai_contracts_test.go b/pkg/providers/property/data_akamai_contracts_test.go index 254351705..a7117bf28 100644 --- a/pkg/providers/property/data_akamai_contracts_test.go +++ b/pkg/providers/property/data_akamai_contracts_test.go @@ -3,7 +3,7 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_cp_code.go b/pkg/providers/property/data_akamai_cp_code.go index 59793f073..597a89561 100644 --- a/pkg/providers/property/data_akamai_cp_code.go +++ b/pkg/providers/property/data_akamai_cp_code.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/property/data_akamai_cp_code_test.go b/pkg/providers/property/data_akamai_cp_code_test.go index 2f093cca3..71223ee2f 100644 --- a/pkg/providers/property/data_akamai_cp_code_test.go +++ b/pkg/providers/property/data_akamai_cp_code_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_properties.go b/pkg/providers/property/data_akamai_properties.go index aa41c0bcb..3ebbc1082 100644 --- a/pkg/providers/property/data_akamai_properties.go +++ b/pkg/providers/property/data_akamai_properties.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -33,16 +33,48 @@ func dataSourceProperties() *schema.Resource { Description: "List of properties", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "contract_id": {Type: schema.TypeString, Computed: true}, - "group_id": {Type: schema.TypeString, Computed: true}, - "latest_version": {Type: schema.TypeInt, Computed: true}, - "note": {Type: schema.TypeString, Computed: true}, - "product_id": {Type: schema.TypeString, Computed: true}, - "production_version": {Type: schema.TypeInt, Computed: true}, - "property_id": {Type: schema.TypeString, Computed: true}, - "property_name": {Type: schema.TypeString, Computed: true}, - "rule_format": {Type: schema.TypeString, Computed: true}, - "staging_version": {Type: schema.TypeInt, Computed: true}, + "contract_id": { + Type: schema.TypeString, + Computed: true, + }, + "group_id": { + Type: schema.TypeString, + Computed: true, + }, + "latest_version": { + Type: schema.TypeInt, + Computed: true, + }, + "note": { + Type: schema.TypeString, + Computed: true, + }, + "product_id": { + Type: schema.TypeString, + Computed: true, + Deprecated: "This field is deprecated. Please use `akamai_property` to get this data", + }, + "production_version": { + Type: schema.TypeInt, + Computed: true, + }, + "property_id": { + Type: schema.TypeString, + Computed: true, + }, + "property_name": { + Type: schema.TypeString, + Computed: true, + }, + "rule_format": { + Type: schema.TypeString, + Computed: true, + Deprecated: "This field is deprecated. Please use `akamai_property` to get this data", + }, + "staging_version": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -81,31 +113,37 @@ func dataPropertiesRead(ctx context.Context, d *schema.ResourceData, m interface // setting concatenated id to uniquely identify data d.SetId(groupID + contractID) - if err := d.Set("properties", sliceResponseProperties(propertiesResponse)); err != nil { + properties, err := sliceResponseProperties(propertiesResponse) + if err != nil { + return diag.FromErr(err) + } + + if err := d.Set("properties", properties); err != nil { return diag.Errorf("error setting properties: %s", err) } return nil } -func sliceResponseProperties(propertiesResponse *papi.GetPropertiesResponse) []map[string]interface{} { +func sliceResponseProperties(propertiesResponse *papi.GetPropertiesResponse) ([]map[string]interface{}, error) { var properties []map[string]interface{} for _, item := range propertiesResponse.Properties.Items { + property := map[string]interface{}{ "contract_id": item.ContractID, "group_id": item.GroupID, "latest_version": item.LatestVersion, "note": item.Note, - "product_id": item.ProductID, + "product_id": nil, "production_version": decodeVersion(item.ProductionVersion), "property_id": item.PropertyID, "property_name": item.PropertyName, - "rule_format": item.RuleFormat, + "rule_format": nil, "staging_version": decodeVersion(item.StagingVersion), } properties = append(properties, property) } - return properties + return properties, nil } func decodeVersion(version interface{}) int { diff --git a/pkg/providers/property/data_akamai_properties_search.go b/pkg/providers/property/data_akamai_properties_search.go index 000ca6f22..01f9b4c42 100644 --- a/pkg/providers/property/data_akamai_properties_search.go +++ b/pkg/providers/property/data_akamai_properties_search.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/property/data_akamai_properties_search_test.go b/pkg/providers/property/data_akamai_properties_search_test.go index a7937aac8..43451f396 100644 --- a/pkg/providers/property/data_akamai_properties_search_test.go +++ b/pkg/providers/property/data_akamai_properties_search_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_properties_test.go b/pkg/providers/property/data_akamai_properties_test.go index 18a53e459..c83e4e102 100644 --- a/pkg/providers/property/data_akamai_properties_test.go +++ b/pkg/providers/property/data_akamai_properties_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -14,7 +14,7 @@ func TestDataProperties(t *testing.T) { t.Run("list properties", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items) + properties := decodePropertyItems(props.Items, "", "") client.On("GetProperties", mock.Anything, @@ -37,7 +37,7 @@ func TestDataProperties(t *testing.T) { t.Run("list properties without group prefix", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items) + properties := decodePropertyItems(props.Items, "", "") client.On("GetProperties", mock.Anything, @@ -60,7 +60,7 @@ func TestDataProperties(t *testing.T) { t.Run("list properties without contract prefix", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items) + properties := decodePropertyItems(props.Items, "", "") client.On("GetProperties", mock.Anything, @@ -91,11 +91,9 @@ func buildPapiProperties() []*papi.Property { GroupID: "grp_test", LatestVersion: 1, Note: fmt.Sprintf("note%v", i), - ProductID: "prd1", ProductionVersion: nil, PropertyID: fmt.Sprintf("prp%v", i), PropertyName: fmt.Sprintf("prpname%v", i), - RuleFormat: "latest", StagingVersion: nil, } } @@ -121,7 +119,7 @@ func buildAggregatedTest(properties []map[string]interface{}, id, groupID, contr return resource.ComposeAggregateTestCheckFunc(testVar...) } -func decodePropertyItems(items []*papi.Property) []map[string]interface{} { +func decodePropertyItems(items []*papi.Property, ruleFormat, productID string) []map[string]interface{} { properties := make([]map[string]interface{}, 0) for _, item := range items { prop := map[string]interface{}{ @@ -129,11 +127,11 @@ func decodePropertyItems(items []*papi.Property) []map[string]interface{} { "group_id": item.GroupID, "latest_version": item.LatestVersion, "note": item.Note, - "product_id": item.ProductID, + "product_id": productID, "production_version": decodeVersion(item.ProductionVersion), "property_id": item.PropertyID, "property_name": item.PropertyName, - "rule_format": item.RuleFormat, + "rule_format": ruleFormat, "staging_version": decodeVersion(item.StagingVersion), } properties = append(properties, prop) diff --git a/pkg/providers/property/data_akamai_property.go b/pkg/providers/property/data_akamai_property.go index 7dd03f897..e08529f39 100644 --- a/pkg/providers/property/data_akamai_property.go +++ b/pkg/providers/property/data_akamai_property.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) @@ -78,6 +78,11 @@ func dataSourceProperty() *schema.Resource { Computed: true, Description: "Property's version currently activated in staging (zero when not active in staging).", }, + "asset_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the property in the Identity and Access Management API.", + }, }, } } @@ -164,6 +169,7 @@ func getRulesForProperty(ctx context.Context, property *papi.Property, meta meta func getPropertyAttributes(propertyResponse *papi.Property, propertyVersionResponse *papi.GetPropertyVersionsResponse) map[string]interface{} { propertyVersion := propertyVersionResponse.Version property := map[string]interface{}{ + "asset_id": propertyResponse.AssetID, "contract_id": propertyResponse.ContractID, "group_id": propertyResponse.GroupID, "latest_version": propertyResponse.LatestVersion, diff --git a/pkg/providers/property/data_akamai_property_activation.go b/pkg/providers/property/data_akamai_property_activation.go index 6a8a2921c..81671ecf9 100644 --- a/pkg/providers/property/data_akamai_property_activation.go +++ b/pkg/providers/property/data_akamai_property_activation.go @@ -3,8 +3,8 @@ package property import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_activation_test.go b/pkg/providers/property/data_akamai_property_activation_test.go index 5eb7ac802..b7e36ef8d 100644 --- a/pkg/providers/property/data_akamai_property_activation_test.go +++ b/pkg/providers/property/data_akamai_property_activation_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_hostnames.go b/pkg/providers/property/data_akamai_property_hostnames.go index f48b17318..64f5783e9 100644 --- a/pkg/providers/property/data_akamai_property_hostnames.go +++ b/pkg/providers/property/data_akamai_property_hostnames.go @@ -5,8 +5,8 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_property_hostnames_test.go b/pkg/providers/property/data_akamai_property_hostnames_test.go index 9a9a1304f..639da19c4 100644 --- a/pkg/providers/property/data_akamai_property_hostnames_test.go +++ b/pkg/providers/property/data_akamai_property_hostnames_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_include.go b/pkg/providers/property/data_akamai_property_include.go index 6eb26424f..5bde6078b 100644 --- a/pkg/providers/property/data_akamai_property_include.go +++ b/pkg/providers/property/data_akamai_property_include.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -28,6 +28,7 @@ type includeDataSource struct { // includeDataSourceModel describes the data source data model for PropertyIncludeDataSource. type includeDataSourceModel struct { + AssetID types.String `tfsdk:"asset_id"` ContractID types.String `tfsdk:"contract_id"` GroupID types.String `tfsdk:"group_id"` IncludeID types.String `tfsdk:"include_id"` @@ -85,6 +86,10 @@ func (d *includeDataSource) Schema(_ context.Context, _ datasource.SchemaRequest MarkdownDescription: "Identifier of the data source", Computed: true, }, + "asset_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "ID of the include in the Identity and Access Management API.", + }, }, } } @@ -130,6 +135,7 @@ func (d *includeDataSource) Read(ctx context.Context, req datasource.ReadRequest include := getIncludeResp.Include + data.AssetID = types.StringValue(include.AssetID) data.Name = types.StringValue(include.IncludeName) data.Type = types.StringValue(string(include.IncludeType)) data.LatestVersion = types.Int64Value(int64(include.LatestVersion)) diff --git a/pkg/providers/property/data_akamai_property_include_activation.go b/pkg/providers/property/data_akamai_property_include_activation.go index 78585cfbe..51122665a 100644 --- a/pkg/providers/property/data_akamai_property_include_activation.go +++ b/pkg/providers/property/data_akamai_property_include_activation.go @@ -6,7 +6,7 @@ import ( "sort" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_include_activation_test.go b/pkg/providers/property/data_akamai_property_include_activation_test.go index 1e634067d..886160b42 100644 --- a/pkg/providers/property/data_akamai_property_include_activation_test.go +++ b/pkg/providers/property/data_akamai_property_include_activation_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/property/data_akamai_property_include_parents.go b/pkg/providers/property/data_akamai_property_include_parents.go index 3d77e0c73..a7c24e866 100644 --- a/pkg/providers/property/data_akamai_property_include_parents.go +++ b/pkg/providers/property/data_akamai_property_include_parents.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_include_parents_test.go b/pkg/providers/property/data_akamai_property_include_parents_test.go index 18b7bc579..1bf8093da 100644 --- a/pkg/providers/property/data_akamai_property_include_parents_test.go +++ b/pkg/providers/property/data_akamai_property_include_parents_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_include_rules.go b/pkg/providers/property/data_akamai_property_include_rules.go index 18bc41e7b..fc17bd801 100644 --- a/pkg/providers/property/data_akamai_property_include_rules.go +++ b/pkg/providers/property/data_akamai_property_include_rules.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_include_rules_test.go b/pkg/providers/property/data_akamai_property_include_rules_test.go index 9c56019c5..3d2a4701f 100644 --- a/pkg/providers/property/data_akamai_property_include_rules_test.go +++ b/pkg/providers/property/data_akamai_property_include_rules_test.go @@ -8,7 +8,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/property/data_akamai_property_include_test.go b/pkg/providers/property/data_akamai_property_include_test.go index fb4428f37..7ad2fc7dd 100644 --- a/pkg/providers/property/data_akamai_property_include_test.go +++ b/pkg/providers/property/data_akamai_property_include_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -31,6 +31,7 @@ func TestDataPropertyInclude(t *testing.T) { Includes: papi.IncludeItems{ Items: []papi.Include{ { + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, @@ -40,6 +41,7 @@ func TestDataPropertyInclude(t *testing.T) { }, }, Include: papi.Include{ + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, @@ -49,6 +51,7 @@ func TestDataPropertyInclude(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "inc_name", "type": "MICROSERVICES", "latest_version": "4", @@ -68,6 +71,7 @@ func TestDataPropertyInclude(t *testing.T) { Includes: papi.IncludeItems{ Items: []papi.Include{ { + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, @@ -77,6 +81,7 @@ func TestDataPropertyInclude(t *testing.T) { }, }, Include: papi.Include{ + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, diff --git a/pkg/providers/property/data_akamai_property_includes.go b/pkg/providers/property/data_akamai_property_includes.go index 4d416ed4a..c673b9511 100644 --- a/pkg/providers/property/data_akamai_property_includes.go +++ b/pkg/providers/property/data_akamai_property_includes.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_includes_test.go b/pkg/providers/property/data_akamai_property_includes_test.go index 2baa857ae..8b86939a8 100644 --- a/pkg/providers/property/data_akamai_property_includes_test.go +++ b/pkg/providers/property/data_akamai_property_includes_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_products.go b/pkg/providers/property/data_akamai_property_products.go index 7284d58cf..f33a297b0 100644 --- a/pkg/providers/property/data_akamai_property_products.go +++ b/pkg/providers/property/data_akamai_property_products.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_property_products_test.go b/pkg/providers/property/data_akamai_property_products_test.go index 0e0a4ac08..a49674eb3 100644 --- a/pkg/providers/property/data_akamai_property_products_test.go +++ b/pkg/providers/property/data_akamai_property_products_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_rule_formats_test.go b/pkg/providers/property/data_akamai_property_rule_formats_test.go index 163c75103..b59990a77 100644 --- a/pkg/providers/property/data_akamai_property_rule_formats_test.go +++ b/pkg/providers/property/data_akamai_property_rule_formats_test.go @@ -3,7 +3,7 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_rules.go b/pkg/providers/property/data_akamai_property_rules.go index 8be464d67..8eb1a07cb 100644 --- a/pkg/providers/property/data_akamai_property_rules.go +++ b/pkg/providers/property/data_akamai_property_rules.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_property_rules_builder.go b/pkg/providers/property/data_akamai_property_rules_builder.go index cef4a9b3d..958194215 100644 --- a/pkg/providers/property/data_akamai_property_rules_builder.go +++ b/pkg/providers/property/data_akamai_property_rules_builder.go @@ -7,7 +7,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/property/ruleformats" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_rules_template_test.go b/pkg/providers/property/data_akamai_property_rules_template_test.go index c643ca4db..f03c399f5 100644 --- a/pkg/providers/property/data_akamai_property_rules_template_test.go +++ b/pkg/providers/property/data_akamai_property_rules_template_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_rules_test.go b/pkg/providers/property/data_akamai_property_rules_test.go index eb29a24f9..7dae88bff 100644 --- a/pkg/providers/property/data_akamai_property_rules_test.go +++ b/pkg/providers/property/data_akamai_property_rules_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_test.go b/pkg/providers/property/data_akamai_property_test.go index 146b5af77..d611ec0a1 100644 --- a/pkg/providers/property/data_akamai_property_test.go +++ b/pkg/providers/property/data_akamai_property_test.go @@ -2,15 +2,13 @@ package property import ( "fmt" - "log" "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/mock" ) @@ -45,6 +43,7 @@ func TestDataProperty(t *testing.T) { }).Return(&papi.GetPropertyResponse{ Properties: papi.PropertiesItems{Items: []*papi.Property{ { + AssetID: "aid_555", ContractID: "ctr_1", GroupID: "grp_1", LatestVersion: 1, @@ -90,6 +89,7 @@ func TestDataProperty(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "property_name", "rules": compactJSON(testutils.LoadFixtureBytes(t, "testdata/TestDataProperty/no_version_rules.json")), "contract_id": "ctr_1", @@ -127,6 +127,7 @@ func TestDataProperty(t *testing.T) { }).Return(&papi.GetPropertyResponse{ Properties: papi.PropertiesItems{Items: []*papi.Property{ { + AssetID: "aid_555", ContractID: "ctr_1", GroupID: "grp_1", LatestVersion: 1, @@ -172,6 +173,7 @@ func TestDataProperty(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "property_name", "rules": compactJSON(testutils.LoadFixtureBytes(t, "testdata/TestDataProperty/with_version_rules.json")), "contract_id": "ctr_1", @@ -209,6 +211,7 @@ func TestDataProperty(t *testing.T) { }).Return(&papi.GetPropertyResponse{ Properties: papi.PropertiesItems{Items: []*papi.Property{ { + AssetID: "aid_555", ContractID: "ctr_1", GroupID: "grp_1", LatestVersion: 1, @@ -252,6 +255,7 @@ func TestDataProperty(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "property_name", "rules": compactJSON(testutils.LoadFixtureBytes(t, "testdata/TestDataProperty/no_version_rules.json")), "contract_id": "ctr_1", @@ -448,22 +452,3 @@ func TestDataProperty(t *testing.T) { }) } } - -func testAccDataSourcePropertyBasic() string { - return ` - provider "akamai" { - papi_section = "papi" - } - -data "akamai_property" "test" { - name = "terraform-test-datasource" - version = 1 -} -` -} - -func testAccCheckDataSourcePropertyDestroy(_ *terraform.State) error { - log.Printf("[DEBUG] [Group] Searching for Property Delete skipped ") - - return nil -} diff --git a/pkg/providers/property/data_property_akamai_contract.go b/pkg/providers/property/data_property_akamai_contract.go index 80a79bbbf..f75d90019 100644 --- a/pkg/providers/property/data_property_akamai_contract.go +++ b/pkg/providers/property/data_property_akamai_contract.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_property_akamai_contract_test.go b/pkg/providers/property/data_property_akamai_contract_test.go index cb65d2fb2..13cfb6370 100644 --- a/pkg/providers/property/data_property_akamai_contract_test.go +++ b/pkg/providers/property/data_property_akamai_contract_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) diff --git a/pkg/providers/property/data_property_akamai_group.go b/pkg/providers/property/data_property_akamai_group.go index ad4373fea..591fcec5a 100644 --- a/pkg/providers/property/data_property_akamai_group.go +++ b/pkg/providers/property/data_property_akamai_group.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_property_akamai_group_test.go b/pkg/providers/property/data_property_akamai_group_test.go index 7ca83034d..72727a937 100644 --- a/pkg/providers/property/data_property_akamai_group_test.go +++ b/pkg/providers/property/data_property_akamai_group_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_property_akamai_groups.go b/pkg/providers/property/data_property_akamai_groups.go index 3bcb7e836..7fcbfac47 100644 --- a/pkg/providers/property/data_property_akamai_groups.go +++ b/pkg/providers/property/data_property_akamai_groups.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_property_akamai_groups_test.go b/pkg/providers/property/data_property_akamai_groups_test.go index 04dbc264b..612634b65 100644 --- a/pkg/providers/property/data_property_akamai_groups_test.go +++ b/pkg/providers/property/data_property_akamai_groups_test.go @@ -4,7 +4,7 @@ import ( "log" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/pkg/providers/property/diff_suppress_funcs.go b/pkg/providers/property/diff_suppress_funcs.go index 4961856b8..1a180ce13 100644 --- a/pkg/providers/property/diff_suppress_funcs.go +++ b/pkg/providers/property/diff_suppress_funcs.go @@ -6,7 +6,7 @@ import ( "reflect" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/diff_suppress_funcs_test.go b/pkg/providers/property/diff_suppress_funcs_test.go index cb59e3934..df9eceb69 100644 --- a/pkg/providers/property/diff_suppress_funcs_test.go +++ b/pkg/providers/property/diff_suppress_funcs_test.go @@ -3,7 +3,7 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/tj/assert" ) diff --git a/pkg/providers/property/helpers.go b/pkg/providers/property/helpers.go index 07cd34ce1..c62036c72 100644 --- a/pkg/providers/property/helpers.go +++ b/pkg/providers/property/helpers.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -226,8 +226,7 @@ type papiKey struct { contractID string } -func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key papiKey, - destGroupID string) error { +func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key papiKey, destGroupID string) error { logger := log.FromContext(ctx).WithFields(log.Fields{ "key": key, @@ -262,7 +261,7 @@ func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key err = iamClient.MoveProperty(ctx, iam.MovePropertyRequest{ PropertyID: int64(iamID), - BodyParams: iam.MovePropertyReqBody{ + Body: iam.MovePropertyRequestBody{ DestinationGroupID: int64(to), SourceGroupID: int64(from), }, diff --git a/pkg/providers/property/helpers_test.go b/pkg/providers/property/helpers_test.go index ce13f4591..3a321cf5a 100644 --- a/pkg/providers/property/helpers_test.go +++ b/pkg/providers/property/helpers_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/property/log_fields.go b/pkg/providers/property/log_fields.go index d121e8639..c4e72d5e7 100644 --- a/pkg/providers/property/log_fields.go +++ b/pkg/providers/property/log_fields.go @@ -5,7 +5,7 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" ) // Get loggable fields from given arguments diff --git a/pkg/providers/property/provider.go b/pkg/providers/property/provider.go index 2ebac4e0f..563987260 100644 --- a/pkg/providers/property/provider.go +++ b/pkg/providers/property/provider.go @@ -6,9 +6,9 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" diff --git a/pkg/providers/property/provider_test.go b/pkg/providers/property/provider_test.go index 7ffd86977..2df3db291 100644 --- a/pkg/providers/property/provider_test.go +++ b/pkg/providers/property/provider_test.go @@ -5,9 +5,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/go-hclog" ) diff --git a/pkg/providers/property/resource_akamai_cp_code.go b/pkg/providers/property/resource_akamai_cp_code.go index 15a79c4b3..276828e29 100644 --- a/pkg/providers/property/resource_akamai_cp_code.go +++ b/pkg/providers/property/resource_akamai_cp_code.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/property/resource_akamai_cp_code_test.go b/pkg/providers/property/resource_akamai_cp_code_test.go index f7285c8ea..ba2780455 100644 --- a/pkg/providers/property/resource_akamai_cp_code_test.go +++ b/pkg/providers/property/resource_akamai_cp_code_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/pkg/providers/property/resource_akamai_edge_hostname.go b/pkg/providers/property/resource_akamai_edge_hostname.go index 63a02f356..c8107ecd9 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname.go +++ b/pkg/providers/property/resource_akamai_edge_hostname.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" @@ -531,13 +531,31 @@ func resourceSecureEdgeHostNameDelete(_ context.Context, d *schema.ResourceData, return nil } +// resourceSecureEdgeHostNameImport accepts the following import ID: +// EdgehostNameID,contractID,groupID[,productID] +// productID is optional and needs to be specified if the resource config contains the product_id +// attribute (which is not the case for the configuration generated by export done with Akamai +// CLI tools). func resourceSecureEdgeHostNameImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { meta := meta.Must(m) client := Client(meta) + logger := meta.Log("PAPI", "resourceSecureEdgeHostNameImport") parts := strings.Split(d.Id(), ",") - if len(parts) < 3 { - return nil, fmt.Errorf("comma-separated list of EdgehostNameID, contractID and groupID has to be supplied in import: %s", d.Id()) + if len(parts) < 3 || len(parts) > 4 { + return nil, fmt.Errorf("expected import identifier with format: "+ + `"EdgehostNameID,contractID,groupID[,productID]". Got: %q`, d.Id()) + } + + if len(parts) == 4 { + if len(parts[3]) == 0 { + return nil, fmt.Errorf("productID is empty for the import ID=%q", d.Id()) + } + productID := str.AddPrefix(parts[3], "prd_") + logger.Debugf("Setting product_id=%s", productID) + if err := d.Set("product_id", productID); err != nil { + return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) + } } edgehostID := parts[0] diff --git a/pkg/providers/property/resource_akamai_edge_hostname_test.go b/pkg/providers/property/resource_akamai_edge_hostname_test.go index 6d1f04fdb..304536cfb 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname_test.go +++ b/pkg/providers/property/resource_akamai_edge_hostname_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -1688,6 +1688,176 @@ func TestResourceEdgeHostname(t *testing.T) { }, }, }, + "error on updating product id": { + init: func(mp *papi.Mock, _ *hapi.Mock) { + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_2", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + }}, + }, nil).Once() + mp.On("CreateEdgeHostname", mock.Anything, papi.CreateEdgeHostnameRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostname: papi.EdgeHostnameCreate{ + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "akamaized.net", + SecureNetwork: "SHARED_CERT", + IPVersionBehavior: "IPV6_COMPLIANCE", + }, + }).Return(&papi.CreateEdgeHostnameResponse{ + EdgeHostnameID: "ehn_456", + }, nil) + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_2", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_456", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV6_COMPLIANCE", + }, + }}, + }, nil) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_akamaized_net.tf")), + }, + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_akamaized_net_different_product_id.tf")), + ExpectError: regexp.MustCompile(`Changes to non-updatable fields 'product_id' and 'certificate' are not permitted`), + }, + }, + }, + "error on updating certificate": { + init: func(mp *papi.Mock, _ *hapi.Mock) { + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV6_PERFORMANCE", + }, + { + ID: "ehn_2", + Domain: "test.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV6_PERFORMANCE", + }, + }}, + }, nil).Once() + mp.On("CreateEdgeHostname", mock.Anything, papi.CreateEdgeHostnameRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostname: papi.EdgeHostnameCreate{ + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "edgekey.net", + SecureNetwork: "ENHANCED_TLS", + IPVersionBehavior: "IPV6_PERFORMANCE", + CertEnrollmentID: 123, + SlotNumber: 123, + }, + }).Return(&papi.CreateEdgeHostnameResponse{ + EdgeHostnameID: "ehn_456", + }, nil) + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_2", + Domain: "test3.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_456", + Domain: "test.edgekey.net", + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "edgekey.net", + IPVersionBehavior: "IPV6_PERFORMANCE", + }, + }}, + }, nil) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_edgekey_net.tf")), + }, + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_edgekey_net_different_certificate.tf")), + ExpectError: regexp.MustCompile(`Changes to non-updatable fields 'product_id' and 'certificate' are not permitted`), + }, + }, + }, "update edge hostname without status email": { init: func(mp *papi.Mock, mh *hapi.Mock) { // 1st step @@ -2134,51 +2304,6 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { UseCases: nil, }, nil) } - expectGetEdgeHostnameHAPI := func(m *hapi.Mock, edgeHostnameID int) *mock.Call { - return m.On("GetEdgeHostname", mock.Anything, hapi.GetCertificateRequest{DNSZone: "edgekey.net", RecordName: "test"}).Return(&hapi.GetEdgeHostnameResponse{ - EdgeHostnameID: edgeHostnameID, - RecordName: "test", - DNSZone: "edgekey.net", - SecurityType: "ENHANCED-TLS", - UseDefaultTTL: true, - UseDefaultMap: true, - IPVersionBehavior: "IPV4", - ProductID: "DSA", - TTL: 21600, - Map: "a;dscb.akamai.net", - SlotNumber: 3250, - Comments: "Created by Property-Manager/PAPI on Tue Feb 21 14:03:36 UTC 2023", - SerialNumber: 1520, - CustomTarget: "", - ChinaCdn: hapi.ChinaCDN{}, - IsEdgeIPBindingEnabled: false, - MapAlias: "", - UseCases: nil, - }, nil) - } - expectGetEdgeHostnameHAPIWithTTL := func(m *hapi.Mock, edgeHostnameID int) *mock.Call { - return m.On("GetEdgeHostname", mock.Anything, hapi.GetCertificateRequest{DNSZone: "edgekey.net", RecordName: "test"}).Return(&hapi.GetEdgeHostnameResponse{ - EdgeHostnameID: edgeHostnameID, - RecordName: "test", - DNSZone: "edgekey.net", - SecurityType: "ENHANCED-TLS", - UseDefaultTTL: false, - UseDefaultMap: true, - IPVersionBehavior: "IPV4", - ProductID: "DSA", - TTL: 56789, - Map: "a;dscb.akamai.net", - SlotNumber: 3250, - Comments: "Created by Property-Manager/PAPI on Tue Feb 21 14:03:36 UTC 2023", - SerialNumber: 1520, - CustomTarget: "", - ChinaCdn: hapi.ChinaCDN{}, - IsEdgeIPBindingEnabled: false, - MapAlias: "", - UseCases: nil, - }, nil) - } - expectGetCertificate := func(m *hapi.Mock) *mock.Call { return m.On("GetCertificate", mock.Anything, hapi.GetCertificateRequest{ RecordName: "test", @@ -2196,7 +2321,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }, nil) } - t.Run("import existing akamaized edgehostname without certificate", func(t *testing.T) { + t.Run("import existing akamaized edgehostname without certificate - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2205,13 +2330,12 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { createEdgeHostnamesAkamaized(client).Once() expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2") expectGetEdgeHostnameAkamaized(client, "ehn_1", "ctr_1", "grp_2").Once() - expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Times(1) + expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Once() useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname_akamaized.tf"), }, { @@ -2223,6 +2347,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { assert.Equal(t, "grp_2", rs.Attributes["group_id"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) assert.Equal(t, "ehn_1", rs.Attributes["id"]) + assert.Equal(t, "", rs.Attributes["product_id"]) assert.Equal(t, "", rs.Attributes["certificate"]) return nil }, @@ -2235,8 +2360,9 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) }) - t.Run("import existing edgehostname with certificate", func(t *testing.T) { + t.Run("import existing edgehostname with certificate - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2245,15 +2371,13 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { createEdgeHostnames(client).Once() expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2") expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() - expectGetEdgeHostnameHAPIByID(clientHapi, 1).Times(3) - expectGetEdgeHostnameHAPI(clientHapi, 1).Times(10) - expectGetCertificate(clientHapi).Times(5) + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() + expectGetCertificate(clientHapi).Once() useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname.tf"), }, { @@ -2265,6 +2389,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { assert.Equal(t, "grp_2", rs.Attributes["group_id"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) assert.Equal(t, "ehn_1", rs.Attributes["id"]) + assert.Equal(t, "", rs.Attributes["product_id"]) assert.Equal(t, "123456", rs.Attributes["certificate"]) return nil }, @@ -2277,8 +2402,9 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) }) - t.Run("import existing edgehostname with missing certificate", func(t *testing.T) { + t.Run("import existing edgehostname with missing certificate - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2287,8 +2413,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { createEdgeHostnames(client).Once() expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2") expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() - expectGetEdgeHostnameHAPIByID(clientHapi, 1).Times(6) - expectGetEdgeHostnameHAPI(clientHapi, 1).Times(10) + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() resp := hapi.Error{ Type: "CERTIFICATE_NOT_FOUND", @@ -2311,7 +2436,6 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname_missing_certificate.tf"), }, { @@ -2323,6 +2447,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { assert.Equal(t, "grp_2", rs.Attributes["group_id"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) assert.Equal(t, "ehn_1", rs.Attributes["id"]) + assert.Equal(t, "", rs.Attributes["product_id"]) assert.Equal(t, "", rs.Attributes["certificate"]) return nil }, @@ -2336,8 +2461,9 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) }) - t.Run("import existing edgehostname with custom ttl", func(t *testing.T) { + t.Run("import existing edgehostname with custom ttl - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2378,14 +2504,12 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() expectGetEdgeHostnameHAPIByIDWithCustomTTL(clientHapi, 1).Times(3) - expectGetEdgeHostnameHAPIWithTTL(clientHapi, 1).Times(10) - expectGetCertificate(clientHapi).Times(5) + expectGetCertificate(clientHapi).Once() useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname_with_ttl.tf"), }, { @@ -2410,6 +2534,203 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing akamaized edgehostname without certificate - product_id supplied", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnamesAkamaized(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnamesAkamaized(client).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostnameAkamaized(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing akamaized edgehostname - product_id without prefix supplied ", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnamesAkamaized(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnamesAkamaized(client).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostnameAkamaized(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing edgehostname with certificate", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnames(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnames(client).Once() + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() + expectGetCertificate(clientHapi).Once() + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing edgehostname with missing certificate", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnames(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnames(client).Once() + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() + + resp := hapi.Error{ + Type: "CERTIFICATE_NOT_FOUND", + Title: "Certificate Not Found", + Status: 404, + Detail: "Details are not available for this certificate; the certificate is missing or access is denied", + Instance: "/hapi/error-instances/a30f67cc-df20-4e02-bbc3-cf7c204a4aab", + RequestInstance: "http://origin.pulsar.akamai.com/hapi/open/v1/dns-zones/edgekey.net/edge-hostnames/example.com/certificate?depth=ALL&accountSwitchKey=F-AC-1937217#d7aa7348", + Method: "GET", + RequestTime: "2022-11-30T18:51:43.482982Z", + } + err := fmt.Errorf("%s: %s: %w", hapi.ErrGetCertificate, hapi.ErrNotFound, &resp) + clientHapi.On("GetCertificate", mock.Anything, hapi.GetCertificateRequest{ + RecordName: "test", + DNSZone: "edgekey.net", + }).Return(nil, err) + + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"certificate"}, + // TODO Remove "certificate" here after implementing wait for EdgeHostname propagation to HAPI in DXE-3821, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import error - too few parts of id", func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + ImportState: true, + ImportStateId: "ehn_1,1", + ResourceName: "akamai_edge_hostname.importedgehostname", + ExpectError: regexp.MustCompile("expected import identifier with format: " + + `"EdgehostNameID,contractID,groupID\[,productID]". Got: "ehn_1,1"`), + }, + }, + }) + }) + t.Run("import error - too many parts of id", func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2,foo", + ResourceName: "akamai_edge_hostname.importedgehostname", + ExpectError: regexp.MustCompile("expected import identifier with format: " + + `"EdgehostNameID,contractID,groupID\[,productID]". Got: "ehn_1,1,2,prd_2,foo"`), + }, + }, + }) + }) + t.Run("import error - empty product id", func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + ImportState: true, + ImportStateId: "ehn_1,1,2,", + ResourceName: "akamai_edge_hostname.importedgehostname", + ExpectError: regexp.MustCompile(`productID is empty for the import ID="ehn_1,1,2,"`), + }, + }, + }) }) } diff --git a/pkg/providers/property/resource_akamai_property.go b/pkg/providers/property/resource_akamai_property.go index 068270225..190ebb277 100644 --- a/pkg/providers/property/resource_akamai_property.go +++ b/pkg/providers/property/resource_akamai_property.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -207,6 +207,11 @@ func resourceProperty() *schema.Resource { Elem: papiError(), Description: "Rule validation warnings", }, + "asset_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the property in the Identity and Access Management API.", + }, }, } } @@ -492,7 +497,6 @@ func resourcePropertyCreate(ctx context.Context, d *schema.ResourceData, m inter PropertyID: propertyID, ContractID: contractID, GroupID: groupID, - ProductID: productID, LatestVersion: 1, } @@ -572,6 +576,7 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa if err != nil { return diag.FromErr(err) } + if v == 0 { // use latest version unless "read_version" != 0 v = property.LatestVersion @@ -626,7 +631,6 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa if err != nil { return diag.FromErr(err) } - property.ProductID = res.Version.ProductID rulesJSON, err := json.Marshal(rules) if err != nil { @@ -635,6 +639,7 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa } attrs := map[string]interface{}{ + "asset_id": property.AssetID, "name": property.PropertyName, "group_id": property.GroupID, "contract_id": property.ContractID, @@ -648,8 +653,8 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa "read_version": readVersionID, "version_notes": res.Version.Note, } - if property.ProductID != "" { - attrs["product_id"] = property.ProductID + if res.Version.ProductID != "" { + attrs["product_id"] = res.Version.ProductID } if err := tf.SetAttrs(d, attrs); err != nil { return diag.FromErr(err) @@ -706,7 +711,6 @@ func resourcePropertyUpdate(ctx context.Context, d *schema.ResourceData, m inter PropertyName: d.Get("name").(string), ContractID: d.Get("contract_id").(string), GroupID: d.Get("group_id").(string), - ProductID: d.Get("product_id").(string), LatestVersion: d.Get("latest_version").(int), StagingVersion: stagingVersion, ProductionVersion: productionVersion, @@ -925,13 +929,14 @@ func resourcePropertyImport(ctx context.Context, d *schema.ResourceData, m inter return []*schema.ResourceData{d}, nil } - var err error var property *papi.Property + var err error var v int + client = Client(meta.Must(m)) if !isDefaultVersion(version) { - property, v, err = fetchProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID, version) + property, v, err = fetchProperty(ctx, client, propertyID, groupID, contractID, version) } else { - property, err = fetchLatestProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID) + property, err = fetchLatestProperty(ctx, client, propertyID, groupID, contractID) } if err != nil { return nil, err @@ -1135,8 +1140,6 @@ func fetchProperty(ctx context.Context, client papi.PAPI, propertyID, groupID, c ProductionVersion: getNetworkActiveVersionNumber(res.Versions.Items, papi.ActivationNetworkProduction), AssetID: res.AssetID, Note: versionItem.Note, - ProductID: versionItem.ProductID, - RuleFormat: versionItem.RuleFormat, } logger.Debug("property versions fetched") diff --git a/pkg/providers/property/resource_akamai_property_activation.go b/pkg/providers/property/resource_akamai_property_activation.go index ddb5d1914..4abcb8721 100644 --- a/pkg/providers/property/resource_akamai_property_activation.go +++ b/pkg/providers/property/resource_akamai_property_activation.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" @@ -216,7 +216,6 @@ func resourcePropertyActivationCreate(ctx context.Context, d *schema.ResourceDat activation, err := lookupActivation(ctx, client, lookupActivationRequest{ propertyID: propertyID, - version: version, network: network, activationType: map[papi.ActivationType]struct{}{ papi.ActivationTypeActivate: {}, @@ -228,7 +227,7 @@ func resourcePropertyActivationCreate(ctx context.Context, d *schema.ResourceDat } // we create a new property activation in case of no previous activation, or deleted activation - if activation == nil || activation.ActivationType == papi.ActivationTypeDeactivate { + if activation == nil || activation.ActivationType == papi.ActivationTypeDeactivate || activation.PropertyVersion != version { notifySet, err := tf.GetSetValue("contact", d) if err != nil { return diag.FromErr(err) @@ -863,7 +862,10 @@ func lookupActivation(ctx context.Context, client papi.PAPI, query lookupActivat // There is an activation in progress, if it's for the same version/network/type we can re-use it _, matchingActivationType := query.activationType[a.ActivationType] - if a.PropertyVersion == query.version && matchingActivationType && a.Network == query.network { + // If query doesn't check version, it should not filter any activation + matchingVersion := query.version == 0 || a.PropertyVersion == query.version + matchingNetwork := a.Network == query.network + if matchingVersion && matchingActivationType && matchingNetwork { // find the most recent activation var aSubmitDate, err = date.Parse(a.SubmitDate) diff --git a/pkg/providers/property/resource_akamai_property_activation_schema_v0.go b/pkg/providers/property/resource_akamai_property_activation_schema_v0.go index d4de1bced..8bdbddebd 100644 --- a/pkg/providers/property/resource_akamai_property_activation_schema_v0.go +++ b/pkg/providers/property/resource_akamai_property_activation_schema_v0.go @@ -1,7 +1,7 @@ package property import ( - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/resource_akamai_property_activation_test.go b/pkg/providers/property/resource_akamai_property_activation_test.go index 1180f3298..1192c2a01 100644 --- a/pkg/providers/property/resource_akamai_property_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -34,7 +34,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // update expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}), nil).Once() - ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() + expectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 2, "STAGING", []string{"user@example.com"}, "property activation note for updating", "atv_update", true, nil).Once() expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for updating", []string{"user@example.com"}, nil).Once() @@ -315,6 +315,34 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { }, }, }, + "property activation when other version is already active": { + init: func(m *papi.Mock) { + // first step + // create + expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() + + firstActivationOnV1 := generateActivationItemMock("atv_activation1", note, 1, papi.ActivationTypeActivate, "2020-09-28T15:04:05Z", []string{"user@example.com"}) + activationOnV2 := generateActivationItemMock("atv_activation2", note, 2, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}) + expectGetActivations(m, "prp_test", papi.GetActivationsResponse{Activations: papi.ActivationsItems{Items: []*papi.Activation{activationOnV2, firstActivationOnV1}}}, nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_activation1", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "", []string{"user@example.com"}, nil).Once() + // read + activationOnV1 := generateActivationItemMock("atv_activation1", note, 1, papi.ActivationTypeActivate, "2020-11-28T15:05:05Z", []string{"user@example.com"}) + allActivations := papi.GetActivationsResponse{Activations: papi.ActivationsItems{Items: []*papi.Activation{activationOnV1, activationOnV2, firstActivationOnV1}}} + expectGetActivations(m, "prp_test", allActivations, nil).Once() + + // delete + expectGetActivations(m, "prp_test", allActivations, nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_update", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "", []string{"user@example.com"}, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestPropertyActivation/deactivated_in_other_source/resource_property_activation.tf"), + Check: resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), + }, + }, + }, "activation with custom timeout - lifecycle": { init: func(m *papi.Mock) { // first step @@ -587,7 +615,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // update - note field not suppressed update of contact field and version expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}), nil).Once() - ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() + expectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 2, "STAGING", []string{"user@example.com", "user2@example.com"}, "property activation note for updating", "atv_update", true, nil).Once() expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for updating", []string{"user@example.com", "user2@example.com"}, nil).Once() @@ -653,7 +681,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // update expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}), nil).Once() - ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() + expectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() // error on update m.On("CreateActivation", AnyCTX, papi.CreateActivationRequest{ PropertyID: "prp_test", @@ -947,4 +975,25 @@ var ( }, }, nil) } + + // Sets up an expected call to papi.GetPropertyVersion() + expectGetPropertyVersion = func(client *papi.Mock, PropertyID, GroupID, ContractID string, Version int, StagStatus, ProdStatus papi.VersionStatus) *mock.Call { + req := papi.GetPropertyVersionRequest{ + PropertyID: PropertyID, + GroupID: GroupID, + ContractID: ContractID, + PropertyVersion: Version, + } + + res := papi.GetPropertyVersionsResponse{ + PropertyID: PropertyID, + GroupID: GroupID, + ContractID: ContractID, + Version: papi.PropertyVersionGetItem{ + StagingStatus: StagStatus, + ProductionStatus: ProdStatus, + }, + } + return client.On("GetPropertyVersion", AnyCTX, req).Return(&res, nil) + } ) diff --git a/pkg/providers/property/resource_akamai_property_activation_unit_test.go b/pkg/providers/property/resource_akamai_property_activation_unit_test.go index ba0acbb5c..e4254d0b8 100644 --- a/pkg/providers/property/resource_akamai_property_activation_unit_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_unit_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/resource_akamai_property_bootstrap.go b/pkg/providers/property/resource_akamai_property_bootstrap.go index 30707acf3..b94dd3ea8 100644 --- a/pkg/providers/property/resource_akamai_property_bootstrap.go +++ b/pkg/providers/property/resource_akamai_property_bootstrap.go @@ -7,7 +7,7 @@ import ( "regexp" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/resource_akamai_property_bootstrap_test.go b/pkg/providers/property/resource_akamai_property_bootstrap_test.go index 6c069770d..ea1bb0b98 100644 --- a/pkg/providers/property/resource_akamai_property_bootstrap_test.go +++ b/pkg/providers/property/resource_akamai_property_bootstrap_test.go @@ -3,106 +3,99 @@ package property import ( "fmt" "regexp" - "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) -type testDataForPropertyBootstrap struct { - propertyID string - name string - groupID string - contractID string - productID string - withoutPrefixes bool +var basicDataBootstrap = mockPropertyData{ + propertyID: "prp_123", + propertyName: "property_name", + groupID: "grp_1", + contractID: "ctr_2", + productID: "prd_3", + assetID: "aid_55555", + moveGroup: moveGroup{ + sourceGroupID: 1, + destinationGroupID: 111, + }, } func TestBootstrapResourceCreate(t *testing.T) { t.Parallel() + + baseChecker := test.NewStateChecker("akamai_property_bootstrap.test"). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_1"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("name", "property_name") + tests := map[string]struct { - configPath string - init func(*testing.T, *papi.Mock, testDataForPropertyBootstrap) - mockData testDataForPropertyBootstrap - error *regexp.Regexp + init func(*testing.T, *mockProperty) + steps []resource.TestStep + error *regexp.Regexp }{ "create": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), + Check: baseChecker.Build(), + }, }, }, "create without prefixes": { - configPath: "testdata/TestResPropertyBootstrap/create_without_prefixes.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - withoutPrefixes: true, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create_without_prefixes.tf"), + Check: baseChecker. + CheckEqual("group_id", "1"). + CheckEqual("contract_id", "2"). + CheckEqual("product_id", "3"). + Build(), + }, }, }, "create with interpretCreate error - group not found": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { + init: func(t *testing.T, p *mockProperty) { req := papi.CreatePropertyRequest{ - GroupID: data.groupID, - ContractID: data.contractID, + GroupID: p.groupID, + ContractID: p.contractID, Property: papi.PropertyCreate{ - ProductID: data.productID, - PropertyName: data.name, + ProductID: p.productID, + PropertyName: p.propertyName, }, } - m.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf( + p.papiMock.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf( "%s: %w: %s", papi.ErrCreateProperty, papi.ErrNotFound, "not found")).Once() // mock empty groups - no group has been found, hence the expected error - m.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ + p.papiMock.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ Groups: papi.GroupItems{ Items: []*papi.Group{}, }, }, nil).Once() }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), + ExpectError: regexp.MustCompile(`Error: group not found: grp_1`), + }, }, - error: regexp.MustCompile(`Error: group not found: grp_1`), }, } @@ -110,23 +103,20 @@ func TestBootstrapResourceCreate(t *testing.T) { name, test := name, test t.Run(name, func(t *testing.T) { t.Parallel() - m := &papi.Mock{} + mp := &mockProperty{ + mockPropertyData: basicDataBootstrap, + papiMock: m, + } if test.init != nil { - test.init(t, m, test.mockData) + test.init(t, mp) } useClient(m, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, test.configPath), - Check: checkPropertyBootstrapAttributes(test.mockData), - ExpectError: test.error, - }, - }, + Steps: test.steps, }) }) @@ -137,11 +127,18 @@ func TestBootstrapResourceCreate(t *testing.T) { func TestBootstrapResourceUpdate(t *testing.T) { t.Parallel() + + baseChecker := test.NewStateChecker("akamai_property_bootstrap.test"). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_1"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("name", "property_name") + tests := map[string]struct { configPathForCreate string configPathForUpdate string - init func(*testing.T, *papi.Mock, *iam.Mock, testDataForPropertyBootstrap) - mockData testDataForPropertyBootstrap + init func(*testing.T, *mockProperty) errorForCreate *regexp.Regexp errorForUpdate *regexp.Regexp updateChecks resource.TestCheckFunc @@ -149,198 +146,89 @@ func TestBootstrapResourceUpdate(t *testing.T) { "create and remove prefixes - no diff": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/create_without_prefixes.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + // read x2 + p.mockGetProperty().Twice() + // read x1 before update + p.mockGetProperty() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - }), + updateChecks: baseChecker.Build(), }, "create and update group id": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_group.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { + init: func(t *testing.T, p *mockProperty) { t.Skip("skipping before moving property is enabled again, see DXE-4176") - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, - data.propertyID).Once() - prp := &papi.Property{ - AssetID: "aid_55555", - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Times(3) - - mockMoveProperty(iamMock, 55555, 1, 111) - - ExpectGetProperty(papiMock, data.propertyID, "grp_111", data.contractID, prp).Twice() - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, "grp_111") - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + p.mockCreateProperty() + // read x2 + p.mockGetProperty().Twice() + // update + p.mockGetProperty() + p.mockMoveProperty() + p.groupID = "grp_111" + // read x2 + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_111", - contractID: "ctr_2", - productID: "prd_3", - }), + updateChecks: baseChecker. + CheckEqual("group_id", "grp_111"). + Build(), }, "create and update name - resource replacement": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", - configPathForUpdate: "testdata/TestResPropertyBootstrap/update_name.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, - data.propertyID).Once() - prp := &papi.Property{ - AssetID: "aid_55555", - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Times(2) - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID).Once() - - ExpectCreateProperty(papiMock, "property_name2", data.groupID, data.contractID, data.productID, - data.propertyID).Once() - - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Once() - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID).Once() - - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + // read x2 + p.mockGetProperty().Twice() + p.mockRemoveProperty() + p.propertyName = "property_name2" + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name2", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - }), + configPathForUpdate: "testdata/TestResPropertyBootstrap/update_name.tf", + updateChecks: baseChecker. + CheckEqual("name", "property_name2"). + Build(), }, "create and update name and group id - resource replacement": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_name_and_group.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { + init: func(t *testing.T, p *mockProperty) { t.Skip("skipping before moving property is enabled again, see DXE-4176") - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, - data.propertyID).Once() - prp := &papi.Property{ - AssetID: "aid_55555", - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Times(2) - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID).Once() - - ExpectCreateProperty(papiMock, "property_name2", "grp_93", data.contractID, data.productID, - data.propertyID).Once() - - ExpectGetProperty(papiMock, data.propertyID, "grp_93", data.contractID, prp).Once() - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, "grp_93").Once() - - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() + p.propertyName = "property_name2" + p.groupID = "grp_93" + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name2", - groupID: "grp_93", - contractID: "ctr_2", - productID: "prd_3", - }), + updateChecks: baseChecker. + CheckEqual("name", "property_name2"). + CheckEqual("group_id", "grp_93"). + Build(), }, "create and update contract - error": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_contract.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, errorForUpdate: regexp.MustCompile("updating field `contract_id` is not possible"), }, "create and update product - error": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_product.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, errorForUpdate: regexp.MustCompile("updating field `product_id` is not possible"), }, @@ -348,24 +236,10 @@ func TestBootstrapResourceUpdate(t *testing.T) { // TODO: remove this test after moving property is enabled again, see DXE-4176 configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_group.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, errorForUpdate: regexp.MustCompile("updating field `group_id` is not possible"), }, @@ -376,10 +250,16 @@ func TestBootstrapResourceUpdate(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() - papiMock := &papi.Mock{} iamMock := &iam.Mock{} + papiMock := &papi.Mock{} + mp := &mockProperty{ + mockPropertyData: basicDataBootstrap, + papiMock: papiMock, + iamMock: iamMock, + } + if test.init != nil { - test.init(t, papiMock, iamMock, test.mockData) + test.init(t, mp) } useClient(papiMock, nil, func() { @@ -390,7 +270,7 @@ func TestBootstrapResourceUpdate(t *testing.T) { Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, test.configPathForCreate), - Check: checkPropertyBootstrapAttributes(test.mockData), + Check: baseChecker.Build(), ExpectError: test.errorForCreate, }, { @@ -410,89 +290,59 @@ func TestBootstrapResourceUpdate(t *testing.T) { func TestBootstrapResourceImport(t *testing.T) { t.Parallel() + + basicDataWithoutContractAndGroup := mockPropertyData{ + propertyID: "prp_123", + propertyName: "property_name", + productID: "prd_3", + assetID: "aid_55555", + } + + baseChecker := test.NewImportChecker(). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_1"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("name", "property_name") + tests := map[string]struct { - configPath string - init func(*testing.T, *papi.Mock, testDataForPropertyBootstrap) - mockData testDataForPropertyBootstrap + init func(*testing.T, *mockProperty) + mockData mockPropertyData importStateID string + stateCheck func(s []*terraform.InstanceState) error error *regexp.Regexp }{ "import with all attributes": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - LatestVersion: 1, - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) - // import - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectGetPropertyVersion(m, data.propertyID, data.groupID, data.contractID, 1, papi.VersionStatusActive, papi.VersionStatusActive) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + mockData: basicDataBootstrap, + init: func(t *testing.T, p *mockProperty) { + p.mockGetProperty() + p.mockGetPropertyVersion() + // read + p.mockGetProperty() }, + stateCheck: baseChecker. + CheckEqual("product_id", ""). + Build(), importStateID: "prp_123,2,1", }, "import with only property_id": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - LatestVersion: 1, - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) + mockData: basicDataWithoutContractAndGroup, + init: func(t *testing.T, p *mockProperty) { // import - ExpectGetProperty(m, data.propertyID, "", "", prp) - ExpectGetPropertyVersion(m, data.propertyID, data.groupID, data.contractID, 1, papi.VersionStatusActive, papi.VersionStatusActive) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + p.mockGetProperty() + p.mockGetPropertyVersion() + // read + p.mockGetProperty() }, + stateCheck: baseChecker. + CheckEqual("group_id", ""). + CheckEqual("contract_id", ""). + CheckEqual("product_id", ""). + Build(), importStateID: "123", }, "import with only property_id and contract_id - error": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - LatestVersion: 1, - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - }, + init: func(t *testing.T, p *mockProperty) {}, importStateID: "123,2", error: regexp.MustCompile("Error: missing group id or contract id"), }, @@ -504,8 +354,13 @@ func TestBootstrapResourceImport(t *testing.T) { t.Parallel() m := &papi.Mock{} + mp := &mockProperty{ + mockPropertyData: test.mockData, + papiMock: m, + } + if test.init != nil { - test.init(t, m, test.mockData) + test.init(t, mp) } useClient(m, nil, func() { @@ -514,15 +369,12 @@ func TestBootstrapResourceImport(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), - Check: checkPropertyBootstrapAttributes(test.mockData), - }, - { - ImportState: true, - ImportStateId: test.importStateID, - ResourceName: "akamai_property_bootstrap.test", - Check: checkPropertyBootstrapAttributes(test.mockData), - ExpectError: test.error, + ImportState: true, + ImportStateId: test.importStateID, + ImportStateCheck: test.stateCheck, + ResourceName: "akamai_property_bootstrap.test", + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), + ExpectError: test.error, }, }, }) @@ -532,21 +384,3 @@ func TestBootstrapResourceImport(t *testing.T) { }) } } - -func checkPropertyBootstrapAttributes(data testDataForPropertyBootstrap) resource.TestCheckFunc { - if data.withoutPrefixes { - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "id", data.propertyID), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "group_id", strings.TrimPrefix(data.groupID, "grp_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "contract_id", strings.TrimPrefix(data.contractID, "ctr_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "product_id", strings.TrimPrefix(data.productID, "prd_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "name", data.name)) - } - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "id", str.AddPrefix(data.propertyID, "prp_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "group_id", str.AddPrefix(data.groupID, "grp_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "contract_id", str.AddPrefix(data.contractID, "ctr_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "product_id", str.AddPrefix(data.productID, "prd_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "name", data.name), - ) -} diff --git a/pkg/providers/property/resource_akamai_property_common.go b/pkg/providers/property/resource_akamai_property_common.go index f4c68c58e..4a1b71696 100644 --- a/pkg/providers/property/resource_akamai_property_common.go +++ b/pkg/providers/property/resource_akamai_property_common.go @@ -6,7 +6,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/resource_akamai_property_helpers_test.go b/pkg/providers/property/resource_akamai_property_helpers_test.go index e6f43dffc..a62337fdf 100644 --- a/pkg/providers/property/resource_akamai_property_helpers_test.go +++ b/pkg/providers/property/resource_akamai_property_helpers_test.go @@ -1,484 +1,399 @@ package property import ( - "context" + "strconv" + "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/stretchr/testify/mock" ) -// Sets up an expected call to papi.GetGroups(), which returns the given parameters -func ExpectGetGroups(client *papi.Mock, State *[]*papi.Group) *mock.Call { - fn := func(ctx context.Context) (*papi.GetGroupsResponse, error) { - var groups []*papi.Group +type mockProperty struct { + mockPropertyData + papiMock *papi.Mock + iamMock *iam.Mock +} - for _, ptr := range *State { - grp := *ptr - groups = append(groups, &grp) - } +type mockPropertyData struct { + propertyName string + groupID string + contractID string + productID string + propertyID string + assetID string + latestVersion int + createFromVersion int + newVersionID int + ruleTree mockRuleTreeData + versions papi.PropertyVersionItems + hostnames papi.HostnameResponseItems + responseErrors []*papi.Error + responseWarnings []*papi.Error + activations papi.ActivationsItems + createActivation papi.Activation + groups papi.GroupItems + moveGroup moveGroup +} - return &papi.GetGroupsResponse{Groups: papi.GroupItems{Items: groups}}, nil - } +type moveGroup struct { + sourceGroupID int64 + destinationGroupID int64 +} - return client.OnGetGroups(AnyCTX, fn) +type mockRuleTreeData struct { + rules papi.Rules + comments string + ruleFormat string + ruleErrors []papi.RuleError + ruleWarnings []papi.RuleWarnings } -// Sets up an expected call to papi.GetProperty() which returns a value depending on the given State pointer. When nil, -// the PAPI response contains a zero-value papi.Property. Otherwise the response will dynamically contain a copy of -// the State made at the time of the call to papi.Mock.GetProperty(). -func ExpectGetProperty(client *papi.Mock, PropertyID, GroupID, ContractID string, State *papi.Property) *mock.Call { - req := papi.GetPropertyRequest{ - PropertyID: PropertyID, - ContractID: ContractID, - GroupID: GroupID, +func (p *mockProperty) mockCreateProperty(err ...error) *mock.Call { + req := papi.CreatePropertyRequest{ + GroupID: p.groupID, + ContractID: p.contractID, + Property: papi.PropertyCreate{ + ProductID: p.productID, + PropertyName: p.propertyName, + RuleFormat: p.ruleTree.ruleFormat, + }, } - fn := func(context.Context, papi.GetPropertyRequest) (*papi.GetPropertyResponse, error) { - var property papi.Property - - // Duplicate the State - if State != nil { - property = *State - } - - // Duplicate the pointers - if property.ProductionVersion != nil { - v := *property.ProductionVersion - property.ProductionVersion = &v - } + if err != nil { + return p.papiMock.On("CreateProperty", AnyCTX, req).Return(nil, err[0]).Once() + } - if property.StagingVersion != nil { - v := *property.StagingVersion - property.StagingVersion = &v - } + resp := papi.CreatePropertyResponse{PropertyID: p.propertyID} - // although optional in PAPI documentation, ProductID is not being set by PAPI in the response - property.ProductID = "" + return p.papiMock.On("CreateProperty", AnyCTX, req).Return(&resp, nil).Once() +} - return &papi.GetPropertyResponse{Property: &property}, nil +func (p *mockProperty) mockGetGroups() *mock.Call { + resp := &papi.GetGroupsResponse{ + Groups: p.groups, } - return client.OnGetProperty(AnyCTX, req, fn) + return p.papiMock.On("GetGroups", AnyCTX).Return(resp, nil).Once() } -// Sets up an expected call to papi.GetPropertyVersionHostnames() which returns a value depending on the value of the -// pointer to State. When nil or empty, the response contains a nil Items member. Otherwise the response contains a -// copy of the value pointed to by State made at the time of the call to papi.GetPropertyVersionHostnames(). -func ExpectGetPropertyVersionHostnames(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, State *[]papi.Hostname) *mock.Call { - req := papi.GetPropertyVersionHostnamesRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - PropertyVersion: PropertyVersion, - IncludeCertStatus: true, +func (p *mockProperty) mockUpdateRuleTree(err ...error) *mock.Call { + rulesUpdate := papi.RulesUpdate{ + Rules: p.ruleTree.rules, + Comments: p.ruleTree.comments, } - fn := func(context.Context, papi.GetPropertyVersionHostnamesRequest) (*papi.GetPropertyVersionHostnamesResponse, error) { - var Items []papi.Hostname - if len(*State) > 0 { - // Duplicate the State - Items = append(Items, *State...) - } + req := papi.UpdateRulesRequest{ + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + ContractID: p.contractID, + GroupID: p.groupID, + Rules: rulesUpdate, + ValidateRules: true, + } - res := papi.GetPropertyVersionHostnamesResponse{ - ContractID: ContractID, - GroupID: GroupID, - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - Hostnames: papi.HostnameResponseItems{Items: Items}, - } + if err != nil { + return p.papiMock.On("UpdateRuleTree", AnyCTX, req).Return(nil, err[0]).Once() + } - return &res, nil + resp := papi.UpdateRulesResponse{ + PropertyID: p.propertyID, + ContractID: p.contractID, + GroupID: p.groupID, + PropertyVersion: p.latestVersion, + RuleFormat: p.ruleTree.ruleFormat, + Rules: p.ruleTree.rules, + Errors: p.ruleTree.ruleErrors, + Warnings: p.ruleTree.ruleWarnings, } - return client.OnGetPropertyVersionHostnames(AnyCTX, req, fn) + return p.papiMock.On("UpdateRuleTree", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected call to papi.UpdatePropertyVersionHostnames() which returns a constant value based on input -// params. If given, the value pointed to by State will be updated with a copy of the given Hostnames when the call -// to papi.Mock.UpdatePropertyVersionHostnames() is made. -func ExpectUpdatePropertyVersionHostnames(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, Hostnames []papi.Hostname, err error) *mock.Call { +func (p *mockProperty) mockUpdatePropertyVersionHostnames(err ...error) *mock.Call { + // Copy hostnames from mock data and remove unnecessary fields (EdgeHostnameID and CertStatus) that are not used in the request to satisfy mocks. + // Use original mock data for the response. + requestHostnames := make([]papi.Hostname, len(p.hostnames.Items)) + copy(requestHostnames, p.hostnames.Items) + for i := range requestHostnames { + requestHostnames[i].EdgeHostnameID = "" + requestHostnames[i].CertStatus = papi.CertStatusItem{} + } + req := papi.UpdatePropertyVersionHostnamesRequest{ - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - ContractID: ContractID, - GroupID: GroupID, - Hostnames: Hostnames, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + ContractID: p.contractID, + GroupID: p.groupID, + Hostnames: requestHostnames, } - call := client.On("UpdatePropertyVersionHostnames", AnyCTX, req) if err != nil { - return call.Return(&papi.UpdatePropertyVersionHostnamesResponse{}, err) + return p.papiMock.On("UpdatePropertyVersionHostnames", AnyCTX, req).Return(&papi.UpdatePropertyVersionHostnamesResponse{}, err[0]).Once() } - res := papi.UpdatePropertyVersionHostnamesResponse{ - ContractID: ContractID, - GroupID: GroupID, - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - Hostnames: papi.HostnameResponseItems{Items: Hostnames}, + resp := papi.UpdatePropertyVersionHostnamesResponse{ + ContractID: p.contractID, + GroupID: p.groupID, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + Hostnames: p.hostnames, } - return call.Return(&res, nil) + return p.papiMock.On("UpdatePropertyVersionHostnames", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected call to papi.GetPropertyVersions() -func ExpectGetPropertyVersions(client *papi.Mock, PropertyID, PropertyName, ContractID, GroupID string, property *papi.Property, versionItems *papi.PropertyVersionItems) *mock.Call { - req := papi.GetPropertyVersionsRequest{ - PropertyID: PropertyID, - ContractID: ContractID, - GroupID: GroupID, - } - var res *papi.GetPropertyVersionsResponse - fn := func(context.Context, papi.GetPropertyVersionsRequest) (*papi.GetPropertyVersionsResponse, error) { - if property != nil { - ContractID = property.ContractID - GroupID = property.GroupID - } - res = &papi.GetPropertyVersionsResponse{ - PropertyID: PropertyID, - PropertyName: PropertyName, - ContractID: ContractID, - GroupID: GroupID, - Versions: *versionItems, - } - - return res, nil +func (p *mockProperty) mockGetProperty() *mock.Call { + req := papi.GetPropertyRequest{ + PropertyID: p.propertyID, + ContractID: p.contractID, + GroupID: p.groupID, } - - return client.OnGetPropertyVersions(AnyCTX, req, fn) -} - -// Sets up an expected call to papi.GetPropertyVersion() -func ExpectGetPropertyVersion(client *papi.Mock, PropertyID, GroupID, ContractID string, Version int, StagStatus, ProdStatus papi.VersionStatus) *mock.Call { - req := papi.GetPropertyVersionRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - PropertyVersion: Version, - } - - res := papi.GetPropertyVersionsResponse{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - Version: papi.PropertyVersionGetItem{ - StagingStatus: StagStatus, - ProductionStatus: ProdStatus, + resp := papi.GetPropertyResponse{ + Property: &papi.Property{ + AssetID: p.assetID, + ContractID: p.contractID, + GroupID: p.groupID, + LatestVersion: p.latestVersion, + // although optional in PAPI documentation, ProductID is not being set by PAPI in the response + PropertyID: p.propertyID, + PropertyName: p.propertyName, }, } - return client.On("GetPropertyVersion", AnyCTX, req).Return(&res, nil) -} -// Sets up an expected call to papi.CreatePropertyVersion() -func ExpectCreatePropertyVersion(client *papi.Mock, PropertyID, GroupID, ContractID string, CreateFromVersion, NewVersion int) *mock.Call { - req := papi.CreatePropertyVersionRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - Version: papi.PropertyVersionCreate{ - CreateFromVersion: CreateFromVersion, - }, + if len(p.versions.Items) > 0 && p.versions.Items[0].StagingStatus == papi.VersionStatusActive { + resp.Property.StagingVersion = &p.versions.Items[0].PropertyVersion } - res := papi.CreatePropertyVersionResponse{PropertyVersion: NewVersion} + if len(p.versions.Items) > 0 && p.versions.Items[0].ProductionStatus == papi.VersionStatusActive { + resp.Property.ProductionVersion = &p.versions.Items[0].PropertyVersion + } - return client.On("CreatePropertyVersion", AnyCTX, req).Return(&res, nil) + return p.papiMock.On("GetProperty", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected successful call to papi.CreateProperty() with a constant success response with the given PropertyID -func ExpectCreateProperty(client *papi.Mock, PropertyName, GroupID, ContractID, ProductID, PropertyID string) *mock.Call { - req := papi.CreatePropertyRequest{ - GroupID: GroupID, - ContractID: ContractID, - Property: papi.PropertyCreate{ - ProductID: ProductID, - PropertyName: PropertyName, - }, +func (p *mockProperty) mockGetPropertyVersionHostnames() *mock.Call { + req := papi.GetPropertyVersionHostnamesRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + PropertyVersion: p.latestVersion, + IncludeCertStatus: true, } - res := papi.CreatePropertyResponse{PropertyID: PropertyID} + resp := papi.GetPropertyVersionHostnamesResponse{ + ContractID: p.contractID, + GroupID: p.groupID, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + Hostnames: p.hostnames, + } - return client.On("CreateProperty", AnyCTX, req).Return(&res, nil) + return p.papiMock.On("GetPropertyVersionHostnames", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected call to papi.RemoveProperty() with a constant success response -func ExpectRemoveProperty(client *papi.Mock, PropertyID, ContractID, GroupID string) *mock.Call { - req := papi.RemovePropertyRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, +func (p *mockProperty) mockGetPropertyVersions() *mock.Call { + req := papi.GetPropertyVersionsRequest{ + PropertyID: p.propertyID, + ContractID: p.contractID, + GroupID: p.groupID, + } + resp := &papi.GetPropertyVersionsResponse{ + PropertyID: p.propertyID, + PropertyName: p.propertyName, + ContractID: p.contractID, + GroupID: p.groupID, + AssetID: p.assetID, + Versions: p.versions, } - res := papi.RemovePropertyResponse{} - return client.On("RemoveProperty", AnyCTX, req).Return(&res, nil) + return p.papiMock.On("GetPropertyVersions", AnyCTX, req).Return(resp, nil).Once() } -// Sets up an expected call to papi.GetRuleTree() which returns a value depending on the value of the -// pointer to State and FormatState. -func ExpectGetRuleTree(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, State *papi.RulesUpdate, RuleFormatState *string, - Errors []*papi.Error, Warnings []*papi.Error) *mock.Call { +func (p *mockProperty) mockGetRuleTree() *mock.Call { req := papi.GetRuleTreeRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - PropertyVersion: PropertyVersion, + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + PropertyVersion: p.latestVersion, ValidateMode: "full", ValidateRules: true, } - fn := func(context.Context, papi.GetRuleTreeRequest) (*papi.GetRuleTreeResponse, error) { - var Rules papi.RulesUpdate - if State != nil { - Rules = *State - } - - res := papi.GetRuleTreeResponse{ - Response: papi.Response{ - Errors: Errors, - Warnings: Warnings, - }, - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - RuleFormat: *RuleFormatState, - Rules: Rules.Rules, - } - - return &res, nil + resp := papi.GetRuleTreeResponse{ + Response: papi.Response{ + Errors: p.responseErrors, + Warnings: p.responseWarnings, + }, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + RuleFormat: p.ruleTree.ruleFormat, + Rules: p.ruleTree.rules, + Comments: p.ruleTree.comments, } - return client.OnGetRuleTree(AnyCTX, req, fn) + return p.papiMock.On("GetRuleTree", AnyCTX, req).Return(&resp, nil).Once() } -func ExpectUpdateRuleTree(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, State *papi.RulesUpdate, RuleFormat string, RuleError []papi.RuleError) *mock.Call { - var RulesUpdate papi.RulesUpdate - if State != nil { - RulesUpdate = *State - } - var res papi.UpdateRulesResponse - req := papi.UpdateRulesRequest{ - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - ContractID: ContractID, - GroupID: GroupID, - Rules: RulesUpdate, +// mockGetRuleTreeActivation mocks the GetRuleTree call executed from property_activation resource. It differs with request +// parameters when compared to the GetRuleTree call executed from property resource. +func (p *mockProperty) mockGetRuleTreeActivation() *mock.Call { + req := papi.GetRuleTreeRequest{ + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, ValidateRules: true, } - fn := func(context.Context, papi.UpdateRulesRequest) (*papi.UpdateRulesResponse, error) { + resp := papi.GetRuleTreeResponse{ + Response: papi.Response{ + Errors: p.responseErrors, + Warnings: p.responseWarnings, + }, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + RuleFormat: p.ruleTree.ruleFormat, + Rules: p.ruleTree.rules, + Comments: p.ruleTree.comments, + } + + return p.papiMock.On("GetRuleTree", AnyCTX, req).Return(&resp, nil).Once() +} + +func (p *mockProperty) mockGetPropertyVersion() *mock.Call { + req := papi.GetPropertyVersionRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + PropertyVersion: p.latestVersion, + } - res = papi.UpdateRulesResponse{ - PropertyID: PropertyID, - ContractID: ContractID, - GroupID: GroupID, - PropertyVersion: PropertyVersion, - RuleFormat: RuleFormat, - Rules: RulesUpdate.Rules, - Errors: RuleError, + var ver papi.PropertyVersionGetItem + if len(p.versions.Items) > 0 { + ver = papi.PropertyVersionGetItem{ + StagingStatus: p.versions.Items[0].StagingStatus, + ProductionStatus: p.versions.Items[0].ProductionStatus, + Note: p.versions.Items[0].Note, + PropertyVersion: p.versions.Items[0].PropertyVersion, } - return &res, nil } - return client.OnUpdateRuleTree(AnyCTX, req, fn).Return(&res, nil) + resp := &papi.GetPropertyVersionsResponse{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + Version: ver, + } + return p.papiMock.On("GetPropertyVersion", AnyCTX, req).Return(resp, nil).Once() } -func updateRuleTreeWithVariables(variables []papi.RuleVariable) *papi.RulesUpdate { - return &papi.RulesUpdate{ - Rules: papi.Rules{ - Name: "default", - Children: []papi.Rules{ - { - Name: "change fwd path", - Behaviors: []papi.RuleBehavior{ - { - Name: "baseDirectory", - Options: papi.RuleOptionsMap{ - "value": "/smth/", - }, - }, - }, - Criteria: []papi.RuleBehavior{ - { - Name: "requestHeader", - Locked: false, - Options: papi.RuleOptionsMap{ - "headerName": "Accept-Encoding", - "matchCaseSensitiveValue": true, - "matchOperator": "IS_ONE_OF", - "matchWildcardName": false, - "matchWildcardValue": false, - }, - }, - }, - CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, - }, - { - Name: "caching", - Behaviors: []papi.RuleBehavior{ - { - Name: "caching", - Options: papi.RuleOptionsMap{ - "behavior": "MAX_AGE", - "mustRevalidate": false, - "ttl": "1m", - }, - }, - }, - CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAny, - }, - }, - Behaviors: []papi.RuleBehavior{ - { - Name: "origin", - Options: papi.RuleOptionsMap{ - "cacheKeyHostname": "REQUEST_HOST_HEADER", - "compress": true, - "enableTrueClientIp": true, - "forwardHostHeader": "REQUEST_HOST_HEADER", - "hostname": "test.domain", - "httpPort": float64(80), - "httpsPort": float64(443), - "originCertificate": "", - "originSni": true, - "originType": "CUSTOMER", - "ports": "", - "trueClientIpClientSetting": false, - "trueClientIpHeader": "True-Client-IP", - "verificationMode": "PLATFORM_SETTINGS", - }, - }, - }, - Options: papi.RuleOptions{}, - Variables: variables, - Comments: "The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.", - }, +func (p *mockProperty) mockRemoveProperty(err ...error) *mock.Call { + req := papi.RemovePropertyRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, } -} + resp := papi.RemovePropertyResponse{} -func updateRuleTreeWithVariablesStep1() *papi.RulesUpdate { - return updateRuleTreeWithVariables([]papi.RuleVariable{ - { - Name: "TEST_EMPTY_FIELDS", - Value: ptr.To(""), - Description: ptr.To(""), - Hidden: true, - Sensitive: false, - }, - { - Name: "TEST_NIL_FIELD", - Description: ptr.To(""), - Value: ptr.To(""), - Hidden: true, - Sensitive: false, - }, - }) + if err != nil { + return p.papiMock.On("RemoveProperty", AnyCTX, req).Return(nil, err[0]).Once() + } + + return p.papiMock.On("RemoveProperty", AnyCTX, req).Return(&resp, nil).Once() } -func updateRuleTreeWithVariablesStep0() *papi.RulesUpdate { - return updateRuleTreeWithVariables([]papi.RuleVariable{ - { - Name: "TEST_EMPTY_FIELDS", - Value: ptr.To(""), - Description: ptr.To(""), - Hidden: true, - Sensitive: false, - }, - { - Name: "TEST_NIL_FIELD", - Description: nil, - Value: ptr.To(""), - Hidden: true, - Sensitive: false, +func (p *mockProperty) mockMoveProperty() { + prpID := strings.TrimPrefix(p.assetID, "aid_") + intPropertyID, err := strconv.ParseInt(prpID, 10, 64) + // shouldn't happen, unless wrong format of propertyID is provided + if err != nil { + panic(err) + } + req := iam.MovePropertyRequest{ + PropertyID: intPropertyID, + Body: iam.MovePropertyRequestBody{ + DestinationGroupID: p.moveGroup.destinationGroupID, + SourceGroupID: p.moveGroup.sourceGroupID, }, - }) -} + } -type mockPropertyData struct { - propertyName string - groupID string - contractID string - productID string - propertyID string - latestVersion int - assetID string - cnameFrom string - cnameTo string + p.iamMock.On("MoveProperty", AnyCTX, req).Return(nil).Once() } -type mockProperty struct { - mockPropertyData - papiMock *papi.Mock +func (p *mockProperty) mockGetActivations() *mock.Call { + req := papi.GetActivationsRequest{ + PropertyID: p.propertyID, + } + resp := papi.GetActivationsResponse{ + Activations: p.activations, + } + return p.papiMock.On("GetActivations", mock.Anything, req).Return(&resp, nil).Once() } -func (p *mockProperty) mockCreateProperty() *mock.Call { - return ExpectCreateProperty(p.papiMock, p.propertyName, p.groupID, p.contractID, p.productID, p.propertyID) -} +func (p *mockProperty) mockCreateActivation() *mock.Call { + req := papi.CreateActivationRequest{ + PropertyID: p.propertyID, + Activation: papi.Activation{ + ActivationType: p.createActivation.ActivationType, + Network: p.createActivation.Network, + NotifyEmails: p.createActivation.NotifyEmails, + PropertyVersion: p.createActivation.PropertyVersion, + }, + } + resp := papi.CreateActivationResponse{ + ActivationID: p.createActivation.ActivationID, + } -func (p *mockProperty) mockUpdatePropertyVersionHostnames() *mock.Call { - return ExpectUpdatePropertyVersionHostnames(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, - []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: p.cnameFrom, - CnameTo: p.cnameTo, - CertProvisioningType: "DEFAULT", - }}, nil) + return p.papiMock.On("CreateActivation", mock.Anything, req).Return(&resp, nil).Once() } -func (p *mockProperty) mockGetProperty() *mock.Call { - return ExpectGetProperty(p.papiMock, p.propertyID, p.groupID, p.contractID, &papi.Property{ - PropertyName: p.propertyName, - GroupID: p.groupID, - ContractID: p.contractID, - ProductID: p.productID, - PropertyID: p.propertyID, - LatestVersion: p.latestVersion, - AssetID: p.assetID, - }) -} +func (p *mockProperty) mockGetActivation() *mock.Call { + req := papi.GetActivationRequest{ + PropertyID: p.propertyID, + ActivationID: p.createActivation.ActivationID, + } + resp := papi.GetActivationResponse{ + Activation: &p.createActivation, + } -func (p *mockProperty) mockGetPropertyVersionHostnames() *mock.Call { - return ExpectGetPropertyVersionHostnames(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, &[]papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: p.cnameFrom, - CnameTo: p.cnameTo, - CertProvisioningType: "DEFAULT", - }}) + return p.papiMock.On("GetActivation", mock.Anything, req).Return(&resp, nil).Once() } -func (p *mockProperty) mockGetRuleTree() *mock.Call { - ruleFormat := "" - return ExpectGetRuleTree(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, nil, &ruleFormat, nil, nil) -} +func (p *mockProperty) mockCreatePropertyVersion() *mock.Call { + req := papi.CreatePropertyVersionRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + Version: papi.PropertyVersionCreate{ + CreateFromVersion: p.createFromVersion, + }, + } -func (p *mockProperty) mockGetPropertyVersion() *mock.Call { - return ExpectGetPropertyVersion(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, papi.VersionStatusInactive, - papi.VersionStatusInactive) -} + resp := papi.CreatePropertyVersionResponse{PropertyVersion: p.newVersionID} -func (p *mockProperty) mockRemoveProperty() *mock.Call { - return ExpectRemoveProperty(p.papiMock, p.propertyID, p.contractID, p.groupID) + return p.papiMock.On("CreatePropertyVersion", AnyCTX, req).Return(&resp, nil).Once() } -func mockResourcePropertyCreate(p *mockProperty) { - p.mockCreateProperty().Once() - p.mockUpdatePropertyVersionHostnames().Once() - mockResourcePropertyRead(p) +// mockResourcePropertyCreateWithVersionHostnames represents the creation workflow where the property and hostnames are created +func mockResourcePropertyCreateWithVersionHostnames(p *mockProperty) { + p.mockCreateProperty() + p.mockUpdatePropertyVersionHostnames() } -func mockResourcePropertyRead(p *mockProperty) { - p.mockGetProperty().Once() - p.mockGetPropertyVersionHostnames().Once() - p.mockGetRuleTree().Once() - p.mockGetPropertyVersion().Once() +// mockResourcePropertyFullCreate represents the full creation workflow where the property, hostnames and rule tree are created +func mockResourcePropertyFullCreate(p *mockProperty) { + p.mockCreateProperty() + p.mockUpdatePropertyVersionHostnames() + p.mockUpdateRuleTree() } -func mockMoveProperty(iamMock *iam.Mock, propertyID, srcGroupID, destGroupID int64) { - iamMock.On("MoveProperty", AnyCTX, iam.MovePropertyRequest{ - PropertyID: propertyID, - BodyParams: iam.MovePropertyReqBody{ - DestinationGroupID: destGroupID, - SourceGroupID: srcGroupID, - }}).Return(nil) +// mockResourcePropertyRead represents the read workflow where GetProperty call is used (version of the property is known) +func mockResourcePropertyRead(p *mockProperty, times ...int) { + i := 1 + if len(times) > 0 { + i = times[0] + } + p.mockGetProperty().Times(i) + p.mockGetPropertyVersionHostnames().Times(i) + p.mockGetRuleTree().Times(i) + p.mockGetPropertyVersion().Times(i) } diff --git a/pkg/providers/property/resource_akamai_property_include.go b/pkg/providers/property/resource_akamai_property_include.go index af818be12..669d8248b 100644 --- a/pkg/providers/property/resource_akamai_property_include.go +++ b/pkg/providers/property/resource_akamai_property_include.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -110,6 +110,11 @@ func resourcePropertyInclude() *schema.Resource { Computed: true, Description: "The most recent version to be activated to the production network", }, + "asset_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the include in the Identity and Access Management API.", + }, }, } } @@ -289,6 +294,7 @@ func resourcePropertyIncludeRead(ctx context.Context, rd *schema.ResourceData, m } attrs := map[string]interface{}{ + "asset_id": include.AssetID, "rules": string(rulesJSON), "name": include.IncludeName, "type": include.IncludeType, diff --git a/pkg/providers/property/resource_akamai_property_include_activation.go b/pkg/providers/property/resource_akamai_property_include_activation.go index c62fc76f7..4b944a7b1 100644 --- a/pkg/providers/property/resource_akamai_property_include_activation.go +++ b/pkg/providers/property/resource_akamai_property_include_activation.go @@ -11,8 +11,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/property/resource_akamai_property_include_activation_test.go b/pkg/providers/property/resource_akamai_property_include_activation_test.go index 07334672b..569e262d2 100644 --- a/pkg/providers/property/resource_akamai_property_include_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_include_activation_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/property/resource_akamai_property_include_test.go b/pkg/providers/property/resource_akamai_property_include_test.go index e4a26136c..6210dab4c 100644 --- a/pkg/providers/property/resource_akamai_property_include_test.go +++ b/pkg/providers/property/resource_akamai_property_include_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -21,6 +21,7 @@ import ( func TestResourcePropertyInclude(t *testing.T) { type testData struct { + assetID string groupID string rulesPath string includeID string @@ -50,6 +51,7 @@ func TestResourcePropertyInclude(t *testing.T) { newGetIncludeResp := func(testData *testData) *papi.GetIncludeResponse { return &papi.GetIncludeResponse{ Include: papi.Include{ + AssetID: testData.assetID, GroupID: testData.groupID, IncludeID: testData.includeID, ContractID: testData.contractID, @@ -294,6 +296,7 @@ func TestResourcePropertyInclude(t *testing.T) { }{ "create include - no rules and no warnings": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", productID: "prd_test", includeID: includeID, @@ -311,6 +314,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_no_rules.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -329,6 +333,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - with rules": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -348,6 +353,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -366,6 +372,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - with rules with comment": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules_with_comment.json", productID: "prd_test", @@ -385,6 +392,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_with_comment.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -403,6 +411,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - rules with validation errors": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -423,6 +432,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -440,6 +450,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - rules with validation warnings": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -460,6 +471,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -478,6 +490,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - rules with validation errors and warnings": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -498,6 +511,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -516,6 +530,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - server returns no warnings on second apply": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -541,6 +556,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -558,6 +574,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -576,6 +593,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - server returns no errors on second apply": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -601,6 +619,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -618,6 +637,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -636,6 +656,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "update include - editable version": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", productID: "prd_test", includeID: includeID, @@ -663,6 +684,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_no_rules.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -680,6 +702,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -698,6 +721,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "update include - create new version": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", productID: "prd_test", includeID: includeID, @@ -730,6 +754,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_no_rules.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -747,6 +772,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), diff --git a/pkg/providers/property/resource_akamai_property_test.go b/pkg/providers/property/resource_akamai_property_test.go index a89e452be..ba88f08bd 100644 --- a/pkg/providers/property/resource_akamai_property_test.go +++ b/pkg/providers/property/resource_akamai_property_test.go @@ -7,1889 +7,2020 @@ import ( "net/http" "path" "regexp" + "slices" "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -func TestResProperty(t *testing.T) { - // These more or less track the state of a Property in PAPI for the lifecycle tests - type TestState struct { - Client *papi.Mock - Property papi.Property - Hostnames []papi.Hostname - VersionItems papi.PropertyVersionItems - Rules papi.RulesUpdate - RuleFormat string - } - - // BehaviorFuncs can be composed to define common patterns of mock PAPI behavior (for Lifecycle tests) - type BehaviorFunc = func(*TestState) - - // Combines many BehaviorFuncs into one - composeBehaviors := func(behaviors ...BehaviorFunc) BehaviorFunc { - return func(State *TestState) { - for _, behave := range behaviors { - behave(State) - } - } - } - - updateRuleTree := func(propertyID, contractID, groupID string, version int, rulesUpdate *papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - ExpectUpdateRuleTree( - state.Client, propertyID, groupID, contractID, version, - rulesUpdate, "", []papi.RuleError{}, - ).Once().Run(func(args mock.Arguments) { - state.Rules = *rulesUpdate - }) - } - } - - setHostnames := func(propertyID string, version int, cnameTo string) BehaviorFunc { - return func(state *TestState) { - newHostnames := []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: "from.test.domain", - CnameTo: cnameTo, - CertProvisioningType: "DEFAULT", - }} - - ExpectUpdatePropertyVersionHostnames(state.Client, propertyID, "grp_0", "ctr_0", version, newHostnames, nil).Once().Run(func(mock.Arguments) { - newResponseHostnames := []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: "from.test.domain", - CnameTo: cnameTo, - CertProvisioningType: "DEFAULT", - EdgeHostnameID: "ehn_123", - CertStatus: papi.CertStatusItem{ - ValidationCname: papi.ValidationCname{ - Hostname: "_acme-challenge.www.example.com", - Target: "{token}.www.example.com.akamai-domain.com", - }, - Staging: []papi.StatusItem{{Status: "PENDING"}}, - Production: []papi.StatusItem{{ - Status: "PENDING", - }, - }, - }, - }} - state.Hostnames = append([]papi.Hostname{}, newResponseHostnames...) - }) - } - } - - setTwoHostnames := func(propertyID string, version int, cnameFrom1, cnameTo1, cnameFrom2, cnameTo2 string) BehaviorFunc { - return func(state *TestState) { - newHostnames := []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom1, - CnameTo: cnameTo1, - CertProvisioningType: "DEFAULT", - }, { - CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom2, - CnameTo: cnameTo2, - CertProvisioningType: "DEFAULT", - }} - - ExpectUpdatePropertyVersionHostnames(state.Client, propertyID, "grp_0", "ctr_0", version, newHostnames, nil).Once().Run(func(mock.Arguments) { - NewResponseHostnames := []papi.Hostname{{ +// TestPropertyLifecycle tests various lifecycle workflows that result in a success +func TestPropertyLifecycle(t *testing.T) { + + // defaultChecker contains basic checks for every test case, that can be built upon + defaultChecker := test.NewStateChecker("akamai_property.test"). + CheckEqual("id", "prp_4"). + CheckEqual("hostnames.0.edge_hostname_id", "ehn_123"). + CheckEqual("name", "test_property"). + CheckEqual("contract_id", "ctr_1"). + CheckEqual("group_id", "grp_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("rule_warnings.#", "0"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("latest_version", "1"). + CheckEqual("staging_version", "0"). + CheckEqual("production_version", "0"). + CheckEqual("rules", `{"rules":{"name":"default","options":{}}}`) + + // basicData holds basic, common data across test cases + basicData := mockPropertyData{ + propertyName: "test_property", + productID: "prd_3", + propertyID: "prp_4", + groupID: "grp_2", + contractID: "ctr_1", + assetID: "aid_5555", + latestVersion: 1, + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, + }, + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom1, - CnameTo: cnameTo1, - CertProvisioningType: "DEFAULT", EdgeHostnameID: "ehn_123", - CertStatus: papi.CertStatusItem{ - ValidationCname: papi.ValidationCname{ - Hostname: "_acme-challenge.www.example.com", - Target: "{token}.www.example.com.akamai-domain.com", - }, - Staging: []papi.StatusItem{{Status: "PENDING"}}, - Production: []papi.StatusItem{{ - Status: "PENDING", - }, - }, - }, - }, { - CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom2, - CnameTo: cnameTo2, + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", CertProvisioningType: "DEFAULT", - EdgeHostnameID: "ehn_123", - CertStatus: papi.CertStatusItem{ - ValidationCname: papi.ValidationCname{ - Hostname: "_acme-challenge.www.example.com", - Target: "{token}.www.example.com.akamai-domain.com", - }, - Staging: []papi.StatusItem{{Status: "PENDING"}}, - Production: []papi.StatusItem{{ - Status: "PENDING", - }, - }, - }, - }} - state.Hostnames = append([]papi.Hostname{}, NewResponseHostnames...) - }) - } - } - - getPropertyVersions := func(propertyID, propertyName, contractID, groupID string, items ...papi.PropertyVersionItems) BehaviorFunc { - return func(state *TestState) { - versionItems := &state.VersionItems - if len(items) > 0 { - versionItems = &items[0] - } - ExpectGetPropertyVersions(state.Client, propertyID, propertyName, contractID, groupID, &state.Property, versionItems) - } - } - - getPropertyVersionResources := func(propertyID, groupID, contractID string, version int, stagStatus, prodStatus papi.VersionStatus) BehaviorFunc { - return func(state *TestState) { - ExpectGetPropertyVersion(state.Client, propertyID, groupID, contractID, version, stagStatus, prodStatus) - } - } - - GetVersionResources := func(propertyID, contractID, groupID string, version int) BehaviorFunc { - return func(state *TestState) { - ExpectGetPropertyVersionHostnames(state.Client, propertyID, groupID, contractID, version, &state.Hostnames) - ExpectGetRuleTree(state.Client, propertyID, groupID, contractID, version, &state.Rules, &state.RuleFormat, nil, nil) - } - } - - GetVersionResourcesDrift := func(propertyID, contractID, groupID string, version int, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - ExpectGetPropertyVersionHostnames(state.Client, propertyID, groupID, contractID, version, &state.Hostnames) - ExpectGetRuleTree(state.Client, propertyID, groupID, contractID, version, &rules, &state.RuleFormat, nil, nil) - } - } - - DeleteProperty := func(propertyID string) BehaviorFunc { - return func(state *TestState) { - ExpectRemoveProperty(state.Client, propertyID, "ctr_0", "grp_0").Once().Run(func(mock.Arguments) { - state.Property = papi.Property{} - state.Rules = papi.RulesUpdate{} - state.Hostnames = nil - state.RuleFormat = "" - state.VersionItems = papi.PropertyVersionItems{} - }) - } - } - - getProperty := func(propertyID string) BehaviorFunc { - return func(state *TestState) { - ExpectGetProperty(state.Client, propertyID, "grp_0", "ctr_0", &state.Property) - } - } - - createProperty := func(propertyName, propertyID string, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - ExpectCreateProperty(state.Client, propertyName, "grp_0", "ctr_0", "prd_0", propertyID).Run(func(mock.Arguments) { - state.Property = papi.Property{ - PropertyName: propertyName, - PropertyID: propertyID, - GroupID: "grp_0", - ContractID: "ctr_0", - ProductID: "prd_0", - LatestVersion: 1, - } - - state.Rules = rules - state.RuleFormat = "v2020-01-01" - getProperty(propertyID)(state) - GetVersionResources(propertyID, "ctr_0", "grp_0", 1)(state) - }).Once() - } - } - - propertyLifecycle := func(propertyName, propertyID, groupID string, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - createProperty(propertyName, propertyID, rules)(state) - GetVersionResources(propertyID, "ctr_0", "grp_0", 1)(state) - DeleteProperty(propertyID)(state) - } + }, + }, + }, } - // propertyLifecycleWithPropertyID covers lifecycle when property_id is set - propertyLifecycleWithPropertyID := func(propertyName, propertyID, groupID string, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - state.Property.PropertyID = "prp_0" - state.Property.LatestVersion = 1 - state.Property.ContractID = "ctr_0" - state.Property.GroupID = "grp_0" - state.Property.PropertyName = "test_property" - state.Rules = rules - state.RuleFormat = "v2020-01-01" - getProperty(propertyID)(state) - GetVersionResources(propertyID, "ctr_0", "grp_0", 1)(state) - // no deletion since it should be covered by property_bootstrap resource - } + // basicDataWithDefaultRules extends basic data with the default rules + basicDataWithDefaultRules := basicData + basicDataWithDefaultRules.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + }, } - propertyLifecycleWithDrift := func(propertyName, propertyID, groupID string, rulesToSend, rulesToReceive papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - createProperty(propertyName, propertyID, rulesToSend)(state) - GetVersionResourcesDrift(propertyID, "ctr_0", "grp_0", 1, rulesToReceive)(state) - DeleteProperty(propertyID)(state) - } + // updatedHostname contains details about the updated hostname + updatedHostname := papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from.test.domain", + CnameTo: "to2.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, + }, } - importProperty := func(propertyID string) BehaviorFunc { - return func(state *TestState) { - // Depending on how much of the import ID is given, the initial property lookup may not have group and contract - ExpectGetProperty(state.Client, "prp_0", "grp_0", "ctr_0", &state.Property).Maybe() - ExpectGetProperty(state.Client, "prp_0", "", "", &state.Property).Maybe() - } + // versionStagingActive represents version of property active only on staging network + versionStagingActive := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusActive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, } - advanceVersion := func(propertyID string, fromVersion, toVersion int) BehaviorFunc { - return func(state *TestState) { - ExpectCreatePropertyVersion(state.Client, propertyID, "grp_0", "ctr_0", fromVersion, toVersion).Once().Run(func(mock.Arguments) { - state.Property.LatestVersion = toVersion - }).Run(func(args mock.Arguments) { - state.Property.LatestVersion = toVersion - state.VersionItems.Items = append(state.VersionItems.Items, - papi.PropertyVersionGetItem{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: toVersion, - StagingStatus: papi.VersionStatusInactive, - }) - }) - GetVersionResources(propertyID, "ctr_0", "grp_0", toVersion)(state) - } + // versionProductionActive represents version of property active only on production network + versionProductionActive := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusActive, + PropertyVersion: 1, + }, + }, } - // TestCheckFunc to verify all standard attributes (for Lifecycle tests) - checkAttrs := func(propertyID, cnameTo, latestVersion, stagingVersion, productionVersion, edgeHostnameId, rules string) resource.TestCheckFunc { - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "id", propertyID), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_to", cnameTo), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.edge_hostname_id", edgeHostnameId), - resource.TestCheckResourceAttr("akamai_property.test", "latest_version", latestVersion), - resource.TestCheckResourceAttr("akamai_property.test", "staging_version", stagingVersion), - resource.TestCheckResourceAttr("akamai_property.test", "production_version", productionVersion), - resource.TestCheckResourceAttr("akamai_property.test", "name", "test_property"), - resource.TestCheckResourceAttr("akamai_property.test", "contract_id", "ctr_0"), - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_0"), - resource.TestCheckResourceAttr("akamai_property.test", "product_id", "prd_0"), - resource.TestCheckResourceAttr("akamai_property.test", "rule_warnings.#", "0"), - resource.TestCheckResourceAttr("akamai_property.test", "rules", rules), - ) + // mockLatestVersionNotActive represents a workflow where no property version is active on any of the networks + mockLatestVersionNotActive := func(p *mockProperty) { + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update + p.mockGetPropertyVersion() + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() } - // addPropertyIDAttrCheck adds resource.TestCheckFunc that checks if property_id attribute was set correctly - addPropertyIDAttrCheck := func(checks resource.TestCheckFunc, propertyID string) resource.TestCheckFunc { - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "property_id", propertyID), - checks, - ) + // mockLatestVersionActiveOnStaging represents a workflow where the second version of property is created and is active on staging network + mockLatestVersionActiveOnStaging := func(p *mockProperty) { + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock staging version active + p.versions = versionStagingActive + // read + mockResourcePropertyRead(p) + // update creates new version with updated hostname and version info + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + p.latestVersion = 2 + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() } - type StepsFunc = func(State *TestState, FixturePath string) []resource.TestStep - - // Defines standard variations of client behaviors for a Lifecycle test - type LifecycleTestCase struct { - Name string - ClientSetup BehaviorFunc - Steps StepsFunc + // mockLatestVersionActiveOnProduction represents a workflow where the second version of property is created and is active on production network + mockLatestVersionActiveOnProduction := func(p *mockProperty) { + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock production version active + p.versions = versionProductionActive + // read + mockResourcePropertyRead(p) + // update creates new version with updated hostname and version info + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + p.latestVersion = 2 + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() } - // Standard test behavior for cases where the property's latest version is deactivated in staging network - latestVersionDeactivatedInStaging := LifecycleTestCase{ - Name: "Latest version is active in staging", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusDeactivated, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusDeactivated, papi.VersionStatusInactive), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusDeactivated, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - StagingVersion := 1 - State.Property.StagingVersion = &StagingVersion - }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "1", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + // grouped tests that always have 2 steps and the config file names are always "step0.tf" and "step1.tf". For different tests, + // add them as separate cases at the end of this function. + tests := map[string]struct { + init func(*testing.T, *mockProperty) + steps []resource.TestStep + checksForCreate resource.TestCheckFunc + checksForUpdate resource.TestCheckFunc + configPlanChecks resource.ConfigPlanChecks + configDir string + }{ + "Lifecycle: property is destroyed and recreated when name is changed": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // delete + p.mockRemoveProperty() + // assign new values for mock data + p.propertyID = "prp_5" + p.propertyName = "renamed_property" + p.hostnames = updatedHostname + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "forceNewOnNameChange", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("id", "prp_5"). + CheckEqual("name", "renamed_property"). + CheckEqual("hostnames.0.cname_to", "to2.test.domain").Build(), }, - } - - // Standard test behavior for cases where the property's latest version is deactivated in production network - latestVersionDeactivatedInProd := LifecycleTestCase{ - Name: "Latest version is active in production", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusDeactivated), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusDeactivated), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusActive, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - ProductionVersion := 1 - State.Property.ProductionVersion = &ProductionVersion - }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "0", "1", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + "Lifecycle: create with propertyID (bootstrap)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + // create (without creation of property, as it was created with bootstrap resource) + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // mock updated hostnames + p.hostnames = updatedHostname + // update + p.mockGetPropertyVersion() + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // no delete as the resource is maintained by bootstrap resource + }, + configDir: "with-propertyID", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is active in staging network - latestVersionActiveInStaging := LifecycleTestCase{ - Name: "Latest version is active in staging", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusActive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusActive), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusActive, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - StagingVersion := 1 - State.Property.StagingVersion = &StagingVersion + "Lifecycle: latest version is deactivated in staging (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock activating staging version + p.versions = versionStagingActive + // read + mockResourcePropertyRead(p) + // update creates new version + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + // update mock data with new version info and updated hostname + p.latestVersion = 2 + p.hostnames = updatedHostname + p.versions = papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusActive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + { + StagingStatus: papi.VersionStatusDeactivated, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 2, + }, }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "1", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + } + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is active in production network - latestVersionActiveInProd := LifecycleTestCase{ - Name: "Latest version is active in production", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusActive), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusActive), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusActive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusInactive, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - ProductionVersion := 1 - State.Property.ProductionVersion = &ProductionVersion + "Lifecycle: latest version is deactivated in production (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock production version active + p.versions = versionProductionActive + // read + mockResourcePropertyRead(p) + // update creates new version with updated hostname and version info + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + p.latestVersion = 2 + p.hostnames = updatedHostname + p.versions = papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusActive, + PropertyVersion: 1, + }, + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusDeactivated, + PropertyVersion: 2, + }, }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "0", "1", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + } + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), }, - } - - // withPropertyID covers case when property was initially created with property_bootstrap resource - withPropertyID := LifecycleTestCase{ - Name: "Create with propertyID", - ClientSetup: composeBehaviors( - propertyLifecycleWithPropertyID("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_0", 1, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: addPropertyIDAttrCheck(checkAttrs("prp_0", "to2.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), "prp_0"), - }, - } + "Lifecycle: latest version is not active (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + mockLatestVersionNotActive(p) + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is not active - latestVersionNotActive := LifecycleTestCase{ - Name: "Latest version not active", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_0", 1, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + "Lifecycle: latest version is active in staging (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "normal", + checksForCreate: defaultChecker. + Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is not active - stagingAndProductionVersionKnownAtPlan := LifecycleTestCase{ - Name: "Latest version not active", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_0", 1, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - ConfigPlanChecks: resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{testutils.FieldsKnownAtPlan{FieldsKnown: []string{"staging_version", "production_version"}, FieldsUnknown: []string{"latest_version"}}}}, - }, - } + "Lifecycle: latest version is active in production (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), }, - } - - // This scenario simulates a new version being created outside of terraform and returned on read after the first step (update should be triggered) - changesMadeOutsideOfTerraform := LifecycleTestCase{ - Name: "Latest version not active", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusInactive), - GetVersionResources("prp_0", "ctr_0", "grp_0", 2), - setHostnames("prp_0", 2, "to.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - State.Property.LatestVersion = 2 - State.Hostnames[0].CnameTo = "changed.test.domain" - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "2", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + "Lifecycle: latest version is not active (contract_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + mockLatestVersionNotActive(p) + }, + configDir: "contract_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is active in staging network - noDiff := LifecycleTestCase{ - Name: "No diff found in update", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{Name: "Default CORS Policy", CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll}}}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, Name: "Default CORS Policy"}}}}), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - } + "Lifecycle: latest version active in staging (contract_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "contract_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), }, - } - - diffCPCode := LifecycleTestCase{ - Name: "Diff cpCode.cpCodeLimits", - ClientSetup: composeBehaviors( - propertyLifecycleWithDrift("test_property", "prp_0", "grp_0", - papi.RulesUpdate{ - Rules: papi.Rules{Behaviors: []papi.RuleBehavior{ - { - Name: "cpCode", - Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "description": "CliTerraformCPCode", - "id": 1.050269e+06, - "name": "DevExpCliTerraformPapiAsSchemaTest", - "products": []interface{}{"Web_App_Accel"}, - }, + "Lifecycle: latest version active in production (contract_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "contract_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), + }, + "Lifecycle: latest version is not active (group_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + mockLatestVersionNotActive(p) + }, + configDir: "group_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), + }, + "Lifecycle: latest version is active in staging (group_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "group_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), + }, + "Lifecycle: latest version is active in production (group_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "group_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), + }, + "Lifecycle: latest version is not active (product_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionNotActive(p) + }, + configDir: "product_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), + }, + "Lifecycle: latest version is active in staging (product_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "product_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), + }, + "Lifecycle: latest version is active in production (product_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "product_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), + }, + "Lifecycle: no diff": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Children: []papi.Rules{ + { + Name: "Default CORS Policy", + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, }, }, }, - Name: "default"}}, - papi.RulesUpdate{ - Rules: papi.Rules{Behaviors: []papi.RuleBehavior{ + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock update in rules by changing the order + p.ruleTree.rules = papi.Rules{Children: []papi.Rules{{CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, Name: "Default CORS Policy"}}} + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "no diff", + checksForCreate: defaultChecker. + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + }, + "Lifecycle: rules custom diff": { + /* + rulesCustomDiff tests rulesCustomDiff function which is in resource_akamai_property.go file. + There is an additional field "options":{} in expected attributes, because with UpdateRuleTree(ctx, req) function + this field added automatically into response, even if it does not exist in rules. + */ + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{Behaviors: []papi.RuleBehavior{ { - Name: "cpCode", + Name: "caching", Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "cpCodeLimits": nil, - "description": "CliTerraformCPCode", - "id": 1.050269e+06, - "name": "DevExpCliTerraformPapiAsSchemaTest", - "products": []interface{}{"Web_App_Accel"}, - }, + "behavior": "MAX_AGE", + "mustRevalidate": false, + "ttl": "12d", }, }, }, - Name: "default"}}, - ), - setHostnames("prp_0", 1, "to.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{ - {Name: "cpCode", + Name: "default"}, + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read + mockResourcePropertyRead(p) + // update ttl in rule tree from 12d to 13d + p.ruleTree.rules.Behaviors = []papi.RuleBehavior{ + { + Name: "caching", Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "description": "CliTerraformCPCode", - "id": 1.050269e+06, - "name": "DevExpCliTerraformPapiAsSchemaTest", - "products": []interface{}{"Web_App_Accel"}, - }, + "behavior": "MAX_AGE", + "mustRevalidate": false, + "ttl": "13d", }, }, - }, - Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"behaviors":[{"name":"cpCode","options":{"value":{"cpCodeLimits":null,"description":"CliTerraformCPCode","id":1050269,"name":"DevExpCliTerraformPapiAsSchemaTest","products":["Web_App_Accel"]}}}],"name":"default","options":{}}}`), - }, - } - }, - } - - /* - rulesCustomDiff tests rulesCustomDiff function which is in resource_akamai_property.go file. - There is an additional field "options":{} in expected attributes, because with UpdateRuleTree(ctx, req) function - this field added automatically into response, even if it does not exist in rules. - */ - rulesCustomDiff := LifecycleTestCase{ - Name: "Diff is only in behaviours.options.ttl", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{{Name: "caching", - Options: papi.RuleOptionsMap{"behavior": "MAX_AGE", "mustRevalidate": false, "ttl": "12d"}}}, - Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{{Name: "caching", - Options: papi.RuleOptionsMap{"behavior": "MAX_AGE", "mustRevalidate": false, "ttl": "12d"}}}, - Name: "default"}}), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{{Name: "caching", - Options: papi.RuleOptionsMap{"behavior": "MAX_AGE", "mustRevalidate": false, "ttl": "13d"}}}, - Name: "default"}}), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"12d"}}],"name":"default","options":{}}}`), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"13d"}}],"name":"default","options":{}}}`), - }, - } - }, - } - - noDiffForHostnames := LifecycleTestCase{ - Name: "No diff found in update", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{Name: "Default CORS Policy", CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll}}}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setTwoHostnames("prp_0", 1, "from1.test.domain", "to1.test.domain", "from2.test.domain", "to2.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, Name: "Default CORS Policy"}}}}), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to1.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to1.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - } + } + // update + p.mockGetPropertyVersion() + p.mockUpdateRuleTree() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "rules custom diff", + checksForCreate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"12d"}}],"name":"default","options":{}}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"13d"}}],"name":"default","options":{}}}`). + Build(), }, - } - - variablesInRuleTree := LifecycleTestCase{ - Name: "Variables in property rule tree", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - GetVersionResources("prp_0", "ctr_0", "grp_0", 1), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, updateRuleTreeWithVariablesStep0()), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, updateRuleTreeWithVariablesStep1()), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"behaviors\":[{\"name\":\"origin\",\"options\":{\"cacheKeyHostname\":\"REQUEST_HOST_HEADER\",\"compress\":true,\"enableTrueClientIp\":true,\"forwardHostHeader\":\"REQUEST_HOST_HEADER\",\"hostname\":\"test.domain\",\"httpPort\":80,\"httpsPort\":443,\"originCertificate\":\"\",\"originSni\":true,\"originType\":\"CUSTOMER\",\"ports\":\"\",\"trueClientIpClientSetting\":false,\"trueClientIpHeader\":\"True-Client-IP\",\"verificationMode\":\"PLATFORM_SETTINGS\"}}],\"children\":[{\"behaviors\":[{\"name\":\"baseDirectory\",\"options\":{\"value\":\"/smth/\"}}],\"criteria\":[{\"name\":\"requestHeader\",\"options\":{\"headerName\":\"Accept-Encoding\",\"matchCaseSensitiveValue\":true,\"matchOperator\":\"IS_ONE_OF\",\"matchWildcardName\":false,\"matchWildcardValue\":false}}],\"name\":\"change fwd path\",\"options\":{},\"criteriaMustSatisfy\":\"all\"},{\"behaviors\":[{\"name\":\"caching\",\"options\":{\"behavior\":\"MAX_AGE\",\"mustRevalidate\":false,\"ttl\":\"1m\"}}],\"name\":\"caching\",\"options\":{},\"criteriaMustSatisfy\":\"any\"}],\"comments\":\"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.\",\"name\":\"default\",\"options\":{},\"variables\":[{\"description\":\"\",\"hidden\":true,\"name\":\"TEST_EMPTY_FIELDS\",\"sensitive\":false,\"value\":\"\"},{\"description\":null,\"hidden\":true,\"name\":\"TEST_NIL_FIELD\",\"sensitive\":false,\"value\":\"\"}]}}"), - }, - { - PreConfig: func() { - State.Property.LatestVersion = 1 + "Lifecycle: no diff for hostnames (hostnames)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Children: []papi.Rules{ + { + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, + Name: "Default CORS Policy", + }, + }, }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"behaviors\":[{\"name\":\"origin\",\"options\":{\"cacheKeyHostname\":\"REQUEST_HOST_HEADER\",\"compress\":true,\"enableTrueClientIp\":true,\"forwardHostHeader\":\"REQUEST_HOST_HEADER\",\"hostname\":\"test.domain\",\"httpPort\":80,\"httpsPort\":443,\"originCertificate\":\"\",\"originSni\":true,\"originType\":\"CUSTOMER\",\"ports\":\"\",\"trueClientIpClientSetting\":false,\"trueClientIpHeader\":\"True-Client-IP\",\"verificationMode\":\"PLATFORM_SETTINGS\"}}],\"children\":[{\"behaviors\":[{\"name\":\"baseDirectory\",\"options\":{\"value\":\"/smth/\"}}],\"criteria\":[{\"name\":\"requestHeader\",\"options\":{\"headerName\":\"Accept-Encoding\",\"matchCaseSensitiveValue\":true,\"matchOperator\":\"IS_ONE_OF\",\"matchWildcardName\":false,\"matchWildcardValue\":false}}],\"name\":\"change fwd path\",\"options\":{},\"criteriaMustSatisfy\":\"all\"},{\"behaviors\":[{\"name\":\"caching\",\"options\":{\"behavior\":\"MAX_AGE\",\"mustRevalidate\":false,\"ttl\":\"1m\"}}],\"name\":\"caching\",\"options\":{},\"criteriaMustSatisfy\":\"any\"}],\"comments\":\"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.\",\"name\":\"default\",\"options\":{},\"variables\":[{\"description\":\"\",\"hidden\":true,\"name\":\"TEST_EMPTY_FIELDS\",\"sensitive\":false,\"value\":\"\"},{\"description\":\"\",\"hidden\":true,\"name\":\"TEST_NIL_FIELD\",\"sensitive\":false,\"value\":\"\"}]}}"), - }, - } - }, - } - - // Test Schema Configuration - - // Run a test case to verify schema validations - assertConfigError := func(t *testing.T, flaw, rx string) func(t *testing.T) { - - fixtureName := strings.ReplaceAll(flaw, " ", "_") - - return func(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/ConfigError/%s.tf", fixtureName), - ExpectError: regexp.MustCompile(rx), - }}, - }) - } - } - - // Test Lifecycle - - // Run a happy-path test case that goes through a complete create-update-destroy cycle - assertLifecycle := func(t *testing.T, name, variant string, tc LifecycleTestCase) func(t *testing.T) { - - fixturePrefix := fmt.Sprintf("testdata/%s/Lifecycle/%s", t.Name(), variant) - - return func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - State := &TestState{Client: client} - tc.ClientSetup(State) - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - IsUnitTest: true, - Steps: tc.Steps(State, fixturePrefix), - }) - }) - - client.AssertExpectations(t) - } - } - - // Test Import - // Run a test case that verifies the resource can be imported by the given ID - assertImportableWithOptions := func(t *testing.T, testName, importID, fileName, rules string, setup []BehaviorFunc) func(t *testing.T) { - - fixturePath := fmt.Sprintf("testdata/%s/Importable/%s", t.Name(), fileName) - - return func(t *testing.T) { - - client := &papi.Mock{} - client.Test(T{t}) - - parameters := strings.Split(importID, ",") - var propertyBootstrap bool - if parameters[len(parameters)-1] == "property-bootstrap" { - propertyBootstrap = true - parameters = parameters[:len(parameters)-1] - } - numberParameters := len(parameters) - lastParameter := parameters[len(parameters)-1] - if propertyBootstrap { - setup = append(setup, propertyLifecycleWithPropertyID("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}})) - } else { - setup = append(setup, propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}})) - } - setup = append(setup, - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - importProperty("prp_0"), - ) - if (numberParameters == 2 || numberParameters == 4) && !isDefaultVersion(lastParameter) { - var contractID, groupID string - if numberParameters == 4 { - contractID = "ctr_0" - groupID = "grp_0" } - if numberParameters == 2 { - setup = append(setup, getPropertyVersions("prp_0", "test_property", "ctr_0", "grp_0")) - } - setup = append(setup, getPropertyVersions("prp_0", "test_property", contractID, groupID)) - } - s := composeBehaviors(setup...) - tc := LifecycleTestCase{ - Name: "Importable", - ClientSetup: s, - Steps: func(State *TestState, _ string) []resource.TestStep { - return []resource.TestStep{ + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - Config: testutils.LoadFixtureString(t, fixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", rules), + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from1.test.domain", + CnameTo: "to1.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", }, - // this step is used to refresh state with updated staging/production statuses { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from2.test.domain", + CnameTo: "to2.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, + }, + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x2 - refresh as nothing other than the order of hostnames changed + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "hostnames", + checksForCreate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to1.test.domain"). + CheckEqual("hostnames.1.cname_to", "to2.test.domain"). + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to1.test.domain"). + CheckEqual("hostnames.1.cname_to", "to2.test.domain"). + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + }, + "Lifecycle: rules with variables": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + Children: []papi.Rules{ + { + Name: "change fwd path", + Behaviors: []papi.RuleBehavior{ { - PropertyVersion: 1, - StagingStatus: papi.VersionStatusActive, - ProductionStatus: papi.VersionStatusActive, + Name: "baseDirectory", + Options: papi.RuleOptionsMap{ + "value": "/smth/", + }, }, - }} - stagingVersion := 1 - State.Property.StagingVersion = &stagingVersion - + }, + Criteria: []papi.RuleBehavior{ + { + Name: "requestHeader", + Locked: false, + Options: papi.RuleOptionsMap{ + "headerName": "Accept-Encoding", + "matchCaseSensitiveValue": true, + "matchOperator": "IS_ONE_OF", + "matchWildcardName": false, + "matchWildcardValue": false, + }, + }, + }, + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, + }, + { + Name: "caching", + Behaviors: []papi.RuleBehavior{ + { + Name: "caching", + Options: papi.RuleOptionsMap{ + "behavior": "MAX_AGE", + "mustRevalidate": false, + "ttl": "1m", + }, + }, + }, + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAny, }, - Config: testutils.LoadFixtureString(t, fixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "1", "0", "ehn_123", rules), - }, - { - ImportState: true, - ImportStateVerify: true, - ImportStateId: importID, - ResourceName: "akamai_property.test", - Config: testutils.LoadFixtureString(t, fixturePath), - ImportStateVerifyIgnore: []string{"product", "read_version"}, - Check: addPropertyIDAttrCheck(checkAttrs("prp_0", "to.test.domain", "1", "1", "0", "ehn_123", rules), "prp_0"), }, - } - }, - } - State := &TestState{Client: client} - tc.ClientSetup(State) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: tc.Steps(State, ""), - }) - }) - - client.AssertExpectations(t) - } - } - - assertImportable := func(t *testing.T, testName, importID string) func(t *testing.T) { - return assertImportableWithOptions(t, testName, importID, "importable.tf", "{\"rules\":{\"name\":\"default\",\"options\":{}}}", []BehaviorFunc{}) - } - - // assertImportableWithBootstrap covers imports when property-bootstrap flag is provided - assertImportableWithBootstrap := func(t *testing.T, testName, importID string) func(t *testing.T) { - return assertImportableWithOptions(t, testName, importID, "importable-with-bootstrap.tf", "{\"rules\":{\"name\":\"default\",\"options\":{}}}", []BehaviorFunc{}) - } - - suppressLogging(t, func() { - - // Test Schema Configuration - - t.Run("Schema Configuration Error: name not given", assertConfigError(t, "name not given", `"name" is required`)) - t.Run("Schema Configuration Error: contract_id not given", assertConfigError(t, "contract_id not given", `Missing required argument`)) - t.Run("Schema Configuration Error: group_id not given", assertConfigError(t, "group_id not given", `Missing required argument`)) - t.Run("Schema Configuration Error: product_id not given", assertConfigError(t, "product_id not given", `Missing required argument`)) - t.Run("Schema Configuration Error: invalid json rules", assertConfigError(t, "invalid json rules", `rules are not valid JSON`)) - t.Run("Schema Configuration Error: invalid name given", assertConfigError(t, "invalid name given", `a name must only contain letters, numbers, and these characters: . _ -`)) - t.Run("Schema Configuration Error: name given too long", assertConfigError(t, "name given too long", `a name must be longer than 0 characters and shorter than 86 characters`)) - - // Test Lifecycle - - // In the tests below update for hostnames is triggered - t.Run("Lifecycle: create with propertyID", assertLifecycle(t, t.Name(), "with-propertyID", withPropertyID)) - t.Run("Lifecycle: latest version is not active (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionActiveInProd)) - t.Run("Lifecycle: latest version is deactivated in staging (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionDeactivatedInStaging)) - t.Run("Lifecycle: latest version is deactivated in production (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionDeactivatedInProd)) - t.Run("Lifecycle: latest version is not active (contract_id without prefix)", assertLifecycle(t, t.Name(), "contract_id without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version active in staging (contract_id without prefix)", assertLifecycle(t, t.Name(), "contract_id without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version active in production (contract_id without prefix)", assertLifecycle(t, t.Name(), "contract_id without prefix", latestVersionActiveInProd)) - t.Run("Lifecycle: latest version is not active (group_id without prefix)", assertLifecycle(t, t.Name(), "group_id without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (group_id without prefix)", assertLifecycle(t, t.Name(), "group_id without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (group_id without prefix)", assertLifecycle(t, t.Name(), "group_id without prefix", latestVersionActiveInProd)) - t.Run("Lifecycle: latest version is not active (product_id without prefix)", assertLifecycle(t, t.Name(), "product_id without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (product_id without prefix)", assertLifecycle(t, t.Name(), "product_id without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (product_id without prefix)", assertLifecycle(t, t.Name(), "product_id without prefix", latestVersionActiveInProd)) - - t.Run("Lifecycle: no diff", assertLifecycle(t, t.Name(), "no diff", noDiff)) - t.Run("Lifecycle: diff cpCode", assertLifecycle(t, t.Name(), "rules diff cpcode", diffCPCode)) - - // Update for rules - t.Run("Lifecycle: rules custom diff", assertLifecycle(t, t.Name(), "rules custom diff", rulesCustomDiff)) - - t.Run("Lifecycle: no diff for hostnames (hostnames)", assertLifecycle(t, t.Name(), "hostnames", noDiffForHostnames)) - - // Update for hostnames - t.Run("Lifecycle: new version changed on server", assertLifecycle(t, t.Name(), "new version changed on server", changesMadeOutsideOfTerraform)) - - // Update for rules - t.Run("Lifecycle: rules with variables", assertLifecycle(t, t.Name(), "rules with variables", variablesInRuleTree)) - - // Update for hostnames - t.Run("Lifecycle: Verify staging_version and production_version known at plan", assertLifecycle(t, t.Name(), "normal", stagingAndProductionVersionKnownAtPlan)) - - // Test Import - - t.Run("Importable: property_id with ds", assertImportableWithOptions(t, "property_id", "prp_0", "importable_with_property_rules_builder.tf", - "{\"rules\":{\"behaviors\":[{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"no new line\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\\n\\tline with new line before and after + tab\\n\"}}],\"name\":\"default\",\"options\":{}}}", - []BehaviorFunc{ - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{ - Rules: papi.Rules{ - Name: "default", - Behaviors: []papi.RuleBehavior{ - {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "no new line"}}, - {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": ""}}, - {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "\n\tline with new line before and after + tab\n"}}, + Behaviors: []papi.RuleBehavior{ + { + Name: "origin", + Options: papi.RuleOptionsMap{ + "cacheKeyHostname": "REQUEST_HOST_HEADER", + "compress": true, + "enableTrueClientIp": true, + "forwardHostHeader": "REQUEST_HOST_HEADER", + "hostname": "test.domain", + "httpPort": float64(80), + "httpsPort": float64(443), + "originCertificate": "", + "originSni": true, + "originType": "CUSTOMER", + "ports": "", + "trueClientIpClientSetting": false, + "trueClientIpHeader": "True-Client-IP", + "verificationMode": "PLATFORM_SETTINGS", + }, }, - }})}, - )) - t.Run("Importable: property_id with property-bootstrap", assertImportableWithBootstrap(t, "property_id", "prp_0,property-bootstrap")) - t.Run("Importable: property_id", assertImportable(t, "property_id", "prp_0")) - t.Run("Importable: property_id and ver_# version", assertImportable(t, "property_id and ver_# version", "prp_0,ver_1")) - t.Run("Importable: property_id and # version", assertImportable(t, "property_id and # version", "prp_0,1")) - t.Run("Importable: property_id and latest", assertImportable(t, "property_id and latest", "prp_0,latest")) - t.Run("Importable: property_id and network", assertImportable(t, "property_id and network", "prp_0,staging")) - t.Run("Importable: unprefixed property_id", assertImportable(t, "unprefixed property_id", "0")) - t.Run("Importable: unprefixed property_id and # version", assertImportable(t, "unprefixed property_id and # version", "0,1")) - t.Run("Importable: unprefixed property_id and ver_# version", assertImportable(t, "unprefixed property_id and ver_# version", "0,ver_1")) - t.Run("Importable: unprefixed property_id and network", assertImportable(t, "unprefixed property_id and network", "0,p")) - t.Run("Importable: property_id and contract_id and group_id", assertImportable(t, "property_id and contract_id and group_id", "prp_0,ctr_0,grp_0")) - t.Run("Importable: property_id, contract_id, group_id and empty version", assertImportable(t, "property_id, contract_id, group_id and empty version", "prp_0,ctr_0,grp_0,")) - t.Run("Importable: property_id, contract_id, group_id and latest", assertImportable(t, "property_id, contract_id, group_id and latest", "prp_0,ctr_0,grp_0,latest")) - t.Run("Importable: property_id, contract_id, group_id and ver_# version", assertImportable(t, "property_id, contract_id, group_id and ver_# version", "prp_0,ctr_0,grp_0,ver_1")) - t.Run("Importable: property_id, contract_id, group_id and # version", assertImportable(t, "property_id, contract_id, group_id and # version", "prp_0,ctr_0,grp_0,1")) - t.Run("Importable: property_id, contract_id, group_id and network", assertImportable(t, "property_id, contract_id, group_id and network", "prp_0,ctr_0,grp_0,staging")) - t.Run("Importable: unprefixed property_id and contract_id and group_id", assertImportable(t, "unprefixed property_id and contract_id and group_id", "0,0,0")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and # version", assertImportable(t, "unprefixed property_id and contract_id, group_id and # version", "0,0,0,1")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and ver_# version", assertImportable(t, "unprefixed property_id and contract_id, group_id and ver_# version", "0,0,0,ver_1")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and latest", assertImportable(t, "unprefixed property_id and contract_id, group_id and latest", "0,0,0,latest")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and network", assertImportable(t, "unprefixed property_id and contract_id, group_id and network", "0,0,0,production")) - - // Test Delete - - t.Run("property is destroyed and recreated when name is changed", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - setup := composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - propertyLifecycle("renamed_property", "prp_1", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_1", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_1", 1, "to2.test.domain"), - ) - setup(&TestState{Client: client}) - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/%s-step0.tf", t.Name()), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), }, - { - Config: testutils.LoadFixtureString(t, "testdata/%s-step1.tf", t.Name()), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_1"), - resource.TestCheckResourceAttr("akamai_property.test", "name", "renamed_property"), - ), + Options: papi.RuleOptions{}, + Variables: []papi.RuleVariable{ + { + Name: "TEST_EMPTY_FIELDS", + Value: ptr.To(""), + Description: ptr.To(""), + Hidden: true, + Sensitive: false, + }, + { + Name: "TEST_NIL_FIELD", + Description: nil, + Value: ptr.To(""), + Hidden: true, + Sensitive: false, + }, }, + Comments: "The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.", }, - }) - }) - - client.AssertExpectations(t) - }) - - t.Run("error when deleting active property", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - setup := composeBehaviors( - createProperty("test_property", "prp_0", papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getProperty("prp_0"), - GetVersionResources("prp_0", "ctr_0", "grp_0", 1), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, "ctr_0", "grp_0"), - setHostnames("prp_0", 1, "to.test.domain"), - ) - setup(&TestState{Client: client}) - - // First call to remove is not successful - req := papi.RemovePropertyRequest{ - PropertyID: "prp_0", - ContractID: "ctr_0", - GroupID: "grp_0", - } - - err := fmt.Errorf(`cannot remove active property "prp_0"`) - client.On("RemoveProperty", AnyCTX, req).Return(nil, err).Once() - - // Second call will be successful (TF test case requires last state to be empty or it's a failed test) - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0").Once() - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/%s/step0.tf", t.Name()), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/%s/step1.tf", t.Name()), - ExpectError: regexp.MustCompile(`cannot remove active property`), - }, + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update with new rules variables (description in TEST_NIL_FIELD is "", was nil) + p.mockGetPropertyVersion() + p.ruleTree.rules.Variables = []papi.RuleVariable{ + { + Name: "TEST_EMPTY_FIELDS", + Value: ptr.To(""), + Description: ptr.To(""), + Hidden: true, + Sensitive: false, }, - }) - }) - - client.AssertExpectations(t) - }) - - // Test validation - - t.Run("error validations when updating property with rules tree", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_1", - ) - - var err error = &papi.Error{ - StatusCode: 400, - Type: "/papi/v1/errors/validation.required_behavior", - Title: "Missing required behavior in default rule", - Detail: "In order for this property to work correctly behavior Content Provider Code needs to be present in the default section", - Instance: "/papi/v1/properties/prp_173136/versions/3/rules#err_100", - BehaviorName: "cpCode", - } - var req = papi.UpdateRulesRequest{ - PropertyID: "prp_1", - ContractID: "ctr_0", - GroupID: "grp_0", - PropertyVersion: 1, - Rules: papi.RulesUpdate{Rules: papi.Rules{ - Name: "update rule tree", - }}, - ValidateRules: true, - } - client.On("UpdateRuleTree", AnyCTX, req).Return(nil, err).Once() - - ExpectRemoveProperty(client, "prp_1", "", "") - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ + { + Name: "TEST_NIL_FIELD", + Description: ptr.To(""), + Value: ptr.To(""), + Hidden: true, + Sensitive: false, + }, + } + p.mockUpdateRuleTree() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "rules with variables", + checksForCreate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"origin","options":{"cacheKeyHostname":"REQUEST_HOST_HEADER","compress":true,"enableTrueClientIp":true,"forwardHostHeader":"REQUEST_HOST_HEADER","hostname":"test.domain","httpPort":80,"httpsPort":443,"originCertificate":"","originSni":true,"originType":"CUSTOMER","ports":"","trueClientIpClientSetting":false,"trueClientIpHeader":"True-Client-IP","verificationMode":"PLATFORM_SETTINGS"}}],"children":[{"behaviors":[{"name":"baseDirectory","options":{"value":"/smth/"}}],"criteria":[{"name":"requestHeader","options":{"headerName":"Accept-Encoding","matchCaseSensitiveValue":true,"matchOperator":"IS_ONE_OF","matchWildcardName":false,"matchWildcardValue":false}}],"name":"change fwd path","options":{},"criteriaMustSatisfy":"all"},{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"1m"}}],"name":"caching","options":{},"criteriaMustSatisfy":"any"}],"comments":"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.","name":"default","options":{},"variables":[{"description":"","hidden":true,"name":"TEST_EMPTY_FIELDS","sensitive":false,"value":""},{"description":null,"hidden":true,"name":"TEST_NIL_FIELD","sensitive":false,"value":""}]}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"origin","options":{"cacheKeyHostname":"REQUEST_HOST_HEADER","compress":true,"enableTrueClientIp":true,"forwardHostHeader":"REQUEST_HOST_HEADER","hostname":"test.domain","httpPort":80,"httpsPort":443,"originCertificate":"","originSni":true,"originType":"CUSTOMER","ports":"","trueClientIpClientSetting":false,"trueClientIpHeader":"True-Client-IP","verificationMode":"PLATFORM_SETTINGS"}}],"children":[{"behaviors":[{"name":"baseDirectory","options":{"value":"/smth/"}}],"criteria":[{"name":"requestHeader","options":{"headerName":"Accept-Encoding","matchCaseSensitiveValue":true,"matchOperator":"IS_ONE_OF","matchWildcardName":false,"matchWildcardValue":false}}],"name":"change fwd path","options":{},"criteriaMustSatisfy":"all"},{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"1m"}}],"name":"caching","options":{},"criteriaMustSatisfy":"any"}],"comments":"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.","name":"default","options":{},"variables":[{"description":"","hidden":true,"name":"TEST_EMPTY_FIELDS","sensitive":false,"value":""},{"description":"","hidden":true,"name":"TEST_NIL_FIELD","sensitive":false,"value":""}]}}`). + Build(), + }, + "Lifecycle: Verify staging_version and production_version known at plan": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update + p.mockGetPropertyVersion() + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), + configPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + testutils.FieldsKnownAtPlan{ + FieldsKnown: []string{"staging_version", "production_version"}, + FieldsUnknown: []string{"latest_version"}, + }, + }, + }, + }, + "Lifecycle: update group id - in place": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.moveGroup = moveGroup{ + sourceGroupID: 2, + destinationGroupID: 222, + } + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before read + mockResourcePropertyRead(p) + // update - moving the property + p.mockMoveProperty() + p.groupID = "grp_222" + // read x1 + mockResourcePropertyRead(p) + // delete + p.mockRemoveProperty() + }, + configDir: "groupIDUpdate", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("group_id", "grp_222"). + Build(), + }, + "Lifecycle: update group id and hostnames - in place": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.moveGroup = moveGroup{ + sourceGroupID: 2, + destinationGroupID: 222, + } + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update - moving the property + // readout for obtaining assetID + p.mockGetProperty() + p.mockMoveProperty() + p.groupID = "grp_222" + // waiting for new groupID + p.mockGetProperty() + // readout for general version calculations + p.mockGetPropertyVersion() + // change in hostnames detected + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_update_with_validation_error_for_rules.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckNoResourceAttr("akamai_property.test", "rules")), - ExpectError: regexp.MustCompile(`validation.required_behavior`), + CnameFrom: "from2.test.domain", + CnameTo: "to.test.domain", + CertProvisioningType: "DEFAULT", + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "ehn_123", }, }, + } + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty().Once() + }, + configDir: "groupIDUpdate/withHostnames", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("group_id", "grp_222"). + Build(), + }, + "Lifecycle: update group id and name - recreate": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.moveGroup = moveGroup{ + sourceGroupID: 2, + destinationGroupID: 222, + } + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + p.mockRemoveProperty().Once() + // recreate the resource + p.propertyName = "dummy_name2" + p.groupID = "grp_222" + // recreate new property + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty().Once() + }, + configDir: "groupIDUpdate/withName", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("group_id", "grp_222"). + CheckEqual("name", "dummy_name2"). + Build(), + }, + } + + for name, test := range tests { + // TODO: Once DXE-4176 is done, un-skip those tests + testsToSkip := []string{"Lifecycle: update group id - in place", "Lifecycle: update group id and hostnames - in place", "Lifecycle: update group id and name - recreate"} + t.Run(name, func(t *testing.T) { + if slices.Contains(testsToSkip, name) { + t.Skip() + } else { + papiMock := &papi.Mock{} + iamMock := &iam.Mock{} + mp := mockProperty{ + papiMock: papiMock, + iamMock: iamMock, + } + test.init(t, &mp) + + useClient(papiMock, nil, func() { + useIam(iamMock, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/%s/step0.tf", test.configDir), + Check: test.checksForCreate, + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/%s/step1.tf", test.configDir), + Check: test.checksForUpdate, + ConfigPlanChecks: test.configPlanChecks, + }, + }, + }) + }) }) - }) - client.AssertExpectations(t) + papiMock.AssertExpectations(t) + } }) - t.Run("validation warning when creating property with rules tree", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_1", - ) - rules := papi.Rules{ + } + + // separate tests as they require different number of steps or filenames + t.Run("Lifecycle: diff cpCode", func(t *testing.T) { + papiMock := &papi.Mock{} + mp := &mockProperty{ + papiMock: papiMock, + mockPropertyData: basicData, + } + mp.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ Behaviors: []papi.RuleBehavior{ { - Name: "origin", + Name: "cpCode", Options: papi.RuleOptionsMap{ - "hostname": "1.2.3.4", - "httpPort": float64(80), - "httpsPort": float64(443), + "value": map[string]interface{}{ + "description": "CliTerraformCPCode", + "id": 1.050269e+06, + "name": "DevExpCliTerraformPapiAsSchemaTest", + "products": []interface{}{"Web_App_Accel"}, + }, }, }, }, - } - var req = papi.UpdateRulesRequest{ - PropertyID: "prp_1", - ContractID: "ctr_0", - GroupID: "grp_0", - PropertyVersion: 1, - Rules: papi.RulesUpdate{Rules: rules}, - ValidateRules: true, - } - warning := papi.RuleWarnings{ - Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", - ErrorLocation: "#/rules/behaviors/1", - Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", - } - client.On("UpdateRuleTree", AnyCTX, req).Return(&papi.UpdateRulesResponse{ - AccountID: "", - ContractID: "ctr_0", - Comments: "", - GroupID: "grp_0", - PropertyID: "prp_1", - PropertyVersion: 1, - Etag: "", - RuleFormat: "", - Rules: rules, - Errors: nil, - Warnings: []papi.RuleWarnings{warning}, - }, nil).Once() - ExpectGetProperty( - client, "prp_1", "grp_0", "ctr_0", - &papi.Property{ - PropertyID: "prp_1", GroupID: "grp_0", ContractID: "ctr_0", LatestVersion: 1, - PropertyName: "test_property", - }, - ) - - ExpectGetPropertyVersionHostnames( - client, "prp_1", "grp_0", "ctr_0", 1, - &[]papi.Hostname{}, - ).Times(2) - ruleFormat := "" - ExpectGetRuleTree( - client, "prp_1", "grp_0", "ctr_0", 1, - &papi.RulesUpdate{ - Rules: rules, - }, &ruleFormat, nil, []*papi.Error{ - { - Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", - ErrorLocation: "#/rules/behaviors/1", - Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", + Name: "default", + }, + } + // create + mockResourcePropertyFullCreate(mp) + // mock rules in the format that API returns to test custom diff functionality on rules (notice `"cpCodeLimits": nil`, which was not present in the request. + mp.ruleTree.rules = papi.Rules{Behaviors: []papi.RuleBehavior{ + { + Name: "cpCode", + Options: papi.RuleOptionsMap{ + "value": map[string]interface{}{ + "cpCodeLimits": nil, + "description": "CliTerraformCPCode", + "id": 1.050269e+06, + "name": "DevExpCliTerraformPapiAsSchemaTest", + "products": []interface{}{"Web_App_Accel"}, }, - }) - ExpectGetPropertyVersion(client, "prp_1", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) + }, + }, + }, + Name: "default"} + // read x2 + mockResourcePropertyRead(mp, 2) + // delete + mp.mockRemoveProperty() - ExpectRemoveProperty(client, "prp_1", "ctr_0", "grp_0") - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_with_validation_warning_for_rules.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "rule_warnings.0.detail", "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.")), - }, + useClient(papiMock, nil, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf"), + Check: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"cpCode","options":{"value":{"cpCodeLimits":null,"description":"CliTerraformCPCode","id":1050269,"name":"DevExpCliTerraformPapiAsSchemaTest","products":["Web_App_Accel"]}}}],"name":"default","options":{}}}`). + Build(), }, - }) + }, }) - - client.AssertExpectations(t) }) + }) - t.Run("validation - when updating a property hostnames to empty it should return error", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_0", - ) - - ExpectGetPropertyVersions(client, "prp_0", "test_property", "ctr_0", "grp_0", nil, &papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + t.Run("Lifecycle: new version changed on server", func(t *testing.T) { + papiMock := &papi.Mock{} + mp := &mockProperty{ + papiMock: papiMock, + mockPropertyData: basicDataWithDefaultRules, + } + // create + mockResourcePropertyCreateWithVersionHostnames(mp) + // read x2 + mockResourcePropertyRead(mp, 2) + // simulate remote change outside terraform, only for response data - new version with updated CnameTo. + mp.latestVersion = 2 + mp.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - PropertyVersion: 1, - StagingStatus: papi.VersionStatusInactive, - ProductionStatus: papi.VersionStatusInactive, - }, - }}) - - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{{ CnameType: "EDGE_HOSTNAME", - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CnameFrom: "from.test.domain", + CnameTo: "changed.test.domain", CertProvisioningType: "DEFAULT", - }}, nil, - ).Once() - - ExpectGetProperty( - client, "prp_0", "grp_0", "ctr_0", - &papi.Property{ - PropertyID: "prp_0", GroupID: "grp_0", ContractID: "ctr_0", LatestVersion: 1, - PropertyName: "test_property", + EdgeHostnameID: "ehn_123", }, - ) - - ExpectGetPropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - &[]papi.Hostname{{ - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", - CertProvisioningType: "DEFAULT", - }}, - ).Times(3) - - ruleFormat := "" - ExpectGetRuleTree( - client, "prp_0", "grp_0", "ctr_0", 1, - &papi.RulesUpdate{}, &ruleFormat, nil, nil) - - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0") - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{}, nil, - ).Once() - - ExpectGetPropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - &[]papi.Hostname{}, - ).Twice() - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), - Check: resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.#", "0"), - ), - ExpectError: regexp.MustCompile("hostnames exist on server and cannot be updated to empty for property with id 'prp_0'. Provide at least one hostname to update existing list of hostnames associated to this property"), - }, - }, - }) - }) - }) - - t.Run("validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' with secure-by-default enabled but remaining default certs == 0 it should return error", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_0", - ) - - ExpectGetPropertyVersions(client, "prp_0", "test_property", "ctr_0", "grp_0", nil, &papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + }, + } + mp.versions = papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ { - PropertyVersion: 1, StagingStatus: papi.VersionStatusInactive, ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 2, }, - }}) - - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{{ + }, + } + // read x1 - remote, updated state + mockResourcePropertyRead(mp) + // update + mp.mockGetPropertyVersion() + // such drift should invoke update function, which should use value from config which should replace the remote value. + // Hence, CnameTo is assigned the value from config for the mock data. + mp.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { CnameType: "EDGE_HOSTNAME", - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", CertProvisioningType: "DEFAULT", - }}, &papi.Error{ - StatusCode: http.StatusTooManyRequests, - Remaining: ptr.To(0), - LimitKey: "DEFAULT_CERTS_PER_CONTRACT", + EdgeHostnameID: "ehn_123", }, - ).Once() - - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0") + }, + } + mp.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(mp, 2) + // delete + mp.mockRemoveProperty() - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), - Check: resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as the limit for DEFAULT certificates has been reached"), - }, + useClient(papiMock, nil, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf"), + Check: defaultChecker.Build(), }, - }) + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf"), + Check: defaultChecker. + CheckEqual("latest_version", "2"). + Build(), + }, + }, }) }) + }) +} + +// TestPropertyImports tests import functionality of property resource +func TestPropertyImport(t *testing.T) { + // Based on importID, different API calls are being made in the Import and Read functions. If the importID allows to + // reconcile specific property version, GetProperty calls are being executed in Import and Read operations. If the property version + // is unknown, GetPropertyVersions is being used instead of GetProperty. + + // mockPropertyImportKnownVersion gathers API calls that are being executed when property version is known. + // Uses GetProperty calls. + mockPropertyImportKnownVersion := func(p *mockProperty) { + // import + p.mockGetProperty() + // read + mockResourcePropertyRead(p) + } - t.Run("validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' not having enabled secure-by-default it should return error", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) + // mockPropertyImportKnownVersion gathers API calls that are being executed when property version is unknown. + // Uses GetPropertyVersions calls. + mockPropertyImportUnknownVersion := func(p *mockProperty) { + // import + p.mockGetPropertyVersions() + // read + p.mockGetPropertyVersions() + p.mockGetPropertyVersionHostnames() + p.mockGetRuleTree() + p.mockGetPropertyVersion() + } - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_0", - ) + // mockPropertyImportKnownVersionAfterImport gather API calls that are being executed when property version is provided and known + // read function, but not during import: hence there is a single call to GetPropertyVersions in import. + mockPropertyImportKnownVersionAfterImport := func(p *mockProperty) { + // import + p.mockGetPropertyVersions() + // read (notice that here one GetPropertyVersions call is omitted) + p.mockGetPropertyVersionHostnames() + p.mockGetRuleTree() + p.mockGetPropertyVersion() + } - ExpectGetPropertyVersions(client, "prp_0", "test_property", "ctr_0", "grp_0", nil, &papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + // basicData holds basic, common data across test cases + basicData := mockPropertyData{ + propertyID: "prp_4", + groupID: "grp_2", + contractID: "ctr_1", + latestVersion: 1, + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - PropertyVersion: 1, - StagingStatus: papi.VersionStatusInactive, + CnameTo: "to.test.domain", + EdgeHostnameID: "ehn_123", + }, + }, + }, + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusActive, ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, }, - }}) + }, + }, + } - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) + // basicDataWithoutGroupAndContract does not contain group and contract parameters for cases where they are not part of importID + basicDataWithoutGroupAndContract := basicData + basicDataWithoutGroupAndContract.groupID = "" + basicDataWithoutGroupAndContract.contractID = "" + + // defaultChecker builds basic, common checks across test cases + defaultChecker := test.NewImportChecker(). + CheckEqual("id", "prp_4"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("hostnames.0.edge_hostname_id", "ehn_123"). + CheckEqual("latest_version", "1"). + CheckEqual("staging_version", "1"). + CheckEqual("production_version", "0"). + CheckEqual("rules", `{"rules":{"name":"","options":{}}}`) - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", - CertProvisioningType: "DEFAULT", - }}, &papi.Error{ - StatusCode: http.StatusForbidden, - Type: "https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/default-cert-provisioning-unavailable", - }, - ).Once() + tests := map[string]struct { + importID string + config string + init func(*testing.T, *mockProperty) + stateCheck func(s []*terraform.InstanceState) error + }{ + "Importable: property_id with ds": { + importID: "prp_4", + config: "testdata/TestResProperty/Importable/importable_with_property_rules_builder.tf", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + Behaviors: []papi.RuleBehavior{ + {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "no new line"}}, + {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": ""}}, + {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "\n\tline with new line before and after + tab\n"}}, + }, + }, + } + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.CheckEqual("rules", "{\"rules\":{\"behaviors\":[{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"no new line\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\\n\\tline with new line before and after + tab\\n\"}}],\"name\":\"default\",\"options\":{}}}").Build(), + }, + "Importable: property_id with property-bootstrap": { + importID: "prp_4,property-bootstrap", + config: "testdata/TestResProperty/Importable/importable-with-bootstrap.tf", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id": { + importID: "prp_4", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and ver_# version": { + importID: "prp_4,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and # version": { + importID: "prp_4,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and latest": { + importID: "prp_4,latest", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and network": { + importID: "prp_4,staging", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id": { + importID: "4", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and # version": { + importID: "4,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and ver_# version": { + importID: "4,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and network": { + importID: "4,s", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and contract_id and group_id": { + importID: "prp_4,ctr_1,grp_2", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and empty version": { + importID: "prp_4,ctr_1,grp_2,", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and latest": { + importID: "prp_4,ctr_1,grp_2,latest", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and ver_# version": { + importID: "prp_4,ctr_1,grp_2,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and # version": { + importID: "prp_4,ctr_1,grp_2,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and network": { + importID: "prp_4,ctr_1,grp_2,staging", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id and group_id": { + importID: "4,1,2", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and # version": { + importID: "4,1,2,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and ver_# version": { + importID: "4,1,2,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and latest": { + importID: "4,1,2,latest", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and network": { + importID: "4,1,2,staging", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + papiMock := &papi.Mock{} + mp := mockProperty{ + papiMock: papiMock, + } + test.init(t, &mp) - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0") + // use default config file if custom is not specified + if test.config == "" { + test.config = "testdata/TestResProperty/Importable/importable.tf" + } - useClient(client, nil, func() { + useClient(papiMock, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), - Check: resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as secure-by-default is not enabled in this account"), + ImportStateCheck: test.stateCheck, + ImportStateId: test.importID, + ImportState: true, + ResourceName: "akamai_property.test", + Config: testutils.LoadFixtureString(t, test.config), + ImportStateVerifyIgnore: []string{"product", "read_version"}, }, }, }) }) - }) - - // Other tests - t.Run("error when the given group is not found", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - req := papi.CreatePropertyRequest{ - ContractID: "ctr_0", - GroupID: "grp_0", - Property: papi.PropertyCreate{ - ProductID: "prd_0", - PropertyName: "property_name", - }, - } - - var err error = &papi.Error{ - StatusCode: 404, - Title: "Not Found", - Detail: "The system was unable to locate the requested resource", - Type: "https://problems.luna.akamaiapis.net/papi/v0/http/not-found", - Instance: "https://akaa-hqgqowhpmkw32kmt-t3owzo37wb5dkern.luna-dev.akamaiapis.net/papi/v1/properties?contractId=ctr_0\\u0026groupId=grp_0#c3fe5f9b0c4a14d1", - } - - client.On("CreateProperty", AnyCTX, req).Return(nil, err).Once() + papiMock.AssertExpectations(t) + }) + } +} - // the papi GetGroups call should not return any matching group - var Groups []*papi.Group - ExpectGetGroups(client, &Groups).Once() +// TestPropertyErrors tests various cases where we should expect an error or validation is triggered +func TestPropertyErrors(t *testing.T) { + // basicData holds basic, common data across test cases + basicData := mockPropertyData{ + propertyName: "test_property", + contractID: "ctr_1", + productID: "prd_3", + groupID: "grp_2", + propertyID: "prp_4", + latestVersion: 1, + } - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Creation/property.tf"), - ExpectError: regexp.MustCompile("group not found: grp_0"), - }}, - }) - }) + defaultChecker := test.NewStateChecker("akamai_property.test"). + CheckEqual("id", "prp_4"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("hostnames.0.edge_hostname_id", "ehn_123"). + CheckEqual("latest_version", "1"). + CheckEqual("staging_version", "0"). + CheckEqual("production_version", "0"). + CheckEqual("name", "test_property"). + CheckEqual("contract_id", "ctr_1"). + CheckEqual("group_id", "grp_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("rule_warnings.#", "0"). + CheckEqual("rules", `{"rules":{"name":"default","options":{}}}`) + + inactiveVersions := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, + } - client.AssertExpectations(t) - }) + defaultHostname := papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, + }, + } - t.Run("error when creating property with non-unique name", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) + defaultRuleTree := mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + }, + } - req := papi.CreatePropertyRequest{ - ContractID: "ctr_0", - GroupID: "grp_0", - Property: papi.PropertyCreate{ - PropertyName: "test_property", - ProductID: "prd_0", + tests := map[string]struct { + init func(*testing.T, *mockProperty) + steps []resource.TestStep + }{ + "error when the given group is not found": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + err := &papi.Error{ + StatusCode: 404, + Title: "Not Found", + Detail: "The system was unable to locate the requested resource", + Type: "https://problems.luna.akamaiapis.net/papi/v0/http/not-found", + Instance: "https://akaa-hqgqowhpmkw32kmt-t3owzo37wb5dkern.luna-dev.akamaiapis.net/papi/v1/properties?contractId=ctr_0\\u0026groupId=grp_0#c3fe5f9b0c4a14d1", + } + p.mockCreateProperty(err) + p.mockGetGroups() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Creation/property.tf"), + ExpectError: regexp.MustCompile("group not found: grp_2"), }, - } - - client.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf("given property name is not unique")) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ + }, + }, + "error when creating property with non-unique name": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + err := fmt.Errorf("given property name is not unique") + p.mockCreateProperty(err) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf"), + ExpectError: regexp.MustCompile(`property name is not unique`), + }, + }, + }, + "error when deleting active property": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.versions = inactiveVersions + p.hostnames = defaultHostname + p.ruleTree = defaultRuleTree + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // refresh before update + mockResourcePropertyRead(p) + // First call to remove is not successful because property is active + err := fmt.Errorf(`cannot remove active property "prp_4"`) + p.mockRemoveProperty(err) + // Second call will be successful (TF test case requires last state to be empty or it's a failed test) + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/error_when_deleting_active_property/step0.tf"), + Check: defaultChecker.Build(), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/error_when_deleting_active_property/step1.tf"), + ExpectError: regexp.MustCompile(`cannot remove active property`), + }, + }, + }, + "error validations when updating property with rules tree": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "update rule tree", + }, + } + // create + p.mockCreateProperty() + err := &papi.Error{ + StatusCode: 400, + Type: "/papi/v1/errors/validation.required_behavior", + Title: "Missing required behavior in default rule", + Detail: "In order for this property to work correctly behavior Content Provider Code needs to be present in the default section", + Instance: "/papi/v1/properties/prp_173136/versions/3/rules#err_100", + BehaviorName: "cpCode", + } + // expect an error while updating rule tree + p.mockUpdateRuleTree(err) + // contract and group are not set in the state, so the property deletion is performed without those attributes + p.contractID = "" + p.groupID = "" + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_update_with_validation_error_for_rules.tf"), + ExpectError: regexp.MustCompile(`validation.required_behavior`), + }, + }, + }, + "validation warning when creating property with rules tree": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.versions = inactiveVersions + p.ruleTree = mockRuleTreeData{ + ruleFormat: "", + ruleWarnings: []papi.RuleWarnings{ { - Config: testutils.LoadFixtureString(t, "testdata/%s.tf", t.Name()), - Check: resource.TestCheckNoResourceAttr("akamai_property.test", "id"), - ExpectError: regexp.MustCompile(`property name is not unique`), + Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", + ErrorLocation: "#/rules/behaviors/1", + Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", }, }, - }) - }) - - client.AssertExpectations(t) - }) - - ruleTreeRes := papi.GetRuleTreeResponse{ - Rules: papi.Rules{ - Name: "default", - Children: []papi.Rules{ - { - Name: "Static Content", + rules: papi.Rules{ Behaviors: []papi.RuleBehavior{ { - Name: "prefetch", - Options: papi.RuleOptionsMap{"enabled": false}, - }, - }, - }, - }, - Behaviors: []papi.RuleBehavior{ - { - Name: "cpCode", - Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "id": float64(12345), - "description": "WAA Example.com", - "products": []interface{}{ - "Web_App_Accel", + Name: "origin", + Options: papi.RuleOptionsMap{ + "hostname": "1.2.3.4", + "httpPort": float64(80), + "httpsPort": float64(443), }, - "name": "WAA Example.com", }, }, }, - }, - Options: papi.RuleOptions{IsSecure: true}, - }, - } - - propertyReadCtx := func(client *papi.Mock, stagStatus, prodStatus papi.VersionStatus) { - ExpectGetProperty( - client, "prp_0", "grp_0", "ctr_0", - &papi.Property{ - PropertyID: "prp_0", GroupID: "grp_0", ContractID: "ctr_0", LatestVersion: 1, - PropertyName: "dxe-2406-issue-example", - }, - ).Once() - ExpectGetPropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - &[]papi.Hostname{ + } + p.responseWarnings = []*papi.Error{ { - CnameFrom: "dxe-2406-issue-example-second.com", - CnameTo: "dxe-2406-issue-example-second.com.example.net", - CertProvisioningType: "CPS_MANAGED", + Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", + ErrorLocation: "#/rules/behaviors/1", + Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", }, - { - CnameFrom: "dxe-2406-issue.com", - CnameTo: "dxe-2406-issue.com.example.net", - CertProvisioningType: "CPS_MANAGED", + } + // create + p.mockCreateProperty() + p.mockUpdateRuleTree() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_with_validation_warning_for_rules.tf"), + Check: defaultChecker. + CheckEqual("rule_warnings.#", "1"). + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"origin","options":{"hostname":"1.2.3.4","httpPort":80,"httpsPort":443}}],"name":"","options":{}}}`). + CheckEqual("rule_warnings.0.detail", "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead."). + CheckMissing("hostnames.0.cname_to"). + CheckMissing("hostnames.0.edge_hostname_id"). + Build(), + }, + }, + }, + "validation - when updating a property hostnames to empty it should return error": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "terraform.provider.myu877.test.net", + CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, }, + } + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{}, + ruleFormat: "", + } + p.versions = inactiveVersions + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // refresh - read + mockResourcePropertyRead(p) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), + Check: defaultChecker. + CheckEqual("rules", `{"rules":{"name":"","options":{}}}`). + CheckEqual("hostnames.0.cname_to", "terraform.provider.myu877.test.net.edgesuite.net"). + CheckEqual("hostnames.#", "1"). + Build(), }, - ).Once() - client.On("GetRuleTree", mock.Anything, papi.GetRuleTreeRequest{ - PropertyID: "prp_0", - GroupID: "grp_0", - ContractID: "ctr_0", - PropertyVersion: 1, - ValidateMode: "full", - ValidateRules: true, - }).Return(&ruleTreeRes, nil).Once() - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, stagStatus, prodStatus).Once() - } - - getActivations := func(client *papi.Mock) { - expectGetActivations(client, "prp_0", papi.GetActivationsResponse{ - Activations: papi.ActivationsItems{ - Items: []*papi.Activation{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf"), + ExpectError: regexp.MustCompile("hostnames exist on server and cannot be updated to empty for property with id 'prp_4'. Provide at least one hostname to update existing list of hostnames associated to this property"), + }, + }, + }, + "validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' with secure-by-default enabled but remaining default certs == 0 it should return error": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - ActivationID: "act_123", - PropertyID: "prp_0", - PropertyVersion: 1, - Network: papi.ActivationNetworkStaging, - Status: papi.ActivationStatusActive, - ActivationType: papi.ActivationTypeActivate, - SubmitDate: "2020-10-28T15:04:05Z", - NotifyEmails: []string{"dummy-user@akamai.com"}, + CnameType: "EDGE_HOSTNAME", + CnameFrom: "terraform.provider.myu877.test.net", + CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CertProvisioningType: "DEFAULT", }, }, + } + // create + p.mockCreateProperty() + err := &papi.Error{ + StatusCode: http.StatusTooManyRequests, + Remaining: ptr.To(0), + LimitKey: "DEFAULT_CERTS_PER_CONTRACT", + } + p.mockUpdatePropertyVersionHostnames(err) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), + ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as the limit for DEFAULT certificates has been reached"), }, - }, nil).Once() - } - - // Update for hostnames and rules - t.Run("400 from UpdatePropertyVersionHostnames - incorrect/invalid edge hostname", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - ruleFormat := "" - - // first step - // create property - ExpectCreateProperty(client, "dxe-2406-issue-example", "grp_0", "ctr_0", "prd_0", "prp_0").Once() - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{ - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue-example-second.com", - CnameTo: "dxe-2406-issue-example-second.com.example.net", - CertProvisioningType: "CPS_MANAGED", + }, + }, + "validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' not having enabled secure-by-default it should return error": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "terraform.provider.myu877.test.net", + CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CertProvisioningType: "DEFAULT", + }, }, - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue.com", - CnameTo: "dxe-2406-issue.com.example.net", - CertProvisioningType: "CPS_MANAGED", - }}, nil, - ).Once() - ExpectUpdateRuleTree(client, "prp_0", "grp_0", "ctr_0", 1, - &papi.RulesUpdate{ - Rules: papi.Rules{ - Name: "default", - Children: []papi.Rules{ - { - Name: "Static Content", - Behaviors: []papi.RuleBehavior{ - { - Name: "prefetch", - Options: papi.RuleOptionsMap{"enabled": false}, + } + p.versions = inactiveVersions + // create + p.mockCreateProperty() + err := &papi.Error{ + StatusCode: http.StatusForbidden, + Type: "https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/default-cert-provisioning-unavailable", + } + p.mockUpdatePropertyVersionHostnames(err) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), + ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as secure-by-default is not enabled in this account"), + }, + }, + }, + "400 from UpdatePropertyVersionHostnames - incorrect/invalid edge hostname": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = mockPropertyData{ + propertyName: "dxe-2406-issue-example", + groupID: "grp_2", + contractID: "ctr_1", + productID: "prd_3", + propertyID: "prp_4", + latestVersion: 1, + ruleTree: mockRuleTreeData{ + ruleFormat: "", + rules: papi.Rules{ + Name: "default", + Children: []papi.Rules{ + { + Name: "Static Content", + Behaviors: []papi.RuleBehavior{ + { + Name: "prefetch", + Options: papi.RuleOptionsMap{"enabled": false}, + }, }, }, }, - }, - Behaviors: []papi.RuleBehavior{ - { - Name: "cpCode", - Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "id": float64(12345), - "description": "WAA Example.com", - "products": []interface{}{ - "Web_App_Accel", + Behaviors: []papi.RuleBehavior{ + { + Name: "cpCode", + Options: papi.RuleOptionsMap{ + "value": map[string]interface{}{ + "id": float64(12345), + "description": "WAA Example.com", + "products": []interface{}{ + "Web_App_Accel", + }, + "name": "WAA Example.com", }, - "name": "WAA Example.com", }, }, }, + Options: papi.RuleOptions{IsSecure: true}, }, - Options: papi.RuleOptions{IsSecure: true}, - }}, ruleFormat, []papi.RuleError{}).Once() - - // read property - propertyReadCtx(client, papi.VersionStatusInactive, papi.VersionStatusInactive) - - // create activation - expectGetRuleTree(client, "prp_0", 1, ruleTreeRes, nil).Once() - expectGetActivations(client, "prp_0", papi.GetActivationsResponse{}, nil).Once() - client.On("CreateActivation", mock.Anything, mock.Anything).Return(&papi.CreateActivationResponse{ActivationID: "act_123"}, nil).Once() - expectGetActivation(client, "prp_0", "act_123", 1, papi.ActivationNetworkStaging, papi.ActivationStatusActive, papi.ActivationTypeActivate, "", []string{"dummy-user@akamai.com"}, nil).Once() - - // read property - propertyReadCtx(client, papi.VersionStatusActive, papi.VersionStatusActive) - - // activation read - getActivations(client) - - // read property - propertyReadCtx(client, papi.VersionStatusActive, papi.VersionStatusActive) - - // activation read - getActivations(client) - - // second step - // property update returns an error on the invalid edgehostname - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusActive, papi.VersionStatusActive).Once() - ExpectCreatePropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, 2) - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 2, - []papi.Hostname{ - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue-example-second.com", - CnameTo: "dxe-2406-issue-example-second.com.example.net", - CertProvisioningType: "CPS_MANAGED", }, - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue.com", - CnameTo: "dxe-2406-issue.com.example.net", - CertProvisioningType: "CPS_MANAGED", + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, }, - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "does-not-exist.com", - CnameTo: "does-not-exist.com.example.net", - CertProvisioningType: "CPS_MANAGED", - }}, fmt.Errorf("%w: request failed: %s", papi.ErrUpdatePropertyVersionHostnames, errors.New("{\n \"type\": \"https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/bad-cnameto\",\n \"title\": \"Bad `cnameTo`\",\n \"detail\": \"The System could not find cnameTo value `does-not-exist.com.example.net`.\",\n \"instance\": \"host/papi/v1/properties/prp_0/versions/2/hostnames?contractId=ctr_0&groupId=grp_0&includeCertStatus=false&validateHostnames=false#efba6490291100b1\",\n \"status\": 400\n}")), - ).Once() - - // terraform clean up - terraform test framework attempts to run destroy plan, if an error is returned on second step - // activation and property deletion - getActivations(client) - client.On("CreateActivation", mock.Anything, mock.Anything).Return(&papi.CreateActivationResponse{ - ActivationID: "act_123", - }, nil).Once() - expectGetActivation(client, "prp_0", "act_123", 1, papi.ActivationNetworkStaging, papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "", []string{"dummy-user@akamai.com"}, nil).Once() - client.On("RemoveProperty", mock.Anything, mock.Anything).Return(&papi.RemovePropertyResponse{ - Message: "removed", - }, nil).Once() - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.akaproperty", "id", "prp_0"), - resource.TestCheckResourceAttr("akamai_property.akaproperty", "hostnames.#", "2"), - ), + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue-example-second.com", + CnameTo: "dxe-2406-issue-example-second.com.example.net", + CertProvisioningType: "CPS_MANAGED", + EdgeHostnameID: "ehn_123", + }, + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue.com", + CnameTo: "dxe-2406-issue.com.example.net", + CertProvisioningType: "CPS_MANAGED", + }, }, + }, + createActivation: papi.Activation{ + ActivationID: "act_123", + ActivationType: papi.ActivationTypeActivate, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + NotifyEmails: []string{"dummy-user@akamai.com"}, + PropertyVersion: 1, + }, + groups: papi.GroupItems{ + Items: []*papi.Group{}, + }, + activations: papi.ActivationsItems{ + Items: []*papi.Activation{}, + }, + } + // akamai_property - create + mockResourcePropertyFullCreate(p) + // akamai_property - read x2 + mockResourcePropertyRead(p, 2) + // akamai_property_activation - create activation + p.mockGetRuleTreeActivation().Once() // GetRuleTree request in activation resources is different from GetRuleTree in property resource + p.mockGetActivations() // no activation + p.mockCreateActivation() + // modify mock data to reflect newly created activation + p.activations = papi.ActivationsItems{ + Items: []*papi.Activation{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.akaproperty", "id", "prp_0"), - resource.TestCheckResourceAttr("akamai_property.akaproperty", "hostnames.#", "3"), - ), - ExpectError: regexp.MustCompile("Error: updating hostnames: request failed:"), + ActivationID: p.createActivation.ActivationID, + ActivationType: papi.ActivationTypeActivate, + GroupID: p.groupID, + PropertyName: p.propertyName, + PropertyID: p.propertyID, + PropertyVersion: p.createActivation.PropertyVersion, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + NotifyEmails: p.createActivation.NotifyEmails, }, }, - }) - }) - - client.AssertExpectations(t) - }) - }) -} - -func TestGroupIDUpdate(t *testing.T) { - t.Skip("skipping before moving property is enabled again, see DXE-4176") - baseData := mockPropertyData{ - propertyName: "dummy_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - propertyID: "prp_12345", - latestVersion: 1, - assetID: "aid_55555", - cnameFrom: "from.test.domain", - cnameTo: "to.test.domain", - } - - baseCheckName := resource.TestCheckResourceAttr("akamai_property.test", "name", "dummy_name") - baseCheckGroupID := resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_1") - baseCheckCnameFrom := resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_from", "from.test.domain") - - commonBaseChecks := resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "contract_id", "ctr_2"), - resource.TestCheckResourceAttr("akamai_property.test", "product_id", "prd_3"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_to", "to.test.domain"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cert_provisioning_type", "DEFAULT")) + } + p.mockGetActivation() - tests := map[string]struct { - init func(*testing.T, *mockProperty, *iam.Mock) - configPathForUpdate string - updateChecks resource.TestCheckFunc - }{ - "update group id - in place": { - init: func(t *testing.T, p *mockProperty, iamMock *iam.Mock) { - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - // second refresh - mockResourcePropertyRead(p) + activatedVersion := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + ProductionStatus: papi.VersionStatusActive, + StagingStatus: papi.VersionStatusActive, + }, + }, + } + p.versions = activatedVersion - // moving the property - // readout for obtaining assetID - p.mockGetProperty().Once() - mockMoveProperty(iamMock, 55555, 1, 111) - p.groupID = "grp_111" - // waiting for new groupID - p.mockGetProperty().Once() - // final read from the update function - mockResourcePropertyRead(p) + // akamai_property_activation - read x2 + p.mockGetActivations().Twice() - // refresh + // akamai_property - read before update mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() - }, - configPathForUpdate: "testdata/TestGroupIDUpdate/update_group_id.tf", + // second step + // property update returns an error on the invalid edgehostname + p.mockGetPropertyVersion() + p.createFromVersion = 1 + p.newVersionID = 2 + p.mockCreatePropertyVersion() + // after creating new version, update latest version of the property to reflect that change + p.latestVersion = p.newVersionID + + // prepare updated hostnames + updatedHostnames := papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue-example-second.com", + CnameTo: "dxe-2406-issue-example-second.com.example.net", + CertProvisioningType: "CPS_MANAGED", + EdgeHostnameID: "ehn_123", + }, + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue.com", + CnameTo: "dxe-2406-issue.com.example.net", + CertProvisioningType: "CPS_MANAGED", + }, + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "does-not-exist.com", + CnameTo: "does-not-exist.com.example.net", + CertProvisioningType: "CPS_MANAGED", + }, + }, + } + p.hostnames = updatedHostnames - updateChecks: resource.ComposeTestCheckFunc( - baseCheckName, - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_111"), - baseCheckCnameFrom, - commonBaseChecks), - }, - "update group id and hostnames - in place": { - init: func(t *testing.T, p *mockProperty, iamMock *iam.Mock) { - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - // second refresh - mockResourcePropertyRead(p) + // return an error while updating property version hostnames + err := fmt.Errorf("%w: request failed: %s", papi.ErrUpdatePropertyVersionHostnames, errors.New("{\n \"type\": \"https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/bad-cnameto\",\n \"title\": \"Bad `cnameTo`\",\n \"detail\": \"The System could not find cnameTo value `does-not-exist.com.example.net`.\",\n \"instance\": \"host/papi/v1/properties/prp_0/versions/2/hostnames?contractId=ctr_0&groupId=grp_0&includeCertStatus=false&validateHostnames=false#efba6490291100b1\",\n \"status\": 400\n}")) + p.mockUpdatePropertyVersionHostnames(err) - // moving the property - // readout for obtaining assetID - p.mockGetProperty().Once() - mockMoveProperty(iamMock, 55555, 1, 111) - p.groupID = "grp_111" - // waiting for new groupID - p.mockGetProperty().Once() - // readout for general version calculations - p.mockGetPropertyVersion().Once() - // change in hostnames detected - p.cnameFrom = "from2.test.domain" - p.mockUpdatePropertyVersionHostnames().Once() - // final read from the update function - mockResourcePropertyRead(p) + // terraform clean up - terraform test framework attempts to run destroy plan, if an error is returned on second step - // refresh - mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() + // activation and property deletion + // update current activations of given property + p.activations = papi.ActivationsItems{ + Items: []*papi.Activation{ + { + ActivationID: "act_123", + PropertyID: "prp_4", + PropertyVersion: 1, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + ActivationType: papi.ActivationTypeActivate, + SubmitDate: "2020-10-28T15:04:05Z", + NotifyEmails: []string{"dummy-user@akamai.com"}, + }, + }, + } + p.mockGetActivations() + // mock deactivate type activation for delete activation resource + p.createActivation = papi.Activation{ + ActivationID: "act_123", + ActivationType: papi.ActivationTypeDeactivate, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + NotifyEmails: []string{"dummy-user@akamai.com"}, + PropertyVersion: 1, + } + // akamai_property_activation - delete + p.mockCreateActivation() + p.mockGetActivation() + // akamai_property - delete + p.mockRemoveProperty() }, - - configPathForUpdate: "testdata/TestGroupIDUpdate/update_group_id_and_hostnames.tf", - - updateChecks: resource.ComposeTestCheckFunc( - baseCheckName, - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_111"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_from", "from2.test.domain"), - commonBaseChecks), - }, - "update group id and name - recreate": { - init: func(t *testing.T, p *mockProperty, iamMock *iam.Mock) { - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - // second refresh - mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() - - // recreate the resource - p.propertyName = "dummy_name2" - p.groupID = "grp_111" - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf"), + Check: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"cpCode","options":{"value":{"description":"WAA Example.com","id":12345,"name":"WAA Example.com","products":["Web_App_Accel"]}}}],"children":[{"behaviors":[{"name":"prefetch","options":{"enabled":false}}],"name":"Static Content","options":{}}],"name":"default","options":{"is_secure":true}}}`). + CheckEqual("name", "dxe-2406-issue-example"). + CheckEqual("hostnames.0.cname_to", "dxe-2406-issue-example-second.com.example.net"). + CheckEqual("hostnames.#", "2"). + Build(), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf"), + ExpectError: regexp.MustCompile("Error: updating hostnames: request failed:"), + }, }, - - configPathForUpdate: "testdata/TestGroupIDUpdate/update_group_id_and_name.tf", - - updateChecks: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "name", "dummy_name2"), - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_111"), - baseCheckCnameFrom, - commonBaseChecks), }, } + for name, test := range tests { t.Run(name, func(t *testing.T) { papiMock := &papi.Mock{} - iamMock := &iam.Mock{} mp := mockProperty{ - papiMock: papiMock, - mockPropertyData: baseData, + papiMock: papiMock, } - test.init(t, &mp, iamMock) + test.init(t, &mp) useClient(papiMock, nil, func() { - useIam(iamMock, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestGroupIDUpdate/base.tf"), - Check: resource.ComposeTestCheckFunc( - baseCheckName, - baseCheckGroupID, - baseCheckCnameFrom, - commonBaseChecks), - }, - { - Config: testutils.LoadFixtureString(t, test.configPathForUpdate), - Check: test.updateChecks, - }, - }, - }) + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: test.steps, }) }) papiMock.AssertExpectations(t) - iamMock.AssertExpectations(t) }) } } +// TestSchemaConfiguration tests errors when invalid HCL configuration is provided +func TestSchemaConfiguration(t *testing.T) { + assertConfigError := func(t *testing.T, flaw, rx string) func(t *testing.T) { + fixtureName := strings.ReplaceAll(flaw, " ", "_") + + return func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/ConfigError/%s.tf", fixtureName), + ExpectError: regexp.MustCompile(rx), + }}, + }) + } + } + + t.Run("Schema Configuration Error: name not given", assertConfigError(t, "name not given", `"name" is required`)) + t.Run("Schema Configuration Error: contract_id not given", assertConfigError(t, "contract_id not given", `Missing required argument`)) + t.Run("Schema Configuration Error: group_id not given", assertConfigError(t, "group_id not given", `Missing required argument`)) + t.Run("Schema Configuration Error: product_id not given", assertConfigError(t, "product_id not given", `Missing required argument`)) + t.Run("Schema Configuration Error: invalid json rules", assertConfigError(t, "invalid json rules", `rules are not valid JSON`)) + t.Run("Schema Configuration Error: invalid name given", assertConfigError(t, "invalid name given", `a name must only contain letters, numbers, and these characters: . _ -`)) + t.Run("Schema Configuration Error: name given too long", assertConfigError(t, "name given too long", `a name must be longer than 0 characters and shorter than 86 characters`)) +} + // TODO: remove this test after moving property is enabled again, see DXE-4176 func TestGroupIDUpdateError(t *testing.T) { baseData := mockPropertyData{ @@ -1900,8 +2031,18 @@ func TestGroupIDUpdateError(t *testing.T) { propertyID: "prp_12345", latestVersion: 1, assetID: "aid_55555", - cnameFrom: "from.test.domain", - cnameTo: "to.test.domain", + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "", + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", + CertProvisioningType: "DEFAULT", + CertStatus: papi.CertStatusItem{}, + }, + }, + }, } papiMock := &papi.Mock{} @@ -1909,11 +2050,12 @@ func TestGroupIDUpdateError(t *testing.T) { papiMock: papiMock, mockPropertyData: baseData, } - mockResourcePropertyCreate(&mp) - // refresh - mockResourcePropertyRead(&mp) - // second refresh + mockResourcePropertyCreateWithVersionHostnames(&mp) + // read x2 + mockResourcePropertyRead(&mp, 2) + // read x1 before update mockResourcePropertyRead(&mp) + // delete mp.mockRemoveProperty().Once() useClient(papiMock, nil, func() { @@ -1922,14 +2064,15 @@ func TestGroupIDUpdateError(t *testing.T) { Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "testdata/TestGroupIDUpdate/base.tf"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "name", "dummy_name"), - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_from", "from.test.domain"), - resource.TestCheckResourceAttr("akamai_property.test", "contract_id", "ctr_2"), - resource.TestCheckResourceAttr("akamai_property.test", "product_id", "prd_3"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_to", "to.test.domain"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cert_provisioning_type", "DEFAULT")), + Check: test.NewStateChecker("akamai_property.test"). + CheckEqual("name", "dummy_name"). + CheckEqual("group_id", "grp_1"). + CheckEqual("hostnames.0.cname_from", "from.test.domain"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("hostnames.0.cert_provisioning_type", "DEFAULT"). + Build(), }, { Config: testutils.LoadFixtureString(t, "testdata/TestGroupIDUpdate/update_group_id.tf"), @@ -1940,180 +2083,118 @@ func TestGroupIDUpdateError(t *testing.T) { }) } -func TestPropertyResource_versionNotesLifecycle(t *testing.T) { +func TestPropertyResource_VersionNotesLifecycle(t *testing.T) { testdataDir := "testdata/TestResProperty/Lifecycle/versionNotes" - resourceName := "akamai_property.test" - - name := "test_property" - ruleFormat := "v2023-01-05" - ctr, grp, prd, id := "ctr_123", "grp_123", "prd_123", "prp_123" - propertyVersion := 1 - versionNotes1, versionNotes2, versionNotes3 := "lifecycleTest", "updatedNotes", "updatedNotes2" - rulesFile1And2, rulesFile3, rulesFile4And5 := "01_02_rules.json", "03_rules.json", "04_05_rules.json" - - client := &papi.Mock{} - - mockRead := func(notes string, rules papi.Rules) testutils.MockCalls { - getPropertyCall := client.On("GetProperty", mock.Anything, papi.GetPropertyRequest{ - PropertyID: id, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.GetPropertyResponse{ - Property: &papi.Property{ - ContractID: ctr, - GroupID: grp, - PropertyID: id, - PropertyName: name, - LatestVersion: propertyVersion, - }, - }, nil) - - getHostnamesCall := client.On("GetPropertyVersionHostnames", mock.Anything, papi.GetPropertyVersionHostnamesRequest{ - ContractID: ctr, - GroupID: grp, - PropertyID: id, - PropertyVersion: propertyVersion, - IncludeCertStatus: true, - }).Return(&papi.GetPropertyVersionHostnamesResponse{}, nil) - - getRuleTreeCall := client.On("GetRuleTree", mock.Anything, papi.GetRuleTreeRequest{ - PropertyID: id, - ContractID: ctr, - GroupID: grp, - PropertyVersion: propertyVersion, - ValidateRules: true, - ValidateMode: papi.RuleValidateModeFull, - }).Return(&papi.GetRuleTreeResponse{ - Rules: rules, - Comments: notes, - RuleFormat: ruleFormat, - }, nil) - - getPropertyVersionCall := client.On("GetPropertyVersion", mock.Anything, papi.GetPropertyVersionRequest{ - PropertyID: id, - PropertyVersion: propertyVersion, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - Note: notes, - ProductID: prd, - ProductionStatus: papi.VersionStatusInactive, - StagingStatus: papi.VersionStatusInactive, - }, - }, nil) - - return testutils.MockCalls{getPropertyCall, getHostnamesCall, getRuleTreeCall, getPropertyVersionCall} - } - - mockUpdate := func(currentNotes, newNotes string, rules papi.Rules) { - client.On("GetPropertyVersion", mock.Anything, papi.GetPropertyVersionRequest{ - PropertyID: id, - PropertyVersion: propertyVersion, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - Note: currentNotes, - ProductID: prd, - ProductionStatus: papi.VersionStatusInactive, - StagingStatus: papi.VersionStatusInactive, - }, - }, nil).Once() - - client.On("UpdateRuleTree", mock.Anything, papi.UpdateRulesRequest{ - PropertyID: id, - GroupID: grp, - ContractID: ctr, - PropertyVersion: propertyVersion, - Rules: papi.RulesUpdate{ - Rules: rules, - Comments: newNotes, - }, - ValidateRules: true, - }).Return(&papi.UpdateRulesResponse{}, nil).Once() - } - - // step 1 - create + read + plan - client.On("CreateProperty", mock.Anything, papi.CreatePropertyRequest{ - ContractID: ctr, - GroupID: grp, - Property: papi.PropertyCreate{ - ProductID: prd, - PropertyName: name, - RuleFormat: ruleFormat, - }, - }).Return(&papi.CreatePropertyResponse{ - PropertyID: id, - }, nil).Once() + rulesFile1And2, rulesFile4And5, rulesFile3 := "01_02_rules.json", "04_05_rules.json", "03_rules.json" rulesJSON := testutils.LoadFixtureBytes(t, path.Join(testdataDir, rulesFile1And2)) var rules1And2 papi.RulesUpdate err := json.Unmarshal(rulesJSON, &rules1And2) require.NoError(t, err) - client.On("UpdateRuleTree", mock.Anything, papi.UpdateRulesRequest{ - PropertyID: id, - GroupID: grp, - ContractID: ctr, - PropertyVersion: propertyVersion, - Rules: papi.RulesUpdate{ - Rules: rules1And2.Rules, - Comments: versionNotes1, + checker := test.NewStateChecker("akamai_property.test"). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_123"). + CheckEqual("contract_id", "ctr_123"). + CheckEqual("latest_version", "1") + + papiMock := &papi.Mock{} + basicData := mockPropertyData{ + propertyName: "test_property", + groupID: "grp_123", + contractID: "ctr_123", + productID: "prd_123", + propertyID: "prp_123", + latestVersion: 1, + assetID: "", + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + Note: versionNotes1, + }, + }, }, - ValidateRules: true, - }).Return(&papi.UpdateRulesResponse{}, nil).Once() + ruleTree: mockRuleTreeData{ + rules: rules1And2.Rules, + comments: versionNotes1, + ruleFormat: "v2023-01-05", + }, + } - mockRead(versionNotes1, rules1And2.Rules).Times(2) + prp := &mockProperty{ + mockPropertyData: basicData, + papiMock: papiMock, + } + + // --- step 1 --- + // create + prp.mockCreateProperty() + prp.mockUpdateRuleTree() + + // read x2 + mockResourcePropertyRead(prp, 2) - // step 2 - refresh + plan - mockRead(versionNotes2, rules1And2.Rules).Times(1) + // --- step 2 --- updated only notes - no triggered update + prp.versions.Items[0].Note = versionNotes2 + prp.ruleTree.comments = versionNotes2 - // step 3 - refresh + update + read + plan - mockRead(versionNotes2, rules1And2.Rules).Times(1) + // refresh x2 - no diff + mockResourcePropertyRead(prp, 2) + // --- step 3 --- var rules3 papi.RulesUpdate rulesJSON = testutils.LoadFixtureBytes(t, path.Join(testdataDir, rulesFile3)) err = json.Unmarshal(rulesJSON, &rules3) require.NoError(t, err) + // update with new notes and rules + prp.versions.Items[0].Note = versionNotes3 + prp.ruleTree.rules = rules3.Rules + prp.ruleTree.comments = versionNotes3 + mockResourcePropertyRead(prp) - mockUpdate(versionNotes3, "updatedNotes2", rules3.Rules) + prp.mockGetPropertyVersion() + prp.mockUpdateRuleTree() - mockRead(versionNotes3, rules3.Rules).Times(2) - - // step 4 - refresh + update + read + plan - mockRead(versionNotes3, rules3.Rules).Times(1) + // read x2 + mockResourcePropertyRead(prp, 2) + // --- step 4 --- + // update with new notes and rules var rules4And5 papi.RulesUpdate rulesJSON = testutils.LoadFixtureBytes(t, path.Join(testdataDir, rulesFile4And5)) err = json.Unmarshal(rulesJSON, &rules4And5) require.NoError(t, err) + prp.ruleTree.comments = rules4And5.Comments + prp.ruleTree.rules = rules4And5.Rules + prp.versions.Items[0].Note = rules4And5.Comments + mockResourcePropertyRead(prp) + prp.mockGetPropertyVersion() + prp.mockUpdateRuleTree() - mockUpdate(versionNotes3, rules4And5.Comments, rules4And5.Rules) - - mockRead(rules4And5.Comments, rules4And5.Rules).Times(2) + // read x2 + mockResourcePropertyRead(prp, 2) - // step 5 - refresh + plan - mockRead(rules4And5.Comments, rules4And5.Rules).Times(1) + // --- step 5 --- same config, no diff + // read x2 + mockResourcePropertyRead(prp, 2) - // cleanup - client.On("RemoveProperty", mock.Anything, papi.RemovePropertyRequest{ - PropertyID: id, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.RemovePropertyResponse{}, nil) + // delete + prp.mockRemoveProperty() - useClient(client, nil, func() { + useClient(papiMock, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "01_with_notes_and_comments.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckResourceAttrJSON(resourceName, "rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "01_expected_rules.json"))), - resource.TestCheckResourceAttr("akamai_property.test", "version_notes", "lifecycleTest"), - ), + Check: checker. + CheckEqual("version_notes", "lifecycleTest"). + CheckEqual("rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "01_expected_rules.json"))). + Build(), }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "02_update_notes_no_diff.tf")), @@ -2121,17 +2202,17 @@ func TestPropertyResource_versionNotesLifecycle(t *testing.T) { }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "03_update_notes_and_rules.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckResourceAttrJSON(resourceName, "rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "03_expected_rules.json"))), - resource.TestCheckResourceAttr("akamai_property.test", "version_notes", "updatedNotes2"), - ), + Check: checker. + CheckEqual("version_notes", "updatedNotes2"). + CheckEqual("rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "03_expected_rules.json"))). + Build(), }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "04_05_remove_notes_update_comments.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckResourceAttrJSON(resourceName, "rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "04_expected_rules.json"))), - resource.TestCheckResourceAttr("akamai_property.test", "version_notes", "Rules_04"), - ), + Check: checker. + CheckEqual("version_notes", "Rules_04"). + CheckEqual("rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "04_expected_rules.json"))). + Build(), }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "04_05_remove_notes_update_comments.tf")), @@ -2140,8 +2221,6 @@ func TestPropertyResource_versionNotesLifecycle(t *testing.T) { }, }) }) - - client.AssertExpectations(t) } func TestValidatePropertyName(t *testing.T) { diff --git a/pkg/providers/property/ruleformats/builder.go b/pkg/providers/property/ruleformats/builder.go index dd4d523c1..3838937e8 100644 --- a/pkg/providers/property/ruleformats/builder.go +++ b/pkg/providers/property/ruleformats/builder.go @@ -6,7 +6,7 @@ import ( "fmt" "reflect" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/ruleformats/rules_schema_reader.go b/pkg/providers/property/ruleformats/rules_schema_reader.go index 09a1131d6..2b92095da 100644 --- a/pkg/providers/property/ruleformats/rules_schema_reader.go +++ b/pkg/providers/property/ruleformats/rules_schema_reader.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf index ab7690ef8..1434ddf5c 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf @@ -4,6 +4,6 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - product_id = "prd_0" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf index 563001ab0..0776e80e9 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf @@ -4,6 +4,6 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - product_id = "prd_0" + contract_id = "ctr_1" + product_id = "prd_3" } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf index 987bc1840..2a4a1895b 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + group_id = "grp_2" + contract_id = "ctr_1" + product_id = "prd_3" rules = "abc" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf index c610bbb1a..562281569 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf @@ -4,7 +4,7 @@ provider "akamai" { resource "akamai_property" "test" { name = "invalid_name_@" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf index adc625338..c7fc5e281 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf @@ -4,7 +4,7 @@ provider "akamai" { resource "akamai_property" "test" { name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf index d3f34c9fc..a6ef4c620 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf @@ -3,7 +3,7 @@ provider "akamai" { } resource "akamai_property" "test" { - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf index 302298122..6f3cbb8b5 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf @@ -4,6 +4,6 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" + contract_id = "ctr_1" + group_id = "grp_2" } diff --git a/pkg/providers/property/testdata/TestResProperty/Creation/property.tf b/pkg/providers/property/testdata/TestResProperty/Creation/property.tf index b9730bec7..ca1fd4420 100644 --- a/pkg/providers/property/testdata/TestResProperty/Creation/property.tf +++ b/pkg/providers/property/testdata/TestResProperty/Creation/property.tf @@ -4,8 +4,8 @@ provider "akamai" { resource "akamai_property" "prop" { - name = "property_name" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf index 0894ac5b8..bf340c6de 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf @@ -6,11 +6,11 @@ data "akamai_property_rules_template" "akarules" { template_file = "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property-snippets/rules.json" } -resource "akamai_property" "akaproperty" { +resource "akamai_property" "test" { name = "dxe-2406-issue-example" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "dxe-2406-issue-example-second.com.example.net" cname_from = "dxe-2406-issue-example-second.com" @@ -28,6 +28,6 @@ resource "akamai_property" "akaproperty" { resource "akamai_property_activation" "aka_property_activate" { contact = ["dummy-user@akamai.com"] network = "STAGING" - property_id = akamai_property.akaproperty.id - version = akamai_property.akaproperty.latest_version + property_id = akamai_property.test.id + version = akamai_property.test.latest_version } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf index b59a450b9..e55ca368f 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf @@ -6,11 +6,11 @@ data "akamai_property_rules_template" "akarules" { template_file = "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property-snippets/rules.json" } -resource "akamai_property" "akaproperty" { +resource "akamai_property" "test" { name = "dxe-2406-issue-example" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "dxe-2406-issue-example-second.com.example.net" cname_from = "dxe-2406-issue-example-second.com" @@ -33,6 +33,6 @@ resource "akamai_property" "akaproperty" { resource "akamai_property_activation" "aka_property_activate" { contact = ["dummy-user@akamai.com"] network = "STAGING" - property_id = akamai_property.akaproperty.id - version = akamai_property.akaproperty.latest_version + property_id = akamai_property.test.id + version = akamai_property.test.latest_version } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf index 8f918efa1..c083aca14 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf @@ -20,17 +20,17 @@ resource "akamai_property" "test" { variable "groupid" { description = "Name of the group associated with this property" - default = "grp_0" + default = "grp_2" } variable "contractid" { description = "Contract ID associated with this property" - default = "ctr_0" + default = "ctr_1" } variable "productid" { description = "Name of the product used to configure this property" - default = "prd_0" + default = "prd_3" } variable "propertyname" { diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf index 7d1fb4d46..a6ad1491b 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf @@ -15,17 +15,17 @@ resource "akamai_property" "test" { variable "groupid" { description = "Name of the group associated with this property" - default = "grp_0" + default = "grp_2" } variable "contractid" { description = "Contract ID associated with this property" - default = "ctr_0" + default = "ctr_1" } variable "productid" { description = "Name of the product used to configure this property" - default = "prd_0" + default = "prd_3" } variable "propertyname" { diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf deleted file mode 100644 index 416e92125..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract = "0" - group_id = "grp_0" - product_id = "prd_0" - - hostnames { - cname_to = "to2.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf index d302c7fb0..8779241a7 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf index 5b9a64878..68429a323 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step0.tf similarity index 79% rename from pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step0.tf index f6adb0e3e..bef0fe547 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step1.tf similarity index 80% rename from pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step1.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step1.tf index 005957624..72e1e25c1 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "renamed_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf deleted file mode 100644 index 613a77357..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group = "0" - product_id = "prd_0" - - hostnames { - cname_to = "to2.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step0.tf similarity index 80% rename from pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step0.tf index 6b22b46c5..171fc92e3 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step0.tf @@ -4,14 +4,13 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product = "0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" cert_provisioning_type = "DEFAULT" } - } diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf new file mode 100644 index 000000000..6143e388b --- /dev/null +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_property" "test" { + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_222" + product_id = "prd_3" + + hostnames { + cname_to = "to.test.domain" + cname_from = "from.test.domain" + cert_provisioning_type = "DEFAULT" + } +} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step0.tf similarity index 80% rename from pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step0.tf index 76313fcce..171fc92e3 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step0.tf @@ -4,14 +4,13 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group = "0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" cert_provisioning_type = "DEFAULT" } - } diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf new file mode 100644 index 000000000..050ff3207 --- /dev/null +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_property" "test" { + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_222" + product_id = "prd_3" + + hostnames { + cname_to = "to.test.domain" + cname_from = "from2.test.domain" + cert_provisioning_type = "DEFAULT" + } +} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step0.tf similarity index 71% rename from pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step0.tf index 339719108..171fc92e3 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step0.tf @@ -3,15 +3,14 @@ provider "akamai" { } resource "akamai_property" "test" { - name = "test_property" - contract = "0" - group_id = "grp_0" - product_id = "prd_0" + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" cert_provisioning_type = "DEFAULT" } - } diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf new file mode 100644 index 000000000..a93aadc03 --- /dev/null +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_property" "test" { + name = "dummy_name2" + contract_id = "ctr_1" + group_id = "grp_222" + product_id = "prd_3" + + hostnames { + cname_to = "to.test.domain" + cname_from = "from.test.domain" + cert_provisioning_type = "DEFAULT" + } +} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf index f5b017c50..b6f905105 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf index bdcf7ff9a..9c2578edf 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf index 8ad44067f..c1181a481 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to1.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf index 861115922..925bb126f 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf index 0ad095277..367a24127 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf index 133ee1144..eb41d388c 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.akarules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf index b3e4efd8a..35f6e0af8 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.akarules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf index 0ad095277..367a24127 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf index 2257fe2a6..b3bb0ac95 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf deleted file mode 100644 index 1ccc9f023..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product = "0" - - hostnames { - cname_to = "to2.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf index b0122f5f5..525b8951a 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf index d40e358ed..4e568c189 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf index 27a7ef95f..624ff7557 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.rules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf index 75e8e0e66..9891f4382 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.rules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf index 088113c23..098aad8b8 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.rules.json hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf index d6e318787..62372f6cd 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf @@ -3,10 +3,10 @@ provider "akamai" { } resource "akamai_property" "test" { - contract_id = "ctr_0" - group_id = "grp_0" name = "test_property" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = jsonencode( { "rules" : { diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf index 4a44b64a4..df829d446 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf @@ -3,10 +3,10 @@ provider "akamai" { } resource "akamai_property" "test" { - contract_id = "ctr_0" - group_id = "grp_0" name = "test_property" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = jsonencode( { "rules" : { diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf index 04b57b61f..72337a4bc 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf @@ -4,10 +4,10 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" - property_id = "prp_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" + property_id = "prp_4" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf index 8e3489304..dd4a8ba2b 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf @@ -4,10 +4,10 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" - property_id = "prp_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" + property_id = "prp_4" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf b/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf index 897b9ca49..73f22d658 100644 --- a/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf +++ b/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf b/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf index d302c7fb0..8779241a7 100644 --- a/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf b/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf index b7ea3909e..6e955eab7 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf +++ b/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" # Fetch the newly created property depends_on = [ akamai_property.test diff --git a/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf b/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf index 92a3bc333..6e736e616 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf +++ b/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" # Fetch the newly created property depends_on = [ akamai_property.test diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf new file mode 100644 index 000000000..b19f304ff --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf @@ -0,0 +1,11 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "importedgehostname" { + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_2" + edge_hostname = "test.akamaized.net" + ip_behavior = "IPV4" +} diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf new file mode 100644 index 000000000..df4c9ff2e --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf @@ -0,0 +1,12 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "importedgehostname" { + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_2" + edge_hostname = "test.edgekey.net" + ip_behavior = "IPV4" + certificate = 123456 +} diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf new file mode 100644 index 000000000..c4862b4b4 --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "edgehostname" { + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_9" + edge_hostname = "test.akamaized.net" + ip_behavior = "IPV6_COMPLIANCE" +} + +output "edge_hostname" { + value = akamai_edge_hostname.edgehostname.edge_hostname +} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf new file mode 100644 index 000000000..605bf2995 --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "edgehostname" { + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" + edge_hostname = "test.edgekey.net" + certificate = 800800 + ip_behavior = "IPV6_PERFORMANCE" +} + +output "edge_hostname" { + value = akamai_edge_hostname.edgehostname.edge_hostname +} \ No newline at end of file diff --git a/pkg/retryablehttp/client.go b/pkg/retryablehttp/client.go index c8fe8f453..ad3328491 100644 --- a/pkg/retryablehttp/client.go +++ b/pkg/retryablehttp/client.go @@ -651,6 +651,14 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } } + // First attempt was already signed + if attempt > 1 && c.PrepareRetry != nil { + if err := c.PrepareRetry(req.Request); err != nil { + prepareErr = err + break + } + } + if c.RequestLogHook != nil { switch v := logger.(type) { case LeveledLogger: @@ -742,10 +750,6 @@ func (c *Client) Do(req *Request) (*http.Response, error) { httpreq := *req.Request req.Request = &httpreq - if err := c.PrepareRetry(req.Request); err != nil { - prepareErr = err - break - } } // this is the closest we have to success criteria diff --git a/pkg/retryablehttp/client_test.go b/pkg/retryablehttp/client_test.go index a751d3fd2..66e0f0ed0 100644 --- a/pkg/retryablehttp/client_test.go +++ b/pkg/retryablehttp/client_test.go @@ -6,6 +6,8 @@ package retryablehttp import ( "bytes" "context" + "crypto/sha256" + "encoding/base64" "errors" "fmt" "io" @@ -373,6 +375,22 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { client.PrepareRetry = func(req *http.Request) error { prepareChecks++ req.Header.Set("foo", strconv.Itoa(prepareChecks)) + + // if the method is POST or PUT, set a header based on request body content + if req.Method == "POST" || req.Method == "PUT" { + bodyBytes, err := io.ReadAll(req.Body) + if err != nil { + t.Fatalf("could not read request body: %s", err) + } + preparedBody := string(bodyBytes) + + if len(preparedBody) > 0 { + sum := sha256.Sum256([]byte(preparedBody)) + contentHash := base64.StdEncoding.EncodeToString(sum[:]) + req.Header.Set("content_hash", contentHash) + } + } + return nil } @@ -385,6 +403,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { var shouldSucceed bool tests := []struct { name string + method string + requestBody string handler ResponseHandlerFunc expectedChecks int // often 2x number of attempts since we check twice expectedPrepareChecks int @@ -392,12 +412,14 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { }{ { name: "nil handler", + method: http.MethodGet, handler: nil, expectedChecks: 1, expectedPrepareChecks: 0, }, { - name: "handler always succeeds", + name: "handler always succeeds", + method: http.MethodGet, handler: func(*http.Response) error { return nil }, @@ -405,7 +427,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedPrepareChecks: 0, }, { - name: "handler always fails in a retryable way", + name: "handler always fails in a retryable way", + method: http.MethodGet, handler: func(*http.Response) error { return errors.New("retryable failure") }, @@ -413,7 +436,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedPrepareChecks: 2, }, { - name: "handler always fails in a nonretryable way", + name: "handler always fails in a nonretryable way", + method: http.MethodGet, handler: func(*http.Response) error { return errors.New("nonretryable failure") }, @@ -421,7 +445,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedPrepareChecks: 0, }, { - name: "handler succeeds on second attempt", + name: "handler succeeds on second attempt", + method: http.MethodGet, handler: func(*http.Response) error { if shouldSucceed { return nil @@ -432,6 +457,34 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedChecks: 4, expectedPrepareChecks: 1, }, + { + name: "POST - handler succeeds on second attempt, using body for PrepareRetry", + method: http.MethodPost, + requestBody: "dummy data", + handler: func(response *http.Response) error { + if shouldSucceed { + return nil + } + shouldSucceed = true + return errors.New("retryable failure") + }, + expectedChecks: 4, + expectedPrepareChecks: 1, + }, + { + name: "PUT - handler succeeds on second attempt, using body for PrepareRetry", + method: http.MethodPut, + requestBody: "dummy data", + handler: func(response *http.Response) error { + if shouldSucceed { + return nil + } + shouldSucceed = true + return errors.New("retryable failure") + }, + expectedChecks: 4, + expectedPrepareChecks: 1, + }, } for _, tt := range tests { @@ -439,8 +492,16 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { checks = 0 prepareChecks = 0 shouldSucceed = false + var req *Request + var err error + // Create the request - req, err := NewRequest("GET", ts.URL, nil) + if tt.requestBody != "" { + req, err = NewRequest(tt.method, ts.URL, strings.NewReader(tt.requestBody)) + } else { + req, err = NewRequest(tt.method, ts.URL, nil) + } + if err != nil { t.Fatalf("err: %v", err) } @@ -471,6 +532,12 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { t.Fatalf("expected changes in request header 'foo' '%s', but got '%s'", expectedHeader, header) } + if tt.method == "POST" || tt.method == "PUT" { + headerFromContent := req.Request.Header.Get("content_hash") + if headerFromContent == "" { + t.Fatalf("expected 'content_hash' header to exist, but it does not") + } + } }) } } diff --git a/scripts/install_terraform.sh b/scripts/install_terraform.sh index 945eac5e3..c16a33f9a 100755 --- a/scripts/install_terraform.sh +++ b/scripts/install_terraform.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="${TERRAFORM_VERSION:-1.7.5}" +VERSION="${TERRAFORM_VERSION:-1.9.5}" VERSION="${VERSION#v}" if [[ -n $(which terraform) && "$(terraform --version | sed 1q | cut -f2 -d" " | cut -c2-)" == "$VERSION" ]]; then