diff --git a/.goreleaser.yml b/.goreleaser.yml index 47ab5aeb5..adea51ffa 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -15,7 +15,7 @@ builds: - -trimpath - -tags=all ldflags: - - -s -w -X github.com/akamai/terraform-provider-akamai/v4/version.ProviderVersion={{.Version}} + - -s -w -X github.com/akamai/terraform-provider-akamai/v5/version.ProviderVersion={{.Version}} goos: - windows - linux diff --git a/CHANGELOG.md b/CHANGELOG.md index c00def43f..2fdd56a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,95 @@ # RELEASE NOTES +## 5.0.0 (Jul 5, 2023) + +#### BREAKING CHANGES: + +* DataStream + * Changed the following data sources in DataStream 2 V2 API: + * `akamai_datastream_activation_history` - changed schema and corresponding implementations. + * `akamai_datastream_dataset_fields` - changed parameter, schema and corresponding implementations. + * `akamai_datastreams` - changed parameter, schema and corresponding implementations. + * Changed the following resources in DataStream 2 V2 API: + * `akamai_datastreams` - changed in schema payload, response attributes and corresponding implementations. + * Updated attribute names in `datastream.connectors`. + * Updated methods in `datastream.stream` for the above changes. + +* PAPI + * Changed default value of `auto_acknowledge_rule_warnings` to `false` in `akamai_property_activation` resource + +* Removed undocumented support for configuring provider with environment variables (`AKAMAI_ACCESS_TOKEN`, `AKAMAI_CLIENT_TOKEN`, `AKAMAI_HOST`, `AKAMAI_CLIENT_SECRET`, `AKAMAI_MAX_BODY`, and their `AKAMAI_{section}_xxx` equivalents). + As an alternative users should now use provider's [config](https://techdocs.akamai.com/terraform/docs/gs-authentication#use-inline-credentials) block with [TF_VAR_](https://developer.hashicorp.com/terraform/language/values/variables#environment-variables) envs when wanting to provide configuration through enviroment variables. + +##### Removed deprecated schema fields + +* Appsec + * `notes` and `activate` fields in `akamai_appsec_activations` resource + * `appsec_section` and `appsec` fields in provider schema + +* CPS + * `enable_multi_stacked_certificates` field in `akamai_cps_dv_enrollment` resource + +* DNS + * `dns_section` and `dns` fields in provider schema + +* GTM + * `gtm_section` and `gtm` fields in provider schema + +* IAM + * `is_locked` field in `akamai_iam_user` resource + +* Network Lists + * `activate` field in `akamai_networklist_activations` resource + * `networklist_section` and `network` fields in provider schema + +* PAPI + * `contract` and `group` fields in `akamai_cp_code` data source + * `group` field in `akamai_contract` data source + * `name` and `contract` fields in `akamai_group` data source + * `contract`, `group` and `product` fields in `akamai_cp_code` resource + * `contract`, `group` and `product` fields in `akamai_edge_hostname` resource + * `property` and `rule_warnings` fields in `akamai_property_activation` resource + * `contract`, `group` and `product` fields in `akamai_property` resource + * `papi_section`, `property_section` and `property` fields in provider schema + +##### Removed deprecated resource + +* PAPI + * `akamai_property_variables` + +#### FEATURES/ENHANCEMENTS: + +* Provider tested and now supports Terraform 1.4.6 +* Migrated `akamai_property_include` data source from SDKv2 to Framework. + +* PAPI + * Added import to `akamai_property_activation` resource + * Extended `akamai_property_rules_builder` data source: added support for rules frozen format `v2023-01-05` and `v2023-05-30` + +* Appsec + * Updated Geo control to include Action for Ukraine. + * Added `akamai_appsec_advanced_settings_pii_learning` data source and resource for managing the PII learning advanced setting. + +#### DEPRECATIONS + +* Deprecated `active` field in `akamai_dns_record` resource + +#### BUG FIXES: + +* CPS + * Fixed bug in `akamai_cps_dv_enrollment` resource when MTLS settings are provided ([#339](https://github.com/akamai/terraform-provider-akamai/issues/339)) + * Fixed `sans` field causing perpetual in-place update in `akamai_cps_third_party_enrollment` ([#415](https://github.com/akamai/terraform-provider-akamai/issues/415)) + +* GTM + * Made `test_object` inside `liveness_test` required only for `test_object_protocol` values: `HTTP`, `HTTPS` or `FTP` ([I#408](https://github.com/akamai/terraform-provider-akamai/issues/408)) + +* Cloudlets + * Added wait for propagation of policy activation deletions, before removing the policy in `akamai_cloudlets_policy` ([I#420](https://github.com/akamai/terraform-provider-akamai/issues/420)) + +* PAPI + * Removed hostname validation on `akamai_property` resource ([I#422](https://github.com/akamai/terraform-provider-akamai/issues/422)) + + ## 4.1.0 (Jun 1, 2023) #### FEATURES/ENHANCEMENTS: @@ -8,7 +98,7 @@ * New data sources: * `akamai_gtm_datacenter` - get datacenter information * `akamai_gtm_datacenters` - get datacenters information - + ## 4.0.0 (May 30, 2023) #### BREAKING CHANGES: @@ -859,8 +949,8 @@ These are the operations supported in the Network Lists API v2: These are the operations supported in the Identity Management: User Administration API v2: * Create a new user -* Update a user’s profile -* Update a user’s role assignments +* Update a user’s profile +* Update a user’s role assignments * Delete a user ## 1.1.1 (Jan 8, 2021) diff --git a/GNUmakefile b/GNUmakefile index bf668c6d4..0068c03d5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -11,7 +11,7 @@ TF_PLUGIN_DIR ?= ~/.terraform.d/plugins install_path = $(TF_PLUGIN_DIR)/$(registry_name)/$(namespace)/$(PKG_NAME)/$(version)/$$(go env GOOS)_$$(go env GOARCH) # Tools versions -golangci-lint-version = v1.50.1 +golangci-lint-version = v1.52.2 tflint-version = v0.45.0 default: build diff --git a/README.md b/README.md index beab2bc0c..7b725c1ff 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ Akamai Provider for Terraform ================== ![Build Status](https://github.com/akamai/terraform-provider-akamai/actions/workflows/checks.yml/badge.svg) -[![Go Report Card](https://goreportcard.com/badge/github.com/akamai/terraform-provider-akamai/v4)](https://goreportcard.com/report/github.com/akamai/terraform-provider-akamai/v4) +[![Go Report Card](https://goreportcard.com/badge/github.com/akamai/terraform-provider-akamai/v5)](https://goreportcard.com/report/github.com/akamai/terraform-provider-akamai/v5) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/akamai/terraform-provider-akamai) [![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-blue.svg)](https://opensource.org/licenses/MPL-2.0) -[![GoDoc](https://godoc.org/github.com/akamai/terraform-provider-akamai?status.svg)](https://pkg.go.dev/github.com/akamai/terraform-provider-akamai/v4) +[![GoDoc](https://godoc.org/github.com/akamai/terraform-provider-akamai?status.svg)](https://pkg.go.dev/github.com/akamai/terraform-provider-akamai/v5) Use the Akamai Provider to manage and provision your Akamai configurations in Terraform. You can use the Akamai Provider for many Akamai products. diff --git a/build/internal/docker_jenkins.bash b/build/internal/docker_jenkins.bash index b0ab90d68..db6b5ad9c 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.3.7" +TERRAFORM_VERSION="1.4.6" STASH_SERVER=git.source.akamai.com GIT_IP=$(dig +short $STASH_SERVER) @@ -92,7 +92,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/v6=../edgegrid; + go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v7=../edgegrid; go mod tidy -compat=1.18' echo "Running golangci-lint" diff --git a/build/internal/package/Dockerfile b/build/internal/package/Dockerfile index c312833ef..fcee36dc4 100644 --- a/build/internal/package/Dockerfile +++ b/build/internal/package/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.0-experimental -ARG TERRAFORM_VERSION="1.3.7" +ARG TERRAFORM_VERSION="1.4.6" FROM alpine:3.16 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 d9aacbebe..d83dd0731 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/v6="./akamaiopen-edgegrid-golang" + go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v7="./akamaiopen-edgegrid-golang" go mod tidy -compat=1.18 } diff --git a/build/internal/releaser/goreleaser_build.bash b/build/internal/releaser/goreleaser_build.bash index 819e98f25..5227567f9 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/v6=../akamaiopen-edgegrid-golang/ +go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v7=../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 897478ee1..ce9883988 100644 --- a/docs/data-sources/data-sources.md +++ b/docs/data-sources/data-sources.md @@ -8,15 +8,15 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi |Subprovider|Description| |---|---| -|[Application Security](https://techdocs.akamai.com/terraform/v4.1/docs/appsec-datasources)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| -|[Bot Manager](https://techdocs.akamai.com/terraform/v4.1/docs/botman-datasources)|Identify, track, and respond to bot activity on your domain or in your app.| -|[Certificates](https://techdocs.akamai.com/terraform/v4.1/docs/cps-datasources)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| -|[Cloudlets](https://techdocs.akamai.com/terraform/v4.1/docs/cl-datasources)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| -|[DataStream](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/edns-datasources)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| -|[EdgeWorkers](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/gtm-datasources)|Use load balancing to manage website and mobile performance demands.| -|[Identity and Access Management](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/ivm-datasources)|Automate image and video delivery optimizations for your website visitors.| -|[Network Lists](https://techdocs.akamai.com/terraform/v4.1/docs/nl-datasources)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| -|[Property](https://techdocs.akamai.com/terraform/v4.1/docs/pm-datasources)|Define rules and behaviors that govern your website delivery based on match criteria.| +|[Application Security](https://techdocs.akamai.com/terraform/v5.0/docs/appsec-datasources)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| +|[Bot Manager](https://techdocs.akamai.com/terraform/v5.0/docs/botman-datasources)|Identify, track, and respond to bot activity on your domain or in your app.| +|[Certificates](https://techdocs.akamai.com/terraform/v5.0/docs/cps-datasources)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| +|[Cloudlets](https://techdocs.akamai.com/terraform/v5.0/docs/cl-datasources)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| +|[DataStream](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/edns-datasources)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| +|[EdgeWorkers](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/gtm-datasources)|Use load balancing to manage website and mobile performance demands.| +|[Identity and Access Management](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/ivm-datasources)|Automate image and video delivery optimizations for your website visitors.| +|[Network Lists](https://techdocs.akamai.com/terraform/v5.0/docs/nl-datasources)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| +|[Property](https://techdocs.akamai.com/terraform/v5.0/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 5a072f3e5..499a44578 100644 --- a/docs/guides/get-started.md +++ b/docs/guides/get-started.md @@ -5,9 +5,9 @@ Use our Terraform provider to provision and manage your Akamai configurations in - Understand the [basics of Terraform](https://learn.hashicorp.com/terraform?utm_source=terraform_io). - Install our [Terraform CLI](https://github.com/akamai/cli-terraform) to export your Akamai configurations. -## How it works +## What you'll do -![Terraform overview](https://techdocs.akamai.com/terraform-images/img/ext-tf-gs.png) +Initialize our provider, set up basic authentication, and begin your Akamai configuration set up. ## Start your configuration @@ -21,7 +21,7 @@ Your Akamai Terraform configuration starts with listing us as a required provide required_providers { akamai = { source = "akamai/akamai" - version = "4.1.0" + version = "5.0.0" } } } @@ -99,18 +99,18 @@ Use the table to find information about the subprovider you’re using. |Subprovider|Description| |---|---| -|[Application Security](https://techdocs.akamai.com/terraform/v4.1/docs/configure-appsec)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| -|[Bot Manager](https://techdocs.akamai.com/terraform/v4.1/docs/set-up-botman)|Identify, track, and respond to bot activity on your domain or in your app.| -|[Certificates](https://techdocs.akamai.com/terraform/v4.1/docs/cps-integration-guide)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| -|[Cloudlets](https://techdocs.akamai.com/terraform/v4.1/docs/set-up-cloudlets)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| -|[DataStream](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/set-up-edgedns)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| -|[EdgeWorkers](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/set-up-gtm)|Use load balancing to manage website and mobile performance demands.| -|[Identity and Access Management](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/set-up-ivm)|Automate image and video delivery optimizations for your website visitors.| -|[Network Lists](https://techdocs.akamai.com/terraform/v4.1/docs/set-up-network-lists)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| -|[Property](https://techdocs.akamai.com/terraform/v4.1/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/v5.0/docs/configure-appsec)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| +|[Bot Manager](https://techdocs.akamai.com/terraform/v5.0/docs/set-up-botman)|Identify, track, and respond to bot activity on your domain or in your app.| +|[Certificates](https://techdocs.akamai.com/terraform/v5.0/docs/cps-integration-guide)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| +|[Cloudlets](https://techdocs.akamai.com/terraform/v5.0/docs/set-up-cloudlets)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| +|[DataStream](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/set-up-edgedns)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| +|[EdgeWorkers](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/set-up-gtm)|Use load balancing to manage website and mobile performance demands.| +|[Identity and Access Management](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/set-up-ivm)|Automate image and video delivery optimizations for your website visitors.| +|[Network Lists](https://techdocs.akamai.com/terraform/v5.0/docs/set-up-network-lists)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| +|[Property](https://techdocs.akamai.com/terraform/v5.0/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 17aff8d3c..f333a219c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,18 +35,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/v4.1/docs/configure-appsec)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| -|[Bot Manager](https://techdocs.akamai.com/terraform/v4.1/docs/set-up-botman)|Identify, track, and respond to bot activity on your domain or in your app.| -|[Certificates](https://techdocs.akamai.com/terraform/v4.1/docs/cps-integration-guide)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| -|[Cloudlets](https://techdocs.akamai.com/terraform/v4.1/docs/set-up-cloudlets)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| -|[DataStream](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/set-up-edgedns)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| -|[EdgeWorkers](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/set-up-gtm)|Use load balancing to manage website and mobile performance demands.| -|[Identity and Access Management](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/set-up-ivm)|Automate image and video delivery optimizations for your website visitors.| -|[Network Lists](https://techdocs.akamai.com/terraform/v4.1/docs/set-up-network-lists)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| -|[Property](https://techdocs.akamai.com/terraform/v4.1/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/v5.0/docs/configure-appsec)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| +|[Bot Manager](https://techdocs.akamai.com/terraform/v5.0/docs/set-up-botman)|Identify, track, and respond to bot activity on your domain or in your app.| +|[Certificates](https://techdocs.akamai.com/terraform/v5.0/docs/cps-integration-guide)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| +|[Cloudlets](https://techdocs.akamai.com/terraform/v5.0/docs/set-up-cloudlets)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| +|[DataStream](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/set-up-edgedns)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| +|[EdgeWorkers](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/set-up-gtm)|Use load balancing to manage website and mobile performance demands.| +|[Identity and Access Management](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/set-up-ivm)|Automate image and video delivery optimizations for your website visitors.| +|[Network Lists](https://techdocs.akamai.com/terraform/v5.0/docs/set-up-network-lists)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| +|[Property](https://techdocs.akamai.com/terraform/v5.0/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 0ba5a5030..ccf64df1c 100644 --- a/docs/resources/resources.md +++ b/docs/resources/resources.md @@ -8,15 +8,15 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi |Subprovider|Description| |---|---| -|[Application Security](https://techdocs.akamai.com/terraform/v4.1/docs/appsec-resources)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| -|[Bot Manager](https://techdocs.akamai.com/terraform/v4.1/docs/botman-resources)|Identify, track, and respond to bot activity on your domain or in your app.| -|[Certificates](https://techdocs.akamai.com/terraform/v4.1/docs/cps-resources)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| -|[Cloudlets](https://techdocs.akamai.com/terraform/v4.1/docs/cl-resources)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| -|[DataStream](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/edns-resources)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| -|[EdgeWorkers](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/gtm-resources)|Use load balancing to manage website and mobile performance demands.| -|[Identity and Access Management](https://techdocs.akamai.com/terraform/v4.1/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/v4.1/docs/ivm-resources)|Automate image and video delivery optimizations for your website visitors.| -|[Network Lists](https://techdocs.akamai.com/terraform/v4.1/docs/nl-resources)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| -|[Property](https://techdocs.akamai.com/terraform/v4.1/docs/pm-resources)|Define rules and behaviors that govern your website delivery based on match criteria.| +|[Application Security](https://techdocs.akamai.com/terraform/v5.0/docs/appsec-resources)|Manage security configurations, security policies, match targets, rate policies, and firewall rules.| +|[Bot Manager](https://techdocs.akamai.com/terraform/v5.0/docs/botman-resources)|Identify, track, and respond to bot activity on your domain or in your app.| +|[Certificates](https://techdocs.akamai.com/terraform/v5.0/docs/cps-resources)|Full life cycle management of SSL certificates for your ​Akamai​ CDN applications.| +|[Cloudlets](https://techdocs.akamai.com/terraform/v5.0/docs/cl-resources)|Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions.| +|[DataStream](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/edns-resources)|Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution.| +|[EdgeWorkers](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/gtm-resources)|Use load balancing to manage website and mobile performance demands.| +|[Identity and Access Management](https://techdocs.akamai.com/terraform/v5.0/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/v5.0/docs/ivm-resources)|Automate image and video delivery optimizations for your website visitors.| +|[Network Lists](https://techdocs.akamai.com/terraform/v5.0/docs/nl-resources)|Automate the creation, deployment, and management of lists used in ​Akamai​ security products.| +|[Property](https://techdocs.akamai.com/terraform/v5.0/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 5be57b734..5ba8bfbcf 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,31 @@ -module github.com/akamai/terraform-provider-akamai/v4 +module github.com/akamai/terraform-provider-akamai/v5 require ( - github.com/akamai/AkamaiOPEN-edgegrid-golang/v6 v6.0.0 + github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.0.0 github.com/allegro/bigcache/v2 v2.2.5 github.com/apex/log v1.9.0 github.com/go-ozzo/ozzo-validation/v4 v4.3.0 github.com/google/go-cmp v0.5.9 github.com/google/uuid v1.3.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 - github.com/hashicorp/go-hclog v1.2.1 - github.com/hashicorp/go-plugin v1.4.6 - github.com/hashicorp/terraform-plugin-go v0.14.1 + github.com/hashicorp/go-hclog v1.5.0 + github.com/hashicorp/terraform-plugin-framework v1.2.0 + github.com/hashicorp/terraform-plugin-go v0.15.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 github.com/jedib0t/go-pretty/v6 v6.0.4 github.com/jinzhu/copier v0.3.2 github.com/spf13/cast v1.3.1 github.com/stretchr/testify v1.7.2 github.com/tj/assert v0.0.3 - google.golang.org/grpc v1.50.1 + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 +) + +require ( + github.com/hashicorp/go-plugin v1.4.9 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + golang.org/x/mod v0.8.0 // indirect + google.golang.org/grpc v1.54.0 // indirect ) require ( @@ -36,14 +44,15 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/hcl/v2 v2.15.0 // indirect + github.com/hashicorp/hc-install v0.5.0 // indirect + github.com/hashicorp/hcl/v2 v2.16.2 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.17.3 // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect - github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect - github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect + github.com/hashicorp/terraform-exec v0.18.1 // indirect + github.com/hashicorp/terraform-json v0.16.0 // indirect + github.com/hashicorp/terraform-plugin-log v0.9.0 + github.com/hashicorp/terraform-plugin-mux v0.10.0 + github.com/hashicorp/terraform-registry-address v0.2.0 // indirect + github.com/hashicorp/terraform-svchost v0.0.1 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/iancoleman/strcase v0.2.0 github.com/jtolds/gls v4.20.0+incompatible // indirect @@ -61,22 +70,20 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.1.1 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect - github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect + github.com/zclconf/go-cty v1.13.1 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 // indirect - golang.org/x/net v0.7.0 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/net v0.8.0 // indirect golang.org/x/sync v0.2.0 - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -// replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v6 => ../AkamaiOPEN-edgegrid-golang +// replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 => ../AkamaiOPEN-edgegrid-golang go 1.18 diff --git a/go.sum b/go.sum index a0dac2d87..d992cae45 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= @@ -10,8 +10,8 @@ github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v6 v6.0.0 h1:YR4Uce34BxhBWxtIqxm86kZ/WWK7v1A8aHBWSnzD3KI= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v6 v6.0.0/go.mod h1:9YKAQNAuk/p5qpbk/2kg28GI23VKpnrCzHOmml3YZzM= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.0.0 h1:MJnLIOgHqWT2cbc8EVE70KuVPCYqf/3Qc4mSti9Rw7M= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v7 v7.0.0/go.mod h1:zZWAMUwE4q5sVPgnjz9jiqtXA01tM3m9HYd6Wk0ev90= 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= @@ -23,18 +23,16 @@ github.com/apex/logs v1.0.0/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDw github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE= github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -43,10 +41,6 @@ github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0 github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -65,30 +59,15 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es= github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -102,49 +81,54 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw= -github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA= -github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.4.9 h1:ESiK220/qE0aGxWdzKIvRH69iLiuN/PjoLTm69RoWtU= +github.com/hashicorp/go-plugin v1.4.9/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= 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.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= -github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= -github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= -github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/hashicorp/hc-install v0.5.0 h1:D9bl4KayIYKEeJ4vUDe9L5huqxZXczKaykSRcmQ0xY0= +github.com/hashicorp/hc-install v0.5.0/go.mod h1:JyzMfbzfSBSjoDCRPna1vi/24BEDxFaCPfdHtM5SCdo= +github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= +github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= -github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= -github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= -github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= -github.com/hashicorp/terraform-plugin-go v0.14.1 h1:cwZzPYla82XwAqpLhSzdVsOMU+6H29tczAwrB0z9Zek= -github.com/hashicorp/terraform-plugin-go v0.14.1/go.mod h1:Bc/K6K26BQ2FHqIELPbpKtt2CzzbQou+0UQF3/0NsCQ= -github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= -github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= +github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= +github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= +github.com/hashicorp/terraform-json v0.16.0 h1:UKkeWRWb23do5LNAFlh/K3N0ymn1qTOO8c+85Albo3s= +github.com/hashicorp/terraform-json v0.16.0/go.mod h1:v0Ufk9jJnk6tcIZvScHvetlKfiNTC+WS21mnXIlc0B0= +github.com/hashicorp/terraform-plugin-framework v1.2.0 h1:MZjFFfULnFq8fh04FqrKPcJ/nGpHOvX4buIygT3MSNY= +github.com/hashicorp/terraform-plugin-framework v1.2.0/go.mod h1:nToI62JylqXDq84weLJ/U3umUsBhZAaTmU0HXIVUOcw= +github.com/hashicorp/terraform-plugin-go v0.15.0 h1:1BJNSUFs09DS8h/XNyJNJaeusQuWc/T9V99ylU9Zwp0= +github.com/hashicorp/terraform-plugin-go v0.15.0/go.mod h1:tk9E3/Zx4RlF/9FdGAhwxHExqIHHldqiQGt20G6g+nQ= +github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= +github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-mux v0.10.0 h1:VejY1BffxGy2iYOaa8DDHavY4k9jbvAE8F3lhruspKY= +github.com/hashicorp/terraform-plugin-mux v0.10.0/go.mod h1:9sdnpmY20xIsl4ItsfODZYE+MgpSy/osXpSf+RwaZCY= github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 h1:zHcMbxY0+rFO9gY99elV/XC/UnQVg7FhRCbj1i5b7vM= github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1/go.mod h1:+tNlb0wkfdsDJ7JEiERLz4HzM19HyiuIoGzTsM7rPpw= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= +github.com/hashicorp/terraform-registry-address v0.2.0 h1:92LUg03NhfgZv44zpNTLBGIbiyTokQCDcdH5BhVHT3s= +github.com/hashicorp/terraform-registry-address v0.2.0/go.mod h1:478wuzJPzdmqT6OGbB/iH82EDcI8VFM4yujknh/1nIs= +github.com/hashicorp/terraform-svchost v0.0.1 h1:Zj6fR5wnpOHnJUmLyWozjMeDaVuE+cstMPj41/eKmSQ= +github.com/hashicorp/terraform-svchost v0.0.1/go.mod h1:ut8JaH0vumgdCfJaihdcZULqkAwHdQNwNH7taIDdsZM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -171,14 +155,15 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= @@ -187,6 +172,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -197,10 +184,10 @@ github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9 github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -211,12 +198,12 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= @@ -246,19 +233,15 @@ github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKw github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= +github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc= +github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/ratelimit v0.2.0 h1:UQE2Bgi7p2B85uP5dC2bbRtig0C+OeNRnNEafLjsLPA= @@ -266,48 +249,36 @@ go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6m golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 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-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0= -golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/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-20210220032951-036812b2e83c/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.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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= @@ -321,64 +292,42 @@ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -397,7 +346,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go index b06103aec..dd0d1077f 100644 --- a/main.go +++ b/main.go @@ -4,27 +4,21 @@ package main import ( "context" "flag" + "log" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" // Load the providers - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" - goplugin "github.com/hashicorp/go-plugin" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/grpc" - - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" + "github.com/hashicorp/terraform-plugin-mux/tf5muxserver" ) -// gRPC message limit of 64MB -const gRPCLimit = 64 << 20 - func main() { var debugMode bool - flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve") flag.Parse() @@ -32,38 +26,25 @@ func main() { // Anything lower and we risk losing those values to the ether hclog.Default().SetLevel(hclog.Trace) - prov := akamai.Provider( - registry.AllProviders()..., - ) + providers := []func() tfprotov5.ProviderServer{ + akamai.NewPluginProvider(registry.PluginSubproviders()...)().GRPCProvider, + providerserver.NewProtocol5( + akamai.NewFrameworkProvider(registry.FrameworkSubproviders()...)(), + ), + } + + muxServer, err := tf5muxserver.NewMuxServer(context.Background(), providers...) + if err != nil { + log.Fatal(err) + } + + var serveOpts []tf5server.ServeOpt if debugMode { - err := plugin.Debug(context.Background(), akamai.ProviderRegistryPath, - &plugin.ServeOpts{ - ProviderFunc: prov, - }) - if err != nil { - panic(err) - } - } else { - // modified implementation of plugin.Serve() method from terraform SDK - // this is done in order to increase the max GRPC limit from 4MB to 64MB - serveConfig := goplugin.ServeConfig{ - HandshakeConfig: plugin.Handshake, - GRPCServer: func(opts []grpc.ServerOption) *grpc.Server { - return grpc.NewServer(append(opts, - grpc.MaxSendMsgSize(gRPCLimit), - grpc.MaxRecvMsgSize(gRPCLimit))...) - }, - VersionedPlugins: map[int]goplugin.PluginSet{ - 5: { - akamai.ProviderRegistryPath: &tf5server.GRPCProviderPlugin{ - GRPCProvider: func() tfprotov5.ProviderServer { - return schema.NewGRPCProviderServer(prov()) - }, - }, - }, - }, - } - goplugin.Serve(&serveConfig) + serveOpts = append(serveOpts, tf5server.WithManagedDebug()) + } + + if err = tf5server.Serve(akamai.ProviderRegistryPath, muxServer.ProviderServer, serveOpts...); err != nil { + log.Fatal(err) } } diff --git a/pkg/akamai/akamai.go b/pkg/akamai/akamai.go new file mode 100644 index 000000000..682a3bbed --- /dev/null +++ b/pkg/akamai/akamai.go @@ -0,0 +1,21 @@ +// Package akamai allows to initialize and set up Akamai Provider +package akamai + +import ( + "fmt" + + "github.com/akamai/terraform-provider-akamai/v5/version" +) + +const ( + // ProviderRegistryPath is the path for the provider in the terraform registry + ProviderRegistryPath = "registry.terraform.io/akamai/akamai" + + // ProviderName is the legacy name of the provider + // Deprecated: terrform now uses registry paths, the shortest of which would be akamai/akamai" + ProviderName = "terraform-provider-akamai" +) + +func userAgent(terraformVersion string) string { + return fmt.Sprintf("Terraform/%s (+https://www.terraform.io) %s/%s", terraformVersion, ProviderName, version.ProviderVersion) +} diff --git a/pkg/akamai/cache_test.go b/pkg/akamai/cache_test.go deleted file mode 100644 index 7d8c8cc3b..000000000 --- a/pkg/akamai/cache_test.go +++ /dev/null @@ -1,297 +0,0 @@ -package akamai - -import ( - "context" - "regexp" - "testing" - - "github.com/apex/log" - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -type ( - cacheSubprovider struct{} -) - -var ( - testInst *cacheSubprovider - - testAccProviders map[string]func() (*schema.Provider, error) - - testAccProvider *schema.Provider -) - -func init() { - hclog.Default().SetLevel(hclog.Trace) - - testAccProvider = Provider(newCacheProvider())() - testAccProviders = map[string]func() (*schema.Provider, error){ - "akamai": func() (*schema.Provider, error) { - return testAccProvider, nil - }, - } -} - -func configCacheSet() string { - return ` -provider "akamai" { - edgerc = "~/.edgerc" - cache_enabled = true -} - -resource "akamai_cache" "test" { - key = "foo" - value = "bar" -} -` -} - -func configCacheGet() string { - return ` -provider "akamai" { - edgerc = "~/.edgerc" - cache_enabled = true -} - -data "akamai_cache" "test" { - key = "foo" -} -` -} - -func configCacheMiss() string { - return ` -provider "akamai" { - edgerc = "~/.edgerc" - cache_enabled = true -} - -data "akamai_cache" "test" { - key = "bad_key" -} -` -} - -func configCacheGetDisabled() string { - return ` -provider "akamai" { - edgerc = "~/.edgerc" - cache_enabled = false -} - -data "akamai_cache" "test" { - key = "foo" -} -` -} - -func configCacheSetDisabled() string { - return ` -provider "akamai" { - edgerc = "~/.edgerc" - cache_enabled = false -} - -resource "akamai_cache" "test" { - key = "foo" - value = "bar" -} -` -} - -func TestCache_ok(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{ - { - Config: configCacheSet(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("akamai_cache.test", "id"), - ), - }, - { - Config: configCacheGet(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_cache.test", "value", "bar"), - ), - }, - }, - }) -} - -func TestCache_miss(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{ - { - Config: configCacheMiss(), - ExpectError: regexp.MustCompile(`cache entry not found`), - }, - }, - }) -} - -func TestCacheGet_disabled(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{ - { - Config: configCacheGetDisabled(), - ExpectError: regexp.MustCompile(`cache is disabled`), - }, - }, - }) -} - -func TestCacheSet_disabled(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{ - { - Config: configCacheSetDisabled(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("akamai_cache.test", "id"), - ), - ExpectError: regexp.MustCompile(`cache is disabled`), - }, - }, - }) -} - -func newCacheProvider() Subprovider { - testInst = &cacheSubprovider{} - return testInst -} - -func testDatasource() *schema.Resource { - return &schema.Resource{ - ReadContext: testCacheGet, - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Required: true, - }, - "value": { - Type: schema.TypeString, - Computed: true, - }, - }, - } -} - -func testResource() *schema.Resource { - return &schema.Resource{ - CreateContext: testCacheSet, - ReadContext: testCacheGet, - DeleteContext: schema.NoopContext, - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "value": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - } -} - -func testCacheSet(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var diags diag.Diagnostics - - meta := Meta(m) - logger := meta.Log("method", "testCacheSet") - - key := d.Get("key").(string) - value := d.Get("value").(string) - - logger.WithField("key", key).Debug("testing cache set") - - if err := meta.CacheSet(testInst, key, value); err != nil { - diags = append(diags, diag.Diagnostic{ - Severity: diag.Error, - Summary: err.Error(), - }) - - return diags - } - - d.SetId(key) - - return nil -} - -func testCacheGet(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - var diags diag.Diagnostics - - meta := Meta(m) - logger := meta.Log("method", "testCacheGet") - - var value string - key := d.Get("key").(string) - - logger.WithField("key", key).Debug("testing cache get") - - if err := meta.CacheGet(testInst, key, &value); err != nil { - diags = append(diags, diag.Diagnostic{ - Severity: diag.Error, - Summary: err.Error(), - }) - - return diags - } - - err := d.Set("value", value) - if err != nil { - diags = append(diags, diag.Diagnostic{ - Severity: diag.Error, - Summary: err.Error(), - }) - - return diags - } - - d.SetId(key) - - return nil -} - -func (d *cacheSubprovider) Name() string { - return "test" -} - -func (d *cacheSubprovider) Version() string { - return "0.0" -} - -func (d *cacheSubprovider) Schema() map[string]*schema.Schema { - return map[string]*schema.Schema{} -} - -func (d *cacheSubprovider) Resources() map[string]*schema.Resource { - return map[string]*schema.Resource{ - "akamai_cache": testResource(), - } -} - -func (d *cacheSubprovider) DataSources() map[string]*schema.Resource { - return map[string]*schema.Resource{ - "akamai_cache": testDatasource(), - } -} - -func (d *cacheSubprovider) Configure(log log.Interface, _ *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - return nil -} diff --git a/pkg/akamai/configure_context.go b/pkg/akamai/configure_context.go new file mode 100644 index 000000000..fdb7ef75a --- /dev/null +++ b/pkg/akamai/configure_context.go @@ -0,0 +1,49 @@ +package akamai + +import ( + "context" + "os" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/google/uuid" + "github.com/spf13/cast" +) + +type contextConfig struct { + edgercPath string + edgercSection string + edgercConfig *edgegrid.Config + userAgent string + ctx context.Context + requestLimit int + enableCache bool +} + +func configureContext(cfg contextConfig) (*meta.OperationMeta, error) { + operationID := uuid.NewString() + log := logger.FromContext(cfg.ctx, "OperationID", operationID) + + edgerc, err := newEdgegridConfig(cfg.edgercPath, cfg.edgercSection, cfg.edgercConfig) + if err != nil { + return nil, err + } + + sess, err := session.New( + session.WithSigner(edgerc), + session.WithUserAgent(cfg.userAgent), + session.WithLog(log), + session.WithHTTPTracing(cast.ToBool(os.Getenv("AKAMAI_HTTP_TRACE_ENABLED"))), + session.WithRequestLimit(cfg.requestLimit), + ) + if err != nil { + return nil, err + } + + cache.Enable(cfg.enableCache) + + return meta.New(sess, log.HCLog(), operationID) +} diff --git a/pkg/akamai/dummy_provider_test.go b/pkg/akamai/dummy_provider_test.go new file mode 100644 index 000000000..de454f069 --- /dev/null +++ b/pkg/akamai/dummy_provider_test.go @@ -0,0 +1,70 @@ +package akamai_test + +import ( + "context" + + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +// dummy subprovider has only one datasource: "akamai_dummy" +// that itself does nothing and is used only for test purposes +// to trigger provider configuration +type dummy struct { +} + +var _ subprovider.Framework = dummy{} + +// DataSources implements subprovider.Framework. +func (dummy) DataSources() []func() datasource.DataSource { + return []func() datasource.DataSource{ + func() datasource.DataSource { + return dummyDataSource{} + }, + } +} + +// Resources implements subprovider.Framework. +func (dummy) Resources() []func() resource.Resource { + return nil +} + +type dummyDataSource struct{} + +type dummyDataSourceModel struct { + ID types.String `tfsdk:"id"` +} + +var _ datasource.DataSource = dummyDataSource{} + +// Metadata implements datasource.DataSource. +func (dummyDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_dummy" +} + +// Read implements datasource.DataSource. +func (dummyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data dummyDataSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + data.ID = types.StringValue("1") + if resp.Diagnostics.Append(resp.State.Set(ctx, &data)...); resp.Diagnostics.HasError() { + return + } +} + +// Schema implements datasource.DataSource. +func (dummyDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + Description: "id", + }, + }, + } +} diff --git a/pkg/akamai/edgegrid.go b/pkg/akamai/edgegrid.go new file mode 100644 index 000000000..57c8be604 --- /dev/null +++ b/pkg/akamai/edgegrid.go @@ -0,0 +1,48 @@ +package akamai + +import ( + "errors" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegrid" +) + +// ErrWrongEdgeGridConfiguration is returned when the configuration could not be read +var ErrWrongEdgeGridConfiguration = errors.New("error reading Akamai EdgeGrid configuration") + +func newEdgegridConfig(path, section string, config *edgegrid.Config) (*edgegrid.Config, error) { + if (path != "" || section != "") && config != nil { + return nil, fmt.Errorf("edgegrid cannot be simultaneously configured with file and config map") // should not happen as schema guarantees that + } + + var edgerc *edgegrid.Config + if config != nil { + edgerc = config + } else { + edgerc = &edgegrid.Config{} + err := edgerc.FromFile(edgercPathOrDefault(path), edgercSectionOrDefault(section)) + if err != nil { + return nil, fmt.Errorf("%w: %s", ErrWrongEdgeGridConfiguration, err) + } + } + + if err := edgerc.Validate(); err != nil { + return nil, fmt.Errorf("%w: %s", ErrWrongEdgeGridConfiguration, err) + } + + return edgerc, nil +} + +func edgercPathOrDefault(path string) string { + if path == "" { + return edgegrid.DefaultConfigFile + } + return path +} + +func edgercSectionOrDefault(section string) string { + if section == "" { + return edgegrid.DefaultSection + } + return section +} diff --git a/pkg/akamai/edgegrid_test.go b/pkg/akamai/edgegrid_test.go new file mode 100644 index 000000000..f29c28350 --- /dev/null +++ b/pkg/akamai/edgegrid_test.go @@ -0,0 +1,62 @@ +package akamai + +import ( + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegrid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewEdgegridConfig(t *testing.T) { + t.Parallel() + + path := "testdata/edgerc" + section := "default" + config := func() *edgegrid.Config { + return &edgegrid.Config{ + Host: "host.com", + AccessToken: "access_token", + ClientToken: "client_token", + ClientSecret: "client_secret", + MaxBody: 0, + AccountKey: "", + } + } + + t.Run("from config map", func(t *testing.T) { + t.Parallel() + + _, err := newEdgegridConfig("", "", config()) + require.NoError(t, err) + }) + + t.Run("from file", func(t *testing.T) { + t.Parallel() + + _, err := newEdgegridConfig(path, section, nil) + require.NoError(t, err) + }) + + t.Run("invalid arguments", func(t *testing.T) { + t.Parallel() + + _, err := newEdgegridConfig(path, "", config()) + assert.Error(t, err) + + _, err = newEdgegridConfig("", section, config()) + assert.Error(t, err) + + _, err = newEdgegridConfig(path, section, config()) + assert.Error(t, err) + }) + + t.Run("validate fail", func(t *testing.T) { + t.Parallel() + + cfg := config() + cfg.Host = "host.com/" + _, err := newEdgegridConfig("", "", cfg) + assert.Error(t, err) + }) +} diff --git a/pkg/akamai/errors.go b/pkg/akamai/errors.go deleted file mode 100644 index fb831b270..000000000 --- a/pkg/akamai/errors.go +++ /dev/null @@ -1,71 +0,0 @@ -package akamai - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" -) - -type ( - // Error is the akamai error interface - Error struct { - summary string - notFound bool - } -) - -var ( - // ErrDuplicateSchemaKey is returned when a duplicate schema key is detected during merge - ErrDuplicateSchemaKey = &Error{"duplicate schema key", false} - - // ErrCacheEntryNotFound returns a cache entry error - ErrCacheEntryNotFound = &Error{"cache entry not found", true} - - // ErrCacheDisabled is returned when the cache is disabled - ErrCacheDisabled = &Error{"cache is disabled", false} - - // ErrProviderNotLoaded returned and panic'd when a requested provider is not loaded - // Users should never see this, unit tests and sanity checks should pick this up - ErrProviderNotLoaded = &Error{"provider not loaded", false} - - // NoticeDeprecatedUseAlias is returned for schema configurations that are deprecated - // Terraform now supports section aliases - // TODO: Add alias example to the examples directory - NoticeDeprecatedUseAlias = func(n string) string { - return fmt.Sprintf(`The setting %q has been deprecated. See: - https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-configurations`, n) - } -) - -// Diagnostic converts the error a diagnostic -func (e Error) Diagnostic(detail ...string) diag.Diagnostic { - d := diag.Diagnostic{ - Severity: diag.Error, - Summary: e.Error(), - } - - if len(detail) > 0 { - d.Detail = detail[0] - } - - return d -} - -// Diagnostics converts the error to a diag.DiaDiagnostics -func (e Error) Diagnostics(detail ...string) diag.Diagnostics { - return []diag.Diagnostic{e.Diagnostic(detail...)} -} - -// Error implements the error interface -func (e Error) Error() string { - return e.summary -} - -// IsNotFoundError is returned if the error has the notFound flag set -func IsNotFoundError(e error) bool { - if e, ok := e.(*Error); ok { - return e.notFound - } - - return false -} diff --git a/pkg/akamai/framework_provider.go b/pkg/akamai/framework_provider.go new file mode 100644 index 000000000..0c94b8f76 --- /dev/null +++ b/pkg/akamai/framework_provider.go @@ -0,0 +1,176 @@ +package akamai + +import ( + "context" + "os" + "strconv" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegrid" + "github.com/akamai/terraform-provider-akamai/v5/pkg/config" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" + "github.com/akamai/terraform-provider-akamai/v5/version" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var _ provider.Provider = &Provider{} + +// Provider is the implementation of akamai terraform provider which uses terraform-plugin-framework +type Provider struct { + subproviders []subprovider.Framework +} + +// ProviderModel represents the model of Provider configuration +type ProviderModel struct { + EdgercPath types.String `tfsdk:"edgerc"` + EdgercSection types.String `tfsdk:"config_section"` + EdgercConfig types.Set `tfsdk:"config"` + CacheEnabled types.Bool `tfsdk:"cache_enabled"` + RequestLimit types.Int64 `tfsdk:"request_limit"` +} + +// EdgegridConfigModel represents the model of edgegrid configuration block +type EdgegridConfigModel struct { + Host types.String `tfsdk:"host"` + AccessToken types.String `tfsdk:"access_token"` + ClientToken types.String `tfsdk:"client_token"` + ClientSecret types.String `tfsdk:"client_secret"` + MaxBody types.Int64 `tfsdk:"max_body"` + AccountKey types.String `tfsdk:"account_key"` +} + +// NewFrameworkProvider returns a function returning Provider as provider.Provider +func NewFrameworkProvider(subproviders ...subprovider.Framework) func() provider.Provider { + return func() provider.Provider { + return &Provider{ + subproviders: subproviders, + } + } +} + +// Metadata configures provider's metadata +func (p *Provider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) { + resp.TypeName = "akamai" + resp.Version = version.ProviderVersion +} + +// Schema sets provider's configuration schema +func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "edgerc": schema.StringAttribute{ + Optional: true, + }, + "config_section": schema.StringAttribute{ + Description: "The section of the edgerc file to use for configuration", + Optional: true, + }, + "cache_enabled": schema.BoolAttribute{ + Optional: true, + }, + "request_limit": schema.Int64Attribute{ + Description: "The maximum number of API requests to be made per second (0 for no limit)", + Optional: true, + }, + }, + Blocks: map[string]schema.Block{ + "config": config.FrameworkOptions(), + }, + } +} + +// Configure configures provider context at the beginning of the lifecycle +// based on the values user specified in the provider configuration block +func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { + var data ProviderModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + if data.EdgercPath.IsNull() { + if v := os.Getenv("EDGERC"); v != "" { + data.EdgercPath = types.StringValue(v) + } + } + + if data.CacheEnabled.IsNull() { + data.CacheEnabled = types.BoolValue(true) + } + + if data.RequestLimit.IsNull() { + v := os.Getenv("AKAMAI_REQUEST_LIMIT") + if v == "" { + data.RequestLimit = types.Int64Value(0) + } else { + reqLimit, err := strconv.Atoi(v) + if err != nil { + resp.Diagnostics.Append(diag.NewErrorDiagnostic("configuring context failed", err.Error())) + return + } + data.RequestLimit = types.Int64Value(int64(reqLimit)) + } + } + + var edgercConfigModels []EdgegridConfigModel + resp.Diagnostics.Append(data.EdgercConfig.ElementsAs(ctx, &edgercConfigModels, false)...) + if resp.Diagnostics.HasError() { + return + } + + var edgercConfig *edgegrid.Config + if len(edgercConfigModels) > 0 { + edgercConfig = &edgegrid.Config{ + Host: edgercConfigModels[0].Host.ValueString(), + ClientToken: edgercConfigModels[0].ClientToken.ValueString(), + ClientSecret: edgercConfigModels[0].ClientSecret.ValueString(), + AccessToken: edgercConfigModels[0].AccessToken.ValueString(), + AccountKey: edgercConfigModels[0].AccountKey.ValueString(), + MaxBody: int(edgercConfigModels[0].MaxBody.ValueInt64()), + } + } + + meta, err := configureContext(contextConfig{ + edgercPath: data.EdgercPath.ValueString(), + edgercSection: data.EdgercSection.ValueString(), + edgercConfig: edgercConfig, + userAgent: userAgent(req.TerraformVersion), + ctx: ctx, + requestLimit: int(data.RequestLimit.ValueInt64()), + enableCache: data.CacheEnabled.ValueBool(), + }) + if err != nil { + resp.Diagnostics.Append(diag.NewErrorDiagnostic("configuring context failed", err.Error())) + return + } + + resp.DataSourceData = meta + resp.ResourceData = meta +} + +// Resources returns slice of fuctions used to instantiate resource implementations +func (p *Provider) Resources(_ context.Context) []func() resource.Resource { + resources := make([]func() resource.Resource, 0) + + for _, subprovider := range p.subproviders { + resources = append(resources, subprovider.Resources()...) + } + + return resources +} + +// DataSources returns slice of fuctions used to instantiate data source implementations +func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource { + dataSources := make([]func() datasource.DataSource, 0) + + for _, subprovider := range p.subproviders { + dataSources = append(dataSources, subprovider.DataSources()...) + } + + return dataSources +} diff --git a/pkg/akamai/framework_provider_test.go b/pkg/akamai/framework_provider_test.go new file mode 100644 index 000000000..9c991d9aa --- /dev/null +++ b/pkg/akamai/framework_provider_test.go @@ -0,0 +1,314 @@ +package akamai_test + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-mux/tf5muxserver" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/stretchr/testify/assert" +) + +func TestFrameworkProvider(t *testing.T) { + t.Parallel() + resp := provider.SchemaResponse{} + + prov := akamai.NewFrameworkProvider(registry.FrameworkSubproviders()...)() + prov.Schema(context.Background(), provider.SchemaRequest{}, &resp) + + assert.False(t, resp.Diagnostics.HasError()) +} + +func TestFramework_ConfigureCache_EnabledInContext(t *testing.T) { + tests := map[string]struct { + cacheEnabled bool + expectedCacheEnabledState bool + }{ + "cache is enabled": { + cacheEnabled: true, + expectedCacheEnabledState: true, + }, + "cache is not enabled": { + cacheEnabled: false, + expectedCacheEnabledState: false, + }, + } + + for name, testcase := range tests { + t.Run(name, func(t *testing.T) { + cache.Enable(false) + + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV5ProviderFactories: newProtoV5ProviderFactory(dummy{}), + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` + provider "akamai" { + cache_enabled = %v + } + data "akamai_dummy" "test" {} + `, testcase.cacheEnabled), + }, + }, + }) + + assert.Equal(t, testcase.expectedCacheEnabledState, cache.IsEnabled()) + }) + } +} + +func TestFramework_ConfigureEdgercInContext(t *testing.T) { + tests := map[string]struct { + key string + value string + expectedError *regexp.Regexp + }{ + "file with EdgeGrid configuration does not exist": { + key: "edgerc", + value: "not_existing_file_path", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: loading config file: open not_existing_file_path: no such file or directory"), + }, + "config section does not exist": { + key: "config_section", + value: "not_existing_config_section", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: provided config section does not exist: section \"not_existing_config_section\" does not exist"), + }, + "with empty edgerc path, default path is used": { + key: "edgerc", + value: "", + expectedError: nil, + }, + } + + for name, testcase := range tests { + t.Run(name, func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV5ProviderFactories: newProtoV5ProviderFactory(dummy{}), + Steps: []resource.TestStep{ + { + ExpectError: testcase.expectedError, + Config: fmt.Sprintf(` + provider "akamai" { + %v = "%v" + } + data "akamai_dummy" "test" {} + `, testcase.key, testcase.value), + }, + }, + }) + }) + } +} + +func TestFramework_EdgercValidate(t *testing.T) { + + tests := map[string]struct { + expectedError *regexp.Regexp + configSection string + }{ + "no host": { + configSection: "no_host", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: required option is missing from edgerc: \"host\""), + }, + "no client_secret": { + configSection: "no_client_secret", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: required option is missing from edgerc: \"client_secret\""), + }, + "no access_token": { + configSection: "no_access_token", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: required option is missing from edgerc: \"access_token\""), + }, + "no client_token": { + configSection: "no_client_token", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: required option is missing from edgerc: \"client_token\""), + }, + "wrong format of host": { + configSection: "validate_edgerc", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: host must not contain '/' at the end: \"host.com/\""), + }, + } + + for name, testcase := range tests { + t.Run(name, func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV5ProviderFactories: newProtoV5ProviderFactory(dummy{}), + Steps: []resource.TestStep{ + { + ExpectError: testcase.expectedError, + Config: fmt.Sprintf(` + provider "akamai" { + cache_enabled = true + edgerc = "testdata/edgerc" + config_section = "%v" + } + data "akamai_dummy" "test" {} + `, testcase.configSection), + }, + }, + }) + }) + } +} + +func TestFramework_EdgercFromConfig(t *testing.T) { + tests := map[string]struct { + expectedError *regexp.Regexp + clientSecret string + host string + accessToken string + clientToken string + }{ + "valid config": { + host: "host.com", + clientSecret: "client_secret", + accessToken: "access_token", + clientToken: "client_token", + }, + "invalid - empty host": { + clientSecret: "client_secret", + accessToken: "access_token", + clientToken: "client_token", + expectedError: regexp.MustCompile("Attribute host cannot be empty"), + }, + "invalid - empty client_secret": { + host: "host.com", + accessToken: "access_token", + clientToken: "client_token", + expectedError: regexp.MustCompile("Attribute client_secret cannot be empty"), + }, + "invalid - empty access_token": { + host: "host.com", + clientSecret: "client_secret", + clientToken: "client_token", + expectedError: regexp.MustCompile("Attribute access_token cannot be empty"), + }, + "invalid - empty client_token": { + clientSecret: "client_secret", + host: "host.com", + accessToken: "access_token", + expectedError: regexp.MustCompile("Attribute client_token cannot be empty"), + }, + "wrong format of host": { + clientSecret: "client_secret", + host: "host.com/", + accessToken: "access_token", + clientToken: "client_token", + expectedError: regexp.MustCompile("error reading Akamai EdgeGrid configuration: host must not contain '/' at the end: \"host.com/\""), + }, + } + + for name, testcase := range tests { + t.Run(name, func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV5ProviderFactories: newProtoV5ProviderFactory(dummy{}), + Steps: []resource.TestStep{ + { + ExpectError: testcase.expectedError, + Config: fmt.Sprintf(` + provider "akamai" { + config { + client_secret = "%v" + host = "%v" + access_token = "%v" + client_token = "%v" + } + } + data "akamai_dummy" "test" {} + `, testcase.clientSecret, testcase.host, testcase.accessToken, testcase.clientToken), + }, + }, + }) + }) + } +} + +func TestFramework_EdgercFromConfig_missing_required_attributes(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV5ProviderFactories: newProtoV5ProviderFactory(dummy{}), + Steps: []resource.TestStep{ + { + ExpectError: regexp.MustCompile("The argument \"host\" is required, but no definition was found"), + Config: ` + provider "akamai" { + config { + client_secret = "client_secret" + access_token = "access_token" + client_token = "client_token" + } + } + data "akamai_dummy" "test" {}`, + }, + { + ExpectError: regexp.MustCompile("The argument \"client_secret\" is required, but no definition was found"), + Config: ` + provider "akamai" { + config { + host = "host" + access_token = "access_token" + client_token = "client_token" + } + } + data "akamai_dummy" "test" {}`, + }, + { + ExpectError: regexp.MustCompile("The argument \"access_token\" is required, but no definition was found"), + Config: ` + provider "akamai" { + config { + host = "host" + client_secret = "client_secret" + client_token = "client_token" + } + } + data "akamai_dummy" "test" {}`, + }, + { + ExpectError: regexp.MustCompile("The argument \"client_token\" is required, but no definition was found"), + Config: ` + provider "akamai" { + config { + host = "host" + client_secret = "client_secret" + access_token = "access_token" + } + } + data "akamai_dummy" "test" {}`, + }, + }, + }) +} + +func newProtoV5ProviderFactory(subproviders ...subprovider.Framework) map[string]func() (tfprotov5.ProviderServer, error) { + return map[string]func() (tfprotov5.ProviderServer, error){ + "akamai": func() (tfprotov5.ProviderServer, error) { + ctx := context.Background() + providers := []func() tfprotov5.ProviderServer{ + akamai.NewPluginProvider()().GRPCProvider, + providerserver.NewProtocol5( + akamai.NewFrameworkProvider(subproviders...)(), + ), + } + + muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...) + if err != nil { + return nil, err + } + + return muxServer.ProviderServer(), nil + }, + } +} diff --git a/pkg/akamai/log.go b/pkg/akamai/log.go deleted file mode 100644 index 33b9f5837..000000000 --- a/pkg/akamai/log.go +++ /dev/null @@ -1,93 +0,0 @@ -package akamai - -import ( - "context" - "os" - "strings" - - "github.com/apex/log" - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" -) - -type ( - logger struct { - log.Logger - l hclog.Logger - } -) - -// 2020/12/02 11:51:03 -const ( - DefaultTimestampFormat = "2006/01/02 03:04:05" -) - -func init() { - if fmt, ok := os.LookupEnv("AKAMAI_TS_FORMAT"); ok { - hclog.DefaultOptions.TimeFormat = fmt - } else { - hclog.DefaultOptions.TimeFormat = DefaultTimestampFormat - } -} - -// LogFromHCLog returns a new log.Interface from an hclog.Logger -func LogFromHCLog(l hclog.Logger) log.Interface { - const ( - defaultLevel = log.InfoLevel - ) - - rval := &logger{ - Logger: log.Logger{ - Level: defaultLevel, - }, - l: l, - } - - // check for trace as the structured logger does not support trace - // just make it debug to get everything from the provider - lvlString := strings.ToLower(logging.LogLevel()) - if lvlString == "trace" { - lvlString = "debug" - } - - if lvl, err := log.ParseLevel(lvlString); err == nil { - rval.Logger.Level = lvl - } - - rval.Logger.Handler = rval - - return rval -} - -// Log returns a global log object, there is no context like operation id -func Log(args ...interface{}) log.Interface { - return LogFromHCLog(hclog.Default().With(args...)) -} - -// LogFromContext returns the logger from the context -func LogFromContext(ctx context.Context, args ...interface{}) log.Interface { - return LogFromHCLog(hclog.FromContext(ctx).With(args...)) -} - -func (h *logger) HandleLog(e *log.Entry) error { - fields := make([]interface{}, 0) - - for k, v := range e.Fields { - fields = append(fields, k, v) - } - - switch e.Level { - case log.DebugLevel: - h.l.Debug(e.Message, fields...) - case log.InfoLevel: - h.l.Info(e.Message, fields...) - case log.WarnLevel: - h.l.Warn(e.Message, fields...) - case log.ErrorLevel: - h.l.Error(e.Message, fields...) - case log.FatalLevel: - panic(e.Message) - } - - return nil -} diff --git a/pkg/akamai/meta.go b/pkg/akamai/meta.go deleted file mode 100644 index bde642f60..000000000 --- a/pkg/akamai/meta.go +++ /dev/null @@ -1,104 +0,0 @@ -package akamai - -import ( - "encoding/json" - "fmt" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/allegro/bigcache/v2" - "github.com/apex/log" - "github.com/hashicorp/go-hclog" -) - -type ( - - // OperationMeta is the akamai meta object interface - OperationMeta interface { - // Log constructs an hclog sublogger and returns the log.Interface - Log(args ...interface{}) log.Interface - - // OperationID returns the operation id - OperationID() string - - // Session returns the operation API session - Session() session.Session - - // CacheGet returns an object from the cache - CacheGet(prov Subprovider, key string, out interface{}) error - - // CacheSet sets a value in the cache - CacheSet(prov Subprovider, key string, val interface{}) error - } - - meta struct { - operationID string - log hclog.Logger - sess session.Session - cacheEnabled bool - } -) - -// Meta return the meta object interface -func Meta(m interface{}) OperationMeta { - return m.(OperationMeta) -} - -// ProviderLog creates a logger for the provider from the meta -func (m *meta) Log(args ...interface{}) log.Interface { - return LogFromHCLog(m.log.With(args...)) -} - -// OperationID returns the operation id from the meta -func (m *meta) OperationID() string { - return m.operationID -} - -// Session returns the meta session -func (m *meta) Session() session.Session { - return m.sess -} - -func (m *meta) CacheSet(prov Subprovider, key string, val interface{}) error { - log := m.Log("meta", "CacheSet") - - if !m.cacheEnabled { - log.Debug("cache disabled") - return ErrCacheDisabled - } - - key = fmt.Sprintf("%s:%s", key, prov.Name()) - - data, err := json.Marshal(val) - if err != nil { - return fmt.Errorf("failed to marshal object to cache: %w", err) - } - - log.Debugf("cache set for for key %s [%d bytes]", key, len(data)) - - return instance.cache.Set(key, data) -} - -func (m *meta) CacheGet(prov Subprovider, key string, out interface{}) error { - log := m.Log("meta", "CacheGet") - - if !m.cacheEnabled { - log.Debug("cache disabled") - return ErrCacheDisabled - } - - key = fmt.Sprintf("%s:%s", key, prov.Name()) - - data, err := instance.cache.Get(key) - if err != nil { - if err == bigcache.ErrEntryNotFound { - log.Debugf("cache miss for for key %s", key) - - return ErrCacheEntryNotFound - } - return err - } - - log.Debugf("cache get for for key %s: [%d bytes]", key, len(data)) - - return json.Unmarshal(data, out) -} diff --git a/pkg/akamai/plugin_provider.go b/pkg/akamai/plugin_provider.go new file mode 100644 index 000000000..cfcb6292b --- /dev/null +++ b/pkg/akamai/plugin_provider.go @@ -0,0 +1,148 @@ +package akamai + +import ( + "context" + "errors" + "fmt" + "os" + "strconv" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegrid" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/collections" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/config" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" +) + +// NewPluginProvider returns the provider function to terraform +func NewPluginProvider(subprovs ...subprovider.Plugin) plugin.ProviderFunc { + prov := &schema.Provider{ + Schema: map[string]*schema.Schema{ + "edgerc": { + Optional: true, + Type: schema.TypeString, + }, + "config_section": { + Description: "The section of the edgerc file to use for configuration", + Optional: true, + Type: schema.TypeString, + }, + "config": { + Optional: true, + Type: schema.TypeSet, + Elem: config.PluginOptions(), + MaxItems: 1, + ConflictsWith: []string{"edgerc", "config_section"}, + }, + "cache_enabled": { + Optional: true, + Type: schema.TypeBool, + }, + "request_limit": { + Optional: true, + Type: schema.TypeInt, + Description: "The maximum number of API requests to be made per second (0 for no limit)", + }, + }, + ResourcesMap: make(map[string]*schema.Resource), + DataSourcesMap: make(map[string]*schema.Resource), + } + + for _, subprov := range subprovs { + if err := collections.AddMap(prov.ResourcesMap, subprov.Resources()); err != nil { + panic(err) + } + + if err := collections.AddMap(prov.DataSourcesMap, subprov.DataSources()); err != nil { + panic(err) + } + } + + prov.ConfigureContextFunc = configureProviderContext(prov) + + return func() *schema.Provider { + return prov + } +} + +func configureProviderContext(p *schema.Provider) schema.ConfigureContextFunc { + return func(ctx context.Context, d *schema.ResourceData) (any, diag.Diagnostics) { + cacheEnabled, err := tf.GetBoolValue("cache_enabled", d) + if err != nil { + if !errors.Is(err, tf.ErrNotFound) { + return nil, diag.FromErr(err) + } + cacheEnabled = true + } + cache.Enable(cacheEnabled) + + edgercPath, err := tf.GetStringValue("edgerc", d) + if err != nil { + if !errors.Is(err, tf.ErrNotFound) { + return nil, diag.FromErr(err) + } + if v := os.Getenv("EDGERC"); v != "" { + edgercPath = v + } + } + + edgercSection, err := tf.GetStringValue("config_section", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return nil, diag.FromErr(err) + } + + envs, err := tf.GetSetValue("config", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return nil, diag.FromErr(err) + } + + var edgercConfig *edgegrid.Config + if err == nil && len(envs.List()) > 0 { + envsMap, ok := envs.List()[0].(map[string]any) + if !ok { + return nil, diag.FromErr(fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "config", "map[string]any")) + } + edgercConfig = &edgegrid.Config{ + Host: envsMap["host"].(string), + ClientToken: envsMap["client_token"].(string), + ClientSecret: envsMap["client_secret"].(string), + AccessToken: envsMap["access_token"].(string), + AccountKey: envsMap["account_key"].(string), + MaxBody: envsMap["max_body"].(int), + } + } + + requestLimit, err := tf.GetIntValue("request_limit", d) + if err != nil { + if !errors.Is(err, tf.ErrNotFound) { + return nil, diag.FromErr(err) + } + if v := os.Getenv("AKAMAI_REQUEST_LIMIT"); v != "" { + requestLimit, err = strconv.Atoi(v) + if err != nil { + return nil, diag.FromErr(err) + } + } + } + + meta, err := configureContext(contextConfig{ + edgercPath: edgercPath, + edgercSection: edgercSection, + edgercConfig: edgercConfig, + userAgent: userAgent(p.TerraformVersion), + ctx: ctx, + requestLimit: requestLimit, + enableCache: cacheEnabled, + }) + if err != nil { + return nil, diag.FromErr(err) + } + + return meta, nil + } +} diff --git a/pkg/akamai/plugin_provider_test.go b/pkg/akamai/plugin_provider_test.go new file mode 100644 index 000000000..8ea779c7a --- /dev/null +++ b/pkg/akamai/plugin_provider_test.go @@ -0,0 +1,179 @@ +package akamai_test + +import ( + "context" + "fmt" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegrid" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + + // Load the providers + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPluginProvider(t *testing.T) { + t.Parallel() + + provider := akamai.NewPluginProvider(registry.PluginSubproviders()...)() + err := provider.InternalValidate() + assert.NoError(t, err) +} + +func TestConfigureCache_EnabledInContext(t *testing.T) { + tests := map[string]struct { + resourceLocalData *schema.ResourceData + expectedCacheEnabledState bool + }{ + "cache is enabled": { + resourceLocalData: getResourceLocalDataWithBoolValue(t, "cache_enabled", true), + expectedCacheEnabledState: true, + }, + "cache is not enabled": { + resourceLocalData: getResourceLocalDataWithBoolValue(t, "cache_enabled", false), + expectedCacheEnabledState: false, + }, + } + for name, test := range tests { + ctx := context.Background() + t.Run(name, func(t *testing.T) { + + prov := akamai.NewPluginProvider() + _, diagnostics := prov().ConfigureContextFunc(ctx, test.resourceLocalData) + require.False(t, diagnostics.HasError()) + + assert.Equal(t, test.expectedCacheEnabledState, cache.IsEnabled()) + }) + } +} + +func TestConfigureEdgercInContext(t *testing.T) { + tests := map[string]struct { + resourceLocalData *schema.ResourceData + expectedDiagnostics diag.Diagnostics + withError bool + }{ + "file with EdgeGrid configuration does not exist": { + resourceLocalData: getResourceLocalData(t, "edgerc", "not_existing_file_path"), + expectedDiagnostics: diag.Errorf("%s: %s: %s", akamai.ErrWrongEdgeGridConfiguration, edgegrid.ErrLoadingFile, "open not_existing_file_path: no such file or directory"), + withError: true, + }, + "config section does not exist": { + resourceLocalData: getResourceLocalData(t, "config_section", "not_existing_config_section"), + expectedDiagnostics: diag.Errorf("%s: %s: %s", akamai.ErrWrongEdgeGridConfiguration, edgegrid.ErrSectionDoesNotExist, "section \"not_existing_config_section\" does not exist"), + withError: true, + }, + "with empty edgerc path, default path is used": { + resourceLocalData: getResourceLocalData(t, "edgerc", ""), + expectedDiagnostics: diag.Diagnostics(nil), + withError: false, + }, + } + + for name, test := range tests { + ctx := context.Background() + t.Run(name, func(t *testing.T) { + prov := akamai.NewPluginProvider() + meta, diagnostics := prov().ConfigureContextFunc(ctx, test.resourceLocalData) + + if test.withError { + assert.Nil(t, meta) + } else { + assert.NotEmpty(t, meta) + } + assert.Equal(t, test.expectedDiagnostics, diagnostics) + }) + } +} + +func getResourceLocalDataWithBoolValue(t *testing.T, key string, value bool) *schema.ResourceData { + resourceSchema := map[string]*schema.Schema{ + key: { + Type: schema.TypeBool, + }, + } + resourceDataMap := map[string]interface{}{ + key: value, + } + return schema.TestResourceDataRaw(t, resourceSchema, resourceDataMap) +} + +func getResourceLocalData(t *testing.T, key string, value interface{}) *schema.ResourceData { + resourceSchema := map[string]*schema.Schema{ + "cache_enabled": { + Type: schema.TypeBool, + }, + key: { + Type: schema.TypeString, + }, + } + + dataMap := map[string]interface{}{ + "cache_enabled": true, + key: value, + } + return schema.TestResourceDataRaw(t, resourceSchema, dataMap) +} + +func TestEdgercValidate(t *testing.T) { + ctx := context.Background() + resourceSchema := map[string]*schema.Schema{ + "cache_enabled": { + Type: schema.TypeBool, + }, + "edgerc": { + Type: schema.TypeString, + }, + "config_section": { + Type: schema.TypeString, + }, + } + tests := map[string]struct { + expectedError error + configSection string + }{ + "no host": { + configSection: "no_host", + expectedError: fmt.Errorf("%s: \"host\"", edgegrid.ErrRequiredOptionEdgerc), + }, + "no client_secret": { + configSection: "no_client_secret", + expectedError: fmt.Errorf("%s: \"client_secret\"", edgegrid.ErrRequiredOptionEdgerc), + }, + "no access_token": { + configSection: "no_access_token", + expectedError: fmt.Errorf("%s: \"access_token\"", edgegrid.ErrRequiredOptionEdgerc), + }, + "no client_token": { + configSection: "no_client_token", + expectedError: fmt.Errorf("%s: \"client_token\"", edgegrid.ErrRequiredOptionEdgerc), + }, + "wrong format of host": { + configSection: "validate_edgerc", + expectedError: fmt.Errorf("host must not contain '/' at the end: \"host.com/\""), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + resourceDataMap := map[string]interface{}{ + "cache_enabled": true, + "edgerc": "testdata/edgerc", + "config_section": test.configSection, + } + resourceData := schema.TestResourceDataRaw(t, resourceSchema, resourceDataMap) + + prov := akamai.NewPluginProvider() + configuredContext, diagnostics := prov().ConfigureContextFunc(ctx, resourceData) + + assert.Nil(t, configuredContext) + assert.Contains(t, diagnostics[0].Summary, test.expectedError.Error()) + }) + } +} diff --git a/pkg/akamai/provider.go b/pkg/akamai/provider.go deleted file mode 100644 index 5c4923213..000000000 --- a/pkg/akamai/provider.go +++ /dev/null @@ -1,321 +0,0 @@ -// Package akamai allows to initialize and set up Akamai Provider -package akamai - -import ( - "context" - "errors" - "fmt" - "os" - "strconv" - "strings" - "sync" - "time" - - "github.com/allegro/bigcache/v2" - "github.com/apex/log" - "github.com/google/uuid" - "github.com/hashicorp/go-hclog" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" - "github.com/spf13/cast" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgegrid" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/config" - "github.com/akamai/terraform-provider-akamai/v4/version" -) - -const ( - // ProviderRegistryPath is the path for the provider in the terraform registry - ProviderRegistryPath = "registry.terraform.io/akamai/akamai" - - // ProviderName is the legacy name of the provider - // Deprecated: terrform now uses registry paths, the shortest of which would be akamai/akamai" - ProviderName = "terraform-provider-akamai" -) - -// ErrWrongEdgeGridConfiguration is returned when the configuration could not be read -var ErrWrongEdgeGridConfiguration = errors.New("error reading Akamai EdgeGrid configuration") - -type ( - // Subprovider is the interface implemented by the sub providers - Subprovider interface { - // Name should return the name of the subprovider - Name() string - - // Version returns the version of the subprovider - Version() string - - // Schema returns the schemas for the subprovider - Schema() map[string]*schema.Schema - - // Resources returns the resources for the subprovider - Resources() map[string]*schema.Resource - - // DataSources returns the datasources for the subprovider - DataSources() map[string]*schema.Resource - - // Configure returns the subprovider opaque state object - Configure(log.Interface, *schema.ResourceData) diag.Diagnostics - } - - provider struct { - schema.Provider - subs map[string]Subprovider - cache *bigcache.BigCache - } -) - -var ( - once sync.Once - - instance *provider -) - -// Provider returns the provider function to terraform -func Provider(provs ...Subprovider) plugin.ProviderFunc { - once.Do(func() { - instance = &provider{ - Provider: schema.Provider{ - Schema: map[string]*schema.Schema{ - "edgerc": { - Optional: true, - Type: schema.TypeString, - DefaultFunc: schema.EnvDefaultFunc("EDGERC", nil), - }, - "config_section": { - Description: "The section of the edgerc file to use for configuration", - Optional: true, - Type: schema.TypeString, - }, - "config": { - Optional: true, - Type: schema.TypeSet, - Elem: config.Options("config"), - MaxItems: 1, - }, - "cache_enabled": { - Optional: true, - Default: true, - Type: schema.TypeBool, - }, - "request_limit": { - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("AKAMAI_REQUEST_LIMIT", 0), - Type: schema.TypeInt, - Description: "The maximum number of API requests to be made per second (0 for no limit)", - }, - }, - ResourcesMap: make(map[string]*schema.Resource), - DataSourcesMap: make(map[string]*schema.Resource), - ProviderMetaSchema: make(map[string]*schema.Schema), - }, - subs: make(map[string]Subprovider), - } - - cache, err := bigcache.NewBigCache(bigcache.DefaultConfig(10 * time.Minute)) - if err != nil { - panic(err) - } - - instance.cache = cache - - for _, p := range provs { - subSchema, err := mergeSchema(p.Schema(), instance.Schema) - if err != nil { - panic(err) - } - instance.Schema = subSchema - resources, err := mergeResource(p.Resources(), instance.ResourcesMap) - if err != nil { - panic(err) - } - instance.ResourcesMap = resources - dataSources, err := mergeResource(p.DataSources(), instance.DataSourcesMap) - if err != nil { - panic(err) - } - instance.DataSourcesMap = dataSources - - instance.subs[p.Name()] = p - } - - instance.ConfigureContextFunc = func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { - return configureContext(ctx, d) - } - }) - - return func() *schema.Provider { - return &instance.Provider - } -} - -func configureContext(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { - // generate an operation id so we can correlate all calls to this provider - opid := uuid.Must(uuid.NewRandom()).String() - - // create a log from the hclog in the context - log := hclog.FromContext(ctx).With( - "OperationID", opid, - ) - - // configure sub-providers - for _, p := range instance.subs { - if err := p.Configure(LogFromHCLog(log), d); err != nil { - return nil, err - } - } - - cacheEnabled, err := tf.GetBoolValue("cache_enabled", d) - if err != nil && !IsNotFoundError(err) { - return nil, diag.FromErr(err) - } - - edgercOps := []edgegrid.Option{edgegrid.WithEnv(true)} - - edgercPath, err := tf.GetStringValue("edgerc", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return nil, diag.FromErr(err) - } - edgercPath = getEdgercPath(edgercPath) - - edgercOps = append(edgercOps, edgegrid.WithFile(edgercPath)) - edgercSection, err := tf.GetStringValue("config_section", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return nil, diag.FromErr(err) - } - if err == nil { - edgercOps = append(edgercOps, edgegrid.WithSection(edgercSection)) - } - envs, err := tf.GetSetValue("config", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return nil, diag.FromErr(err) - } - if err == nil && len(envs.List()) > 0 { - envsMap, ok := envs.List()[0].(map[string]interface{}) - if !ok { - return nil, diag.FromErr(fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "config", "map[string]interface{}")) - } - err = setEdgegridEnvs(envsMap, edgercSection) - if err != nil { - return nil, diag.FromErr(err) - } - } - - requestLimit, err := tf.GetIntValue("request_limit", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return nil, diag.FromErr(err) - } - - edgerc, err := edgegrid.New(edgercOps...) - if err != nil { - return nil, diag.Errorf("%s: %s", ErrWrongEdgeGridConfiguration, err.Error()) - } - - if err := edgerc.Validate(); err != nil { - return nil, diag.Errorf(err.Error()) - } - - // PROVIDER_VERSION env value must be updated in version file, for every new release. - userAgent := instance.UserAgent(ProviderName, version.ProviderVersion) - logger := LogFromHCLog(log) - logger.Infof("Provider version: %s", version.ProviderVersion) - - logger.Debugf("Using request_limit value %d", requestLimit) - sess, err := session.New( - session.WithSigner(edgerc), - session.WithUserAgent(userAgent), - session.WithLog(logger), - session.WithHTTPTracing(cast.ToBool(os.Getenv("AKAMAI_HTTP_TRACE_ENABLED"))), - session.WithRequestLimit(requestLimit), - ) - if err != nil { - return nil, diag.FromErr(err) - } - - meta := &meta{ - log: log, - operationID: opid, - sess: sess, - cacheEnabled: cacheEnabled, - } - - return meta, nil -} - -func getEdgercPath(edgercPath string) string { - if edgercPath == "" { - edgercPath = edgegrid.DefaultConfigFile - } - return edgercPath -} - -func setEdgegridEnvs(envsMap map[string]interface{}, section string) error { - configEnvs := []string{"ACCESS_TOKEN", "CLIENT_TOKEN", "HOST", "CLIENT_SECRET", "MAX_BODY"} - prefix := "AKAMAI" - if section != "" { - prefix = fmt.Sprintf("%s_%s", prefix, strings.ToUpper(section)) - } - for _, env := range configEnvs { - var value string - var ok bool - switch env { - case "ACCESS_TOKEN": - value, ok = envsMap["access_token"].(string) - if !ok { - return fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "access_token", "string") - } - case "CLIENT_TOKEN": - value, ok = envsMap["client_token"].(string) - if !ok { - return fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "client_token", "string") - } - case "HOST": - value, ok = envsMap["host"].(string) - if !ok { - return fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "host", "string") - } - case "CLIENT_SECRET": - value, ok = envsMap["client_secret"].(string) - if !ok { - return fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "client_secret", "string") - } - case "MAX_BODY": - maxBody, ok := envsMap["max_body"].(int) - if !ok { - return fmt.Errorf("%w: %s, %q", tf.ErrInvalidType, "max_body", "int") - } - value = strconv.Itoa(maxBody) - } - env = fmt.Sprintf("%s_%s", prefix, env) - if os.Getenv(env) != "" { - continue - } - if err := os.Setenv(env, value); err != nil { - return err - } - } - return nil -} - -func mergeSchema(from, to map[string]*schema.Schema) (map[string]*schema.Schema, error) { - for k, v := range from { - if _, ok := to[k]; ok { - return nil, fmt.Errorf("%w: %s", ErrDuplicateSchemaKey, k) - } - to[k] = v - } - return to, nil -} - -func mergeResource(from, to map[string]*schema.Resource) (map[string]*schema.Resource, error) { - for k, v := range from { - if _, ok := to[k]; ok { - return nil, fmt.Errorf("%w: %s", ErrDuplicateSchemaKey, k) - } - to[k] = v - } - return to, nil -} diff --git a/pkg/akamai/provider_test.go b/pkg/akamai/provider_test.go deleted file mode 100644 index c03c01a4d..000000000 --- a/pkg/akamai/provider_test.go +++ /dev/null @@ -1,476 +0,0 @@ -package akamai - -import ( - "context" - "errors" - "fmt" - "os" - "strings" - "testing" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgegrid" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/require" - "github.com/tj/assert" -) - -func unsetEnvs(t *testing.T) map[string]string { - configVars := map[string]struct{}{ - "AKAMAI_ACCESS_TOKEN": {}, - "AKAMAI_CLIENT_TOKEN": {}, - "AKAMAI_CLIENT_SECRET": {}, - "AKAMAI_HOST": {}, - "AKAMAI_MAX_BODY": {}, - } - existingEnvs := make(map[string]string) - - globalEnvs := os.Environ() - for _, env := range globalEnvs { - envKeyValue := strings.SplitN(env, "=", 2) - if _, ok := configVars[envKeyValue[0]]; ok { - existingEnvs[envKeyValue[0]] = envKeyValue[1] - } - } - for key := range existingEnvs { - err := os.Unsetenv(key) - assert.NoError(t, err) - } - return existingEnvs -} - -func restoreEnvs(t *testing.T, envs map[string]string) { - for k, v := range envs { - err := os.Setenv(k, v) - assert.NoError(t, err) - } -} - -func TestSetEdgegridEnvs(t *testing.T) { - tests := map[string]struct { - givenMap map[string]interface{} - givenSection string - setEnvs map[string]string - expectedEnvs map[string]string - }{ - "no section provided": { - givenMap: map[string]interface{}{ - "access_token": "test_access_token", - "client_token": "test_client_token", - "client_secret": "test_client_secret", - "host": "test_host", - "max_body": 123, - }, - expectedEnvs: map[string]string{ - "AKAMAI_ACCESS_TOKEN": "test_access_token", - "AKAMAI_CLIENT_TOKEN": "test_client_token", - "AKAMAI_CLIENT_SECRET": "test_client_secret", - "AKAMAI_HOST": "test_host", - "AKAMAI_MAX_BODY": "123", - }, - }, - "custom section provided": { - givenMap: map[string]interface{}{ - "access_token": "test_access_token", - "client_token": "test_client_token", - "client_secret": "test_client_secret", - "host": "test_host", - "max_body": 123, - }, - givenSection: "test", - expectedEnvs: map[string]string{ - "AKAMAI_TEST_ACCESS_TOKEN": "test_access_token", - "AKAMAI_TEST_CLIENT_TOKEN": "test_client_token", - "AKAMAI_TEST_CLIENT_SECRET": "test_client_secret", - "AKAMAI_TEST_HOST": "test_host", - "AKAMAI_TEST_MAX_BODY": "123", - }, - }, - "envs are already set": { - givenMap: map[string]interface{}{ - "access_token": "test_access_token", - "client_token": "test_client_token", - "client_secret": "test_client_secret", - "host": "test_host", - "max_body": 123, - }, - givenSection: "test", - setEnvs: map[string]string{ - "AKAMAI_TEST_ACCESS_TOKEN": "existing_access_token", - "AKAMAI_TEST_CLIENT_TOKEN": "existing_client_token", - "AKAMAI_TEST_CLIENT_SECRET": "existing_client_secret", - "AKAMAI_TEST_HOST": "existing_host", - "AKAMAI_TEST_MAX_BODY": "321", - }, - expectedEnvs: map[string]string{ - "AKAMAI_TEST_ACCESS_TOKEN": "existing_access_token", - "AKAMAI_TEST_CLIENT_TOKEN": "existing_client_token", - "AKAMAI_TEST_CLIENT_SECRET": "existing_client_secret", - "AKAMAI_TEST_HOST": "existing_host", - "AKAMAI_TEST_MAX_BODY": "321", - }, - }, - } - - for name, test := range tests { - t.Run(name, func(t *testing.T) { - existingEnvs := unsetEnvs(t) - defer restoreEnvs(t, existingEnvs) - - currentEnvs := make(map[string]string, len(test.expectedEnvs)) - for k := range test.expectedEnvs { - currentEnvs[k] = os.Getenv(k) - err := os.Unsetenv(k) - require.NoError(t, err) - } - defer func() { - for k, v := range currentEnvs { - err := os.Setenv(k, v) - require.NoError(t, err) - } - }() - for k, v := range test.setEnvs { - require.NoError(t, os.Setenv(k, v)) - } - - err := setEdgegridEnvs(test.givenMap, test.givenSection) - require.NoError(t, err) - for k, v := range test.expectedEnvs { - assert.Equal(t, v, os.Getenv(k)) - } - }) - } -} - -func TestSetWrongTypeForEdgegridEnvs(t *testing.T) { - - tests := map[string]struct { - environmentVars map[string]interface{} - }{ - "nil value for access_token": { - environmentVars: map[string]interface{}{"access_token": nil}, - }, - "nil value for client_token": { - environmentVars: map[string]interface{}{"client_token": nil}, - }, - "nil value for host": { - environmentVars: map[string]interface{}{"host": nil}, - }, - "nil value for client_secret": { - environmentVars: map[string]interface{}{"client_secret": nil}, - }, - "wrong type of max_body value": { - environmentVars: map[string]interface{}{"max_body": "not a number"}, - }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - err := setEdgegridEnvs(test.environmentVars, "some section") - assert.True(t, errors.Is(err, tf.ErrInvalidType)) - }) - } -} - -func TestConfigureCache_EnabledInContext(t *testing.T) { - tests := map[string]struct { - resourceLocalData *schema.ResourceData - expectedMeta meta - expectedDiagnostics diag.Diagnostics - }{ - "cache is enabled": { - resourceLocalData: getResourceLocalDataWithBoolValue(t, "cache_enabled", true), - expectedMeta: meta{ - cacheEnabled: true, - }, - expectedDiagnostics: diag.Diagnostics(nil), - }, - "cache is not enabled": { - resourceLocalData: getResourceLocalDataWithBoolValue(t, "cache_enabled", false), - expectedMeta: meta{ - cacheEnabled: false, - }, - expectedDiagnostics: diag.Diagnostics(nil), - }, - } - for name, test := range tests { - ctx := context.Background() - t.Run(name, func(t *testing.T) { - - configuredContext, diagnostics := configureContext(ctx, test.resourceLocalData) - metaCtx := configuredContext.(*meta) - - assert.Equal(t, test.expectedDiagnostics, diagnostics) - assert.Equal(t, test.expectedMeta.cacheEnabled, metaCtx.cacheEnabled) - assert.NotEmpty(t, metaCtx.log) - assert.NotEmpty(t, metaCtx.operationID) - assert.NotEmpty(t, metaCtx.sess) - }) - } -} - -func TestConfigureEdgercInContext(t *testing.T) { - tests := map[string]struct { - resourceLocalData *schema.ResourceData - expectedDiagnostics diag.Diagnostics - withError bool - }{ - "file with EdgeGrid configuration does not exist": { - resourceLocalData: getResourceLocalData(t, "edgerc", "not_existing_file_path"), - expectedDiagnostics: diag.Errorf("%s: %s: %s: %s", ErrWrongEdgeGridConfiguration, "unable to load config from environment or .edgerc file", edgegrid.ErrLoadingFile, "open not_existing_file_path: no such file or directory"), - withError: true, - }, - "config section does not exist": { - resourceLocalData: getResourceLocalData(t, "config_section", "not_existing_config_section"), - expectedDiagnostics: diag.Errorf("%s: %s: %s: %s", ErrWrongEdgeGridConfiguration, "unable to load config from environment or .edgerc file", edgegrid.ErrSectionDoesNotExist, "section \"not_existing_config_section\" does not exist"), - withError: true, - }, - "with empty edgerc path, default path is used": { - resourceLocalData: getResourceLocalData(t, "edgerc", ""), - expectedDiagnostics: diag.Diagnostics(nil), - withError: false, - }, - } - - for name, test := range tests { - ctx := context.Background() - t.Run(name, func(t *testing.T) { - existingEnvs := unsetEnvs(t) - defer restoreEnvs(t, existingEnvs) - - meta, diagnostics := configureContext(ctx, test.resourceLocalData) - if test.withError { - assert.Nil(t, meta) - } else { - assert.NotEmpty(t, meta) - } - assert.Equal(t, test.expectedDiagnostics, diagnostics) - }) - } -} - -func getResourceLocalDataWithBoolValue(t *testing.T, key string, value bool) *schema.ResourceData { - resourceSchema := map[string]*schema.Schema{ - key: { - Type: schema.TypeBool, - }, - } - resourceDataMap := map[string]interface{}{ - key: value, - } - return schema.TestResourceDataRaw(t, resourceSchema, resourceDataMap) -} - -func getResourceLocalData(t *testing.T, key string, value interface{}) *schema.ResourceData { - resourceSchema := map[string]*schema.Schema{ - "cache_enabled": { - Type: schema.TypeBool, - }, - key: { - Type: schema.TypeString, - }, - } - - dataMap := map[string]interface{}{ - "cache_enabled": true, - key: value, - } - return schema.TestResourceDataRaw(t, resourceSchema, dataMap) -} - -func TestGetEdgercPath(t *testing.T) { - tests := map[string]struct { - edgercPath string - expectedEdgercPath string - }{ - "empty edgerc path": { - edgercPath: "", - expectedEdgercPath: edgegrid.DefaultConfigFile, - }, - "existing edgerc path": { - edgercPath: "../.edgerc", - expectedEdgercPath: "../.edgerc", - }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - edgercPath := getEdgercPath(test.edgercPath) - assert.Equal(t, test.expectedEdgercPath, edgercPath) - }) - } -} - -func TestEdgercValidate(t *testing.T) { - ctx := context.Background() - resourceSchema := map[string]*schema.Schema{ - "cache_enabled": { - Type: schema.TypeBool, - }, - "edgerc": { - Type: schema.TypeString, - }, - "config_section": { - Type: schema.TypeString, - }, - } - tests := map[string]struct { - expectedError error - configSection string - }{ - "no host": { - configSection: "no_host", - expectedError: fmt.Errorf("%s: \"host\"", edgegrid.ErrRequiredOptionEdgerc), - }, - "no client_secret": { - configSection: "no_client_secret", - expectedError: fmt.Errorf("%s: \"client_secret\"", edgegrid.ErrRequiredOptionEdgerc), - }, - "no access_token": { - configSection: "no_access_token", - expectedError: fmt.Errorf("%s: \"access_token\"", edgegrid.ErrRequiredOptionEdgerc), - }, - "no client_token": { - configSection: "no_client_token", - expectedError: fmt.Errorf("%s: \"client_token\"", edgegrid.ErrRequiredOptionEdgerc), - }, - "wrong format of host": { - configSection: "validate_edgerc", - expectedError: fmt.Errorf("host must not contain '/' at the end: \"host.com/\""), - }, - } - - for name, test := range tests { - t.Run(name, func(t *testing.T) { - resourceDataMap := map[string]interface{}{ - "cache_enabled": true, - "edgerc": "testdata/edgerc", - "config_section": test.configSection, - } - resourceData := schema.TestResourceDataRaw(t, resourceSchema, resourceDataMap) - configuredContext, diagnostics := configureContext(ctx, resourceData) - - assert.Nil(t, configuredContext) - assert.Contains(t, diagnostics[0].Summary, test.expectedError.Error()) - }) - } -} - -func Test_mergeSchema(t *testing.T) { - tests := map[string]struct { - from map[string]*schema.Schema - to map[string]*schema.Schema - expectedSchemaMap map[string]*schema.Schema - errorExpected bool - }{ - "both schemas are the same": { - from: getFirstSchema(), - to: getFirstSchema(), - errorExpected: true, - }, - "two different schemas": { - from: getFirstSchema(), - to: getSecondSchema(), - expectedSchemaMap: map[string]*schema.Schema{ - "test element": { - Optional: true, - Type: schema.TypeString, - Description: "element with type string", - }, - "different test element": { - Optional: true, - Type: schema.TypeBool, - Description: "element with type bool", - }, - }, - errorExpected: false, - }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - mergedSchema, err := mergeSchema(test.from, test.to) - if test.errorExpected { - assert.Nil(t, mergedSchema) - assert.True(t, errors.Is(err, ErrDuplicateSchemaKey)) - } else { - assert.Nil(t, err) - assert.Equal(t, test.expectedSchemaMap, mergedSchema) - } - }) - } -} - -func Test_mergeResource(t *testing.T) { - tests := map[string]struct { - from map[string]*schema.Resource - to map[string]*schema.Resource - expectedResourceMap map[string]*schema.Resource - errorExpected bool - }{ - "both resources are the same": { - from: map[string]*schema.Resource{ - "some resource": { - Schema: getFirstSchema(), - }, - }, - to: map[string]*schema.Resource{ - "some resource": { - Schema: getFirstSchema(), - }, - }, - errorExpected: true, - }, - "two different resources": { - from: map[string]*schema.Resource{ - "first resource": { - Schema: getFirstSchema(), - }, - }, - to: map[string]*schema.Resource{ - "second resource": { - Schema: getSecondSchema(), - }, - }, - expectedResourceMap: map[string]*schema.Resource{ - "first resource": { - Schema: getFirstSchema(), - }, - "second resource": { - Schema: getSecondSchema(), - }, - }, - errorExpected: false, - }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - mergedResource, err := mergeResource(test.from, test.to) - if test.errorExpected { - assert.Nil(t, mergedResource) - assert.True(t, errors.Is(err, ErrDuplicateSchemaKey)) - } else { - assert.Nil(t, err) - assert.Equal(t, test.expectedResourceMap, mergedResource) - } - }) - } -} - -func getFirstSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "test element": { - Optional: true, - Type: schema.TypeString, - Description: "element with type string", - }, - } -} - -func getSecondSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "different test element": { - Optional: true, - Type: schema.TypeBool, - Description: "element with type bool", - }, - } -} diff --git a/pkg/akamai/testdata/edgerc b/pkg/akamai/testdata/edgerc index b02854777..27a28ef11 100644 --- a/pkg/akamai/testdata/edgerc +++ b/pkg/akamai/testdata/edgerc @@ -1,3 +1,9 @@ +[default] +client_secret = client_secret +host = host.com +access_token = access_token +client_token = client_token + [validate_edgerc] client_secret = client_secret host = host.com/ diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go new file mode 100644 index 000000000..8fed10c9b --- /dev/null +++ b/pkg/cache/cache.go @@ -0,0 +1,104 @@ +// Package cache contains provider's cache instance +package cache + +import ( + "encoding/json" + "errors" + "fmt" + "time" + + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/allegro/bigcache/v2" +) + +var ( + // ErrDisabled is returned when Get or Set is called on a disabled cache + ErrDisabled = errors.New("cache disabled") + // ErrEntryNotFound is returned when object under the given key does not exist + ErrEntryNotFound = errors.New("cache entry not found") +) + +var defaultCache = newCache(10 * time.Minute) + +type cache struct { + cache *bigcache.BigCache + enabled bool +} + +// BucketName can be used as a bucket argument to Set and Get functions +type BucketName string + +// Name returns BucketID as a string +func (b BucketName) Name() string { + return string(b) +} + +// Bucket defines a contract for a bucket used to form a key +type Bucket interface { + Name() string +} + +func newCache(eviction time.Duration) *cache { + c, err := bigcache.NewBigCache(bigcache.DefaultConfig(eviction)) + if err != nil { + panic(err) + } + + return &cache{cache: c} +} + +// Enable is used to enable or disable cache +func Enable(enabled bool) { + defaultCache.enabled = enabled +} + +// IsEnabled returns whether cache is enabled +func IsEnabled() bool { + return defaultCache.enabled +} + +// Set sets the given value under the key in cache +func Set(bucket Bucket, key string, val any) error { + log := logger.Get("cache", "CacheSet") + + if !defaultCache.enabled { + log.Debug("cache disabled") + return ErrDisabled + } + + key = fmt.Sprintf("%s:%s", key, bucket.Name()) + + data, err := json.Marshal(val) + if err != nil { + return fmt.Errorf("failed to marshal object to cache: %w", err) + } + + log.Debugf("cache set for for key %s [%d bytes]", key, len(data)) + + return defaultCache.cache.Set(key, data) +} + +// Get returns value stored under the key from cache and writes it into out +func Get(bucket Bucket, key string, out any) error { + log := logger.Get("cache", "CacheGet") + + if !defaultCache.enabled { + log.Debug("cache disabled") + return ErrDisabled + } + + key = fmt.Sprintf("%s:%s", key, bucket.Name()) + + data, err := defaultCache.cache.Get(key) + if err != nil { + if errors.Is(err, bigcache.ErrEntryNotFound) { + log.Debugf("cache miss for key %s", key) + return ErrEntryNotFound + } + return err + } + + log.Debugf("cache get for for key %s: [%d bytes]", key, len(data)) + + return json.Unmarshal(data, out) +} diff --git a/pkg/cache/cache_test.go b/pkg/cache/cache_test.go new file mode 100644 index 000000000..2086bf2dd --- /dev/null +++ b/pkg/cache/cache_test.go @@ -0,0 +1,45 @@ +package cache + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type TestObject struct { + ID string +} + +func TestCache(t *testing.T) { + bucket := BucketName("testBucket") + key := "testKey" + object := TestObject{"1234"} + + err := Set(bucket, key, object) + assert.ErrorIs(t, err, ErrDisabled) + + err = Get(bucket, key, nil) + assert.ErrorIs(t, err, ErrDisabled) + + Enable(true) + + err = Set(bucket, key, object) + require.NoError(t, err) + + var out TestObject + err = Get(bucket, key, &out) + require.NoError(t, err) + assert.Equal(t, object, out) + + err = Get(bucket, key+"5", &out) + assert.ErrorIs(t, err, ErrEntryNotFound) + + Enable(false) + + err = Set(bucket, key, object) + assert.ErrorIs(t, err, ErrDisabled) + + err = Get(bucket, key, nil) + assert.ErrorIs(t, err, ErrDisabled) +} diff --git a/pkg/common/collections/collections.go b/pkg/common/collections/collections.go new file mode 100644 index 000000000..056220fb6 --- /dev/null +++ b/pkg/common/collections/collections.go @@ -0,0 +1,2 @@ +// Package collections contains useful functions for working with collections +package collections diff --git a/pkg/common/collections/map.go b/pkg/common/collections/map.go new file mode 100644 index 000000000..0b9ea8857 --- /dev/null +++ b/pkg/common/collections/map.go @@ -0,0 +1,17 @@ +package collections + +import "errors" + +// ErrDuplicateKey is returned when the key already exists in the map +var ErrDuplicateKey = errors.New("duplicate key") + +// AddMap populates 'to' with elements found in 'from' +func AddMap[K comparable, V any](to, from map[K]V) error { + for k, v := range from { + if _, ok := to[k]; ok { + return ErrDuplicateKey + } + to[k] = v + } + return nil +} diff --git a/pkg/common/collections/map_test.go b/pkg/common/collections/map_test.go new file mode 100644 index 000000000..d48acba7f --- /dev/null +++ b/pkg/common/collections/map_test.go @@ -0,0 +1,43 @@ +package collections + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestAddMap(t *testing.T) { + to := map[int]string{ + 0: "a", + 2: "c", + } + + from := map[int]string{ + 1: "b", + 3: "d", + } + + err := AddMap(to, from) + require.NoError(t, err) + + assert.Contains(t, to, 1) + assert.Equal(t, "b", to[1]) + + assert.Contains(t, to, 3) + assert.Equal(t, "d", to[3]) +} + +func TestAddMap_duplicate_key(t *testing.T) { + to := map[int]string{ + 0: "a", + 2: "c", + } + + from := map[int]string{ + 0: "b", + } + + err := AddMap(to, from) + assert.ErrorIs(t, err, ErrDuplicateKey) +} diff --git a/pkg/akamai/test_helpers.go b/pkg/common/testutils/testutils.go similarity index 61% rename from pkg/akamai/test_helpers.go rename to pkg/common/testutils/testutils.go index 4094ae9eb..ac1bb3c39 100644 --- a/pkg/akamai/test_helpers.go +++ b/pkg/common/testutils/testutils.go @@ -1,19 +1,20 @@ -package akamai +// Package testutils gathers reusable pieces useful for testing +package testutils import ( "fmt" "os" ) -// TFTestTempDir specifies the location of tmp directory which will be used by provider SDK's testing framework -const TFTestTempDir = "./test_tmp" +// tfTestTempDir specifies the location of tmp directory which will be used by provider SDK's testing framework +const tfTestTempDir = "./test_tmp" // TFTestSetup contains common setup for tests in all subproviders func TFTestSetup() error { - if err := os.MkdirAll(TFTestTempDir, 0755); err != nil { + if err := os.MkdirAll(tfTestTempDir, 0755); err != nil { return fmt.Errorf("test setup failed: %s", err) } - if err := os.Setenv("TF_ACC_TEMP_DIR", TFTestTempDir); err != nil { + if err := os.Setenv("TF_ACC_TEMP_DIR", tfTestTempDir); err != nil { return fmt.Errorf("test setup failed: %s", err) } return nil @@ -21,7 +22,7 @@ func TFTestSetup() error { // TFTestTeardown contains common teardown for tests in all subproviders func TFTestTeardown() error { - if err := os.RemoveAll(TFTestTempDir); err != nil { + if err := os.RemoveAll(tfTestTempDir); err != nil { return fmt.Errorf("test teardown failed: %s", err) } if err := os.Unsetenv("TF_ACC_TEMP_DIR"); err != nil { diff --git a/pkg/common/tf/validators/string.go b/pkg/common/tf/validators/string.go new file mode 100644 index 000000000..02da37513 --- /dev/null +++ b/pkg/common/tf/validators/string.go @@ -0,0 +1,44 @@ +package validators + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.String = notEmptyStringValidator{} + +// notEmptyValidator validates that a string Attribute's length is at least a certain value. +type notEmptyStringValidator struct{} + +// Description describes the validation in plain text formatting. +func (v notEmptyStringValidator) Description(_ context.Context) string { + return "Attribute cannot be empty" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v notEmptyStringValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// ValidateString performs the validation. +func (v notEmptyStringValidator) ValidateString(ctx context.Context, request validator.StringRequest, response *validator.StringResponse) { + if request.ConfigValue.IsNull() || request.ConfigValue.IsUnknown() { + return + } + + value := request.ConfigValue.ValueString() + if value != "" { + return + } + + attr, _ := request.PathExpression.Steps().LastStep() + response.Diagnostics.AddAttributeError(request.Path, v.Description(ctx), fmt.Sprintf("Attribute %s cannot be empty", attr)) +} + +// NotEmptyString returns an validator which ensures that any configured +// attribute value is not an empty string. +func NotEmptyString() validator.String { + return notEmptyStringValidator{} +} diff --git a/pkg/common/tf/validators/validators.go b/pkg/common/tf/validators/validators.go new file mode 100644 index 000000000..8a77ed510 --- /dev/null +++ b/pkg/common/tf/validators/validators.go @@ -0,0 +1,2 @@ +// Package validators contains custom terraform schema validators +package validators diff --git a/pkg/config/config.go b/pkg/config/config.go index 16d26e7bb..9e785c0f5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -2,94 +2,70 @@ package config import ( - "errors" - "os" - "strings" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf/validators" + frameworkSchema "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + pluginSchema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Options initializes and returns terraform.Resource with credentials for given section -func Options(section string) *schema.Resource { - section = strings.ToUpper(section) - - return &schema.Resource{ - Schema: map[string]*schema.Schema{ +// PluginOptions returns edgegrid config schema for terraform-plugin-sdk +func PluginOptions() *pluginSchema.Resource { + return &pluginSchema.Resource{ + Schema: map[string]*pluginSchema.Schema{ "host": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: func() (interface{}, error) { - if v := os.Getenv("AKAMAI_" + section + "_HOST"); v != "" { - return v, nil - } else if v := os.Getenv("AKAMAI_HOST"); v != "" { - return v, nil - } - return nil, errors.New("host not set") - }, + Type: pluginSchema.TypeString, + Required: true, }, "access_token": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: func() (interface{}, error) { - if v := os.Getenv("AKAMAI_" + section + "_ACCESS_TOKEN"); v != "" { - return v, nil - } else if v := os.Getenv("AKAMAI_ACCESS_TOKEN"); v != "" { - return v, nil - } - - return nil, errors.New("access_token not set") - }, + Type: pluginSchema.TypeString, + Required: true, }, "client_token": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: func() (interface{}, error) { - if v := os.Getenv("AKAMAI_" + section + "_CLIENT_TOKEN"); v != "" { - return v, nil - } else if v := os.Getenv("AKAMAI_CLIENT_TOKEN"); v != "" { - return v, nil - } - - return nil, errors.New("client_token not set") - }, + Type: pluginSchema.TypeString, + Required: true, }, "client_secret": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: func() (interface{}, error) { - if v := os.Getenv("AKAMAI_" + section + "_CLIENT_SECRET"); v != "" { - return v, nil - } else if v := os.Getenv("AKAMAI_CLIENT_SECRET"); v != "" { - return v, nil - } - - return nil, errors.New("client_secret not set") - }, + Type: pluginSchema.TypeString, + Required: true, }, "max_body": { - Type: schema.TypeInt, + Type: pluginSchema.TypeInt, Optional: true, - DefaultFunc: func() (interface{}, error) { - if v := os.Getenv("AKAMAI_" + section + "_MAX_SIZE"); v != "" { - return v, nil - } else if v := os.Getenv("AKAMAI_MAX_SIZE"); v != "" { - return v, nil - } - - return 131072, nil - }, }, "account_key": { - Type: schema.TypeString, + Type: pluginSchema.TypeString, Optional: true, - DefaultFunc: func() (interface{}, error) { - if v := os.Getenv("AKAMAI_" + section + "_ACCOUNT_KEY"); v != "" { - return v, nil - } else if v := os.Getenv("AKAMAI_ACCOUNT_KEY"); v != "" { - return v, nil - } + }, + }, + } +} - return "", nil +// FrameworkOptions returns edgegrid config schema for terraform-plugin-framework +func FrameworkOptions() frameworkSchema.SetNestedBlock { + return frameworkSchema.SetNestedBlock{ + NestedObject: frameworkSchema.NestedBlockObject{ + Attributes: map[string]frameworkSchema.Attribute{ + "host": frameworkSchema.StringAttribute{ + Required: true, + Validators: []validator.String{validators.NotEmptyString()}, + }, + "access_token": frameworkSchema.StringAttribute{ + Required: true, + Validators: []validator.String{validators.NotEmptyString()}, + }, + "client_token": frameworkSchema.StringAttribute{ + Required: true, + Validators: []validator.String{validators.NotEmptyString()}, + }, + "client_secret": frameworkSchema.StringAttribute{ + Required: true, + Validators: []validator.String{validators.NotEmptyString()}, + }, + "max_body": frameworkSchema.Int64Attribute{ + Optional: true, + }, + "account_key": frameworkSchema.StringAttribute{ + Optional: true, }, }, }, diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go new file mode 100644 index 000000000..981f1776e --- /dev/null +++ b/pkg/logger/logger.go @@ -0,0 +1,96 @@ +// Package logger contains types and functions related to logging in terraform provider +package logger + +import ( + "context" + "os" + "strings" + + "github.com/apex/log" + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" +) + +// Logger is a wrapper over log.Logger and hclog.Logger +type Logger struct { + log.Logger + hclog hclog.Logger +} + +const defaultTimestampFormat = "2006/01/02 03:04:05" + +func init() { + if fmt, ok := os.LookupEnv("AKAMAI_TS_FORMAT"); ok { + hclog.DefaultOptions.TimeFormat = fmt + } else { + hclog.DefaultOptions.TimeFormat = defaultTimestampFormat + } +} + +// HCLog returns Logger's hclog +func (l *Logger) HCLog() hclog.Logger { + return l.hclog +} + +// FromHCLog returns a new Logger from a hclog.Logger +func FromHCLog(hclog hclog.Logger) *Logger { + const ( + defaultLevel = log.InfoLevel + ) + + rval := &Logger{ + Logger: log.Logger{ + Level: defaultLevel, + }, + hclog: hclog, + } + + // check for trace as the structured logger does not support trace + // just make it debug to get everything from the provider + lvlString := strings.ToLower(logging.LogLevel()) + if lvlString == "trace" { + lvlString = "debug" + } + + if lvl, err := log.ParseLevel(lvlString); err == nil { + rval.Logger.Level = lvl + } + + rval.Logger.Handler = rval + + return rval +} + +// Get returns a global log object, there is no context like operation id +func Get(args ...interface{}) *Logger { + return FromHCLog(hclog.Default().With(args...)) +} + +// FromContext returns the logger from the context +func FromContext(ctx context.Context, args ...interface{}) *Logger { + return FromHCLog(hclog.FromContext(ctx).With(args...)) +} + +// HandleLog implements the logic for handling log events +func (l *Logger) HandleLog(e *log.Entry) error { + fields := make([]interface{}, 0) + + for k, v := range e.Fields { + fields = append(fields, k, v) + } + + switch e.Level { + case log.DebugLevel: + l.hclog.Debug(e.Message, fields...) + case log.InfoLevel: + l.hclog.Info(e.Message, fields...) + case log.WarnLevel: + l.hclog.Warn(e.Message, fields...) + case log.ErrorLevel: + l.hclog.Error(e.Message, fields...) + case log.FatalLevel: + panic(e.Message) + } + + return nil +} diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go new file mode 100644 index 000000000..1c3b772b4 --- /dev/null +++ b/pkg/meta/meta.go @@ -0,0 +1,80 @@ +// Package meta contains code related to provider's meta information +package meta + +import ( + "errors" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/apex/log" + "github.com/hashicorp/go-hclog" +) + +var _ Meta = &OperationMeta{} + +type ( + // Meta is the akamai meta object interface + Meta interface { + // Log constructs an hclog sublogger and returns the log.Interface + Log(args ...interface{}) log.Interface + + // OperationID returns the operation id + OperationID() string + + // Session returns the operation API session + Session() session.Session + } + + // OperationMeta is the implementation of Meta interface + OperationMeta struct { + operationID string + log hclog.Logger + sess session.Session + } +) + +// ErrNilLog is an error returned from New(...) when log argument is nil +var ErrNilLog = errors.New("nil log argument") + +// ErrNilSession is an error returned from New(...) when session argument is nil +var ErrNilSession = errors.New("nil session argument") + +// New returns a new OperationMeta +func New(sess session.Session, log hclog.Logger, operationID string) (*OperationMeta, error) { + if log == nil { + return nil, ErrNilLog + } + if sess == nil { + return nil, ErrNilSession + } + return &OperationMeta{ + operationID: operationID, + sess: sess, + log: log, + }, nil +} + +// Must performs type assertion on m and panics if m does not hold Meta value +func Must(m any) Meta { + v, ok := m.(Meta) + if !ok { + panic(fmt.Sprintf("%v does not implement Meta interface", m)) + } + return v +} + +// Log creates a logger for the provider from the meta +func (m *OperationMeta) Log(args ...interface{}) log.Interface { + return logger.FromHCLog(m.log.With(args...)) +} + +// OperationID returns the operation id from the meta +func (m *OperationMeta) OperationID() string { + return m.operationID +} + +// Session returns the meta session +func (m *OperationMeta) Session() session.Session { + return m.sess +} diff --git a/pkg/meta/meta_test.go b/pkg/meta/meta_test.go new file mode 100644 index 000000000..b1ad87bd5 --- /dev/null +++ b/pkg/meta/meta_test.go @@ -0,0 +1,63 @@ +package meta + +import ( + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/hashicorp/go-hclog" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestMeta(t *testing.T) { + var sess = session.Must(session.New()) + var logger = hclog.New(hclog.DefaultOptions) + operationID := "opID" + + meta, err := New(sess, logger, operationID) + assert.NoError(t, err) + + t.Run("Session() return sess", func(t *testing.T) { + assert.Equal(t, sess, meta.Session()) + }) + t.Run("OperationID() return operationID", func(t *testing.T) { + assert.Equal(t, operationID, meta.OperationID()) + }) +} + +func TestNew_err(t *testing.T) { + var sess = session.Must(session.New()) + var logger = hclog.New(hclog.DefaultOptions) + + t.Run("nil log", func(t *testing.T) { + _, err := New(sess, nil, "") + assert.Error(t, err, ErrNilLog) + }) + t.Run("nil session", func(t *testing.T) { + _, err := New(nil, logger, "") + assert.Error(t, err, ErrNilSession) + }) + +} + +func TestMust(t *testing.T) { + t.Run("no panic", func(t *testing.T) { + var sess = session.Must(session.New()) + var logger = hclog.New(hclog.DefaultOptions) + + meta, err := New(sess, logger, "") + require.NoError(t, err) + + var m interface{} = meta + assert.NotPanics(t, func() { + _ = Must(m) + }) + }) + + t.Run("panics for non meta", func(t *testing.T) { + var m interface{} = "not_meta" + assert.Panics(t, func() { + _ = Must(m) + }) + }) +} diff --git a/pkg/providers/appsec/appsec.go b/pkg/providers/appsec/appsec.go index 1f336439f..78486c663 100644 --- a/pkg/providers/appsec/appsec.go +++ b/pkg/providers/appsec/appsec.go @@ -1,10 +1,10 @@ -//go:build all || appsec -// +build all appsec - package appsec -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" + +// SubproviderName defines name of the appsec subprovider +const SubproviderName = "appsec" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/appsec/config_versions.go b/pkg/providers/appsec/config_versions.go index 06e268189..5c8ad123d 100644 --- a/pkg/providers/appsec/config_versions.go +++ b/pkg/providers/appsec/config_versions.go @@ -6,8 +6,9 @@ import ( "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + akameta "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) // Utility functions for determining current and latest versions of a security @@ -36,14 +37,14 @@ var ( // and the API client obtained from m. Log messages are written to m's logger. A // mutex prevents calls made by multiple resources from creating unnecessary clones. func getModifiableConfigVersion(ctx context.Context, configID int, resource string, m interface{}) (int, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "getModifiableConfigVersion") // If the version info is in the cache, return it immediately. cacheKey := fmt.Sprintf("%s:%d", "getModifiableConfigVersion", configID) configuration := &appsec.GetConfigurationResponse{} - if err := meta.CacheGet(inst, cacheKey, configuration); err == nil { + if err := cache.Get(cache.BucketName(SubproviderName), cacheKey, configuration); err == nil { logger.Debugf("Resource %s returning modifiable version %d from cache", resource, configuration.LatestVersion) return configuration.LatestVersion, nil } @@ -56,13 +57,13 @@ func getModifiableConfigVersion(ctx context.Context, configID int, resource stri }() // If the version info is in the cache, return it immediately. - err := meta.CacheGet(inst, cacheKey, configuration) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, configuration) if err == nil { logger.Debugf("Resource %s returning modifiable version %d from cache", resource, configuration.LatestVersion) return configuration.LatestVersion, nil } // Any error response other than 'not found' or 'cache disabled' is a problem. - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return 0, err } @@ -80,8 +81,8 @@ func getModifiableConfigVersion(ctx context.Context, configID int, resource stri stagingVersion := configuration.StagingVersion productionVersion := configuration.ProductionVersion if latestVersion != stagingVersion && latestVersion != productionVersion { - if err := meta.CacheSet(inst, cacheKey, configuration); err != nil { - if !errors.Is(err, akamai.ErrCacheDisabled) { + if err := cache.Set(cache.BucketName(SubproviderName), cacheKey, configuration); err != nil { + if !errors.Is(err, cache.ErrDisabled) { logger.Errorf("unable to set latestVersion %d into cache") } } @@ -102,7 +103,7 @@ func getModifiableConfigVersion(ctx context.Context, configID int, resource stri } configuration.LatestVersion = ccr.Version - if err := meta.CacheSet(inst, cacheKey, configuration); err != nil && !errors.Is(err, akamai.ErrCacheDisabled) { + if err := cache.Set(cache.BucketName(SubproviderName), cacheKey, configuration); err != nil && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("unable to set latestVersion %d into cache: %s", err.Error()) } @@ -114,14 +115,14 @@ func getModifiableConfigVersion(ctx context.Context, configID int, resource stri // configuration. API calls are made using the supplied context and the API client // obtained from m. Log messages are written to m's logger. func getLatestConfigVersion(ctx context.Context, configID int, m interface{}) (int, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "getLatestConfigVersion") // Return the cached value if we have one cacheKey := fmt.Sprintf("%s:%d", "getLatestConfigVersion", configID) configuration := &appsec.GetConfigurationResponse{} - if err := meta.CacheGet(inst, cacheKey, configuration); err == nil { + if err := cache.Get(cache.BucketName(SubproviderName), cacheKey, configuration); err == nil { logger.Debugf("Found config %d, returning %d as its latest version", configuration.ID, configuration.LatestVersion) return configuration.LatestVersion, nil } @@ -133,13 +134,13 @@ func getLatestConfigVersion(ctx context.Context, configID int, m interface{}) (i latestVersionMutex.Unlock() }() - err := meta.CacheGet(inst, cacheKey, configuration) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, configuration) if err == nil { logger.Debugf("Found config %d, returning %d as its latest version", configuration.ID, configuration.LatestVersion) return configuration.LatestVersion, nil } // Any error response other than 'not found' or 'cache disabled' is a problem. - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return 0, err } @@ -149,7 +150,7 @@ func getLatestConfigVersion(ctx context.Context, configID int, m interface{}) (i logger.Errorf("error calling GetConfiguration: %s", err.Error()) return 0, err } - if err := meta.CacheSet(inst, cacheKey, configuration); err != nil && !errors.Is(err, akamai.ErrCacheDisabled) { + if err := cache.Set(cache.BucketName(SubproviderName), cacheKey, configuration); err != nil && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error caching latestVersion into cache: %s", err.Error()) } @@ -161,7 +162,7 @@ func getLatestConfigVersion(ctx context.Context, configID int, m interface{}) (i // active in staging and production respectively. API calls are made using the supplied // context and the API client obtained from m. Log messages are written to m's logger. func getActiveConfigVersions(ctx context.Context, configID int, m interface{}) (int, int, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "getActiveConfigVersions") diff --git a/pkg/providers/appsec/custom_validations.go b/pkg/providers/appsec/custom_validations.go index 7f01d37b7..3f6e2b43b 100644 --- a/pkg/providers/appsec/custom_validations.go +++ b/pkg/providers/appsec/custom_validations.go @@ -5,11 +5,11 @@ import ( "fmt" "strings" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -59,7 +59,7 @@ func validateWithBotManActions(v interface{}, path cty.Path) diag.Diagnostics { // specified in the resources's ID, to ensure that the user has not inadvertently modified the configuration's value; // any such modifications indicate an incorrect understanding of the Update operation. func VerifyIDUnchanged(_ context.Context, d *schema.ResourceDiff, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("APPSEC", "VerifyIDUnchanged") if d.HasChange("config_id") { 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 49bff3862..e6803d6e5 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,9 +6,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceAdvancedSettingsAttackPayloadLogging() *schema.Resource { } func dataSourceAdvancedSettingsAttackPayloadLoggingRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsAttackPayloadLoggingRead") 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 752d6dce9..976f02b05 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 b621a2ac1..f1cf8c0cb 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,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceAdvancedSettingsEvasivePathMatch() *schema.Resource { } func dataSourceAdvancedSettingsEvasivePathMatchRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsEvasivePathMatchRead") 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 61047272a..4ad20060a 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 bcfbd8316..7d7aca200 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceAdvancedSettingsLogging() *schema.Resource { } func dataSourceAdvancedSettingsLoggingRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsLoggingRead") 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 10ce451a4..5bc3b43f4 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 new file mode 100644 index 000000000..f1d2b0826 --- /dev/null +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go @@ -0,0 +1,86 @@ +package appsec + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func dataSourceAdvancedSettingsPIILearning() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceAdvancedSettingsPIILearningRead, + Schema: map[string]*schema.Schema{ + "config_id": { + Type: schema.TypeInt, + Required: true, + Description: "Unique identifier of the security configuration", + }, + "json": { + Type: schema.TypeString, + Computed: true, + Description: "JSON representation", + }, + "output_text": { + Type: schema.TypeString, + Computed: true, + Description: "Text representation", + }, + }, + } +} + +func dataSourceAdvancedSettingsPIILearningRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + meta := meta.Must(m) + client := inst.Client(meta) + logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsPIILearningRead") + + configID, err := tf.GetIntValue("config_id", d) + if err != nil { + return diag.FromErr(err) + } + + version, err := getLatestConfigVersion(ctx, configID, m) + if err != nil { + return diag.FromErr(err) + } + + advancedSettingsPIILearning, err := client.GetAdvancedSettingsPIILearning(ctx, appsec.GetAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: int64(configID), + Version: version, + }, + }) + if err != nil { + logger.Errorf("calling 'getAdvancedSettingsPIILearning': %s", err.Error()) + return diag.FromErr(err) + } + + ots := OutputTemplates{} + InitTemplates(ots) + + outputText, err := RenderTemplates(ots, "advancedSettingsPIILearningDS", advancedSettingsPIILearning) + if err != nil { + return diag.FromErr(err) + } + if err := d.Set("output_text", outputText); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + + jsonBody, err := json.Marshal(advancedSettingsPIILearning) + if err != nil { + return diag.FromErr(err) + } + if err := d.Set("json", string(jsonBody)); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + + d.SetId(strconv.Itoa(configID)) + + return nil +} 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 new file mode 100644 index 000000000..a7980aafb --- /dev/null +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go @@ -0,0 +1,126 @@ +package appsec + +import ( + "bytes" + "encoding/json" + "errors" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func checkOutputText(value string) error { + matched, _ := regexp.MatchString("(?s).*ENABLE PII LEARNING.*true.*", value) + if !matched { + return errors.New("expected result not found") + } + return nil +} + +func TestAkamaiAdvancedSettingsPIILearning_data_basic(t *testing.T) { + t.Run("match by AdvancedSettingsPIILearning ID", func(t *testing.T) { + client := &appsec.Mock{} + + config := appsec.GetConfigurationResponse{} + err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &config) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&config, nil) + + getPIILearningResponse := appsec.AdvancedSettingsPIILearningResponse{} + piiLearningBytes := loadFixtureBytes("testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json") + var piiLearningJSON bytes.Buffer + err = json.Compact(&piiLearningJSON, []byte(piiLearningBytes)) + require.NoError(t, err) + err = json.Unmarshal(piiLearningBytes, &getPIILearningResponse) + require.NoError(t, err) + + client.On("GetAdvancedSettingsPIILearning", + mock.Anything, + appsec.GetAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: 43253, + Version: 7, + }, + }, + ).Return(&getPIILearningResponse, nil) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestDSAdvancedSettingsPIILearning/match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_appsec_advanced_settings_pii_learning.test", "id", "43253"), + resource.TestCheckResourceAttr("data.akamai_appsec_advanced_settings_pii_learning.test", "json", piiLearningJSON.String()), + resource.TestCheckResourceAttrWith("data.akamai_appsec_advanced_settings_pii_learning.test", "output_text", checkOutputText), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + +} + +func TestAkamaiAdvancedSettingsPIILearning_data_missing_parameter(t *testing.T) { + t.Run("match by AdvancedSettingsPIILearning ID", func(t *testing.T) { + client := &appsec.Mock{} + + config := appsec.GetConfigurationResponse{} + err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &config) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&config, nil) + + getPIILearningResponse := appsec.AdvancedSettingsPIILearningResponse{} + piiLearningBytes := loadFixtureBytes("testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json") + var piiLearningJSON bytes.Buffer + err = json.Compact(&piiLearningJSON, []byte(piiLearningBytes)) + require.NoError(t, err) + err = json.Unmarshal(piiLearningBytes, &getPIILearningResponse) + require.NoError(t, err) + + client.On("GetAdvancedSettingsPIILearning", + mock.Anything, + appsec.GetAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: 43253, + Version: 7, + }, + }, + ).Return(nil, errors.New("API call failure")) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestDSAdvancedSettingsPIILearning/match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_appsec_advanced_settings_pii_learning.test", "id", "43253"), + ), + ExpectError: regexp.MustCompile(`API call failure`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) +} 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 7c6dacd27..776389b32 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,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceAdvancedSettingsPragmaHeader() *schema.Resource { } func dataSourceAdvancedSettingsPragmaHeaderRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsPragmaHeaderRead") 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 5ab8fa007..e86bdbcab 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 0c72c01ea..f68f16321 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,7 +36,7 @@ func dataSourceAdvancedSettingsPrefetch() *schema.Resource { } func dataSourceAdvancedSettingsPrefetchRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsPrefetchRead") 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 93e49554c..391f63788 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 23c3bb304..7e872c488 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,9 +6,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceAdvancedSettingsRequestBody() *schema.Resource { } func dataSourceAdvancedSettingsRequestBodyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAdvancedSettingsRequestBodyRead") 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 8e5e895bc..f84ec49b0 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go b/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go index 585b40b9a..9b7c9582d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -53,7 +53,7 @@ func dataSourceAPIEndpoints() *schema.Resource { } func dataSourceAPIEndpointsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAPIEndpointsRead") 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 d6ec5b743..b9021a26f 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 ba9a5b232..2517777de 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,7 +31,7 @@ func dataSourceAPIHostnameCoverage() *schema.Resource { } func dataSourceAPIHostnameCoverageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAPIHostnameCoverageRead") 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 f77f92804..62ead25a2 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,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceAPIHostnameCoverageMatchTargets() *schema.Resource { } func dataSourceAPIHostnameCoverageMatchTargetsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAPIHostnameCoverageMatchTargetsRead") 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 9bba302a7..b386d8156 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 b214b1558..95ede519a 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,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceAPIHostnameCoverageOverlapping() *schema.Resource { } func dataSourceAPIHostnameCoverageOverlappingRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAPIHostnameCoverageOverlappingRead") 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 b324f3b94..a28604dc8 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 b2cdc8c00..f4ee176d9 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 d426ddccb..d9b29c655 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -47,7 +47,7 @@ func dataSourceAPIRequestConstraints() *schema.Resource { } func dataSourceAPIRequestConstraintsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAPIRequestConstraintsRead") 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 80f16852f..fb2e6ec4f 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_attack_groups.go b/pkg/providers/appsec/data_akamai_appsec_attack_groups.go index 5edfdb4bd..3aa9dc6b7 100644 --- a/pkg/providers/appsec/data_akamai_appsec_attack_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_attack_groups.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -57,7 +57,7 @@ func dataSourceAttackGroups() *schema.Resource { } func dataSourceAttackGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceAttackGroupsRead") 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 12e4b10ed..aa3e6d65d 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 bb65c59af..fd0c56e80 100644 --- a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go +++ b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -47,7 +47,7 @@ func dataSourceBypassNetworkLists() *schema.Resource { } func dataSourceBypassNetworkListsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceBypassNetworkListsRead") 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 52d81a1d7..e6e15c19d 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration.go b/pkg/providers/appsec/data_akamai_appsec_configuration.go index 7bc39f757..e9c2a2ad4 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration.go @@ -5,9 +5,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -51,7 +51,7 @@ func dataSourceConfiguration() *schema.Resource { } func dataSourceConfigurationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationRead") diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_test.go b/pkg/providers/appsec/data_akamai_appsec_configuration_test.go index bdfce029a..d609ab159 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_version.go b/pkg/providers/appsec/data_akamai_appsec_configuration_version.go index c669f8397..3338ec849 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_version.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_version.go @@ -5,9 +5,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -51,7 +51,7 @@ func dataSourceConfigurationVersion() *schema.Resource { } func dataSourceConfigurationVersionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceConfigurationVersionRead") 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 42277fe58..fb607914a 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go b/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go index 28872f552..5aa83e8ee 100644 --- a/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go @@ -5,9 +5,9 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -51,7 +51,7 @@ func dataSourceContractsGroups() *schema.Resource { } func dataSourceContractsGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceContractsGroupsRead") 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 0f99fd2d1..08a6c8130 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_deny.go b/pkg/providers/appsec/data_akamai_appsec_custom_deny.go index ade838e3b..ed02dcf03 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_deny.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_deny.go @@ -5,9 +5,9 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceCustomDeny() *schema.Resource { } func dataSourceCustomDenyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceCustomDenyRead") 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 a825f042c..ec03f8c65 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 961c8139f..5e17c7016 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go @@ -5,9 +5,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceCustomRuleActions() *schema.Resource { } func dataSourceCustomRuleActionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceCustomRuleActionsRead") 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 b56352132..10a192ba6 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rules.go b/pkg/providers/appsec/data_akamai_appsec_custom_rules.go index c3e6b8f46..8a49d8bcd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rules.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceCustomRules() *schema.Resource { } func dataSourceCustomRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceCustomRulesRead") 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 64c2957f1..3ca26191b 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval.go b/pkg/providers/appsec/data_akamai_appsec_eval.go index 0a44b0fd6..533f692d2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataSourceEval() *schema.Resource { } func dataSourceEvalRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceEvalRead") diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_groups.go b/pkg/providers/appsec/data_akamai_appsec_eval_groups.go index 953edf7f3..e9bb2c90b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_groups.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -56,7 +56,7 @@ func dataSourceEvalGroups() *schema.Resource { } func dataSourceEvalGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceEvalGroupsRead") 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 925b2bd2c..43aa05fba 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 ea271d481..f8119d99d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -45,7 +45,7 @@ func dataSourceEvalPenaltyBox() *schema.Resource { } func dataSourceEvalPenaltyBoxRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceEvalPenaltyBoxRead") 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 497f30cfa..47fb1d644 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_rules.go b/pkg/providers/appsec/data_akamai_appsec_eval_rules.go index 6b52398aa..154f28648 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_rules.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -57,7 +57,7 @@ func dataSourceEvalRules() *schema.Resource { } func dataSourceEvalRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceEvalRuleActionsRead") 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 ec5b78d63..8c7238776 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_test.go index fa2c2fc62..59b3c2add 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_export_configuration.go b/pkg/providers/appsec/data_akamai_appsec_export_configuration.go index c1c690423..d15332ebf 100644 --- a/pkg/providers/appsec/data_akamai_appsec_export_configuration.go +++ b/pkg/providers/appsec/data_akamai_appsec_export_configuration.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -47,7 +47,7 @@ func dataSourceExportConfiguration() *schema.Resource { } func dataSourceExportConfigurationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceExportConfigurationRead") 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 5aa57c1ec..5b6f5e0ab 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go index c8ff0ad87..ecbbc615c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -43,7 +43,7 @@ func dataSourceFailoverHostnames() *schema.Resource { } func dataSourceFailoverHostnamesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceFailoverHostnamesRead") 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 ffbf4e564..d0611eea4 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_ip_geo.go b/pkg/providers/appsec/data_akamai_appsec_ip_geo.go index e913d1b75..425b3dfd4 100644 --- a/pkg/providers/appsec/data_akamai_appsec_ip_geo.go +++ b/pkg/providers/appsec/data_akamai_appsec_ip_geo.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -48,6 +48,11 @@ func dataSourceIPGeo() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Description: "List of unique identifiers of network lists allowed through the firewall regardless of mode, geo_network_lists and ip_network_lists values", }, + "ukraine_geo_control_action": { + Type: schema.TypeString, + Computed: true, + Description: "Action set for Ukraine geo control", + }, "output_text": { Type: schema.TypeString, Computed: true, @@ -58,7 +63,7 @@ func dataSourceIPGeo() *schema.Resource { } func dataSourceIPGeoRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceIPGeoRead") @@ -133,6 +138,11 @@ func dataSourceIPGeoRead(ctx context.Context, d *schema.ResourceData, m interfac return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } } + if ipgeo.UkraineGeoControls != nil && ipgeo.UkraineGeoControls.Action != "" { + if err := d.Set("ukraine_geo_control_action", ipgeo.UkraineGeoControls.Action); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + } } d.SetId(strconv.Itoa(getIPGeo.ConfigID)) 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 028b39faa..155ffdf70 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 051b2670c..bd3d6c1d7 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,7 +36,7 @@ func dataSourceMalwareContentTypes() *schema.Resource { } func dataSourceMalwareContentTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceMalwareContentTypesRead") 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 c088e8af9..444c03588 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policies.go b/pkg/providers/appsec/data_akamai_appsec_malware_policies.go index d7767c057..679c20a6b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policies.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policies.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -43,7 +43,7 @@ func dataSourceMalwarePolicies() *schema.Resource { } func dataSourceMalwarePoliciesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceMalwarePoliciesRead") 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 8ec3b8b21..5e5f852d2 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 99f003955..b8b8b2262 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go @@ -5,9 +5,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceMalwarePolicyActions() *schema.Resource { } func dataSourceMalwarePolicyActionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceMalwarePolicyActionsRead") 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 5dc275be1..f71e75132 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_match_targets.go b/pkg/providers/appsec/data_akamai_appsec_match_targets.go index 1371b8e05..ebab3a24d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_match_targets.go +++ b/pkg/providers/appsec/data_akamai_appsec_match_targets.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -55,7 +55,7 @@ func dataSourceMatchTargets() *schema.Resource { } func dataSourceMatchTargetsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceMatchTargetsRead") 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 920736772..e6fbb0fa0 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box.go index 7d836d907..5935d3011 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -45,7 +45,7 @@ func dataSourcePenaltyBox() *schema.Resource { } func dataSourcePenaltyBoxRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourcePenaltyBoxRead") 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 a746874af..3e0579bbe 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policies.go b/pkg/providers/appsec/data_akamai_appsec_rate_policies.go index a0d4504f5..5581b2ddf 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policies.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policies.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceRatePolicies() *schema.Resource { } func dataSourceRatePoliciesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceRatePoliciesRead") 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 c79323d20..90b5d3305 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 e375c449f..530da8866 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go @@ -5,9 +5,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceRatePolicyActions() *schema.Resource { } func dataSourceRatePolicyActionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceRatePolicyActionsRead") 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 a377bf99a..007119061 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go index fcd101aaf..b4d9cee9c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceReputationAnalysis() *schema.Resource { } func dataSourceReputationAnalysisRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceReputationAnalysisRead") 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 846c4f3af..e610bebbe 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 7bed9d605..787837fda 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -52,7 +52,7 @@ func dataSourceReputationProfileActions() *schema.Resource { } func dataSourceReputationProfileActionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceReputationProfileActionsRead") 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 8dd348d7c..bd858ebee 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go index c9f385061..530b7f528 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceReputationProfiles() *schema.Resource { } func dataSourceReputationProfilesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceReputationProfilesRead") 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 7ae54c1ad..cad4f536e 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go index 0c1006d1b..1bfc52df5 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go +++ b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceRuleUpgrade() *schema.Resource { } func dataSourceRuleUpgradeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceRuleUpgradeRead") 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 e74e809ac..afdaf37f2 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_rules.go b/pkg/providers/appsec/data_akamai_appsec_rules.go index 662ab42c3..ac4182d87 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_rules.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -57,7 +57,7 @@ func dataSourceRules() *schema.Resource { } func dataSourceRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceRulesRead") diff --git a/pkg/providers/appsec/data_akamai_appsec_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_rules_test.go index 95e6ae9d5..dd241180a 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy.go b/pkg/providers/appsec/data_akamai_appsec_security_policy.go index cebfe6bf7..0106d9a1c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy.go @@ -6,9 +6,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -53,7 +53,7 @@ func dataSourceSecurityPolicy() *schema.Resource { } func dataSourceSecurityPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceSecurityPolicyRead") 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 e09ae7db7..7c7c578e3 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -81,7 +81,7 @@ func dataSourcePolicyProtections() *schema.Resource { } func dataSourcePolicyProtectionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourcePolicyProtectionsRead") 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 860f73ae6..28b7a17ab 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 84aae36c8..607e4b793 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go index d27796a22..053e3c41c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -66,7 +66,7 @@ func dataSourceSelectableHostnames() *schema.Resource { } func dataSourceSelectableHostnamesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceSelectableHostnamesRead") 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 dea31d5f9..15f032eb4 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go index a1b8e217b..a0484704b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -42,7 +42,7 @@ func dataSourceSelectedHostnames() *schema.Resource { } func dataSourceSelectedHostnamesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceSelectedHostnamesRead") 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 86feaee8d..15f05531c 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go b/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go index 5d0a29e74..0feb1fe82 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -37,7 +37,7 @@ func dataSourceSiemDefinitions() *schema.Resource { } func dataSourceSiemDefinitionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceSiemDefinitionsRead") 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 dae20612a..dfe2ac6e4 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_settings.go b/pkg/providers/appsec/data_akamai_appsec_siem_settings.go index 360a6735e..7add2879a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_settings.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,7 +36,7 @@ func dataSourceSiemSettings() *schema.Resource { } func dataSourceSiemSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceSiemSettingsRead") 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 cb579b862..a7b467990 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 0f6d112de..fea844764 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,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func dataSourceSlowPostProtectionSettings() *schema.Resource { } func dataSourceSlowPostProtectionSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceSlowPostProtectionSettingsRead") 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 896cc2cbc..35428bf83 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_threat_intel.go b/pkg/providers/appsec/data_akamai_appsec_threat_intel.go index ff364acc9..ec3f7b76c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_threat_intel.go +++ b/pkg/providers/appsec/data_akamai_appsec_threat_intel.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -46,7 +46,7 @@ func dataSourceThreatIntel() *schema.Resource { } func dataSourceThreatIntelRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceThreatIntelRead") 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 b5efb23ae..b3ceb1476 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go index 2ba348c3a..ff4ab6cab 100644 --- a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go +++ b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -59,7 +59,7 @@ func dataSourceTuningRecommendations() *schema.Resource { } func dataSourceTuningRecommendationsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceTuningRecommendationsRead") 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 988c2b19f..e5bdc00d3 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_version_notes.go b/pkg/providers/appsec/data_akamai_appsec_version_notes.go index 77fa8718d..4c6f16e72 100644 --- a/pkg/providers/appsec/data_akamai_appsec_version_notes.go +++ b/pkg/providers/appsec/data_akamai_appsec_version_notes.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,7 +36,7 @@ func dataSourceVersionNotes() *schema.Resource { } func dataSourceVersionNotesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceVersionNotesRead") 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 b42b01d91..00bb7b47e 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/data_akamai_appsec_waf_mode.go b/pkg/providers/appsec/data_akamai_appsec_waf_mode.go index 6c1468f8e..dba18091d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_waf_mode.go +++ b/pkg/providers/appsec/data_akamai_appsec_waf_mode.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -66,7 +66,7 @@ func dataSourceWAFMode() *schema.Resource { } func dataSourceWAFModeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceWAFModeRead") 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 7646c56f5..8dd54a73f 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 75e1e1b85..cf9153810 100644 --- a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -70,7 +70,7 @@ func dataSourceWAPSelectedHostnames() *schema.Resource { } func dataSourceWAPSelectedHostnamesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "dataSourceWAPSelectedHostnamesRead") 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 86d35a6ac..daed9feb6 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/diff_suppress_funcs.go b/pkg/providers/appsec/diff_suppress_funcs.go index dcc3bbaa9..474d2c9a6 100644 --- a/pkg/providers/appsec/diff_suppress_funcs.go +++ b/pkg/providers/appsec/diff_suppress_funcs.go @@ -8,7 +8,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/appsec/provider.go b/pkg/providers/appsec/provider.go index d6da31e42..090ed3868 100644 --- a/pkg/providers/appsec/provider.go +++ b/pkg/providers/appsec/provider.go @@ -2,39 +2,35 @@ package appsec import ( - "fmt" "sync" - "github.com/apex/log" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/config" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers appsec resources and data sources + Subprovider struct { client appsec.APPSEC } - // Option is a appsec provider option - Option func(p *provider) + + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -44,194 +40,129 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{ - "appsec_section": { - Optional: true, - Type: schema.TypeString, - Default: "default", - Deprecated: akamai.NoticeDeprecatedUseAlias("appsec_section"), - }, - "appsec": { - Optional: true, - Type: schema.TypeSet, - Elem: config.Options("appsec"), - Deprecated: akamai.NoticeDeprecatedUseAlias("appsec"), - }, - }, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_appsec_advanced_settings_attack_payload_logging": dataSourceAdvancedSettingsAttackPayloadLogging(), - "akamai_appsec_advanced_settings_evasive_path_match": dataSourceAdvancedSettingsEvasivePathMatch(), - "akamai_appsec_advanced_settings_logging": dataSourceAdvancedSettingsLogging(), - "akamai_appsec_advanced_settings_pragma_header": dataSourceAdvancedSettingsPragmaHeader(), - "akamai_appsec_advanced_settings_prefetch": dataSourceAdvancedSettingsPrefetch(), - "akamai_appsec_advanced_settings_request_body": dataSourceAdvancedSettingsRequestBody(), - "akamai_appsec_api_endpoints": dataSourceAPIEndpoints(), - "akamai_appsec_api_request_constraints": dataSourceAPIRequestConstraints(), - "akamai_appsec_attack_groups": dataSourceAttackGroups(), - "akamai_appsec_bypass_network_lists": dataSourceBypassNetworkLists(), - "akamai_appsec_configuration": dataSourceConfiguration(), - "akamai_appsec_configuration_version": dataSourceConfigurationVersion(), - "akamai_appsec_contracts_groups": dataSourceContractsGroups(), - "akamai_appsec_custom_deny": dataSourceCustomDeny(), - "akamai_appsec_custom_rule_actions": dataSourceCustomRuleActions(), - "akamai_appsec_custom_rules": dataSourceCustomRules(), - "akamai_appsec_eval": dataSourceEval(), - "akamai_appsec_eval_groups": dataSourceEvalGroups(), - "akamai_appsec_eval_penalty_box": dataSourceEvalPenaltyBox(), - "akamai_appsec_eval_rules": dataSourceEvalRules(), - "akamai_appsec_export_configuration": dataSourceExportConfiguration(), - "akamai_appsec_failover_hostnames": dataSourceFailoverHostnames(), - "akamai_appsec_hostname_coverage": dataSourceAPIHostnameCoverage(), - "akamai_appsec_hostname_coverage_match_targets": dataSourceAPIHostnameCoverageMatchTargets(), - "akamai_appsec_hostname_coverage_overlapping": dataSourceAPIHostnameCoverageOverlapping(), - "akamai_appsec_ip_geo": dataSourceIPGeo(), - "akamai_appsec_malware_content_types": dataSourceMalwareContentTypes(), - "akamai_appsec_malware_policies": dataSourceMalwarePolicies(), - "akamai_appsec_malware_policy_actions": dataSourceMalwarePolicyActions(), - "akamai_appsec_match_targets": dataSourceMatchTargets(), - "akamai_appsec_penalty_box": dataSourcePenaltyBox(), - "akamai_appsec_rate_policies": dataSourceRatePolicies(), - "akamai_appsec_rate_policy_actions": dataSourceRatePolicyActions(), - "akamai_appsec_reputation_profile_actions": dataSourceReputationProfileActions(), - "akamai_appsec_reputation_profile_analysis": dataSourceReputationAnalysis(), - "akamai_appsec_reputation_profiles": dataSourceReputationProfiles(), - "akamai_appsec_rule_upgrade_details": dataSourceRuleUpgrade(), - "akamai_appsec_rules": dataSourceRules(), - "akamai_appsec_security_policy": dataSourceSecurityPolicy(), - "akamai_appsec_security_policy_protections": dataSourcePolicyProtections(), - "akamai_appsec_selectable_hostnames": dataSourceSelectableHostnames(), - "akamai_appsec_selected_hostnames": dataSourceSelectedHostnames(), - "akamai_appsec_siem_definitions": dataSourceSiemDefinitions(), - "akamai_appsec_siem_settings": dataSourceSiemSettings(), - "akamai_appsec_slow_post": dataSourceSlowPostProtectionSettings(), - "akamai_appsec_threat_intel": dataSourceThreatIntel(), - "akamai_appsec_tuning_recommendations": dataSourceTuningRecommendations(), - "akamai_appsec_version_notes": dataSourceVersionNotes(), - "akamai_appsec_waf_mode": dataSourceWAFMode(), - "akamai_appsec_wap_selected_hostnames": dataSourceWAPSelectedHostnames(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_appsec_activations": resourceActivations(), - "akamai_appsec_advanced_settings_attack_payload_logging": resourceAdvancedSettingsAttackPayloadLogging(), - "akamai_appsec_advanced_settings_evasive_path_match": resourceAdvancedSettingsEvasivePathMatch(), - "akamai_appsec_advanced_settings_logging": resourceAdvancedSettingsLogging(), - "akamai_appsec_advanced_settings_pragma_header": resourceAdvancedSettingsPragmaHeader(), - "akamai_appsec_advanced_settings_prefetch": resourceAdvancedSettingsPrefetch(), - "akamai_appsec_advanced_settings_request_body": resourceAdvancedSettingsRequestBody(), - "akamai_appsec_api_constraints_protection": resourceAPIConstraintsProtection(), - "akamai_appsec_api_request_constraints": resourceAPIRequestConstraints(), - "akamai_appsec_attack_group": resourceAttackGroup(), - "akamai_appsec_bypass_network_lists": resourceBypassNetworkLists(), - "akamai_appsec_configuration": resourceConfiguration(), - "akamai_appsec_configuration_rename": resourceConfigurationRename(), - "akamai_appsec_custom_deny": resourceCustomDeny(), - "akamai_appsec_custom_rule": resourceCustomRule(), - "akamai_appsec_custom_rule_action": resourceCustomRuleAction(), - "akamai_appsec_eval": resourceEval(), - "akamai_appsec_eval_group": resourceEvalGroup(), - "akamai_appsec_eval_penalty_box": resourceEvalPenaltyBox(), - "akamai_appsec_eval_rule": resourceEvalRule(), - "akamai_appsec_ip_geo": resourceIPGeo(), - "akamai_appsec_ip_geo_protection": resourceIPGeoProtection(), - "akamai_appsec_malware_policy": resourceMalwarePolicy(), - "akamai_appsec_malware_policy_action": resourceMalwarePolicyAction(), - "akamai_appsec_malware_policy_actions": resourceMalwarePolicyActions(), - "akamai_appsec_malware_protection": resourceMalwareProtection(), - "akamai_appsec_match_target": resourceMatchTarget(), - "akamai_appsec_match_target_sequence": resourceMatchTargetSequence(), - "akamai_appsec_penalty_box": resourcePenaltyBox(), - "akamai_appsec_rate_policy": resourceRatePolicy(), - "akamai_appsec_rate_policy_action": resourceRatePolicyAction(), - "akamai_appsec_rate_protection": resourceRateProtection(), - "akamai_appsec_reputation_profile": resourceReputationProfile(), - "akamai_appsec_reputation_profile_action": resourceReputationProfileAction(), - "akamai_appsec_reputation_profile_analysis": resourceReputationAnalysis(), - "akamai_appsec_reputation_protection": resourceReputationProtection(), - "akamai_appsec_rule": resourceRule(), - "akamai_appsec_rule_upgrade": resourceRuleUpgrade(), - "akamai_appsec_security_policy": resourceSecurityPolicy(), - "akamai_appsec_security_policy_rename": resourceSecurityPolicyRename(), - "akamai_appsec_selected_hostnames": resourceSelectedHostname(), - "akamai_appsec_siem_settings": resourceSiemSettings(), - "akamai_appsec_slow_post": resourceSlowPostProtectionSetting(), - "akamai_appsec_slowpost_protection": resourceSlowPostProtection(), - "akamai_appsec_threat_intel": resourceThreatIntel(), - "akamai_appsec_version_notes": resourceVersionNotes(), - "akamai_appsec_waf_mode": resourceWAFMode(), - "akamai_appsec_waf_protection": resourceWAFProtection(), - "akamai_appsec_wap_selected_hostnames": resourceWAPSelectedHostnames(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c appsec.APPSEC) Option { - return func(p *provider) { +func withClient(c appsec.APPSEC) option { + return func(p *Subprovider) { p.client = c } } // Client returns the PAPI interface -func (p *provider) Client(meta akamai.OperationMeta) appsec.APPSEC { +func (p *Subprovider) Client(meta meta.Meta) appsec.APPSEC { if p.client != nil { return p.client } return appsec.Client(meta.Session()) } -func getAPPSECV1Service(d *schema.ResourceData) (interface{}, error) { - var section string - - for _, s := range tf.FindStringValues(d, "appsec_section", "config_section") { - if s != "default" { - section = s - break - } - } - - if section != "" { - if err := d.Set("config_section", section); err != nil { - return nil, fmt.Errorf("%s: %s", tf.ErrValueSet, err.Error()) - } +// Resources returns terraform resources for appsec +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_appsec_activations": resourceActivations(), + "akamai_appsec_advanced_settings_attack_payload_logging": resourceAdvancedSettingsAttackPayloadLogging(), + "akamai_appsec_advanced_settings_evasive_path_match": resourceAdvancedSettingsEvasivePathMatch(), + "akamai_appsec_advanced_settings_logging": resourceAdvancedSettingsLogging(), + "akamai_appsec_advanced_settings_pii_learning": resourceAdvancedSettingsPIILearning(), + "akamai_appsec_advanced_settings_pragma_header": resourceAdvancedSettingsPragmaHeader(), + "akamai_appsec_advanced_settings_prefetch": resourceAdvancedSettingsPrefetch(), + "akamai_appsec_advanced_settings_request_body": resourceAdvancedSettingsRequestBody(), + "akamai_appsec_api_constraints_protection": resourceAPIConstraintsProtection(), + "akamai_appsec_api_request_constraints": resourceAPIRequestConstraints(), + "akamai_appsec_attack_group": resourceAttackGroup(), + "akamai_appsec_bypass_network_lists": resourceBypassNetworkLists(), + "akamai_appsec_configuration": resourceConfiguration(), + "akamai_appsec_configuration_rename": resourceConfigurationRename(), + "akamai_appsec_custom_deny": resourceCustomDeny(), + "akamai_appsec_custom_rule": resourceCustomRule(), + "akamai_appsec_custom_rule_action": resourceCustomRuleAction(), + "akamai_appsec_eval": resourceEval(), + "akamai_appsec_eval_group": resourceEvalGroup(), + "akamai_appsec_eval_penalty_box": resourceEvalPenaltyBox(), + "akamai_appsec_eval_rule": resourceEvalRule(), + "akamai_appsec_ip_geo": resourceIPGeo(), + "akamai_appsec_ip_geo_protection": resourceIPGeoProtection(), + "akamai_appsec_malware_policy": resourceMalwarePolicy(), + "akamai_appsec_malware_policy_action": resourceMalwarePolicyAction(), + "akamai_appsec_malware_policy_actions": resourceMalwarePolicyActions(), + "akamai_appsec_malware_protection": resourceMalwareProtection(), + "akamai_appsec_match_target": resourceMatchTarget(), + "akamai_appsec_match_target_sequence": resourceMatchTargetSequence(), + "akamai_appsec_penalty_box": resourcePenaltyBox(), + "akamai_appsec_rate_policy": resourceRatePolicy(), + "akamai_appsec_rate_policy_action": resourceRatePolicyAction(), + "akamai_appsec_rate_protection": resourceRateProtection(), + "akamai_appsec_reputation_profile": resourceReputationProfile(), + "akamai_appsec_reputation_profile_action": resourceReputationProfileAction(), + "akamai_appsec_reputation_profile_analysis": resourceReputationAnalysis(), + "akamai_appsec_reputation_protection": resourceReputationProtection(), + "akamai_appsec_rule": resourceRule(), + "akamai_appsec_rule_upgrade": resourceRuleUpgrade(), + "akamai_appsec_security_policy": resourceSecurityPolicy(), + "akamai_appsec_security_policy_rename": resourceSecurityPolicyRename(), + "akamai_appsec_selected_hostnames": resourceSelectedHostname(), + "akamai_appsec_siem_settings": resourceSiemSettings(), + "akamai_appsec_slow_post": resourceSlowPostProtectionSetting(), + "akamai_appsec_slowpost_protection": resourceSlowPostProtection(), + "akamai_appsec_threat_intel": resourceThreatIntel(), + "akamai_appsec_version_notes": resourceVersionNotes(), + "akamai_appsec_waf_mode": resourceWAFMode(), + "akamai_appsec_waf_protection": resourceWAFProtection(), + "akamai_appsec_wap_selected_hostnames": resourceWAPSelectedHostnames(), } - - return nil, nil } -func (p *provider) Name() string { - return "appsec" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v1.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap -} - -func (p *provider) Configure(log log.Interface, d *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - _, err := getAPPSECV1Service(d) - if err != nil { - return nil +// DataSources returns terraform data sources for appsec +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_appsec_advanced_settings_attack_payload_logging": dataSourceAdvancedSettingsAttackPayloadLogging(), + "akamai_appsec_advanced_settings_evasive_path_match": dataSourceAdvancedSettingsEvasivePathMatch(), + "akamai_appsec_advanced_settings_logging": dataSourceAdvancedSettingsLogging(), + "akamai_appsec_advanced_settings_pii_learning": dataSourceAdvancedSettingsPIILearning(), + "akamai_appsec_advanced_settings_pragma_header": dataSourceAdvancedSettingsPragmaHeader(), + "akamai_appsec_advanced_settings_prefetch": dataSourceAdvancedSettingsPrefetch(), + "akamai_appsec_advanced_settings_request_body": dataSourceAdvancedSettingsRequestBody(), + "akamai_appsec_api_endpoints": dataSourceAPIEndpoints(), + "akamai_appsec_api_request_constraints": dataSourceAPIRequestConstraints(), + "akamai_appsec_attack_groups": dataSourceAttackGroups(), + "akamai_appsec_bypass_network_lists": dataSourceBypassNetworkLists(), + "akamai_appsec_configuration": dataSourceConfiguration(), + "akamai_appsec_configuration_version": dataSourceConfigurationVersion(), + "akamai_appsec_contracts_groups": dataSourceContractsGroups(), + "akamai_appsec_custom_deny": dataSourceCustomDeny(), + "akamai_appsec_custom_rule_actions": dataSourceCustomRuleActions(), + "akamai_appsec_custom_rules": dataSourceCustomRules(), + "akamai_appsec_eval": dataSourceEval(), + "akamai_appsec_eval_groups": dataSourceEvalGroups(), + "akamai_appsec_eval_penalty_box": dataSourceEvalPenaltyBox(), + "akamai_appsec_eval_rules": dataSourceEvalRules(), + "akamai_appsec_export_configuration": dataSourceExportConfiguration(), + "akamai_appsec_failover_hostnames": dataSourceFailoverHostnames(), + "akamai_appsec_hostname_coverage": dataSourceAPIHostnameCoverage(), + "akamai_appsec_hostname_coverage_match_targets": dataSourceAPIHostnameCoverageMatchTargets(), + "akamai_appsec_hostname_coverage_overlapping": dataSourceAPIHostnameCoverageOverlapping(), + "akamai_appsec_ip_geo": dataSourceIPGeo(), + "akamai_appsec_malware_content_types": dataSourceMalwareContentTypes(), + "akamai_appsec_malware_policies": dataSourceMalwarePolicies(), + "akamai_appsec_malware_policy_actions": dataSourceMalwarePolicyActions(), + "akamai_appsec_match_targets": dataSourceMatchTargets(), + "akamai_appsec_penalty_box": dataSourcePenaltyBox(), + "akamai_appsec_rate_policies": dataSourceRatePolicies(), + "akamai_appsec_rate_policy_actions": dataSourceRatePolicyActions(), + "akamai_appsec_reputation_profile_actions": dataSourceReputationProfileActions(), + "akamai_appsec_reputation_profile_analysis": dataSourceReputationAnalysis(), + "akamai_appsec_reputation_profiles": dataSourceReputationProfiles(), + "akamai_appsec_rule_upgrade_details": dataSourceRuleUpgrade(), + "akamai_appsec_rules": dataSourceRules(), + "akamai_appsec_security_policy": dataSourceSecurityPolicy(), + "akamai_appsec_security_policy_protections": dataSourcePolicyProtections(), + "akamai_appsec_selectable_hostnames": dataSourceSelectableHostnames(), + "akamai_appsec_selected_hostnames": dataSourceSelectedHostnames(), + "akamai_appsec_siem_definitions": dataSourceSiemDefinitions(), + "akamai_appsec_siem_settings": dataSourceSiemSettings(), + "akamai_appsec_slow_post": dataSourceSlowPostProtectionSettings(), + "akamai_appsec_threat_intel": dataSourceThreatIntel(), + "akamai_appsec_tuning_recommendations": dataSourceTuningRecommendations(), + "akamai_appsec_version_notes": dataSourceVersionNotes(), + "akamai_appsec_waf_mode": dataSourceWAFMode(), + "akamai_appsec_wap_selected_hostnames": dataSourceWAPSelectedHostnames(), } - - return nil } diff --git a/pkg/providers/appsec/provider_test.go b/pkg/providers/appsec/provider_test.go index a26cdaf72..0d8241c42 100644 --- a/pkg/providers/appsec/provider_test.go +++ b/pkg/providers/appsec/provider_test.go @@ -7,8 +7,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -16,32 +17,23 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - -func testAccPreCheck(_ *testing.T) { - -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/appsec/resource_akamai_appsec_activations.go b/pkg/providers/appsec/resource_akamai_appsec_activations.go index 4ae1185f4..101e97bb9 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_activations.go +++ b/pkg/providers/appsec/resource_akamai_appsec_activations.go @@ -7,9 +7,9 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -47,25 +47,10 @@ func resourceActivations() *schema.Resource { Default: "STAGING", Description: "Network on which to activate the configuration version (STAGING or PRODUCTION)", }, - "activate": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Whether to activate or deactivate the specified security configuration and version", - Deprecated: `The setting activate has been deprecated; "terraform apply" will always perform activation. (Use "terraform destroy" for deactivation.)`, - }, "note": { - Type: schema.TypeString, - Optional: true, - Description: "Note describing the activation. Will use timestamp if omitted.", - ConflictsWith: []string{"notes"}, - }, - "notes": { - Type: schema.TypeString, - Optional: true, - Description: "Note describing the activation", - Deprecated: `The setting notes has been deprecated. Use "note" instead.`, - ConflictsWith: []string{"note"}, + Type: schema.TypeString, + Optional: true, + Description: "Note describing the activation. Will use timestamp if omitted.", }, "notification_emails": { Type: schema.TypeSet, @@ -98,7 +83,7 @@ var ( ) func resourceActivationsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceActivationsCreate") logger.Debug("in resourceActivationsCreate") @@ -120,12 +105,6 @@ func resourceActivationsCreate(ctx context.Context, d *schema.ResourceData, m in if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - if note == "" { - note, err = tf.GetStringValue("notes", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return diag.FromErr(err) - } - } if note == "" { note, err = defaultActivationNote(false) if err != nil { @@ -187,7 +166,7 @@ func resourceActivationsCreate(ctx context.Context, d *schema.ResourceData, m in } func resourceActivationsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceActivationsRead") logger.Debug("in resourceActivationsRead") @@ -215,7 +194,7 @@ func resourceActivationsRead(ctx context.Context, d *schema.ResourceData, m inte } func resourceActivationsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceActivationsUpdate") logger.Debug("in resourceActivationsUpdate") @@ -237,12 +216,6 @@ func resourceActivationsUpdate(ctx context.Context, d *schema.ResourceData, m in if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - if errors.Is(err, tf.ErrNotFound) { - note, err = tf.GetStringValue("notes", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return diag.FromErr(err) - } - } if note == "" { note, err = defaultActivationNote(false) if err != nil { @@ -305,7 +278,7 @@ func resourceActivationsUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourceActivationsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceActivationsRemove") logger.Debug("in resourceActivationsDelete") @@ -332,12 +305,6 @@ func resourceActivationsDelete(ctx context.Context, d *schema.ResourceData, m in if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - if note == "" { - note, err = tf.GetStringValue("notes", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return diag.FromErr(err) - } - } if note == "" { note, err = defaultActivationNote(true) if err != nil { @@ -404,7 +371,7 @@ func resourceActivationsDelete(ctx context.Context, d *schema.ResourceData, m in } func resourceImporter(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceActivationsImport") logger.Debug("in appsec_activation resource's resourceImporter") @@ -438,9 +405,6 @@ func resourceImporter(ctx context.Context, d *schema.ResourceData, m interface{} for _, activation := range response.ActivationHistory { if activation.Version == version && activation.Network == network { d.SetId(strconv.Itoa(activation.ActivationID)) - if err = d.Set("activate", true); err != nil { - return nil, err - } if err = d.Set("config_id", configID); err != nil { return nil, err } diff --git a/pkg/providers/appsec/resource_akamai_appsec_activations_test.go b/pkg/providers/appsec/resource_akamai_appsec_activations_test.go index 7257964cc..25ed65e96 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_activations_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_activations_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 7dd51d200..7a07229ca 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,9 +8,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -52,7 +52,7 @@ func resourceAdvancedSettingsAttackPayloadLogging() *schema.Resource { } func resourceAdvancedSettingsAttackPayloadLoggingImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("APPSEC", "resourceAdvancedSettingsAttackPayloadLoggingImport") logger.Debugf("Import AdvancedSettingsAttackPayloadLogging") @@ -117,7 +117,7 @@ func resourceAdvancedSettingsAttackPayloadLoggingImport(ctx context.Context, d * } func resourceAdvancedSettingsAttackPayloadLoggingCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsAttackPayloadLoggingCreate") logger.Debugf("in resourceAdvancedSettingsAttackPayloadLoggingCreate") @@ -156,7 +156,7 @@ func resourceAdvancedSettingsAttackPayloadLoggingCreate(ctx context.Context, d * } func resourceAdvancedSettingsAttackPayloadLoggingRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsAttackPayloadLoggingRead") logger.Debugf("in resourceAdvancedSettingsLoggingRead") @@ -202,7 +202,7 @@ func resourceAdvancedSettingsAttackPayloadLoggingRead(ctx context.Context, d *sc } func resourceAdvancedSettingsAttackPayloadLoggingUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsAttackPayloadLoggingUpdate") logger.Debugf("in resourceAdvancedSettingsAttackPayloadLoggingUpdate") @@ -238,7 +238,7 @@ func resourceAdvancedSettingsAttackPayloadLoggingUpdate(ctx context.Context, d * } func resourceAdvancedSettingsAttackPayloadLoggingDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsAttackPayloadLoggingDelete") logger.Debugf("in resourceAdvancedSettingsAttackPayloadLoggingDelete") 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 966120fb7..113b0a6b9 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 2d696bd5c..1387bc1ea 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,9 +7,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -51,7 +51,7 @@ func resourceAdvancedSettingsEvasivePathMatch() *schema.Resource { } func resourceAdvancedSettingsEvasivePathMatchCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsEvasivePathMatchCreate") logger.Debugf("in resourceAdvancedSettingsEvasivePathMatchCreate") @@ -96,7 +96,7 @@ func resourceAdvancedSettingsEvasivePathMatchCreate(ctx context.Context, d *sche } func resourceAdvancedSettingsEvasivePathMatchRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsEvasivePathMatchRead") logger.Debugf("in resourceAdvancedSettingsEvasivePathMatchRead") @@ -154,7 +154,7 @@ func resourceAdvancedSettingsEvasivePathMatchRead(ctx context.Context, d *schema } func resourceAdvancedSettingsEvasivePathMatchUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsEvasivePathMatchUpdate") logger.Debugf("in resourceAdvancedSettingsEvasivePathMatchUpdate") @@ -207,7 +207,7 @@ func resourceAdvancedSettingsEvasivePathMatchUpdate(ctx context.Context, d *sche } func resourceAdvancedSettingsEvasivePathMatchDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsEvasivePathMatchDelete") logger.Debugf("in resourceAdvancedSettingsEvasivePathMatchDelete") 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 14d12e5e3..f40c64e98 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 615858f60..a32895f8c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go @@ -8,9 +8,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceAdvancedSettingsLogging() *schema.Resource { } func resourceAdvancedSettingsLoggingCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsLoggingCreate") logger.Debugf("in resourceAdvancedSettingsLoggingCreate") @@ -99,7 +99,7 @@ func resourceAdvancedSettingsLoggingCreate(ctx context.Context, d *schema.Resour } func resourceAdvancedSettingsLoggingRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsLoggingRead") logger.Debugf("in resourceAdvancedSettingsLoggingRead") @@ -161,7 +161,7 @@ func resourceAdvancedSettingsLoggingRead(ctx context.Context, d *schema.Resource } func resourceAdvancedSettingsLoggingUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsLoggingUpdate") logger.Debugf("in resourceAdvancedSettingsLoggingUpdate") @@ -214,7 +214,7 @@ func resourceAdvancedSettingsLoggingUpdate(ctx context.Context, d *schema.Resour } func resourceAdvancedSettingsLoggingDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsLoggingDelete") logger.Debugf("in resourceAdvancedSettingsLoggingDelete") 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 ba27eb22b..fd71c11b2 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 new file mode 100644 index 000000000..ba2ba4ce2 --- /dev/null +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go @@ -0,0 +1,172 @@ +package appsec + +import ( + "context" + "fmt" + "strconv" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "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" +) + +func resourceAdvancedSettingsPIILearning() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceAdvancedSettingsPIILearningCreate, + ReadContext: resourceAdvancedSettingsPIILearningRead, + UpdateContext: resourceAdvancedSettingsPIILearningUpdate, + DeleteContext: resourceAdvancedSettingsPIILearningDelete, + CustomizeDiff: customdiff.All( + VerifyIDUnchanged, + ), + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: map[string]*schema.Schema{ + "config_id": { + Type: schema.TypeInt, + Required: true, + Description: "Unique identifier of the security configuration", + }, + "enable_pii_learning": { + Type: schema.TypeBool, + Required: true, + Description: "Whether to enable the PII learning advanced setting", + }, + }, + } +} + +func resourceAdvancedSettingsPIILearningCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + meta := meta.Must(m) + client := inst.Client(meta) + logger := meta.Log("APPSEC", "resourceAdvancedSettingsPIILearningCreate") + + configID, err := tf.GetIntValue("config_id", d) + if err != nil { + return diag.FromErr(err) + } + version, err := getModifiableConfigVersion(ctx, configID, "piiLearningSetting", m) + if err != nil { + return diag.FromErr(err) + } + enablePIILearning, err := tf.GetBoolValue("enable_pii_learning", d) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateAdvancedSettingsPIILearning(ctx, appsec.UpdateAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: int64(configID), + Version: version, + }, + EnablePIILearning: enablePIILearning, + }) + if err != nil { + logger.Errorf("calling 'updateAdvancedSettingsPIILearning': %s", err.Error()) + return diag.FromErr(err) + } + + d.SetId(fmt.Sprintf("%d", configID)) + + return resourceAdvancedSettingsPIILearningRead(ctx, d, m) +} + +func resourceAdvancedSettingsPIILearningRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + meta := meta.Must(m) + client := inst.Client(meta) + logger := meta.Log("APPSEC", "resourceAdvancedSettingsPIILearningRead") + + configID, err := strconv.Atoi(d.Id()) + if err != nil { + return diag.FromErr(err) + } + version, err := getLatestConfigVersion(ctx, configID, m) + if err != nil { + return diag.FromErr(err) + } + + advancedSettingsPIILearning, err := client.GetAdvancedSettingsPIILearning(ctx, appsec.GetAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: int64(configID), + Version: version, + }, + }) + if err != nil { + logger.Errorf("calling 'getAdvancedSettingsPIILearning': %s", err.Error()) + return diag.FromErr(err) + } + + if err := d.Set("config_id", configID); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + if err := d.Set("enable_pii_learning", advancedSettingsPIILearning.EnablePIILearning); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + + return nil +} + +func resourceAdvancedSettingsPIILearningUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + meta := meta.Must(m) + client := inst.Client(meta) + logger := meta.Log("APPSEC", "resourceAdvancedSettingsPIILearningUpdate") + + configID, err := strconv.Atoi(d.Id()) + if err != nil { + return diag.FromErr(err) + } + version, err := getModifiableConfigVersion(ctx, configID, "piiLearningSetting", m) + if err != nil { + return diag.FromErr(err) + } + enablePIILearning, err := tf.GetBoolValue("enable_pii_learning", d) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateAdvancedSettingsPIILearning(ctx, appsec.UpdateAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: int64(configID), + Version: version, + }, + EnablePIILearning: enablePIILearning, + }) + if err != nil { + logger.Errorf("calling 'updateAdvancedSettingsPIILearning': %s", err.Error()) + return diag.FromErr(err) + } + + return resourceAdvancedSettingsPIILearningRead(ctx, d, m) +} + +func resourceAdvancedSettingsPIILearningDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + meta := meta.Must(m) + client := inst.Client(meta) + logger := meta.Log("APPSEC", "resourceAdvancedSettingsPIILearningDelete") + + configID, err := strconv.Atoi(d.Id()) + if err != nil { + return diag.FromErr(err) + } + version, err := getModifiableConfigVersion(ctx, configID, "piiLearningSetting", m) + if err != nil { + return diag.FromErr(err) + } + + _, err = client.UpdateAdvancedSettingsPIILearning(ctx, appsec.UpdateAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: int64(configID), + Version: version, + }, + EnablePIILearning: false, + }) + if err != nil { + logger.Errorf("calling 'updateAdvancedSettingsPIILearning': %s", err.Error()) + return diag.FromErr(err) + } + return nil +} 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 new file mode 100644 index 000000000..f84d33de0 --- /dev/null +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go @@ -0,0 +1,152 @@ +package appsec + +import ( + "bytes" + "encoding/json" + "errors" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func TestAkamaiAdvancedSettingsPIILearning_res_basic(t *testing.T) { + t.Run("match by AdvancedSettingsPIILearning", func(t *testing.T) { + client := &appsec.Mock{} + + configResponse := appsec.GetConfigurationResponse{} + err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &configResponse) + require.NoError(t, err) + + getResponse := appsec.AdvancedSettingsPIILearningResponse{} + err = json.Unmarshal(loadFixtureBytes("testdata/TestResAdvancedSettingsPIILearning/PIILearning.json"), &getResponse) + require.NoError(t, err) + + updateResponse := appsec.AdvancedSettingsPIILearningResponse{} + piiLearningBytes := loadFixtureBytes("testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json") + var piiLearningJSON bytes.Buffer + err = json.Compact(&piiLearningJSON, []byte(piiLearningBytes)) + require.NoError(t, err) + err = json.Unmarshal(piiLearningBytes, &updateResponse) + require.NoError(t, err) + + removeResponse := appsec.AdvancedSettingsPIILearningResponse{} + err = json.Unmarshal(loadFixtureBytes("testdata/TestResAdvancedSettingsPIILearning/PIILearning.json"), &removeResponse) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&configResponse, nil) + + client.On("UpdateAdvancedSettingsPIILearning", + mock.Anything, + appsec.UpdateAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: 43253, + Version: 7, + }, + EnablePIILearning: true}, + ).Return(&updateResponse, nil) + + client.On("GetAdvancedSettingsPIILearning", + mock.Anything, + appsec.GetAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: 43253, + Version: 7}, + }, + ).Return(&getResponse, nil) + + client.On("UpdateAdvancedSettingsPIILearning", + mock.Anything, + appsec.UpdateAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: 43253, + Version: 7, + }, + }, + ).Return(&removeResponse, nil) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResAdvancedSettingsPIILearning/match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_advanced_settings_pii_learning.test", "id", "43253"), + resource.TestCheckResourceAttr("akamai_appsec_advanced_settings_pii_learning.test", "enable_pii_learning", "true"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + +} + +func TestAkamaiAdvancedSettingsPIILearning_res_api_call_failure(t *testing.T) { + t.Run("match by AdvancedSettingsPIILearning", func(t *testing.T) { + client := &appsec.Mock{} + + configResponse := appsec.GetConfigurationResponse{} + err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &configResponse) + require.NoError(t, err) + + getResponse := appsec.AdvancedSettingsPIILearningResponse{} + err = json.Unmarshal(loadFixtureBytes("testdata/TestResAdvancedSettingsPIILearning/PIILearning.json"), &getResponse) + require.NoError(t, err) + + updateResponse := appsec.AdvancedSettingsPIILearningResponse{} + piiLearningBytes := loadFixtureBytes("testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json") + var piiLearningJSON bytes.Buffer + err = json.Compact(&piiLearningJSON, []byte(piiLearningBytes)) + require.NoError(t, err) + err = json.Unmarshal(piiLearningBytes, &updateResponse) + require.NoError(t, err) + + removeResponse := appsec.AdvancedSettingsPIILearningResponse{} + err = json.Unmarshal(loadFixtureBytes("testdata/TestResAdvancedSettingsPIILearning/PIILearning.json"), &removeResponse) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&configResponse, nil) + + client.On("UpdateAdvancedSettingsPIILearning", + mock.Anything, + appsec.UpdateAdvancedSettingsPIILearningRequest{ + ConfigVersion: appsec.ConfigVersion{ + ConfigID: 43253, + Version: 7, + }, + EnablePIILearning: true}, + ).Return(nil, errors.New("API call failure")) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResAdvancedSettingsPIILearning/match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_advanced_settings_pii_learning.test", "id", "43253"), + ), + ExpectError: regexp.MustCompile(`API call failure`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) +} 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 039d652bc..bf02d65e3 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,9 +8,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -51,7 +51,7 @@ func resourceAdvancedSettingsPragmaHeader() *schema.Resource { } func resourceAdvancedSettingsPragmaHeaderCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPragmaHeaderCreate") logger.Debugf("in resourceAdvancedSettingsPragmaHeaderCreate") @@ -95,7 +95,7 @@ func resourceAdvancedSettingsPragmaHeaderCreate(ctx context.Context, d *schema.R } func resourceAdvancedSettingsPragmaHeaderRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPragmaHeaderRead") logger.Debug("in resourceAdvancedSettingsPragmaHeaderRead") @@ -158,7 +158,7 @@ func resourceAdvancedSettingsPragmaHeaderRead(ctx context.Context, d *schema.Res } func resourceAdvancedSettingsPragmaHeaderDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPragmaHeaderDelete") logger.Debugf("in resourceAdvancedSettingsPragmaHeaderDelete") @@ -212,7 +212,7 @@ func resourceAdvancedSettingsPragmaHeaderDelete(ctx context.Context, d *schema.R } func resourceAdvancedSettingsPragmaHeaderUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPragmaHeaderUpdate") logger.Debugf("in resourceAdvancedSettingsPragmaHeaderUpdate") 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 bfb67c178..f72d06c9e 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 80cb8111d..03a9dba01 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -61,7 +61,7 @@ func resourceAdvancedSettingsPrefetch() *schema.Resource { } func resourceAdvancedSettingsPrefetchCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPrefetchCreate") logger.Debugf("in resourceAdvancedSettingsPrefetchCreate") @@ -117,7 +117,7 @@ func resourceAdvancedSettingsPrefetchCreate(ctx context.Context, d *schema.Resou } func resourceAdvancedSettingsPrefetchRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPrefetchRead") logger.Debugf("in resourceAdvancedSettingsPrefetchRead") @@ -162,7 +162,7 @@ func resourceAdvancedSettingsPrefetchRead(ctx context.Context, d *schema.Resourc } func resourceAdvancedSettingsPrefetchUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPrefetchUpdate") logger.Debugf("in resourceAdvancedSettingsPrefetchUpdate") @@ -216,7 +216,7 @@ func resourceAdvancedSettingsPrefetchUpdate(ctx context.Context, d *schema.Resou } func resourceAdvancedSettingsPrefetchDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsPrefetchDelete") logger.Debugf("in resourceAdvancedSettingsPrefetchDelete") 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 13758849a..2c45aa96f 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 c8f7545c9..82a2d6925 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,9 +7,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -48,7 +48,7 @@ func resourceAdvancedSettingsRequestBody() *schema.Resource { } func resourceAdvancedSettingsRequestBodyImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("APPSEC", "resourceAdvancedSettingsRequestBodyImport") logger.Debugf("Import AdvancedSettingsRequestBody") @@ -108,7 +108,7 @@ func resourceAdvancedSettingsRequestBodyImport(ctx context.Context, d *schema.Re } func resourceAdvancedSettingsRequestBodyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("APPSEC", "resourceAdvancedSettingsRequestBodyCreate") logger.Debugf("in resourceAdvancedSettingsRequestBodyCreate") @@ -116,7 +116,7 @@ func resourceAdvancedSettingsRequestBodyCreate(ctx context.Context, d *schema.Re } func upsertAdvancedSettingsRequestBody(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) configID, err := tf.GetIntValue("config_id", d) @@ -151,7 +151,7 @@ func upsertAdvancedSettingsRequestBody(ctx context.Context, d *schema.ResourceDa return resourceAdvancedSettingsRequestBodyRead(ctx, d, m) } func resourceAdvancedSettingsRequestBodyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsRequestBodyRead") logger.Debugf("in resourceAdvancedSettingsRequestBodyRead") @@ -193,7 +193,7 @@ func resourceAdvancedSettingsRequestBodyRead(ctx context.Context, d *schema.Reso } func resourceAdvancedSettingsRequestBodyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("APPSEC", "resourceAdvancedSettingsRequestBodyUpdate") logger.Debugf("in resourceAdvancedSettingsRequestBodyUpdate") @@ -201,7 +201,7 @@ func resourceAdvancedSettingsRequestBodyUpdate(ctx context.Context, d *schema.Re } func resourceAdvancedSettingsRequestBodyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAdvancedSettingsRequestBodyDelete") logger.Debugf("in resourceAdvancedSettingsRequestBodyDelete") 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 27c9175ea..6a757e413 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 b9eab484a..1c8f45861 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceAPIConstraintsProtection() *schema.Resource { } func resourceAPIConstraintsProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIConstraintsProtectionCreate") logger.Debugf("in resourceAPIConstraintsProtectionCreate") @@ -94,7 +94,7 @@ func resourceAPIConstraintsProtectionCreate(ctx context.Context, d *schema.Resou } func resourceAPIConstraintsProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIConstraintsProtectionRead") logger.Debugf("in resourceAPIConstraintsProtectionRead") @@ -149,7 +149,7 @@ func resourceAPIConstraintsProtectionRead(ctx context.Context, d *schema.Resourc } func resourceAPIConstraintsProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIConstraintsProtectionUpdate") logger.Debugf("in resourceAPIConstraintsProtectionUpdate") @@ -188,7 +188,7 @@ func resourceAPIConstraintsProtectionUpdate(ctx context.Context, d *schema.Resou } func resourceAPIConstraintsProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIConstraintsProtectionDelete") logger.Debugf("in resourceAPIConstraintsProtectionDelete") 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 df3725e0b..6cf32fa91 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -88,7 +88,6 @@ func TestAkamaiAPICoProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ 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 e33e0e571..fb6be35b3 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -57,7 +57,7 @@ func resourceAPIRequestConstraints() *schema.Resource { } func resourceAPIRequestConstraintsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIRequestConstraintsCreate") logger.Debugf("in resourceAPIRequestConstraintsCreate") @@ -107,7 +107,7 @@ func resourceAPIRequestConstraintsCreate(ctx context.Context, d *schema.Resource } func resourceAPIRequestConstraintsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIRequestConstraintsRead") logger.Debugf("in resourceAPIRequestConstraintsRead") @@ -170,7 +170,7 @@ func resourceAPIRequestConstraintsRead(ctx context.Context, d *schema.ResourceDa } func resourceAPIRequestConstraintsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIRequestConstraintsUpdate") logger.Debugf("in resourceAPIRequestConstraintsUpdate") @@ -215,7 +215,7 @@ func resourceAPIRequestConstraintsUpdate(ctx context.Context, d *schema.Resource } func resourceAPIRequestConstraintsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAPIRequestConstraintsDelete") logger.Debugf("in resourceAPIRequestConstraintsDelete") 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 8b1354f21..3d894b2ca 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_attack_group.go b/pkg/providers/appsec/resource_akamai_appsec_attack_group.go index 834fa95bd..2bf776579 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_attack_group.go +++ b/pkg/providers/appsec/resource_akamai_appsec_attack_group.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -66,7 +66,7 @@ func resourceAttackGroup() *schema.Resource { } func resourceAttackGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAttackGroupCreate") logger.Debugf(" in resourceAttackGroupCreate") @@ -122,7 +122,7 @@ func resourceAttackGroupCreate(ctx context.Context, d *schema.ResourceData, m in } func resourceAttackGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAttackGroupRead") logger.Debugf(" in resourceAttackGroupRead") @@ -181,7 +181,7 @@ func resourceAttackGroupRead(ctx context.Context, d *schema.ResourceData, m inte } func resourceAttackGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAttackGroupUpdate") logger.Debugf(" in resourceAttackGroupUpdate") @@ -235,7 +235,7 @@ func resourceAttackGroupUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourceAttackGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceAttackGroupDelete") logger.Debugf(" in resourceAttackGroupDelete") 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 5197daaf9..782a14c8c 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 171a641af..971adac07 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go +++ b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go @@ -5,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -47,7 +47,7 @@ func resourceBypassNetworkLists() *schema.Resource { } func resourceBypassNetworkListsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceBypassNetworkListsCreate") logger.Debug("in resourceBypassNetworkListsCreate") @@ -92,7 +92,7 @@ func resourceBypassNetworkListsCreate(ctx context.Context, d *schema.ResourceDat } func resourceBypassNetworkListsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceBypassNetworkListsRead") logger.Debug("in resourceBypassNetworkListsRead") @@ -136,7 +136,7 @@ func resourceBypassNetworkListsRead(ctx context.Context, d *schema.ResourceData, } func resourceBypassNetworkListsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceBypassNetworkListsUpdate") logger.Debug("in resourceBypassNetworkListsUpdate") @@ -182,7 +182,7 @@ func resourceBypassNetworkListsUpdate(ctx context.Context, d *schema.ResourceDat func resourceBypassNetworkListsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceBypassNetworkListsDelete") logger.Debug("in resourceBypassNetworkListsDelete") 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 559a11f86..afe02af71 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration.go b/pkg/providers/appsec/resource_akamai_appsec_configuration.go index 699ad4583..4f8419476 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -72,7 +72,7 @@ func resourceConfiguration() *schema.Resource { } func resourceConfigurationCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationCreate") logger.Debug("in resourceConfigurationCreate") @@ -156,7 +156,7 @@ func resourceConfigurationCreate(ctx context.Context, d *schema.ResourceData, m } func resourceConfigurationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationRead") logger.Debug("in resourceConfigurationRead") @@ -213,7 +213,7 @@ func resourceConfigurationRead(ctx context.Context, d *schema.ResourceData, m in } func resourceConfigurationUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationUpdate") logger.Debug("in resourceConfigurationUpdate") @@ -277,7 +277,7 @@ func resourceConfigurationUpdate(ctx context.Context, d *schema.ResourceData, m } func resourceConfigurationDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationDelete") logger.Debug("in resourceConfigurationDelete") diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go index cb1af7b56..a3e488ddd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go @@ -5,9 +5,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -49,7 +49,7 @@ func resourceConfigurationRename() *schema.Resource { } func resourceConfigurationRenameCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationRenameCreate") logger.Debugf("in resourceConfigurationRenameCreate") @@ -85,7 +85,7 @@ func resourceConfigurationRenameCreate(ctx context.Context, d *schema.ResourceDa } func resourceConfigurationRenameRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationRenameRead") logger.Debugf("in resourceConfigurationRenameRead") @@ -119,7 +119,7 @@ func resourceConfigurationRenameRead(ctx context.Context, d *schema.ResourceData } func resourceConfigurationRenameUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceConfigurationRenameUpdate") logger.Debugf("in resourceConfigurationRenameUpdate") 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 553f551e9..88429209f 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go index fbaa8c97f..3b1095495 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go b/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go index 84d72a2f3..61da96302 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go @@ -7,9 +7,9 @@ import ( "log" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -54,7 +54,7 @@ func resourceCustomDeny() *schema.Resource { } func resourceCustomDenyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomDenyCreate") logger.Debugf("in resourceCustomDenyCreate") @@ -94,7 +94,7 @@ func resourceCustomDenyCreate(ctx context.Context, d *schema.ResourceData, m int } func resourceCustomDenyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomDenyRead") logger.Debugf("in resourceCustomDenyRead") @@ -144,7 +144,7 @@ func resourceCustomDenyRead(ctx context.Context, d *schema.ResourceData, m inter } func resourceCustomDenyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomDenyUpdate") logger.Debugf("in resourceCustomDenyUpdate") @@ -185,7 +185,7 @@ func resourceCustomDenyUpdate(ctx context.Context, d *schema.ResourceData, m int } func resourceCustomDenyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomDenyDelete") logger.Debugf("in resourceCustomDenyDelete") 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 c37700ae4..379ab436d 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go index 487d66295..1c696fe97 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -53,7 +53,7 @@ func resourceCustomRule() *schema.Resource { } func resourceCustomRuleCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleCreate") logger.Debugf("in resourceCustomRuleCreate") @@ -91,7 +91,7 @@ func resourceCustomRuleCreate(ctx context.Context, d *schema.ResourceData, m int } func resourceCustomRuleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleRead") logger.Debugf("in resourceCustomRuleRead") @@ -141,7 +141,7 @@ func resourceCustomRuleRead(ctx context.Context, d *schema.ResourceData, m inter } func resourceCustomRuleUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleUpdate") logger.Debugf("in resourceCustomRuleUpdate") @@ -181,7 +181,7 @@ func resourceCustomRuleUpdate(ctx context.Context, d *schema.ResourceData, m int } func resourceCustomRuleDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleDelete") logger.Debugf("in resourceCustomRuleDelete") @@ -212,7 +212,7 @@ func resourceCustomRuleDelete(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - var status string = customrules.CustomRules[0].Status + var status = customrules.CustomRules[0].Status if strings.Compare(status, "unused") == 0 { removeCustomRule := appsec.RemoveCustomRuleRequest{ 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 d87adc89d..5c9f4872e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -56,7 +56,7 @@ func resourceCustomRuleAction() *schema.Resource { } func resourceCustomRuleActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleActionCreate") logger.Debugf("in resourceCustomRuleActionCreate") @@ -102,7 +102,7 @@ func resourceCustomRuleActionCreate(ctx context.Context, d *schema.ResourceData, } func resourceCustomRuleActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleActionRead") logger.Debugf("in resourceCustomRuleActionRead") @@ -154,7 +154,7 @@ func resourceCustomRuleActionRead(ctx context.Context, d *schema.ResourceData, m } func resourceCustomRuleActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleActionUpdate") logger.Debugf("in resourceCustomRuleActionUpdate") @@ -199,7 +199,7 @@ func resourceCustomRuleActionUpdate(ctx context.Context, d *schema.ResourceData, } func resourceCustomRuleActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceCustomRuleActionDelete") logger.Debugf("in resourceCustomRuleActionDelete") 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 0d60a0d79..83526ebdd 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 0040b2091..364c7205f 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval.go b/pkg/providers/appsec/resource_akamai_appsec_eval.go index 0e2984e5a..869795506 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -87,7 +87,7 @@ func resourceEval() *schema.Resource { } func resourceEvalCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalCreate") logger.Debugf(" in resourceEvalCreate") @@ -134,7 +134,7 @@ func resourceEvalCreate(ctx context.Context, d *schema.ResourceData, m interface } func resourceEvalRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalRead") logger.Debugf(" in resourceEvalRead") @@ -188,7 +188,7 @@ func resourceEvalRead(ctx context.Context, d *schema.ResourceData, m interface{} } func resourceEvalUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalUpdate") logger.Debugf(" in resourceEvalUpdate") @@ -233,7 +233,7 @@ func resourceEvalUpdate(ctx context.Context, d *schema.ResourceData, m interface } func resourceEvalDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalDelete") logger.Debugf(" in resourceEvalDelete") diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_group.go b/pkg/providers/appsec/resource_akamai_appsec_eval_group.go index 6ad763bce..73124f74f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_group.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_group.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -66,7 +66,7 @@ func resourceEvalGroup() *schema.Resource { } func resourceEvalGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalGroupCreate") logger.Debugf("in resourceEvalGroupCreate") @@ -123,7 +123,7 @@ func resourceEvalGroupCreate(ctx context.Context, d *schema.ResourceData, m inte } func resourceEvalGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalGroupRead") logger.Debugf("in resourceEvalGroupRead") @@ -182,7 +182,7 @@ func resourceEvalGroupRead(ctx context.Context, d *schema.ResourceData, m interf } func resourceEvalGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalGroupUpdate") logger.Debugf("in resourceEvalGroupUpdate") @@ -236,7 +236,7 @@ func resourceEvalGroupUpdate(ctx context.Context, d *schema.ResourceData, m inte } func resourceEvalGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalgroupDelete") logger.Debugf("in resourceEvalGroupDelete") 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 4c4add41b..1ef99bb19 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 d7c05c1bc..168f782a3 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go @@ -5,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -60,7 +60,7 @@ func resourceEvalPenaltyBox() *schema.Resource { } func resourceEvalPenaltyBoxCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalPenaltyBoxCreate") logger.Debugf("in resourceEvalPenaltyBoxCreate") @@ -106,7 +106,7 @@ func resourceEvalPenaltyBoxCreate(ctx context.Context, d *schema.ResourceData, m } func resourceEvalPenaltyBoxRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalPenaltyBoxRead") logger.Debugf("in resourceEvalPenaltyBoxRead") @@ -154,7 +154,7 @@ func resourceEvalPenaltyBoxRead(ctx context.Context, d *schema.ResourceData, m i } func resourceEvalPenaltyBoxUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalPenaltyBoxUpdate") logger.Debugf("in resourceEvalPenaltyBoxUpdate") @@ -199,7 +199,7 @@ func resourceEvalPenaltyBoxUpdate(ctx context.Context, d *schema.ResourceData, m } func resourceEvalPenaltyBoxDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalPenaltyBoxDelete") logger.Debugf("in resourceEvalPenaltyBoxDelete") 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 d1ada0a2a..d7df3a1a9 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go b/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go index 9a10f4250..5ede74deb 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -66,7 +66,7 @@ func resourceEvalRule() *schema.Resource { } func resourceEvalRuleCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalRuleCreate") logger.Debugf("in resourceEvalRuleCreate") @@ -122,7 +122,7 @@ func resourceEvalRuleCreate(ctx context.Context, d *schema.ResourceData, m inter } func resourceEvalRuleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalRuleRead") logger.Debugf("in resourceEvalRuleRead") @@ -184,7 +184,7 @@ func resourceEvalRuleRead(ctx context.Context, d *schema.ResourceData, m interfa } func resourceEvalRuleUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalRuleUpdate") logger.Debugf("in resourceEvalRuleUpdate") @@ -240,7 +240,7 @@ func resourceEvalRuleUpdate(ctx context.Context, d *schema.ResourceData, m inter } func resourceEvalRuleDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceEvalRuleDelete") logger.Debugf("in resourceEvalRuleDelete") 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 30dfe3d0a..d053c07a9 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_test.go index 183d98df7..20170004a 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go index a9868efdb..b7a3b1fec 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -68,6 +68,11 @@ func resourceIPGeo() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Description: "List of IDs of network list that are always allowed", }, + "ukraine_geo_control_action": { + Type: schema.TypeString, + Optional: true, + Description: "Action set for Ukraine geo control", + }, }, } } @@ -115,7 +120,7 @@ func ipControlsFromBlockAndAllowLists(blockedIPLists []interface{}, exceptionIPL } func resourceIPGeoCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoCreate") logger.Debugf("in resourceIPGeoCreate") @@ -148,6 +153,10 @@ func resourceIPGeoCreate(ctx context.Context, d *schema.ResourceData, m interfac if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } + ukraineGeoControlAction, err := tf.GetStringValue("ukraine_geo_control_action", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return diag.FromErr(err) + } request := appsec.UpdateIPGeoRequest{ ConfigID: configID, @@ -163,6 +172,9 @@ func resourceIPGeoCreate(ctx context.Context, d *schema.ResourceData, m interfac request.Block = "blockSpecificIPGeo" request.GeoControls = geoControlsFromBlockLists(blockedGeoLists) request.IPControls = ipControlsFromBlockAndAllowLists(blockedIPLists, exceptionIPLists) + if ukraineGeoControlAction != "" { + request.UkraineGeoControls = &appsec.UkraineGeoControl{Action: ukraineGeoControlAction} + } } _, err = client.UpdateIPGeo(ctx, request) @@ -177,7 +189,7 @@ func resourceIPGeoCreate(ctx context.Context, d *schema.ResourceData, m interfac } func resourceIPGeoRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoRead") logger.Debugf("in resourceIPGeoRead") @@ -269,11 +281,16 @@ func readForBlockSpecificIPGeo(d *schema.ResourceData, ipgeo *appsec.GetIPGeoRes return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } } + if ipgeo.UkraineGeoControls != nil { + if err := d.Set("ukraine_geo_control_action", ipgeo.UkraineGeoControls.Action); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + } return nil } func resourceIPGeoUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoUpdate") logger.Debugf("in resourceIPGeoUpdate") @@ -307,6 +324,10 @@ func resourceIPGeoUpdate(ctx context.Context, d *schema.ResourceData, m interfac if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } + ukraineGeoControlAction, err := tf.GetStringValue("ukraine_geo_control_action", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return diag.FromErr(err) + } request := appsec.UpdateIPGeoRequest{ ConfigID: configID, @@ -321,6 +342,9 @@ func resourceIPGeoUpdate(ctx context.Context, d *schema.ResourceData, m interfac request.Block = "blockSpecificIPGeo" request.GeoControls = geoControlsFromBlockLists(blockedGeoLists) request.IPControls = ipControlsFromBlockAndAllowLists(blockedIPLists, exceptionIPLists) + if ukraineGeoControlAction != "" { + request.UkraineGeoControls = &appsec.UkraineGeoControl{Action: ukraineGeoControlAction} + } } _, err = client.UpdateIPGeo(ctx, request) @@ -333,7 +357,7 @@ func resourceIPGeoUpdate(ctx context.Context, d *schema.ResourceData, m interfac } func resourceIPGeoDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoDelete") logger.Debugf("in resourceIPGeoDelete") 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 eece684c6..e3c0c3fda 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceIPGeoProtection() *schema.Resource { } func resourceIPGeoProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoProtectionCreate") logger.Debugf("in resourceIPGeoProtectionCreate") @@ -93,7 +93,7 @@ func resourceIPGeoProtectionCreate(ctx context.Context, d *schema.ResourceData, } func resourceIPGeoProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoProtectionRead") logger.Debugf("in resourceIPGeoProtectionRead") @@ -147,7 +147,7 @@ func resourceIPGeoProtectionRead(ctx context.Context, d *schema.ResourceData, m } func resourceIPGeoProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoProtectionUpdate") logger.Debugf("in resourceIPGeoProtectionUpdate") @@ -185,7 +185,7 @@ func resourceIPGeoProtectionUpdate(ctx context.Context, d *schema.ResourceData, } func resourceIPGeoProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceIPGeoProtectionDelete") logger.Debugf("in resourceIPGeoProtectionDelete") 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 cd037bd6b..58de6b68b 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -88,7 +88,6 @@ func TestAkamaiIPGeoProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ 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 3d29d0aaa..a8e3a8f95 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go @@ -4,79 +4,99 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestAkamaiIPGeo_res_block(t *testing.T) { + var ( + configVersion = func(t *testing.T, configId int, client *appsec.Mock) appsec.GetConfigurationResponse { + configResponse := appsec.GetConfigurationResponse{} + err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &configResponse) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: configId}, + ).Return(&configResponse, nil) + + return configResponse + } + + getIPGeoResponse = func(t *testing.T, configId int, version int, policyId string, path string, client *appsec.Mock) appsec.GetIPGeoResponse { + getIPGeoResponse := appsec.GetIPGeoResponse{} + err := json.Unmarshal(loadFixtureBytes(path), &getIPGeoResponse) + require.NoError(t, err) + + client.On("GetIPGeo", + mock.Anything, + appsec.GetIPGeoRequest{ConfigID: configId, Version: version, PolicyID: policyId}, + ).Return(&getIPGeoResponse, nil) + + return getIPGeoResponse + } + + updateIPGeoResponse = func(t *testing.T, configId int, version int, policyId string, path string, request appsec.UpdateIPGeoRequest, client *appsec.Mock) appsec.UpdateIPGeoResponse { + updateIPGeoResponse := appsec.UpdateIPGeoResponse{} + err := json.Unmarshal(loadFixtureBytes(path), &updateIPGeoResponse) + require.NoError(t, err) + + client.On("UpdateIPGeo", + mock.Anything, + request, + ).Return(&updateIPGeoResponse, nil) + return updateIPGeoResponse + } + + updateIPGeoProtectionResponseAllProtectionsFalse = func(t *testing.T, configId int, version int, policyId string, path string, client *appsec.Mock) appsec.UpdateIPGeoProtectionResponse { + updateIPGeoProtectionResponseAllProtectionsFalse := appsec.UpdateIPGeoProtectionResponse{} + err := json.Unmarshal(loadFixtureBytes(path), &updateIPGeoProtectionResponseAllProtectionsFalse) + require.NoError(t, err) + + client.On("UpdateIPGeoProtection", + mock.Anything, + appsec.UpdateIPGeoProtectionRequest{ConfigID: configId, Version: version, PolicyID: policyId}, + ).Return(&updateIPGeoProtectionResponseAllProtectionsFalse, nil).Once() + return updateIPGeoProtectionResponseAllProtectionsFalse + } + ) t.Run("match by IPGeo ID", func(t *testing.T) { client := &appsec.Mock{} - - getConfigurationResponse := appsec.GetConfigurationResponse{} - err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &getConfigurationResponse) - require.NoError(t, err) - client.On("GetConfiguration", - mock.Anything, - appsec.GetConfigurationRequest{ConfigID: 43253}, - ).Return(&getConfigurationResponse, nil) - - updateIPGeoResponse := appsec.UpdateIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeo.json"), &updateIPGeoResponse) - require.NoError(t, err) - client.On("UpdateIPGeo", - mock.Anything, - appsec.UpdateIPGeoRequest{ - ConfigID: 43253, - Version: 7, - PolicyID: "AAAA_81230", - Block: "blockSpecificIPGeo", - GeoControls: &appsec.IPGeoGeoControls{ - BlockedIPNetworkLists: &appsec.IPGeoNetworkLists{ - NetworkList: []string{ - "40731_BMROLLOUTGEO", - "44831_ECSCGEOBLACKLIST", - }, + configVersion(t, 43253, client) + + updateRequest := appsec.UpdateIPGeoRequest{ + ConfigID: 43253, + Version: 7, + PolicyID: "AAAA_81230", + Block: "blockSpecificIPGeo", + GeoControls: &appsec.IPGeoGeoControls{ + BlockedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "40731_BMROLLOUTGEO", + "44831_ECSCGEOBLACKLIST", }, }, - IPControls: &appsec.IPGeoIPControls{ - BlockedIPNetworkLists: &appsec.IPGeoNetworkLists{ - NetworkList: []string{ - "49181_ADTIPBLACKLIST", - "49185_ADTWAFBYPASSLIST", - }, + }, + IPControls: &appsec.IPGeoIPControls{ + BlockedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "49181_ADTIPBLACKLIST", + "49185_ADTWAFBYPASSLIST", }, - AllowedIPNetworkLists: &appsec.IPGeoNetworkLists{ - NetworkList: []string{ - "68762_ADYEN", - "69601_ADYENPRODWHITELIST", - }, + }, + AllowedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "68762_ADYEN", + "69601_ADYENPRODWHITELIST", }, }, }, - ).Return(&updateIPGeoResponse, nil) - - getIPGeoResponse := appsec.GetIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeo.json"), &getIPGeoResponse) - require.NoError(t, err) - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - updateIPGeoProtectionResponseAllProtectionsFalse := appsec.UpdateIPGeoProtectionResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeoProtection/PolicyProtections.json"), &updateIPGeoProtectionResponseAllProtectionsFalse) - require.NoError(t, err) - client.On("UpdateIPGeoProtection", - mock.Anything, - appsec.UpdateIPGeoProtectionRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&updateIPGeoProtectionResponseAllProtectionsFalse, nil).Once() + } + getIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeo.json", client) + updateIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeo.json", updateRequest, client) + updateIPGeoProtectionResponseAllProtectionsFalse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeoProtection/PolicyProtections.json", client) useClient(client, func() { resource.Test(t, resource.TestCase{ @@ -95,62 +115,86 @@ func TestAkamaiIPGeo_res_block(t *testing.T) { client.AssertExpectations(t) }) -} - -func TestAkamaiIPGeo_res_allow(t *testing.T) { - t.Run("match by IPGeo ID", func(t *testing.T) { + t.Run("match by Ukraine Geo ID", func(t *testing.T) { client := &appsec.Mock{} - getConfigurationResponse := appsec.GetConfigurationResponse{} - err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &getConfigurationResponse) - require.NoError(t, err) - client.On("GetConfiguration", - mock.Anything, - appsec.GetConfigurationRequest{ConfigID: 43253}, - ).Return(&getConfigurationResponse, nil) - - updateIPGeoResponse := appsec.UpdateIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeoAllow.json"), &updateIPGeoResponse) - require.NoError(t, err) - client.On("UpdateIPGeo", - mock.Anything, - appsec.UpdateIPGeoRequest{ - ConfigID: 43253, - Version: 7, - PolicyID: "AAAA_81230", - Block: "blockAllTrafficExceptAllowedIPs", - IPControls: &appsec.IPGeoIPControls{ - AllowedIPNetworkLists: &appsec.IPGeoNetworkLists{ - NetworkList: []string{ - "68762_ADYEN", - "69601_ADYENPRODWHITELIST", - }, + configVersion(t, 43253, client) + + updateRequest := appsec.UpdateIPGeoRequest{ + ConfigID: 43253, + Version: 7, + PolicyID: "AAAA_81230", + Block: "blockSpecificIPGeo", + GeoControls: &appsec.IPGeoGeoControls{ + BlockedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "40731_BMROLLOUTGEO", + "44831_ECSCGEOBLACKLIST", + }, + }, + }, + IPControls: &appsec.IPGeoIPControls{ + BlockedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "49181_ADTIPBLACKLIST", + "49185_ADTWAFBYPASSLIST", + }, + }, + AllowedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "68762_ADYEN", + "69601_ADYENPRODWHITELIST", }, }, }, - ).Return(&updateIPGeoResponse, nil) - - getIPGeoResponse := appsec.GetIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeoAllow.json"), &getIPGeoResponse) - require.NoError(t, err) - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - updateIPGeoProtectionResponseAllProtectionsFalse := appsec.UpdateIPGeoProtectionResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeoProtection/PolicyProtections.json"), &updateIPGeoProtectionResponseAllProtectionsFalse) - require.NoError(t, err) - client.On("UpdateIPGeoProtection", - mock.Anything, - appsec.UpdateIPGeoProtectionRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&updateIPGeoProtectionResponseAllProtectionsFalse, nil).Once() + UkraineGeoControls: &appsec.UkraineGeoControl{ + Action: "alert", + }, + } + getIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeo.json", client) + updateIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeo.json", updateRequest, client) + updateIPGeoProtectionResponseAllProtectionsFalse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeoProtection/PolicyProtections.json", client) + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResIPGeo/ukraine_match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_ip_geo.test1", "id", "43253:AAAA_81230"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("match by IPGeo Allow ID", func(t *testing.T) { + client := &appsec.Mock{} + + configVersion(t, 43253, client) + + updateRequest := appsec.UpdateIPGeoRequest{ + ConfigID: 43253, + Version: 7, + PolicyID: "AAAA_81230", + Block: "blockAllTrafficExceptAllowedIPs", + IPControls: &appsec.IPGeoIPControls{ + AllowedIPNetworkLists: &appsec.IPGeoNetworkLists{ + NetworkList: []string{ + "68762_ADYEN", + "69601_ADYENPRODWHITELIST", + }, + }, + }, + } + getIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeoAllow.json", client) + updateIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeoAllow.json", updateRequest, client) + updateIPGeoProtectionResponseAllProtectionsFalse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeoProtection/PolicyProtections.json", client) useClient(client, func() { resource.Test(t, resource.TestCase{ IsUnitTest: true, @@ -168,54 +212,22 @@ func TestAkamaiIPGeo_res_allow(t *testing.T) { client.AssertExpectations(t) }) -} -func TestAkamaiIPGeo_res_block_with_empty_lists(t *testing.T) { t.Run("block with empty lists", func(t *testing.T) { - client := &appsec.Mock{} - getConfigurationResponse := appsec.GetConfigurationResponse{} - err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &getConfigurationResponse) - require.NoError(t, err) - client.On("GetConfiguration", - mock.Anything, - appsec.GetConfigurationRequest{ConfigID: 43253}, - ).Return(&getConfigurationResponse, nil) - - updateIPGeoResponse := appsec.UpdateIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeoBlockOnly.json"), &updateIPGeoResponse) - require.NoError(t, err) - client.On("UpdateIPGeo", - mock.Anything, - appsec.UpdateIPGeoRequest{ - ConfigID: 43253, - Version: 7, - PolicyID: "AAAA_81230", - Block: "blockSpecificIPGeo", - }, - ).Return(&updateIPGeoResponse, nil) - - getIPGeoResponse := appsec.GetIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeoBlockOnly.json"), &getIPGeoResponse) - require.NoError(t, err) - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - updateIPGeoProtectionResponseAllProtectionsFalse := appsec.UpdateIPGeoProtectionResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeoProtection/PolicyProtections.json"), &updateIPGeoProtectionResponseAllProtectionsFalse) - require.NoError(t, err) - client.On("UpdateIPGeoProtection", - mock.Anything, - appsec.UpdateIPGeoProtectionRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&updateIPGeoProtectionResponseAllProtectionsFalse, nil).Once() + client := &appsec.Mock{} + configVersion(t, 43253, client) + + updateRequest := appsec.UpdateIPGeoRequest{ + ConfigID: 43253, + Version: 7, + PolicyID: "AAAA_81230", + Block: "blockSpecificIPGeo", + } + getIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeoBlockOnly.json", client) + updateIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeoBlockOnly.json", updateRequest, client) + updateIPGeoProtectionResponseAllProtectionsFalse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeoProtection/PolicyProtections.json", client) useClient(client, func() { resource.Test(t, resource.TestCase{ IsUnitTest: true, @@ -233,54 +245,23 @@ func TestAkamaiIPGeo_res_block_with_empty_lists(t *testing.T) { client.AssertExpectations(t) }) -} -func TestAkamaiIPGeo_res_allow_with_empty_lists(t *testing.T) { t.Run("allow with empty lists", func(t *testing.T) { + client := &appsec.Mock{} - getConfigurationResponse := appsec.GetConfigurationResponse{} - err := json.Unmarshal(loadFixtureBytes("testdata/TestResConfiguration/LatestConfiguration.json"), &getConfigurationResponse) - require.NoError(t, err) - client.On("GetConfiguration", - mock.Anything, - appsec.GetConfigurationRequest{ConfigID: 43253}, - ).Return(&getConfigurationResponse, nil) - - updateIPGeoResponse := appsec.UpdateIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeoAllowOnly.json"), &updateIPGeoResponse) - require.NoError(t, err) - client.On("UpdateIPGeo", - mock.Anything, - appsec.UpdateIPGeoRequest{ - ConfigID: 43253, - Version: 7, - PolicyID: "AAAA_81230", - Block: "blockAllTrafficExceptAllowedIPs", - }, - ).Return(&updateIPGeoResponse, nil) - - getIPGeoResponse := appsec.GetIPGeoResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeo/IPGeoAllowOnly.json"), &getIPGeoResponse) - require.NoError(t, err) - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - client.On("GetIPGeo", - mock.Anything, - appsec.GetIPGeoRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&getIPGeoResponse, nil) - - updateIPGeoProtectionResponseAllProtectionsFalse := appsec.UpdateIPGeoProtectionResponse{} - err = json.Unmarshal(loadFixtureBytes("testdata/TestResIPGeoProtection/PolicyProtections.json"), &updateIPGeoProtectionResponseAllProtectionsFalse) - require.NoError(t, err) - client.On("UpdateIPGeoProtection", - mock.Anything, - appsec.UpdateIPGeoProtectionRequest{ConfigID: 43253, Version: 7, PolicyID: "AAAA_81230"}, - ).Return(&updateIPGeoProtectionResponseAllProtectionsFalse, nil).Once() + configVersion(t, 43253, client) + + updateRequest := appsec.UpdateIPGeoRequest{ + ConfigID: 43253, + Version: 7, + PolicyID: "AAAA_81230", + Block: "blockAllTrafficExceptAllowedIPs", + } + getIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeoAllowOnly.json", client) + updateIPGeoResponse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeo/IPGeoAllowOnly.json", updateRequest, client) + updateIPGeoProtectionResponseAllProtectionsFalse(t, 43253, 7, "AAAA_81230", "testdata/TestResIPGeoProtection/PolicyProtections.json", client) useClient(client, func() { resource.Test(t, resource.TestCase{ IsUnitTest: true, diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go index fdd9710dc..fc9bbf02b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -50,7 +50,7 @@ func resourceMalwarePolicy() *schema.Resource { } func resourceMalwarePolicyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyCreate") logger.Debugf("in resourceMalwarePolicyCreate") @@ -89,7 +89,7 @@ func resourceMalwarePolicyCreate(ctx context.Context, d *schema.ResourceData, m } func resourceMalwarePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyRead") logger.Debugf("in resourceMalwarePolicyRead") @@ -152,7 +152,7 @@ func resourceMalwarePolicyRead(ctx context.Context, d *schema.ResourceData, m in } func resourceMalwarePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyUpdate") logger.Debugf("in resourceMalwarePolicy`Update") @@ -199,7 +199,7 @@ func resourceMalwarePolicyUpdate(ctx context.Context, d *schema.ResourceData, m } func resourceMalwarePolicyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyDelete") logger.Debugf("in resourceMalwarePolicyDelete") 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 8e04752a9..9da130bdd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go @@ -5,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -58,7 +58,7 @@ func resourceMalwarePolicyAction() *schema.Resource { } func resourceMalwarePolicyActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionCreate") logger.Debugf("in resourceMalwarePolicyActionCreate") @@ -107,7 +107,7 @@ func resourceMalwarePolicyActionCreate(ctx context.Context, d *schema.ResourceDa } func resourceMalwarePolicyActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionRead") logger.Debugf("in resourceMalwarePolicyActionRead") @@ -166,7 +166,7 @@ func resourceMalwarePolicyActionRead(ctx context.Context, d *schema.ResourceData } func resourceMalwarePolicyActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionUpdate") logger.Debugf("in resourceMalwarePolicyActionUpdate") @@ -214,7 +214,7 @@ func resourceMalwarePolicyActionUpdate(ctx context.Context, d *schema.ResourceDa } func resourceMalwarePolicyActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionDelete") logger.Debugf("in resourceMalwarePolicyActionDelete") 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 6e55da9c8..e547a90e4 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 69f3b2010..22f27bf0f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -50,7 +50,7 @@ func resourceMalwarePolicyActions() *schema.Resource { } func resourceMalwarePolicyActionsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionsCreate") logger.Debugf("in resourceMalwarePolicyActionsCreate") @@ -90,7 +90,7 @@ func resourceMalwarePolicyActionsCreate(ctx context.Context, d *schema.ResourceD } func resourceMalwarePolicyActionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionsRead") logger.Debugf("in resourceMalwarePolicyActionsRead") @@ -138,7 +138,7 @@ func resourceMalwarePolicyActionsRead(ctx context.Context, d *schema.ResourceDat } func resourceMalwarePolicyActionsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwarePolicyActionsUpdate") logger.Debugf("in resourceMalwarePolicyActionsUpdate") 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 e43a28e17..534eb3e49 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 7df4bdd6f..e4f0a7b77 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go b/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go index 52ffa6dbc..5c6946ddf 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -52,7 +52,7 @@ func resourceMalwareProtection() *schema.Resource { } func resourceMalwareProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwareProtectionCreate") logger.Debugf("in resourceMalwareProtectionCreate") @@ -91,7 +91,7 @@ func resourceMalwareProtectionCreate(ctx context.Context, d *schema.ResourceData } func resourceMalwareProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwareProtectionRead") logger.Debugf("in resourceMalwareProtectionRead") @@ -144,7 +144,7 @@ func resourceMalwareProtectionRead(ctx context.Context, d *schema.ResourceData, } func resourceMalwareProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwareProtectionUpdate") logger.Debugf("in resourceMalwareProtectionUpdate") @@ -182,7 +182,7 @@ func resourceMalwareProtectionUpdate(ctx context.Context, d *schema.ResourceData } func resourceMalwareProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMalwareProtectionDelete") logger.Debugf("in resourceMalwareProtectionDelete") 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 766e629d3..bd662108b 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -67,7 +67,6 @@ func TestAkamaiMalwareProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target.go b/pkg/providers/appsec/resource_akamai_appsec_match_target.go index 861cc321e..b1bd4fedc 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -53,7 +53,7 @@ func resourceMatchTarget() *schema.Resource { } func resourceMatchTargetCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetCreate") logger.Debugf("in resourceMatchTargetCreate") @@ -87,7 +87,7 @@ func resourceMatchTargetCreate(ctx context.Context, d *schema.ResourceData, m in } func resourceMatchTargetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetRead") logger.Debugf("in resourceMatchTargetRead") @@ -140,7 +140,7 @@ func resourceMatchTargetRead(ctx context.Context, d *schema.ResourceData, m inte } func resourceMatchTargetUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetUpdate") logger.Debugf("in resourceMatchTargetUpdate") @@ -183,7 +183,7 @@ func resourceMatchTargetUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourceMatchTargetDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetDelete") logger.Debugf("in resourceMatchTargetDelete") 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 f43d80027..b2dfb20d0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -45,7 +45,7 @@ func resourceMatchTargetSequence() *schema.Resource { } func resourceMatchTargetSequenceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetSequenceCreate") logger.Debugf("in resourceMatchTargetSequenceCreate") @@ -78,7 +78,7 @@ func resourceMatchTargetSequenceCreate(ctx context.Context, d *schema.ResourceDa } func resourceMatchTargetSequenceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetSequenceRead") logger.Debugf("in resourceMatchTargetSequenceRead") @@ -126,7 +126,7 @@ func resourceMatchTargetSequenceRead(ctx context.Context, d *schema.ResourceData } func resourceMatchTargetSequenceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceMatchTargetSequenceUpdate") logger.Debugf("in resourceMatchTargetSequenceUpdate") 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 068f5a5c4..505fabe25 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 551ffea79..6c3da7c7e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go index 4eed110d4..26d4e4f42 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -61,7 +61,7 @@ func resourcePenaltyBox() *schema.Resource { } func resourcePenaltyBoxCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourcePenaltyBoxCreate") logger.Debugf("in resourcePenaltyBoxCreate") @@ -107,7 +107,7 @@ func resourcePenaltyBoxCreate(ctx context.Context, d *schema.ResourceData, m int } func resourcePenaltyBoxRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourcePenaltyBoxRead") logger.Debugf("in resourcePenaltyBoxRead") @@ -155,7 +155,7 @@ func resourcePenaltyBoxRead(ctx context.Context, d *schema.ResourceData, m inter } func resourcePenaltyBoxUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourcePenaltyBoxUpdate") logger.Debugf("in resourcePenaltyBoxUpdate") @@ -200,7 +200,7 @@ func resourcePenaltyBoxUpdate(ctx context.Context, d *schema.ResourceData, m int } func resourcePenaltyBoxDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourcePenaltyBoxDelete") logger.Debugf("in resourcePenaltyBoxDelete") 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 8034da40c..a5d3fc6a6 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go index 6fb8b04c4..37a549134 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -53,7 +53,7 @@ func resourceRatePolicy() *schema.Resource { } func resourceRatePolicyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyCreate") logger.Debugf("in resourceRatePolicyCreate") @@ -88,7 +88,7 @@ func resourceRatePolicyCreate(ctx context.Context, d *schema.ResourceData, m int } func resourceRatePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyRead") logger.Debugf("in resourceRatePolicyRead") @@ -141,7 +141,7 @@ func resourceRatePolicyRead(ctx context.Context, d *schema.ResourceData, m inter } func resourceRatePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyUpdate") logger.Debugf("in resourceRatePolicy`Update") @@ -185,7 +185,7 @@ func resourceRatePolicyUpdate(ctx context.Context, d *schema.ResourceData, m int } func resourceRatePolicyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyDelete") logger.Debugf("in resourceRatePolicyDelete") 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 72e5a8cd5..fd8cccc8d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go @@ -5,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -62,7 +62,7 @@ func resourceRatePolicyAction() *schema.Resource { } func resourceRatePolicyActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyActionCreate") logger.Debugf("in resourceRatePolicyActionCreate") @@ -113,7 +113,7 @@ func resourceRatePolicyActionCreate(ctx context.Context, d *schema.ResourceData, } func resourceRatePolicyActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyActionRead") logger.Debugf("in resourceRatePolicyActionRead") @@ -174,7 +174,7 @@ func resourceRatePolicyActionRead(ctx context.Context, d *schema.ResourceData, m } func resourceRatePolicyActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyActionUpdate") logger.Debugf("in resourceRatePolicyActionUpdate") @@ -224,7 +224,7 @@ func resourceRatePolicyActionUpdate(ctx context.Context, d *schema.ResourceData, } func resourceRatePolicyActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRatePolicyActionDelete") logger.Debugf("in resourceRatePolicyActionDelete") 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 8e2ee5297..c521bbd8b 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 5b7bdc275..a474de929 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go b/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go index 32fc19a99..aaec3236a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -54,7 +54,7 @@ func resourceRateProtection() *schema.Resource { } func resourceRateProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRateProtectionCreate") logger.Debugf("in resourceRateProtectionCreate") @@ -94,7 +94,7 @@ func resourceRateProtectionCreate(ctx context.Context, d *schema.ResourceData, m } func resourceRateProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRateProtectionRead") logger.Debugf("in resourceRateProtectionRead") @@ -148,7 +148,7 @@ func resourceRateProtectionRead(ctx context.Context, d *schema.ResourceData, m i } func resourceRateProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRateProtectionUpdate") logger.Debugf("in resourceRateProtectionUpdate") @@ -187,7 +187,7 @@ func resourceRateProtectionUpdate(ctx context.Context, d *schema.ResourceData, m } func resourceRateProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRateProtectionDelete") logger.Debugf("in resourceRateProtectionDelete") 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 0d761a4db..2f858f8dd 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -88,7 +88,6 @@ func TestAkamaiRateProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go index ab70f56b2..902d8d1e1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceReputationAnalysis() *schema.Resource { } func resourceReputationAnalysisCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationAnalysisCreate") logger.Debugf("in resourceReputationAnalysisCreate") @@ -101,7 +101,7 @@ func resourceReputationAnalysisCreate(ctx context.Context, d *schema.ResourceDat } func resourceReputationAnalysisRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationAnalysisRead") logger.Debugf("in resourceReputationAnalysisRead") @@ -149,7 +149,7 @@ func resourceReputationAnalysisRead(ctx context.Context, d *schema.ResourceData, } func resourceReputationAnalysisUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationAnalysisUpdate") logger.Debugf("in resourceReputationAnalysisUpdate") @@ -194,7 +194,7 @@ func resourceReputationAnalysisUpdate(ctx context.Context, d *schema.ResourceDat } func resourceReputationAnalysisDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationAnalysisDelete") logger.Debugf("in resourceReputationAnalysisDelete") 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 b4e133bb8..448464a7e 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go index e2def2ee9..6a6397178 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -53,7 +53,7 @@ func resourceReputationProfile() *schema.Resource { } func resourceReputationProfileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileCreate") logger.Debug("in resourceReputationProfileCreate") @@ -91,7 +91,7 @@ func resourceReputationProfileCreate(ctx context.Context, d *schema.ResourceData } func resourceReputationProfileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileRead") logger.Debug("in resourceReputationProfileRead") @@ -144,7 +144,7 @@ func resourceReputationProfileRead(ctx context.Context, d *schema.ResourceData, } func resourceReputationProfileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileUpdate") logger.Debug("in resourceReputationProfileUpdate") @@ -190,7 +190,7 @@ func resourceReputationProfileUpdate(ctx context.Context, d *schema.ResourceData } func resourceReputationProfileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileDelete") logger.Debug("in resourceReputationProfileDelete") 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 65957f0eb..51404ff5b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -56,7 +56,7 @@ func resourceReputationProfileAction() *schema.Resource { } func resourceReputationProfileActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileActionCreate") logger.Debugf("in resourceReputationProfileActionCreate") @@ -102,7 +102,7 @@ func resourceReputationProfileActionCreate(ctx context.Context, d *schema.Resour } func resourceReputationProfileActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileActionRead") logger.Debugf("in resourceReputationProfileActionRead") @@ -156,7 +156,7 @@ func resourceReputationProfileActionRead(ctx context.Context, d *schema.Resource } func resourceReputationProfileActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileActionUpdate") logger.Debugf("in resourceReputationProfileActionUpdate") @@ -201,7 +201,7 @@ func resourceReputationProfileActionUpdate(ctx context.Context, d *schema.Resour } func resourceReputationProfileActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProfileActionDelete") logger.Debugf("in resourceReputationProfileActionDelete") 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 5a431010d..606bbfe93 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 72f183f8e..e19d0b176 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go index 2f36548e7..2e124b8ee 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceReputationProtection() *schema.Resource { } func resourceReputationProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProtectionCreate") logger.Debugf("in resourceReputationProtectionCreate") @@ -95,7 +95,7 @@ func resourceReputationProtectionCreate(ctx context.Context, d *schema.ResourceD } func resourceReputationProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProtectionRead") logger.Debugf("in resourceReputationProtectionRead") @@ -149,7 +149,7 @@ func resourceReputationProtectionRead(ctx context.Context, d *schema.ResourceDat } func resourceReputationProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProtectionUpdate") logger.Debugf("in resourceReputationProtectionUpdate") @@ -188,7 +188,7 @@ func resourceReputationProtectionUpdate(ctx context.Context, d *schema.ResourceD } func resourceReputationProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceReputationProtectionDelete") logger.Debugf("in resourceReputationProtectionDelete") 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 00c6f0605..3ba61c87a 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -88,7 +88,6 @@ func TestAkamaiReputationProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule.go b/pkg/providers/appsec/resource_akamai_appsec_rule.go index c634de984..522cc82fa 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule.go @@ -8,9 +8,10 @@ import ( "strconv" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + akameta "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -73,7 +74,7 @@ func resourceRule() *schema.Resource { } func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleCreate") logger.Debugf("in resourceRuleCreate") @@ -132,13 +133,13 @@ func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, m interface } func getWAFMode(ctx context.Context, m interface{}, configID int, version int, policyID string) (string, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "getWAFMode") cacheKey := fmt.Sprintf("%s:%d:%d:%s", "getWAFMode", configID, version, policyID) getWAFModeResponse := &appsec.GetWAFModeResponse{} - if err := meta.CacheGet(inst, cacheKey, getWAFModeResponse); err == nil { + if err := cache.Get(cache.BucketName(SubproviderName), cacheKey, getWAFModeResponse); err == nil { logger.Debugf("returning wafMode %s for config/version/policy %d/%d/%s", getWAFModeResponse.Mode, configID, version, policyID) return getWAFModeResponse.Mode, nil @@ -151,14 +152,14 @@ func getWAFMode(ctx context.Context, m interface{}, configID int, version int, p getWAFModeMutex.Unlock() }() - err := meta.CacheGet(inst, cacheKey, getWAFModeResponse) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, getWAFModeResponse) if err == nil { logger.Debugf("returning wafMode %s for config/version/policy %d/%d/%s", getWAFModeResponse.Mode, configID, version, policyID) return getWAFModeResponse.Mode, nil } // Any error response other than 'not found' or 'cache disabled' is a problem. - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return "", err } @@ -173,8 +174,8 @@ func getWAFMode(ctx context.Context, m interface{}, configID int, version int, p logger.Errorf("calling 'GetWAFMode': %s", err.Error()) return "", err } - if err := meta.CacheSet(inst, cacheKey, wafMode); err != nil { - if !errors.Is(err, akamai.ErrCacheDisabled) { + if err := cache.Set(cache.BucketName(SubproviderName), cacheKey, wafMode); err != nil { + if !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error caching WAFMode: %s", err.Error()) } } @@ -182,7 +183,7 @@ func getWAFMode(ctx context.Context, m interface{}, configID int, version int, p } func resourceRuleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleRead") logger.Debugf("in resourceRuleRead") @@ -246,7 +247,7 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, m interface{} } func resourceRuleUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleUpdate") logger.Debugf("in resourceRuleUpdate") @@ -302,8 +303,7 @@ func resourceRuleUpdate(ctx context.Context, d *schema.ResourceData, m interface } func resourceRuleDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleDelete") logger.Debugf("in resourceRuleDelete") diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_rule_test.go index ac2b72cda..efecfd865 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go index 93d0793a2..3bf5f4c81 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -71,7 +71,7 @@ func resourceRuleUpgrade() *schema.Resource { } func resourceRuleUpgradeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleUpgradeCreate") logger.Debugf(" in resourceRuleUpgradeCreate") @@ -114,7 +114,7 @@ func resourceRuleUpgradeCreate(ctx context.Context, d *schema.ResourceData, m in } func resourceRuleUpgradeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleUpgradeRead") logger.Debugf(" in resourceRuleUpgradeRead") @@ -165,7 +165,7 @@ func resourceRuleUpgradeRead(ctx context.Context, d *schema.ResourceData, m inte } func resourceRuleUpgradeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceRuleUpgradeUpdate") logger.Debugf(" in resourceRuleUpgradeUpdate") 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 0cf9d31a1..9e75bc1a2 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy.go index 867fad600..6964d101b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -70,7 +70,7 @@ func resourceSecurityPolicy() *schema.Resource { } func resourceSecurityPolicyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyCreate") logger.Debugf("in resourceSecurityPolicyCreate") @@ -145,7 +145,7 @@ func resourceSecurityPolicyCreate(ctx context.Context, d *schema.ResourceData, m } func resourceSecurityPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyRead") logger.Debugf("in resourceSecurityPolicyRead") @@ -198,7 +198,7 @@ func resourceSecurityPolicyRead(ctx context.Context, d *schema.ResourceData, m i } func resourceSecurityPolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyUpdate") logger.Debugf("in resourceSecurityPolicyUpdate") @@ -245,7 +245,7 @@ func resourceSecurityPolicyUpdate(ctx context.Context, d *schema.ResourceData, m } func resourceSecurityPolicyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyDelete") logger.Debugf("in resourceSecurityPolicyDelete") 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 1f0af0561..0685bbff2 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -47,7 +47,7 @@ func resourceSecurityPolicyRename() *schema.Resource { } func resourceSecurityPolicyRenameCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyRenameCreate") logger.Debugf("in resourceSecurityPolicyRenameCreate") @@ -88,7 +88,7 @@ func resourceSecurityPolicyRenameCreate(ctx context.Context, d *schema.ResourceD } func resourceSecurityPolicyRenameRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyRenameRead") logger.Debugf("in resourceSecurityPolicyRenameRead") @@ -132,7 +132,7 @@ func resourceSecurityPolicyRenameRead(ctx context.Context, d *schema.ResourceDat } func resourceSecurityPolicyRenameUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSecurityPolicyRenameUpdate") logger.Debugf("in resourceSecurityPolicyRenameUpdate") 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 d151e1acc..2108a3b17 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 335aefdc6..1d61af51a 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go index da6c8e3f8..ff357e31c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go +++ b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go @@ -5,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -56,7 +56,7 @@ func resourceSelectedHostname() *schema.Resource { } func resourceSelectedHostnameCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSelectedHostnameCreate") logger.Debugf("in resourceSelectedHostnameCreate") @@ -144,7 +144,7 @@ func resourceSelectedHostnameCreate(ctx context.Context, d *schema.ResourceData, } func resourceSelectedHostnameRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSelectedHostnameRead") logger.Debugf("in resourceSelectedHostnameRead") @@ -189,7 +189,7 @@ func resourceSelectedHostnameRead(ctx context.Context, d *schema.ResourceData, m } func resourceSelectedHostnameUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSelectedHostnameUpdate") logger.Debugf("in resourceSelectedHostnameUpdate") 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 0e6fdd839..c77a7c6ef 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go index b0552f940..5474155b0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -66,7 +66,7 @@ func resourceSiemSettings() *schema.Resource { } func resourceSiemSettingsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSiemSettingsCreate") logger.Debugf("in resourceSiemSettingsCreate") @@ -127,7 +127,7 @@ func resourceSiemSettingsCreate(ctx context.Context, d *schema.ResourceData, m i } func resourceSiemSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSiemSettingsRead") logger.Debugf("in resourceSiemSettingsRead") @@ -175,7 +175,7 @@ func resourceSiemSettingsRead(ctx context.Context, d *schema.ResourceData, m int } func resourceSiemSettingsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSiemSettingsUpdate") logger.Debugf("in resourceSiemSettingsUpdate") @@ -234,7 +234,7 @@ func resourceSiemSettingsUpdate(ctx context.Context, d *schema.ResourceData, m i } func resourceSiemSettingsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSiemSettingsDelete") logger.Debugf("in resourceSiemSettingsDelete") 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 d80fee956..3d92e39cd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 4f7d54af8..3136f53cf 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,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -73,7 +73,7 @@ func resourceSlowPostProtectionSetting() *schema.Resource { } func resourceSlowPostProtectionSettingCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionSettingCreate") logger.Debugf("in resourceSlowPostProtectionSettingCreate") @@ -129,7 +129,7 @@ func resourceSlowPostProtectionSettingCreate(ctx context.Context, d *schema.Reso } func resourceSlowPostProtectionSettingRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionSettingRead") logger.Debugf("in resourceSlowPostProtectionSettingRead") @@ -186,7 +186,7 @@ func resourceSlowPostProtectionSettingRead(ctx context.Context, d *schema.Resour } func resourceSlowPostProtectionSettingUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionSettingUpdate") logger.Debugf("in resourceSlowPostProtectionSettingUpdate") @@ -241,7 +241,7 @@ func resourceSlowPostProtectionSettingUpdate(ctx context.Context, d *schema.Reso } func resourceSlowPostProtectionSettingDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionSettingDelete") logger.Debugf("in resourceSlowPostProtectionSettingDelete") 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 627c07bf6..7736805db 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go index 999946a41..47a5f14f6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceSlowPostProtection() *schema.Resource { } func resourceSlowPostProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionCreate") logger.Debugf("in resourceSlowPostProtectionCreate") @@ -94,7 +94,7 @@ func resourceSlowPostProtectionCreate(ctx context.Context, d *schema.ResourceDat } func resourceSlowPostProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionRead") logger.Debugf("in resourceSlowPostProtectionRead") @@ -149,7 +149,7 @@ func resourceSlowPostProtectionRead(ctx context.Context, d *schema.ResourceData, } func resourceSlowPostProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionUpdate") logger.Debugf("in resourceSlowPostProtectionUpdate") @@ -188,7 +188,7 @@ func resourceSlowPostProtectionUpdate(ctx context.Context, d *schema.ResourceDat } func resourceSlowPostProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceSlowPostProtectionDelete") logger.Debugf("in resourceSlowPostProtectionDelete") 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 19124dd8c..2e1d773df 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -67,7 +67,6 @@ func TestAkamaiSlowPostProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ diff --git a/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go b/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go index bee3f9cc7..115e3936d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go +++ b/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go @@ -5,11 +5,11 @@ import ( "fmt" "strconv" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/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" @@ -55,7 +55,7 @@ func resourceThreatIntel() *schema.Resource { } func resourceThreatIntelCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceThreatIntelCreate") logger.Debugf("in resourceThreatIntelCreate") @@ -96,7 +96,7 @@ func resourceThreatIntelCreate(ctx context.Context, d *schema.ResourceData, m in } func resourceThreatIntelRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceThreatIntelRead") logger.Debugf(" in resourceThreatIntelRead") @@ -141,7 +141,7 @@ func resourceThreatIntelRead(ctx context.Context, d *schema.ResourceData, m inte } func resourceThreatIntelUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceThreatIntelUpdate") logger.Debugf("in resourceThreatIntelUpdate") @@ -182,7 +182,7 @@ func resourceThreatIntelUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourceThreatIntelDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("APPSEC", "resourceThreatIntelDelete") logger.Debugf("in resourceThreatIntelDelete") return nil 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 6ba2dc75a..c808a5ee2 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_version_notes.go b/pkg/providers/appsec/resource_akamai_appsec_version_notes.go index 338d875e1..aa9588266 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_version_notes.go +++ b/pkg/providers/appsec/resource_akamai_appsec_version_notes.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -50,7 +50,7 @@ func resourceVersionNotes() *schema.Resource { } func resourceVersionNotesCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceVersionNotesCreate") logger.Debugf("in resourceVersionNotesCreate") @@ -86,7 +86,7 @@ func resourceVersionNotesCreate(ctx context.Context, d *schema.ResourceData, m i } func resourceVersionNotesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceVersionNotesRead") logger.Debugf("in resourceVersionNotesRead") @@ -131,7 +131,7 @@ func resourceVersionNotesRead(ctx context.Context, d *schema.ResourceData, m int } func resourceVersionNotesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceVersionNotesUpdate") logger.Debugf("in resourceVersionNotesUpdate") 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 f7a500d53..58e0647b6 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go b/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go index 04afeddca..c944f8154 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -82,7 +82,7 @@ func resourceWAFMode() *schema.Resource { } func resourceWAFModeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFModeCreate") logger.Debugf(" in resourceWAFModeCreate") @@ -123,7 +123,7 @@ func resourceWAFModeCreate(ctx context.Context, d *schema.ResourceData, m interf } func resourceWAFModeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFModeRead") logger.Debugf(" in resourceWAFModeRead") @@ -189,7 +189,7 @@ func resourceWAFModeRead(ctx context.Context, d *schema.ResourceData, m interfac } func resourceWAFModeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFModeUpdate") logger.Debugf(" in resourceWAFModeUpdate") 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 7f0673e60..59e508567 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go b/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go index 5a163b5f8..7b0065db3 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceWAFProtection() *schema.Resource { } func resourceWAFProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFProtectionCreate") logger.Debugf("in resourceWAFProtectionCreate") @@ -94,7 +94,7 @@ func resourceWAFProtectionCreate(ctx context.Context, d *schema.ResourceData, m } func resourceWAFProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFProtectionRead") logger.Debugf("in resourceWAFProtectionRead") @@ -149,7 +149,7 @@ func resourceWAFProtectionRead(ctx context.Context, d *schema.ResourceData, m in } func resourceWAFProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFProtectionUpdate") logger.Debugf("in resourceWAFProtectionUpdate") @@ -188,7 +188,7 @@ func resourceWAFProtectionUpdate(ctx context.Context, d *schema.ResourceData, m } func resourceWAFProtectionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAFProtectionDelete") logger.Debugf("in resourceWAFProtectionDelete") 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 8387d4daa..0852009d9 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -67,7 +67,6 @@ func TestAkamaiWAFProtection_res_basic(t *testing.T) { useClient(client, func() { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, IsUnitTest: true, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ 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 a3a480f1e..0e0aa7d9b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go +++ b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/appsec" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -58,7 +58,7 @@ func resourceWAPSelectedHostnames() *schema.Resource { } func resourceWAPSelectedHostnamesCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAPSelectedHostnamesCreate") logger.Debugf("in resourceWAPSelectedHostnamesCreate") @@ -130,7 +130,7 @@ func resourceWAPSelectedHostnamesCreate(ctx context.Context, d *schema.ResourceD } func resourceWAPSelectedHostnamesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAPSelectedHostnamesRead") logger.Debugf("in resourceWAPSelectedHostnamesRead") @@ -178,7 +178,7 @@ func resourceWAPSelectedHostnamesRead(ctx context.Context, d *schema.ResourceDat } func resourceWAPSelectedHostnamesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("APPSEC", "resourceWAPSelectedHostnamesUpdate") logger.Debugf("in resourceWAPSelectedHostnamesUpdate") 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 a251055de..eb09b53d3 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/templates.go b/pkg/providers/appsec/templates.go index 011a70268..b0039b7d8 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/v6/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/appsec" "github.com/jedib0t/go-pretty/v6/table" ) @@ -270,6 +270,7 @@ func InitTemplates(otm map[string]*OutputTemplate) { otm["advancedSettingsAttackPayloadLoggingDS"] = &OutputTemplate{TemplateName: "advancedSettingsAttackPayloadLoggingDS", TableTitle: "Enabled|Request Body|Response Body", TemplateType: "TABULAR", TemplateString: "{{.Enabled}}|{{.RequestBody.Type}}|{{.ResponseBody.Type}}"} otm["advancedSettingsLoggingDS"] = &OutputTemplate{TemplateName: "advancedSettingsLoggingDS", TableTitle: "Allow Sampling|Cookies|Custom Headers|Standard Headers", TemplateType: "TABULAR", TemplateString: "{{.AllowSampling}}|{{.Cookies.Type}} {{.Cookies.Values}}|{{.CustomHeaders.Type}} {{.CustomHeaders.Values}}|{{.StandardHeaders.Type}} {{.StandardHeaders.Values}}"} otm["advancedSettingsEvasivePathMatchDS"] = &OutputTemplate{TemplateName: "advancedSettingsEvasivePathMatchDS", TableTitle: "Enable Path Match", TemplateType: "TABULAR", TemplateString: "{{.EnablePathMatch}}"} + otm["advancedSettingsPIILearningDS"] = &OutputTemplate{TemplateName: "advancedSettingsPIILearningDS", TableTitle: "Enable PII Learning", TemplateType: "TABULAR", TemplateString: "{{.EnablePIILearning}}"} otm["advancedSettingsPrefetchDS"] = &OutputTemplate{TemplateName: "advancedSettingsPrefetchDS", TableTitle: "Enable App Layer|All Extension|Enable Rate Controls|Extensions", TemplateType: "TABULAR", TemplateString: "{{.EnableAppLayer}}|{{.AllExtensions}}|{{.EnableRateControls}}|{{range $index, $element := .Extensions}}{{.}} {{end}}"} otm["advancedSettingsPragmaHeaderDS"] = &OutputTemplate{TemplateName: "Pragma header excluded conditions", TableTitle: "Action|Condition Operator|Exclude Conditions", TemplateType: "TABULAR", TemplateString: "{{.Action}}|{{.ConditionOperator}}|{{.ExcludeCondition}}"} otm["advancedSettingsRequestBodyDS"] = &OutputTemplate{TemplateName: "advancedSettingsRequestBodyDS", TableTitle: "Request Body Inspection Limit", TemplateType: "TABULAR", TemplateString: "{{.RequestBodyInspectionLimitInKB}}"} diff --git a/pkg/providers/appsec/testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json b/pkg/providers/appsec/testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json new file mode 100644 index 000000000..b3d999700 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestDSAdvancedSettingsPIILearning/PIILearning.json @@ -0,0 +1,3 @@ +{ + "enablePiiLearning": true +} diff --git a/pkg/providers/appsec/testdata/TestDSAdvancedSettingsPIILearning/match_by_id.tf b/pkg/providers/appsec/testdata/TestDSAdvancedSettingsPIILearning/match_by_id.tf new file mode 100644 index 000000000..299a05d80 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestDSAdvancedSettingsPIILearning/match_by_id.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../test/edgerc" + cache_enabled = false +} + +data "akamai_appsec_advanced_settings_pii_learning" "test" { + config_id = 43253 +} + diff --git a/pkg/providers/appsec/testdata/TestDSIPGeo/IPGeo.json b/pkg/providers/appsec/testdata/TestDSIPGeo/IPGeo.json index fbfbcc736..a3dc08d32 100644 --- a/pkg/providers/appsec/testdata/TestDSIPGeo/IPGeo.json +++ b/pkg/providers/appsec/testdata/TestDSIPGeo/IPGeo.json @@ -18,5 +18,8 @@ "53712_TESTLIST123" ] } + }, + "ukraineGeoControl": { + "action": "alert" } } \ No newline at end of file diff --git a/pkg/providers/appsec/testdata/TestResActivations/match_by_id.tf b/pkg/providers/appsec/testdata/TestResActivations/match_by_id.tf index 880dabbc8..8d8a157c2 100644 --- a/pkg/providers/appsec/testdata/TestResActivations/match_by_id.tf +++ b/pkg/providers/appsec/testdata/TestResActivations/match_by_id.tf @@ -8,7 +8,6 @@ resource "akamai_appsec_activations" "test" { version = 7 network = "STAGING" note = "TEST Notes" - activate = true notification_emails = ["martin@email.io"] } diff --git a/pkg/providers/appsec/testdata/TestResAdvancedSettingsPIILearning/PIILearning.json b/pkg/providers/appsec/testdata/TestResAdvancedSettingsPIILearning/PIILearning.json new file mode 100644 index 000000000..b3d999700 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResAdvancedSettingsPIILearning/PIILearning.json @@ -0,0 +1,3 @@ +{ + "enablePiiLearning": true +} diff --git a/pkg/providers/appsec/testdata/TestResAdvancedSettingsPIILearning/match_by_id.tf b/pkg/providers/appsec/testdata/TestResAdvancedSettingsPIILearning/match_by_id.tf new file mode 100644 index 000000000..53f35aff9 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResAdvancedSettingsPIILearning/match_by_id.tf @@ -0,0 +1,10 @@ +provider "akamai" { + edgerc = "../../test/edgerc" + cache_enabled = false +} + +resource "akamai_appsec_advanced_settings_pii_learning" "test" { + config_id = 43253 + enable_pii_learning = true +} + diff --git a/pkg/providers/appsec/testdata/TestResIPGeo/UkraineGeo.json b/pkg/providers/appsec/testdata/TestResIPGeo/UkraineGeo.json new file mode 100644 index 000000000..48d043ad5 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResIPGeo/UkraineGeo.json @@ -0,0 +1,25 @@ +{ + "block": "blockSpecificIPGeo", + "geoControls": { + "blockedIPNetworkLists": { + "networkList": [ + "40731_BMROLLOUTGEO","44831_ECSCGEOBLACKLIST" + ] + } + }, + "ipControls": { + "blockedIPNetworkLists": { + "networkList": [ + "49181_ADTIPBLACKLIST","49185_ADTWAFBYPASSLIST" + ] + }, + "allowedIPNetworkLists": { + "networkList": [ + "68762_ADYEN", "69601_ADYENPRODWHITELIST" + ] + } + }, + "ukraineGeoControl": { + "action": "alert" + } +} diff --git a/pkg/providers/appsec/testdata/TestResIPGeo/ukraine_match_by_id.tf b/pkg/providers/appsec/testdata/TestResIPGeo/ukraine_match_by_id.tf new file mode 100644 index 000000000..ac2c13ea8 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResIPGeo/ukraine_match_by_id.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../test/edgerc" + cache_enabled = false +} + +resource "akamai_appsec_ip_geo" "test1" { + config_id = 43253 + security_policy_id = "AAAA_81230" + mode = "block" + geo_network_lists = ["40731_BMROLLOUTGEO", "44831_ECSCGEOBLACKLIST"] + ip_network_lists = ["49181_ADTIPBLACKLIST", "49185_ADTWAFBYPASSLIST"] + exception_ip_network_lists = ["68762_ADYEN", "69601_ADYENPRODWHITELIST"] + ukraine_geo_control_action = "alert" +} + diff --git a/pkg/providers/botman/botman.go b/pkg/providers/botman/botman.go index f3f512008..077f553b9 100644 --- a/pkg/providers/botman/botman.go +++ b/pkg/providers/botman/botman.go @@ -1,10 +1,10 @@ -//go:build all || botman -// +build all botman - package botman -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" + +// SubproviderName defines name of the botman subprovider +const SubproviderName = "botman" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/botman/cache.go b/pkg/providers/botman/cache.go index 0248bf0aa..0040c2e37 100644 --- a/pkg/providers/botman/cache.go +++ b/pkg/providers/botman/cache.go @@ -6,8 +6,9 @@ import ( "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + akameta "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/apex/log" ) @@ -20,15 +21,15 @@ var ( // getBotDetectionAction reads from the cache if present, or makes a getAll call to fetch all Bot Detection Actions for a security policy, stores in the cache and filters the required Bot Detection Action using ID. func getBotDetectionAction(ctx context.Context, request botman.GetBotDetectionActionRequest, m interface{}) (map[string]interface{}, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("BotMan", "getBotDetectionAction") cacheKey := fmt.Sprintf("%s:%d:%d:%s", "getBotDetectionAction", request.ConfigID, request.Version, request.SecurityPolicyID) botDetectionActions := &botman.GetBotDetectionActionListResponse{} - err := meta.CacheGet(inst, cacheKey, botDetectionActions) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, botDetectionActions) // if cache is disabled use GetBotDetectionAction to fetch one action at a time - if errors.Is(err, akamai.ErrCacheDisabled) { + if errors.Is(err, cache.ErrDisabled) { return client.GetBotDetectionAction(ctx, request) } if err == nil { @@ -41,12 +42,12 @@ func getBotDetectionAction(ctx context.Context, request botman.GetBotDetectionAc botDetectionActionMutex.Unlock() }() - err = meta.CacheGet(inst, cacheKey, botDetectionActions) + err = cache.Get(cache.BucketName(SubproviderName), cacheKey, botDetectionActions) if err == nil { return filterBotDetectionAction(botDetectionActions, request, logger) } - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return nil, err } @@ -61,8 +62,8 @@ func getBotDetectionAction(ctx context.Context, request botman.GetBotDetectionAc return nil, err } - err = meta.CacheSet(inst, cacheKey, botDetectionActions) - if err != nil && !errors.Is(err, akamai.ErrCacheDisabled) { + err = cache.Set(cache.BucketName(SubproviderName), cacheKey, botDetectionActions) + if err != nil && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error caching botDetectionActions into cache: %s", err.Error()) return nil, err } @@ -82,15 +83,15 @@ func filterBotDetectionAction(botDetectionActions *botman.GetBotDetectionActionL // getCustomBotCategoryAction reads from the cache if present, or makes a getAll call to fetch all Custom Bot Category Actions for a security policy, stores in the cache and filters the required Custom Bot Category Action using ID. func getCustomBotCategoryAction(ctx context.Context, request botman.GetCustomBotCategoryActionRequest, m interface{}) (map[string]interface{}, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("BotMan", "getCustomBotCategoryAction") cacheKey := fmt.Sprintf("%s:%d:%d:%s", "getCustomBotCategoryAction", request.ConfigID, request.Version, request.SecurityPolicyID) customBotCategoryActions := &botman.GetCustomBotCategoryActionListResponse{} - err := meta.CacheGet(inst, cacheKey, customBotCategoryActions) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, customBotCategoryActions) // if cache is disabled use GetCustomBotCategoryAction to fetch one action at a time - if errors.Is(err, akamai.ErrCacheDisabled) { + if errors.Is(err, cache.ErrDisabled) { return client.GetCustomBotCategoryAction(ctx, request) } if err == nil { @@ -103,12 +104,12 @@ func getCustomBotCategoryAction(ctx context.Context, request botman.GetCustomBot customBotCategoryActionMutex.Unlock() }() - err = meta.CacheGet(inst, cacheKey, customBotCategoryActions) + err = cache.Get(cache.BucketName(SubproviderName), cacheKey, customBotCategoryActions) if err == nil { return filterCustomBotCategoryAction(customBotCategoryActions, request, logger) } - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return nil, err } @@ -123,8 +124,8 @@ func getCustomBotCategoryAction(ctx context.Context, request botman.GetCustomBot return nil, err } - err = meta.CacheSet(inst, cacheKey, customBotCategoryActions) - if err != nil && !errors.Is(err, akamai.ErrCacheDisabled) { + err = cache.Set(cache.BucketName(SubproviderName), cacheKey, customBotCategoryActions) + if err != nil && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error caching customBotCategoryActions into cache: %s", err.Error()) return nil, err } @@ -144,15 +145,15 @@ func filterCustomBotCategoryAction(customBotCategoryActions *botman.GetCustomBot // getAkamaiBotCategoryAction reads from the cache if present, or makes a getAll call to fetch all Akamai Bot Category Actions for a security policy, stores in the cache and filters the required Akamai Bot Category Action using ID. func getAkamaiBotCategoryAction(ctx context.Context, request botman.GetAkamaiBotCategoryActionRequest, m interface{}) (map[string]interface{}, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("BotMan", "getAkamaiBotCategoryAction") cacheKey := fmt.Sprintf("%s:%d:%d:%s", "getAkamaiBotCategoryAction", request.ConfigID, request.Version, request.SecurityPolicyID) akamaiBotCategoryActions := &botman.GetAkamaiBotCategoryActionListResponse{} - err := meta.CacheGet(inst, cacheKey, akamaiBotCategoryActions) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, akamaiBotCategoryActions) // if cache is disabled use GetAkamaiBotCategoryAction to fetch one action at a time - if errors.Is(err, akamai.ErrCacheDisabled) { + if errors.Is(err, cache.ErrDisabled) { return client.GetAkamaiBotCategoryAction(ctx, request) } if err == nil { @@ -165,12 +166,12 @@ func getAkamaiBotCategoryAction(ctx context.Context, request botman.GetAkamaiBot akamaiBotCategoryActionMutex.Unlock() }() - err = meta.CacheGet(inst, cacheKey, akamaiBotCategoryActions) + err = cache.Get(cache.BucketName(SubproviderName), cacheKey, akamaiBotCategoryActions) if err == nil { return filterAkamaiBotCategoryAction(akamaiBotCategoryActions, request, logger) } - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return nil, err } @@ -185,8 +186,8 @@ func getAkamaiBotCategoryAction(ctx context.Context, request botman.GetAkamaiBot return nil, err } - err = meta.CacheSet(inst, cacheKey, akamaiBotCategoryActions) - if err != nil && !errors.Is(err, akamai.ErrCacheDisabled) { + err = cache.Set(cache.BucketName(SubproviderName), cacheKey, akamaiBotCategoryActions) + if err != nil && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error caching akamaiBotCategoryActions into cache: %s", err.Error()) return nil, err } @@ -206,15 +207,15 @@ func filterAkamaiBotCategoryAction(akamaiBotCategoryActions *botman.GetAkamaiBot // getTransactionalEndpoint reads from the cache if present, or makes a getAll call to fetch all Transactional Endpoints for a security policy, stores in the cache and filters the required Transactional Endpoint using ID. func getTransactionalEndpoint(ctx context.Context, request botman.GetTransactionalEndpointRequest, m interface{}) (map[string]interface{}, error) { - meta := akamai.Meta(m) + meta := akameta.Must(m) client := inst.Client(meta) logger := meta.Log("BotMan", "getTransactionalEndpoint") cacheKey := fmt.Sprintf("%s:%d:%d:%s", "getTransactionalEndpoint", request.ConfigID, request.Version, request.SecurityPolicyID) transactionalEndpoints := &botman.GetTransactionalEndpointListResponse{} - err := meta.CacheGet(inst, cacheKey, transactionalEndpoints) + err := cache.Get(cache.BucketName(SubproviderName), cacheKey, transactionalEndpoints) // if cache is disabled use GetTransactionalEndpoint to fetch one action at a time - if errors.Is(err, akamai.ErrCacheDisabled) { + if errors.Is(err, cache.ErrDisabled) { return client.GetTransactionalEndpoint(ctx, request) } if err == nil { @@ -227,12 +228,12 @@ func getTransactionalEndpoint(ctx context.Context, request botman.GetTransaction transactionalEndpointMutex.Unlock() }() - err = meta.CacheGet(inst, cacheKey, transactionalEndpoints) + err = cache.Get(cache.BucketName(SubproviderName), cacheKey, transactionalEndpoints) if err == nil { return filterTransactionalEndpoint(transactionalEndpoints, request, logger) } - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error reading from cache: %s", err.Error()) return nil, err } @@ -247,8 +248,8 @@ func getTransactionalEndpoint(ctx context.Context, request botman.GetTransaction return nil, err } - err = meta.CacheSet(inst, cacheKey, transactionalEndpoints) - if err != nil && !errors.Is(err, akamai.ErrCacheDisabled) { + err = cache.Set(cache.BucketName(SubproviderName), cacheKey, transactionalEndpoints) + if err != nil && !errors.Is(err, cache.ErrDisabled) { logger.Errorf("error caching transactionalEndpoints into cache: %s", err.Error()) return nil, err } diff --git a/pkg/providers/botman/custom_validations.go b/pkg/providers/botman/custom_validations.go index 630a52e0c..8fc51372d 100644 --- a/pkg/providers/botman/custom_validations.go +++ b/pkg/providers/botman/custom_validations.go @@ -6,9 +6,9 @@ import ( "fmt" "strings" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -63,7 +63,7 @@ func verifyOperationIDUnchanged(c context.Context, d *schema.ResourceDiff, m int } func verifyIDUnchanged(_ context.Context, d *schema.ResourceDiff, m interface{}, key string) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "verifyIDUnchanged") if d.Id() == "" { 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 482a7505a..0436c0b5a 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go @@ -5,10 +5,10 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -30,7 +30,7 @@ func dataSourceAkamaiBotCategory() *schema.Resource { } func dataSourceAkamaiBotCategoryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceAkamaiBotCategoryRead") 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 94da91c38..4f57230e1 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,9 +6,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func dataSourceAkamaiBotCategoryAction() *schema.Resource { } func dataSourceAkamaiBotCategoryActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceAkamaiBotCategoryActionRead") 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 5d0daaa3d..73936daf3 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 b33f609cd..891fc76a6 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 2b6364d0a..3c3a5e373 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go @@ -5,10 +5,10 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -30,7 +30,7 @@ func dataSourceAkamaiDefinedBot() *schema.Resource { } func dataSourceAkamaiDefinedBotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceAkamaiDefinedBotRead") 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 2a8973b51..fb98c84cf 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 fa6687a92..3153d4f4e 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -29,7 +29,7 @@ func dataSourceBotAnalyticsCookie() *schema.Resource { } func dataSourceBotAnalyticsCookieRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotAnalyticsCookieRead") logger.Debugf("in dataSourceBotAnalyticsCookieRead") 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 c92d95a3c..e6ed87e47 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values.go index 03285b59e..6775ffb17 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values.go @@ -4,9 +4,9 @@ import ( "context" "encoding/json" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -24,7 +24,7 @@ func dataSourceBotAnalyticsCookieValues() *schema.Resource { } func dataSourceBotAnalyticsCookieValuesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotAnalyticsCookieValuesRead") 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 d493eef61..e0580e95c 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 04d6a2bd7..30b81d74a 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_category_exception.go +++ b/pkg/providers/botman/data_akamai_botman_bot_category_exception.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -33,7 +33,7 @@ func dataSourceBotCategoryException() *schema.Resource { } func dataSourceBotCategoryExceptionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotCategoryExceptionRead") logger.Debugf("in dataSourceBotCategoryExceptionRead") 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 5629821df..69691fce0 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 633fb31db..129537117 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection.go @@ -5,10 +5,10 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -30,7 +30,7 @@ func dataSourceBotDetection() *schema.Resource { } func dataSourceBotDetectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotDetectionRead") 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 8443c695a..44157f7fd 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_action.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_action.go @@ -6,9 +6,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func dataSourceBotDetectionAction() *schema.Resource { } func dataSourceBotDetectionActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotDetectionActionRead") logger.Debugf("in dataSourceBotDetectionActionRead") 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 d2a06b355..a68c808ee 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 cda632006..9c0dc59c9 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 4d47cd61c..9b1df5d8c 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,10 +6,10 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataSourceBotEndpointCoverageReport() *schema.Resource { } func dataSourceBotEndpointCoverageReportRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotEndpointCoverageReportRead") logger.Debugf("in dataSourceBotEndpointCoverageReportRead") 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 a324e7897..f4fccb0fd 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 08a6ba3b9..63b9b8520 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_management_settings.go +++ b/pkg/providers/botman/data_akamai_botman_bot_management_settings.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -33,7 +33,7 @@ func dataSourceBotManagementSettings() *schema.Resource { } func dataSourceBotManagementSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceBotManagementSettingsRead") logger.Debugf("in dataSourceBotManagementSettingsRead") 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 98a302b51..c3f5ef391 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 97e3a9190..4bb824267 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_action.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_action.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataSourceChallengeAction() *schema.Resource { } func dataSourceChallengeActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceChallengeActionRead") 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 f79b1706d..7471c933c 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_action_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 3caa47879..7a25cf844 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -29,7 +29,7 @@ func dataSourceChallengeInterceptionRules() *schema.Resource { } func dataSourceChallengeInterceptionRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceChallengeInterceptionRulesRead") logger.Debugf("in dataSourceChallengeInterceptionRulesRead") 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 07af97cdb..f88d45cb9 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 33ef885de..9fcc46d1e 100644 --- a/pkg/providers/botman/data_akamai_botman_client_side_security.go +++ b/pkg/providers/botman/data_akamai_botman_client_side_security.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -29,7 +29,7 @@ func dataSourceClientSideSecurity() *schema.Resource { } func dataSourceClientSideSecurityRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceClientSideSecurityRead") logger.Debugf("in dataSourceClientSideSecurityRead") 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 9d42a5313..2863f8408 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 c93687ab6..f7228b5cc 100644 --- a/pkg/providers/botman/data_akamai_botman_conditional_action.go +++ b/pkg/providers/botman/data_akamai_botman_conditional_action.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataSourceConditionalAction() *schema.Resource { } func dataSourceConditionalActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceConditionalActionRead") 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 04591e7bd..de5680433 100644 --- a/pkg/providers/botman/data_akamai_botman_conditional_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_conditional_action_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 c39834ab8..14d843f79 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -34,7 +34,7 @@ func dataSourceCustomBotCategory() *schema.Resource { } func dataSourceCustomBotCategoryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceCustomBotCategoryRead") 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 112cdc4b1..aeb691ef4 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,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func dataSourceCustomBotCategoryAction() *schema.Resource { } func dataSourceCustomBotCategoryActionsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceCustomBotCategoryActionsRead") 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 fe9939dca..03f8af80d 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 f0438125b..1c67c56ef 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,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -29,7 +29,7 @@ func dataSourceCustomBotCategorySequence() *schema.Resource { } func dataSourceCustomBotCategorySequenceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceCustomBotCategorySequenceRead") logger.Debugf("in dataSourceCustomBotCategorySequenceRead") 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 ea00b8954..bd4c0e291 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 c7a3ce51d..0130dfbe5 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 b58e02a72..be3c06713 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -34,7 +34,7 @@ func dataSourceCustomClient() *schema.Resource { } func dataSourceCustomClientRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceCustomClientRead") logger.Debugf("in dataSourceCustomClientRead") 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 36360b134..8fe9d78a9 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 9e201e77c..1fd1c5a39 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -34,7 +34,7 @@ func dataSourceCustomDefinedBot() *schema.Resource { } func dataSourceCustomDefinedBotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceCustomDefinedBotRead") 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 d7870ec0f..be7496858 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 c1ad8cba7..1bd8cd448 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_deny_action.go +++ b/pkg/providers/botman/data_akamai_botman_custom_deny_action.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataSourceCustomDenyAction() *schema.Resource { } func dataSourceCustomDenyActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceCustomDenyActionRead") 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 20e43aee8..27db98668 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 fbbafd145..c10f828c3 100644 --- a/pkg/providers/botman/data_akamai_botman_javascript_injection.go +++ b/pkg/providers/botman/data_akamai_botman_javascript_injection.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -33,7 +33,7 @@ func dataSourceJavascriptInjection() *schema.Resource { } func dataSourceJavascriptInjectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceJavascriptInjectionRead") logger.Debugf("in dataSourceJavascriptInjectionRead") 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 4c57b7f70..d54386e3c 100644 --- a/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go +++ b/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 93080919f..a588fa935 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,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -34,7 +34,7 @@ func dataSourceRecategorizedAkamaiDefinedBot() *schema.Resource { } func dataSourceRecategorizedAkamaiDefinedBotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceRecategorizedAkamaiDefinedBotRead") logger.Debugf("in dataSourceRecategorizedAkamaiDefinedBotRead") 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 b71527632..870fac180 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 272d58a52..9cf10919e 100644 --- a/pkg/providers/botman/data_akamai_botman_response_action.go +++ b/pkg/providers/botman/data_akamai_botman_response_action.go @@ -6,9 +6,9 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -34,7 +34,7 @@ func dataSourceResponseAction() *schema.Resource { } func dataSourceResponseActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceResponseActionRead") logger.Debugf("in dataSourceResponseActionRead") 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 da5229525..c3377b00f 100644 --- a/pkg/providers/botman/data_akamai_botman_response_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_response_action_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 33e148724..5b04a6d7c 100644 --- a/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go +++ b/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go @@ -7,9 +7,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataSourceServeAlternateAction() *schema.Resource { } func dataSourceServeAlternateActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceServeAlternateActionRead") 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 ee4782f99..f27e530af 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 28776245a..22df588cd 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go @@ -6,9 +6,9 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func dataSourceTransactionalEndpoint() *schema.Resource { } func dataSourceTransactionalEndpointRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceTransactionalEndpointRead") logger.Debugf("in dataSourceTransactionalEndpointRead") 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 2c87d540c..72d6eb24c 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -29,7 +29,7 @@ func dataSourceTransactionalEndpointProtection() *schema.Resource { } func dataSourceTransactionalEndpointProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "dataSourceTransactionalEndpointProtectionRead") logger.Debugf("in dataSourceTransactionalEndpointProtectionRead") 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 7dfd60c0f..ef9a0bddb 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 22143ab85..f3999957c 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/botman/provider.go b/pkg/providers/botman/provider.go index abc9003c9..4e575deb4 100644 --- a/pkg/providers/botman/provider.go +++ b/pkg/providers/botman/provider.go @@ -2,43 +2,39 @@ package botman import ( - "fmt" "sync" - "github.com/apex/log" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/appsec" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/appsec" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers botman resources and data sources + Subprovider struct { client botman.BotMan } - // Option is a botman provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider getLatestConfigVersion = appsec.GetLatestConfigVersion getModifiableConfigVersion = appsec.GetModifiableConfigVersion ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -48,127 +44,74 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - DataSourcesMap: map[string]*schema.Resource{ - "akamai_botman_akamai_bot_category": dataSourceAkamaiBotCategory(), - "akamai_botman_akamai_bot_category_action": dataSourceAkamaiBotCategoryAction(), - "akamai_botman_akamai_defined_bot": dataSourceAkamaiDefinedBot(), - "akamai_botman_bot_analytics_cookie": dataSourceBotAnalyticsCookie(), - "akamai_botman_bot_analytics_cookie_values": dataSourceBotAnalyticsCookieValues(), - "akamai_botman_bot_category_exception": dataSourceBotCategoryException(), - "akamai_botman_bot_detection": dataSourceBotDetection(), - "akamai_botman_bot_detection_action": dataSourceBotDetectionAction(), - "akamai_botman_bot_endpoint_coverage_report": dataSourceBotEndpointCoverageReport(), - "akamai_botman_bot_management_settings": dataSourceBotManagementSettings(), - "akamai_botman_challenge_action": dataSourceChallengeAction(), - "akamai_botman_challenge_interception_rules": dataSourceChallengeInterceptionRules(), - "akamai_botman_client_side_security": dataSourceClientSideSecurity(), - "akamai_botman_conditional_action": dataSourceConditionalAction(), - "akamai_botman_custom_bot_category": dataSourceCustomBotCategory(), - "akamai_botman_custom_bot_category_action": dataSourceCustomBotCategoryAction(), - "akamai_botman_custom_bot_category_sequence": dataSourceCustomBotCategorySequence(), - "akamai_botman_custom_client": dataSourceCustomClient(), - "akamai_botman_custom_defined_bot": dataSourceCustomDefinedBot(), - "akamai_botman_custom_deny_action": dataSourceCustomDenyAction(), - "akamai_botman_javascript_injection": dataSourceJavascriptInjection(), - "akamai_botman_recategorized_akamai_defined_bot": dataSourceRecategorizedAkamaiDefinedBot(), - "akamai_botman_response_action": dataSourceResponseAction(), - "akamai_botman_serve_alternate_action": dataSourceServeAlternateAction(), - "akamai_botman_transactional_endpoint": dataSourceTransactionalEndpoint(), - "akamai_botman_transactional_endpoint_protection": dataSourceTransactionalEndpointProtection(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_botman_akamai_bot_category_action": resourceAkamaiBotCategoryAction(), - "akamai_botman_bot_analytics_cookie": resourceBotAnalyticsCookie(), - "akamai_botman_bot_category_exception": resourceBotCategoryException(), - "akamai_botman_bot_detection_action": resourceBotDetectionAction(), - "akamai_botman_bot_management_settings": resourceBotManagementSettings(), - "akamai_botman_challenge_action": resourceChallengeAction(), - "akamai_botman_challenge_interception_rules": resourceChallengeInterceptionRules(), - "akamai_botman_client_side_security": resourceClientSideSecurity(), - "akamai_botman_conditional_action": resourceConditionalAction(), - "akamai_botman_custom_bot_category": resourceCustomBotCategory(), - "akamai_botman_custom_bot_category_action": resourceCustomBotCategoryAction(), - "akamai_botman_custom_bot_category_sequence": resourceCustomBotCategorySequence(), - "akamai_botman_custom_client": resourceCustomClient(), - "akamai_botman_custom_defined_bot": resourceCustomDefinedBot(), - "akamai_botman_custom_deny_action": resourceCustomDenyAction(), - "akamai_botman_javascript_injection": resourceJavascriptInjection(), - "akamai_botman_recategorized_akamai_defined_bot": resourceRecategorizedAkamaiDefinedBot(), - "akamai_botman_serve_alternate_action": resourceServeAlternateAction(), - "akamai_botman_transactional_endpoint": resourceTransactionalEndpoint(), - "akamai_botman_transactional_endpoint_protection": resourceTransactionalEndpointProtection(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c botman.BotMan) Option { - return func(p *provider) { +func withClient(c botman.BotMan) option { + return func(p *Subprovider) { p.client = c } } // Client returns the PAPI interface -func (p *provider) Client(meta akamai.OperationMeta) botman.BotMan { +func (p *Subprovider) Client(meta meta.Meta) botman.BotMan { if p.client != nil { return p.client } return botman.Client(meta.Session()) } -func getBotmanService(d *schema.ResourceData) (interface{}, error) { - var section string - - for _, s := range tf.FindStringValues(d, "botman_section", "config_section") { - if s != "default" { - section = s - break - } - } - - if section != "" { - if err := d.Set("config_section", section); err != nil { - return nil, fmt.Errorf("%s: %s", tf.ErrValueSet, err.Error()) - } +// Resources returns terraform resources for botman +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_botman_akamai_bot_category_action": resourceAkamaiBotCategoryAction(), + "akamai_botman_bot_analytics_cookie": resourceBotAnalyticsCookie(), + "akamai_botman_bot_category_exception": resourceBotCategoryException(), + "akamai_botman_bot_detection_action": resourceBotDetectionAction(), + "akamai_botman_bot_management_settings": resourceBotManagementSettings(), + "akamai_botman_challenge_action": resourceChallengeAction(), + "akamai_botman_challenge_interception_rules": resourceChallengeInterceptionRules(), + "akamai_botman_client_side_security": resourceClientSideSecurity(), + "akamai_botman_conditional_action": resourceConditionalAction(), + "akamai_botman_custom_bot_category": resourceCustomBotCategory(), + "akamai_botman_custom_bot_category_action": resourceCustomBotCategoryAction(), + "akamai_botman_custom_bot_category_sequence": resourceCustomBotCategorySequence(), + "akamai_botman_custom_client": resourceCustomClient(), + "akamai_botman_custom_defined_bot": resourceCustomDefinedBot(), + "akamai_botman_custom_deny_action": resourceCustomDenyAction(), + "akamai_botman_javascript_injection": resourceJavascriptInjection(), + "akamai_botman_recategorized_akamai_defined_bot": resourceRecategorizedAkamaiDefinedBot(), + "akamai_botman_serve_alternate_action": resourceServeAlternateAction(), + "akamai_botman_transactional_endpoint": resourceTransactionalEndpoint(), + "akamai_botman_transactional_endpoint_protection": resourceTransactionalEndpointProtection(), } - - return nil, nil } -func (p *provider) Name() string { - return "botman" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v1.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap -} - -func (p *provider) Configure(log log.Interface, d *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - _, err := getBotmanService(d) - if err != nil { - return nil +// DataSources returns terraform data sources for botman +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_botman_akamai_bot_category": dataSourceAkamaiBotCategory(), + "akamai_botman_akamai_bot_category_action": dataSourceAkamaiBotCategoryAction(), + "akamai_botman_akamai_defined_bot": dataSourceAkamaiDefinedBot(), + "akamai_botman_bot_analytics_cookie": dataSourceBotAnalyticsCookie(), + "akamai_botman_bot_analytics_cookie_values": dataSourceBotAnalyticsCookieValues(), + "akamai_botman_bot_category_exception": dataSourceBotCategoryException(), + "akamai_botman_bot_detection": dataSourceBotDetection(), + "akamai_botman_bot_detection_action": dataSourceBotDetectionAction(), + "akamai_botman_bot_endpoint_coverage_report": dataSourceBotEndpointCoverageReport(), + "akamai_botman_bot_management_settings": dataSourceBotManagementSettings(), + "akamai_botman_challenge_action": dataSourceChallengeAction(), + "akamai_botman_challenge_interception_rules": dataSourceChallengeInterceptionRules(), + "akamai_botman_client_side_security": dataSourceClientSideSecurity(), + "akamai_botman_conditional_action": dataSourceConditionalAction(), + "akamai_botman_custom_bot_category": dataSourceCustomBotCategory(), + "akamai_botman_custom_bot_category_action": dataSourceCustomBotCategoryAction(), + "akamai_botman_custom_bot_category_sequence": dataSourceCustomBotCategorySequence(), + "akamai_botman_custom_client": dataSourceCustomClient(), + "akamai_botman_custom_defined_bot": dataSourceCustomDefinedBot(), + "akamai_botman_custom_deny_action": dataSourceCustomDenyAction(), + "akamai_botman_javascript_injection": dataSourceJavascriptInjection(), + "akamai_botman_recategorized_akamai_defined_bot": dataSourceRecategorizedAkamaiDefinedBot(), + "akamai_botman_response_action": dataSourceResponseAction(), + "akamai_botman_serve_alternate_action": dataSourceServeAlternateAction(), + "akamai_botman_transactional_endpoint": dataSourceTransactionalEndpoint(), + "akamai_botman_transactional_endpoint_protection": dataSourceTransactionalEndpointProtection(), } - - return nil } diff --git a/pkg/providers/botman/provider_test.go b/pkg/providers/botman/provider_test.go index 6361adc8e..13eb4ccb2 100644 --- a/pkg/providers/botman/provider_test.go +++ b/pkg/providers/botman/provider_test.go @@ -9,8 +9,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -18,28 +19,23 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex 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 af64c65c9..c3407453e 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,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -53,7 +53,7 @@ func resourceAkamaiBotCategoryAction() *schema.Resource { } func resourceAkamaiBotCategoryActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceAkamaiBotCategoryActionCreate") logger.Debugf("in resourceAkamaiBotCategoryActionCreate") @@ -108,7 +108,7 @@ func resourceAkamaiBotCategoryActionRead(ctx context.Context, d *schema.Resource func akamaiBotCategoryActionRead(ctx context.Context, d *schema.ResourceData, m interface{}, readFromCache bool) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceAkamaiBotCategoryActionRead") logger.Debugf("in resourceAkamaiBotCategoryActionRead") @@ -174,7 +174,7 @@ func akamaiBotCategoryActionRead(ctx context.Context, d *schema.ResourceData, m } func resourceAkamaiBotCategoryActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceAkamaiBotCategoryActionUpdate") logger.Debugf("in resourceAkamaiBotCategoryActionUpdate") @@ -221,7 +221,7 @@ func resourceAkamaiBotCategoryActionUpdate(ctx context.Context, d *schema.Resour } func resourceAkamaiBotCategoryActionDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceAkamaiBotCategoryActionDelete") logger.Debugf("in resourceAkamaiBotCategoryActionDelete") logger.Info("Botman API does not support akamai bot category action deletion - resource will only be removed from state") 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 d4f59d237..7bdf129cd 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 d0aa135fe..8fcf5e100 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go @@ -5,9 +5,9 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -42,7 +42,7 @@ func resourceBotAnalyticsCookie() *schema.Resource { } func resourceBotAnalyticsCookieCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotAnalyticsCookieCreate") logger.Debugf("in resourceBotAnalyticsCookieCreate") @@ -80,7 +80,7 @@ func resourceBotAnalyticsCookieCreate(ctx context.Context, d *schema.ResourceDat } func resourceBotAnalyticsCookieRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotAnalyticsCookieRead") logger.Debugf("in resourceBotAnalyticsCookieRead") @@ -122,7 +122,7 @@ func resourceBotAnalyticsCookieRead(ctx context.Context, d *schema.ResourceData, } func resourceBotAnalyticsCookieUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotAnalyticsCookieUpdate") logger.Debugf("in resourceBotAnalyticsCookieUpdate") @@ -158,7 +158,7 @@ func resourceBotAnalyticsCookieUpdate(ctx context.Context, d *schema.ResourceDat } func resourceBotAnalyticsDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceBotAnalyticsDelete") logger.Debugf("in resourceBotAnalyticsDelete") logger.Info("Botman API does not support bot analytics cookie settings deletion - resource will only be removed from state") 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 98db23e9c..5e582c346 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 7b8fa8823..0e2dcac00 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -49,7 +49,7 @@ func resourceBotCategoryException() *schema.Resource { } func resourceBotCategoryExceptionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotCategoryExceptionCreate") logger.Debugf("in resourceBotCategoryExceptionCreate") @@ -93,7 +93,7 @@ func resourceBotCategoryExceptionCreate(ctx context.Context, d *schema.ResourceD } func resourceBotCategoryExceptionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotCategoryExceptionRead") logger.Debugf("in resourceBotCategoryExceptionRead") @@ -145,7 +145,7 @@ func resourceBotCategoryExceptionRead(ctx context.Context, d *schema.ResourceDat } func resourceBotCategoryExceptionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotCategoryExceptionUpdate") logger.Debugf("in resourceBotCategoryExceptionUpdate") @@ -189,7 +189,7 @@ func resourceBotCategoryExceptionUpdate(ctx context.Context, d *schema.ResourceD } func resourceBotCategoryExceptionDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceBotCategoryExceptionDelete") logger.Debugf("in resourceBotCategoryExceptionDelete") logger.Info("Botman API does not support bot category exception deletion - resource will only be removed from state") 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 556796198..5264f9f96 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 e3f29ede3..009092b48 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -54,7 +54,7 @@ func resourceBotDetectionAction() *schema.Resource { } func resourceBotDetectionActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotDetectionActionCreate") logger.Debugf("in resourceBotDetectionActionCreate") @@ -107,7 +107,7 @@ func resourceBotDetectionActionRead(ctx context.Context, d *schema.ResourceData, return botDetectionActionRead(ctx, d, m, true) } func botDetectionActionRead(ctx context.Context, d *schema.ResourceData, m interface{}, readFromCache bool) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotDetectionActionRead") logger.Debugf("in resourceBotDetectionActionRead") @@ -172,7 +172,7 @@ func botDetectionActionRead(ctx context.Context, d *schema.ResourceData, m inter } func resourceBotDetectionActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotDetectionActionUpdate") logger.Debugf("in resourceBotDetectionActionUpdate") @@ -219,7 +219,7 @@ func resourceBotDetectionActionUpdate(ctx context.Context, d *schema.ResourceDat } func resourceBotDetectionActionDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceBotDetectionActionDelete") logger.Debugf("in resourceBotDetectionActionDelete") logger.Info("Botman API does not support bot detection category action deletion - resource will only be removed from state") 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 2bc671a6a..278a311bd 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 9512e3bbe..b933486f7 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -49,7 +49,7 @@ func resourceBotManagementSettings() *schema.Resource { } func resourceBotManagementSettingsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotManagementSettingsCreate") logger.Debugf("in resourceBotManagementSettingsCreate") @@ -93,7 +93,7 @@ func resourceBotManagementSettingsCreate(ctx context.Context, d *schema.Resource } func resourceBotManagementSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotManagementSettingsRead") logger.Debugf("in resourceBotManagementSettingsRead") @@ -145,7 +145,7 @@ func resourceBotManagementSettingsRead(ctx context.Context, d *schema.ResourceDa } func resourceBotManagementSettingsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceBotManagementSettingsUpdate") logger.Debugf("in resourceBotManagementSettingsUpdate") @@ -189,7 +189,7 @@ func resourceBotManagementSettingsUpdate(ctx context.Context, d *schema.Resource } func resourceBotManagementSettingsDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceBotManagementSettingsDelete") logger.Debugf("in resourceBotManagementSettingsDelete") logger.Info("Botman API does not support bot management settings deletion - resource will only be removed from state") 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 ce03636a4..dc801caad 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 0ec6ac9ac..2305fbf8f 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_action.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_action.go @@ -6,10 +6,10 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -49,7 +49,7 @@ func resourceChallengeAction() *schema.Resource { } func resourceChallengeActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeActionCreateAction") logger.Debugf("in resourceChallengeActionCreateAction") @@ -87,7 +87,7 @@ func resourceChallengeActionCreate(ctx context.Context, d *schema.ResourceData, } func resourceChallengeActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeActionRead") logger.Debugf("in resourceChallengeActionRead") @@ -142,7 +142,7 @@ func resourceChallengeActionRead(ctx context.Context, d *schema.ResourceData, m } func resourceChallengeActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeActionUpdate") logger.Debugf("in resourceChallengeActionUpdate") @@ -186,7 +186,7 @@ func resourceChallengeActionUpdate(ctx context.Context, d *schema.ResourceData, } func resourceChallengeActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeActionDelete") logger.Debugf("in resourceChallengeActionDelete") 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 60fef40a7..e96cb3d89 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 c6ab95aec..4d7c7b455 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -43,7 +43,7 @@ func resourceChallengeInterceptionRules() *schema.Resource { } func resourceChallengeInterceptionRulesCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeInterceptionRulesCreate") logger.Debugf("in resourceChallengeInterceptionRulesCreate") @@ -81,7 +81,7 @@ func resourceChallengeInterceptionRulesCreate(ctx context.Context, d *schema.Res } func resourceChallengeInterceptionRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeInterceptionRulesRead") logger.Debugf("in resourceChallengeInterceptionRulesRead") @@ -124,7 +124,7 @@ func resourceChallengeInterceptionRulesRead(ctx context.Context, d *schema.Resou } func resourceChallengeInterceptionRulesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceChallengeInterceptionRulesUpdate") logger.Debugf("in resourceChallengeInterceptionRulesUpdate") @@ -160,7 +160,7 @@ func resourceChallengeInterceptionRulesUpdate(ctx context.Context, d *schema.Res } func resourceChallengeInterceptionRulesDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceChallengeInterceptionRulesDelete") logger.Debugf("in resourceChallengeInterceptionRulesDelete") logger.Info("Botman API does not support client side security settings deletion - resource will only be removed from state") 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 73b3fa5d5..146c5ed6a 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 efa6443d1..02d112349 100644 --- a/pkg/providers/botman/resource_akamai_botman_client_side_security.go +++ b/pkg/providers/botman/resource_akamai_botman_client_side_security.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -43,7 +43,7 @@ func resourceClientSideSecurity() *schema.Resource { } func resourceClientSideSecurityCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceClientSideSecurityCreate") logger.Debugf("in resourceClientSideSecurityCreate") @@ -81,7 +81,7 @@ func resourceClientSideSecurityCreate(ctx context.Context, d *schema.ResourceDat } func resourceClientSideSecurityRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceClientSideSecurityRead") logger.Debugf("in resourceClientSideSecurityRead") @@ -124,7 +124,7 @@ func resourceClientSideSecurityRead(ctx context.Context, d *schema.ResourceData, } func resourceClientSideSecurityUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceClientSideSecurityUpdate") logger.Debugf("in resourceClientSideSecurityUpdate") @@ -160,7 +160,7 @@ func resourceClientSideSecurityUpdate(ctx context.Context, d *schema.ResourceDat } func resourceClientSideSecurityDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceClientSideSecurityDelete") logger.Debugf("in resourceClientSideSecurityDelete") logger.Info("Botman API does not support client side security settings deletion - resource will only be removed from state") 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 84035df92..cee9093e3 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 8415de81b..135718ce7 100644 --- a/pkg/providers/botman/resource_akamai_botman_conditional_action.go +++ b/pkg/providers/botman/resource_akamai_botman_conditional_action.go @@ -6,10 +6,10 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -49,7 +49,7 @@ func resourceConditionalAction() *schema.Resource { } func resourceConditionalActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceConditionalActionCreateAction") logger.Debugf("in resourceConditionalActionCreateAction") @@ -87,7 +87,7 @@ func resourceConditionalActionCreate(ctx context.Context, d *schema.ResourceData } func resourceConditionalActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceConditionalActionRead") logger.Debugf("in resourceConditionalActionRead") @@ -142,7 +142,7 @@ func resourceConditionalActionRead(ctx context.Context, d *schema.ResourceData, } func resourceConditionalActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceConditionalActionUpdate") logger.Debugf("in resourceConditionalActionUpdate") @@ -186,7 +186,7 @@ func resourceConditionalActionUpdate(ctx context.Context, d *schema.ResourceData } func resourceConditionalActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceConditionalActionDelete") logger.Debugf("in resourceConditionalActionDelete") 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 53cc8e572..2c34754ed 100644 --- a/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 a4ef5e036..ee58c153d 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go @@ -6,10 +6,10 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -49,7 +49,7 @@ func resourceCustomBotCategory() *schema.Resource { } func resourceCustomBotCategoryCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryCreateAction") logger.Debugf("in resourceCustomBotCategoryCreateAction") @@ -87,7 +87,7 @@ func resourceCustomBotCategoryCreate(ctx context.Context, d *schema.ResourceData } func resourceCustomBotCategoryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryRead") logger.Debugf("in resourceCustomBotCategoryRead") @@ -145,7 +145,7 @@ func resourceCustomBotCategoryRead(ctx context.Context, d *schema.ResourceData, } func resourceCustomBotCategoryUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryUpdate") logger.Debugf("in resourceCustomBotCategoryUpdate") @@ -189,7 +189,7 @@ func resourceCustomBotCategoryUpdate(ctx context.Context, d *schema.ResourceData } func resourceCustomBotCategoryDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryDelete") logger.Debugf("in resourceCustomBotCategoryDelete") 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 34b2c4ac6..7b8509043 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,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -55,7 +55,7 @@ func resourceCustomBotCategoryAction() *schema.Resource { } func resourceCustomBotCategoryActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryActionCreate") logger.Debugf("in resourceCustomBotCategoryActionCreate") @@ -109,7 +109,7 @@ func resourceCustomBotCategoryActionRead(ctx context.Context, d *schema.Resource } func customBotCategoryActionRead(ctx context.Context, d *schema.ResourceData, m interface{}, readFromCache bool) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryActionRead") logger.Debugf("in resourceCustomBotCategoryActionRead") @@ -174,7 +174,7 @@ func customBotCategoryActionRead(ctx context.Context, d *schema.ResourceData, m } func resourceCustomBotCategoryActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategoryActionUpdate") logger.Debugf("in resourceCustomBotCategoryActionUpdate") @@ -221,7 +221,7 @@ func resourceCustomBotCategoryActionUpdate(ctx context.Context, d *schema.Resour } func resourceCustomBotCategoryActionDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceCustomBotCategoryActionDelete") logger.Debugf("in resourceCustomBotCategoryActionDelete") logger.Info("Botman API does not support custom bot category action deletion - resource will only be removed from state") 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 bcc1631c3..f603d59bf 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) 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 fe43053fc..fa2f2970d 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,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -39,7 +39,7 @@ func resourceCustomBotCategorySequence() *schema.Resource { } func resourceCustomBotCategorySequenceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategorySequenceCreate") logger.Debugf("in resourceCustomBotCategorySequenceCreate") @@ -81,7 +81,7 @@ func resourceCustomBotCategorySequenceCreate(ctx context.Context, d *schema.Reso } func resourceCustomBotCategorySequenceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategorySequenceUpdate") logger.Debugf("in resourceCustomBotCategorySequenceUpdate") @@ -121,7 +121,7 @@ func resourceCustomBotCategorySequenceUpdate(ctx context.Context, d *schema.Reso } func resourceCustomBotCategorySequenceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomBotCategorySequenceRead") logger.Debugf("in resourceCustomBotCategorySequenceRead") @@ -158,7 +158,7 @@ func resourceCustomBotCategorySequenceRead(ctx context.Context, d *schema.Resour } func resourceCustomBotCategorySequenceDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceCustomBotCategorySequenceDelete") logger.Debugf("in resourceCustomBotCategorySequenceDelete") logger.Info("Botman API does not support custom bot category sequence deletion - resource will only be removed from state") 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 9ff1f6225..965f3a32f 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,9 +3,9 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) 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 98e868e64..2092775d2 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 23473c044..5e5d6d12f 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -47,7 +47,7 @@ func resourceCustomClient() *schema.Resource { } func resourceCustomClientCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomClientCreateAction") logger.Debugf("in resourceCustomClientCreateAction") @@ -85,7 +85,7 @@ func resourceCustomClientCreate(ctx context.Context, d *schema.ResourceData, m i } func resourceCustomClientRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomClientReadAction") logger.Debugf("in resourceCustomClientReadAction") @@ -139,7 +139,7 @@ func resourceCustomClientRead(ctx context.Context, d *schema.ResourceData, m int } func resourceCustomClientUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomClientUpdateAction") logger.Debugf("in resourceCustomClientUpdateAction") @@ -183,7 +183,7 @@ func resourceCustomClientUpdate(ctx context.Context, d *schema.ResourceData, m i } func resourceCustomClientDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomClientDeleteAction") logger.Debugf("in resourceCustomClientDeleteAction") 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 1dafff9d0..8bb09d8f6 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 525d5f55a..d13c7c9f5 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -47,7 +47,7 @@ func resourceCustomDefinedBot() *schema.Resource { } func resourceCustomDefinedBotCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDefinedBotCreate") logger.Debugf("in resourceCustomDefinedBotCreate") @@ -85,7 +85,7 @@ func resourceCustomDefinedBotCreate(ctx context.Context, d *schema.ResourceData, } func resourceCustomDefinedBotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDefinedBotRead") logger.Debugf("in resourceCustomDefinedBotRead") @@ -139,7 +139,7 @@ func resourceCustomDefinedBotRead(ctx context.Context, d *schema.ResourceData, m } func resourceCustomDefinedBotUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDefinedBotUpdate") logger.Debugf("in resourceCustomDefinedBotUpdate") @@ -183,7 +183,7 @@ func resourceCustomDefinedBotUpdate(ctx context.Context, d *schema.ResourceData, } func resourceCustomDefinedBotDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDefinedBotDelete") logger.Debugf("in resourceCustomDefinedBotDelete") 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 bbaa1f832..926a28cb8 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 bb157f4c8..156689557 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go @@ -6,10 +6,10 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -49,7 +49,7 @@ func resourceCustomDenyAction() *schema.Resource { } func resourceCustomDenyActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDenyActionCreateAction") logger.Debugf("in resourceCustomDenyActionCreateAction") @@ -87,7 +87,7 @@ func resourceCustomDenyActionCreate(ctx context.Context, d *schema.ResourceData, } func resourceCustomDenyActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDenyActionRead") logger.Debugf("in resourceCustomDenyActionRead") @@ -142,7 +142,7 @@ func resourceCustomDenyActionRead(ctx context.Context, d *schema.ResourceData, m } func resourceCustomDenyActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDenyActionUpdate") logger.Debugf("in resourceCustomDenyActionUpdate") @@ -186,7 +186,7 @@ func resourceCustomDenyActionUpdate(ctx context.Context, d *schema.ResourceData, } func resourceCustomDenyActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceCustomDenyActionDelete") logger.Debugf("in resourceCustomDenyActionDelete") 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 1b2c9a338..8f0154955 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 8994dbb71..775b985c8 100644 --- a/pkg/providers/botman/resource_akamai_botman_javascript_injection.go +++ b/pkg/providers/botman/resource_akamai_botman_javascript_injection.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -49,7 +49,7 @@ func resourceJavascriptInjection() *schema.Resource { } func resourceJavascriptInjectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceJavascriptInjectionCreate") logger.Debugf("in resourceJavascriptInjectionCreate") @@ -93,7 +93,7 @@ func resourceJavascriptInjectionCreate(ctx context.Context, d *schema.ResourceDa } func resourceJavascriptInjectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceJavascriptInjectionRead") logger.Debugf("in resourceJavascriptInjectionRead") @@ -141,7 +141,7 @@ func resourceJavascriptInjectionRead(ctx context.Context, d *schema.ResourceData } func resourceJavascriptInjectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceJavascriptInjectionUpdate") logger.Debugf("in resourceJavascriptInjectionUpdate") @@ -185,7 +185,7 @@ func resourceJavascriptInjectionUpdate(ctx context.Context, d *schema.ResourceDa } func resourceJavascriptInjectionDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceJavascriptInjectionDelete") logger.Debugf("in resourceJavascriptInjectionDelete") logger.Info("Botman API does not support javascript injection deletion - resource will only be removed from state") 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 f5e65a394..b2b4c588f 100644 --- a/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go +++ b/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go @@ -3,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 401c7b4a5..88e6eca60 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,9 +5,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -44,7 +44,7 @@ func resourceRecategorizedAkamaiDefinedBot() *schema.Resource { } func resourceRecategorizedAkamaiDefinedBotCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceRecategorizedAkamaiDefinedBotCreateAction") logger.Debugf("in resourceRecategorizedAkamaiDefinedBotCreateAction") @@ -88,7 +88,7 @@ func resourceRecategorizedAkamaiDefinedBotCreate(ctx context.Context, d *schema. } func resourceRecategorizedAkamaiDefinedBotRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceRecategorizedAkamaiDefinedBotReadAction") logger.Debugf("in resourceRecategorizedAkamaiDefinedBotReadAction") @@ -136,7 +136,7 @@ func resourceRecategorizedAkamaiDefinedBotRead(ctx context.Context, d *schema.Re } func resourceRecategorizedAkamaiDefinedBotUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceRecategorizedAkamaiDefinedBotUpdateAction") logger.Debugf("in resourceRecategorizedAkamaiDefinedBotUpdateAction") @@ -180,7 +180,7 @@ func resourceRecategorizedAkamaiDefinedBotUpdate(ctx context.Context, d *schema. } func resourceRecategorizedAkamaiDefinedBotDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceRecategorizedAkamaiDefinedBotDeleteAction") logger.Debugf("in resourceRecategorizedAkamaiDefinedBotDeleteAction") 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 0d03ecdad..fdca79f1c 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 616882af0..6c00e88d6 100644 --- a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go +++ b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go @@ -6,10 +6,10 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -49,7 +49,7 @@ func resourceServeAlternateAction() *schema.Resource { } func resourceServeAlternateActionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceServeAlternateActionCreateAction") logger.Debugf("in resourceServeAlternateActionCreateAction") @@ -87,7 +87,7 @@ func resourceServeAlternateActionCreate(ctx context.Context, d *schema.ResourceD } func resourceServeAlternateActionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceServeAlternateActionRead") logger.Debugf("in resourceServeAlternateActionRead") @@ -142,7 +142,7 @@ func resourceServeAlternateActionRead(ctx context.Context, d *schema.ResourceDat } func resourceServeAlternateActionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceServeAlternateActionUpdate") logger.Debugf("in resourceServeAlternateActionUpdate") @@ -186,7 +186,7 @@ func resourceServeAlternateActionUpdate(ctx context.Context, d *schema.ResourceD } func resourceServeAlternateActionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceServeAlternateActionDelete") logger.Debugf("in resourceServeAlternateActionDelete") 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 e884e5e65..fb944c3ee 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,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 084503d6e..66f24b8e6 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go @@ -6,9 +6,9 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -53,7 +53,7 @@ func resourceTransactionalEndpoint() *schema.Resource { } func resourceTransactionalEndpointCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointCreateAction") logger.Debugf("in resourceTransactionalEndpointCreateAction") @@ -106,7 +106,7 @@ func resourceTransactionalEndpointRead(ctx context.Context, d *schema.ResourceDa } func transactionalEndpointRead(ctx context.Context, d *schema.ResourceData, m interface{}, readFromCache bool) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointReadAction") logger.Debugf("in resourceTransactionalEndpointReadAction") @@ -181,7 +181,7 @@ func transactionalEndpointRead(ctx context.Context, d *schema.ResourceData, m in } func resourceTransactionalEndpointUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointUpdateAction") logger.Debugf("in resourceTransactionalEndpointUpdateAction") @@ -228,7 +228,7 @@ func resourceTransactionalEndpointUpdate(ctx context.Context, d *schema.Resource } func resourceTransactionalEndpointDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointDeleteAction") logger.Debugf("in resourceTransactionalEndpointDeleteAction") 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 05e29da87..6c1ed67ee 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -43,7 +43,7 @@ func resourceTransactionalEndpointProtection() *schema.Resource { } func resourceTransactionalEndpointProtectionCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointProtectionCreate") logger.Debugf("in resourceTransactionalEndpointProtectionCreate") @@ -81,7 +81,7 @@ func resourceTransactionalEndpointProtectionCreate(ctx context.Context, d *schem } func resourceTransactionalEndpointProtectionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointProtectionRead") logger.Debugf("in resourceTransactionalEndpointProtectionRead") @@ -126,7 +126,7 @@ func resourceTransactionalEndpointProtectionRead(ctx context.Context, d *schema. } func resourceTransactionalEndpointProtectionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("botman", "resourceTransactionalEndpointProtectionUpdate") logger.Debugf("in resourceTransactionalEndpointProtectionUpdate") @@ -162,7 +162,7 @@ func resourceTransactionalEndpointProtectionUpdate(ctx context.Context, d *schem } func resourceTransactionEndpointProtectionDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("botman", "resourceTransactionEndpointProtectionDelete") logger.Debugf("in resourceTransactionEndpointProtectionDelete") logger.Info("Botman API does not support transactional endpoint protection deletion - resource will only be removed from state") 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 4d7ece331..6204b85b0 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,8 +3,8 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 9769c7c31..082831815 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/botman" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/botman" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/cloudlets/cloudlets.go b/pkg/providers/cloudlets/cloudlets.go index 162c0be6d..a9a434f0e 100644 --- a/pkg/providers/cloudlets/cloudlets.go +++ b/pkg/providers/cloudlets/cloudlets.go @@ -1,10 +1,7 @@ -//go:build all || cloudlets -// +build all cloudlets - package cloudlets -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } 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 172560a96..121c7bc80 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 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 03dd98620..fb378bee5 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go @@ -6,10 +6,10 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -228,7 +228,7 @@ func dataSourceCloudletsApplicationLoadBalancer() *schema.Resource { } func dataApplicationLoadBalancerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) log := meta.Log("Cloudlets", "dataApplicationLoadBalancerRead") log.Debug("Reading Load Balancer") 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 5f67b0633..35f54f231 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,8 +4,8 @@ import ( "context" "encoding/json" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 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 e12a64267..4cc1c0f40 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,8 +4,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) 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 fc9c21cf4..c1f6187b7 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 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 e4b2123ee..e0b9ee823 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 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 8ad9735f2..a501eb6c6 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 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 97fb0e449..036978747 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go index 479d72bda..b7ddadcb3 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go @@ -6,12 +6,12 @@ import ( "errors" "fmt" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" ) func dataSourceCloudletsPolicy() *schema.Resource { @@ -285,7 +285,7 @@ func populateSchemaFieldsWithPolicyVersion(p *cloudlets.PolicyVersion, d *schema } func dataSourceCloudletsPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) log := meta.Log("Cloudlets", "dataSourceCloudletsPolicyRead") client := inst.Client(meta) diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go index 93bdaedaa..10c5d7f79 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" ) func TestDataCloudletsPolicy(t *testing.T) { 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 cccc73b13..115c606c3 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" 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 08d603fef..6c5d01955 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,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" diff --git a/pkg/providers/cloudlets/match_rules.go b/pkg/providers/cloudlets/match_rules.go index a56cb4a23..8758eba96 100644 --- a/pkg/providers/cloudlets/match_rules.go +++ b/pkg/providers/cloudlets/match_rules.go @@ -7,8 +7,8 @@ import ( "io" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/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 c85974d2a..50c1374dd 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/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/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.go b/pkg/providers/cloudlets/policy_version.go index df709fffe..b34358dcd 100644 --- a/pkg/providers/cloudlets/policy_version.go +++ b/pkg/providers/cloudlets/policy_version.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" ) func getAllPolicyVersions(ctx context.Context, policyID int64, client cloudlets.Cloudlets) ([]cloudlets.PolicyVersion, error) { diff --git a/pkg/providers/cloudlets/policy_version_test.go b/pkg/providers/cloudlets/policy_version_test.go index aa7b2d8be..0b0cf43c9 100644 --- a/pkg/providers/cloudlets/policy_version_test.go +++ b/pkg/providers/cloudlets/policy_version_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/tj/assert" diff --git a/pkg/providers/cloudlets/provider.go b/pkg/providers/cloudlets/provider.go index 67e260533..108169185 100644 --- a/pkg/providers/cloudlets/provider.go +++ b/pkg/providers/cloudlets/provider.go @@ -4,35 +4,34 @@ package cloudlets import ( "sync" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers cloudlets resources and data sources + Subprovider struct { client cloudlets.Cloudlets } - // Option is a cloudlets provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -42,70 +41,42 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{}, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_cloudlets_api_prioritization_match_rule": dataSourceCloudletsAPIPrioritizationMatchRule(), - "akamai_cloudlets_application_load_balancer": dataSourceCloudletsApplicationLoadBalancer(), - "akamai_cloudlets_application_load_balancer_match_rule": dataSourceCloudletsApplicationLoadBalancerMatchRule(), - "akamai_cloudlets_audience_segmentation_match_rule": dataSourceCloudletsAudienceSegmentationMatchRule(), - "akamai_cloudlets_edge_redirector_match_rule": dataSourceCloudletsEdgeRedirectorMatchRule(), - "akamai_cloudlets_forward_rewrite_match_rule": dataSourceCloudletsForwardRewriteMatchRule(), - "akamai_cloudlets_phased_release_match_rule": dataSourceCloudletsPhasedReleaseMatchRule(), - "akamai_cloudlets_request_control_match_rule": dataSourceCloudletsRequestControlMatchRule(), - "akamai_cloudlets_visitor_prioritization_match_rule": dataSourceCloudletsVisitorPrioritizationMatchRule(), - "akamai_cloudlets_policy": dataSourceCloudletsPolicy(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_cloudlets_application_load_balancer": resourceCloudletsApplicationLoadBalancer(), - "akamai_cloudlets_application_load_balancer_activation": resourceCloudletsApplicationLoadBalancerActivation(), - "akamai_cloudlets_policy": resourceCloudletsPolicy(), - "akamai_cloudlets_policy_activation": resourceCloudletsPolicyActivation(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c cloudlets.Cloudlets) Option { - return func(p *provider) { +func withClient(c cloudlets.Cloudlets) option { + return func(p *Subprovider) { p.client = c } } // Client returns the Cloudlets interface -func (p *provider) Client(meta akamai.OperationMeta) cloudlets.Cloudlets { +func (p *Subprovider) Client(meta meta.Meta) cloudlets.Cloudlets { if p.client != nil { return p.client } return cloudlets.Client(meta.Session()) } -func (p *provider) Name() string { - return "cloudlets" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for cloudlets +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_cloudlets_application_load_balancer": resourceCloudletsApplicationLoadBalancer(), + "akamai_cloudlets_application_load_balancer_activation": resourceCloudletsApplicationLoadBalancerActivation(), + "akamai_cloudlets_policy": resourceCloudletsPolicy(), + "akamai_cloudlets_policy_activation": resourceCloudletsPolicyActivation(), + } } -func (p *provider) Configure(_ log.Interface, _ *schema.ResourceData) diag.Diagnostics { - return nil +// DataSources returns terraform data sources for cloudlets +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_cloudlets_api_prioritization_match_rule": dataSourceCloudletsAPIPrioritizationMatchRule(), + "akamai_cloudlets_application_load_balancer": dataSourceCloudletsApplicationLoadBalancer(), + "akamai_cloudlets_application_load_balancer_match_rule": dataSourceCloudletsApplicationLoadBalancerMatchRule(), + "akamai_cloudlets_audience_segmentation_match_rule": dataSourceCloudletsAudienceSegmentationMatchRule(), + "akamai_cloudlets_edge_redirector_match_rule": dataSourceCloudletsEdgeRedirectorMatchRule(), + "akamai_cloudlets_forward_rewrite_match_rule": dataSourceCloudletsForwardRewriteMatchRule(), + "akamai_cloudlets_phased_release_match_rule": dataSourceCloudletsPhasedReleaseMatchRule(), + "akamai_cloudlets_request_control_match_rule": dataSourceCloudletsRequestControlMatchRule(), + "akamai_cloudlets_visitor_prioritization_match_rule": dataSourceCloudletsVisitorPrioritizationMatchRule(), + "akamai_cloudlets_policy": dataSourceCloudletsPolicy(), + } } diff --git a/pkg/providers/cloudlets/provider_test.go b/pkg/providers/cloudlets/provider_test.go index ec9eff25c..0466a7939 100644 --- a/pkg/providers/cloudlets/provider_test.go +++ b/pkg/providers/cloudlets/provider_test.go @@ -8,39 +8,34 @@ import ( "sync" "testing" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var testAccProviders map[string]func() (*schema.Provider, error) - var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex 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 e3189170a..62d65d566 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go @@ -7,10 +7,10 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ozzo "github.com/go-ozzo/ozzo-validation/v4" "github.com/go-ozzo/ozzo-validation/v4/is" "github.com/hashicorp/go-cty/cty" @@ -296,7 +296,7 @@ func validateLivenessHosts(ctx context.Context, client cloudlets.Cloudlets, d *s } func resourceALBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -336,7 +336,7 @@ func resourceALBCreate(ctx context.Context, d *schema.ResourceData, m interface{ } func resourceALBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -387,7 +387,7 @@ func resourceALBRead(ctx context.Context, d *schema.ResourceData, m interface{}) } func resourceALBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -449,7 +449,7 @@ func resourceALBUpdate(ctx context.Context, d *schema.ResourceData, m interface{ // resource will simply be removed from state in that case // to allow re-using existing config, create function also covers the import functionality, saving the existing origin and version in state func resourceALBDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceLoadBalancerConfigurationDelete") logger.Debug("Deleting load balancer configuration") logger.Info("Cloudlets API does not support load balancer configuration and load balancer configuration version deletion - resource will only be removed from state") @@ -459,7 +459,7 @@ func resourceALBDelete(_ context.Context, d *schema.ResourceData, m interface{}) // resourceALBImport does a basic import based on the originID specified it imports the latest version func resourceALBImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceALBImport") logger.Debug("Import ALB") 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 0872ae63b..821ee9442 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 @@ -8,10 +8,10 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/apex/log" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -72,7 +72,7 @@ var ( ) func resourceApplicationLoadBalancerActivationDelete(_ context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceApplicationLoadBalancerActivationDelete") logger.Debug("Deleting cloudlets application load balancer activation from local schema only") logger.Info("Cloudlets API does not support application load balancer activation version deletion - resource will only be removed from state") @@ -81,7 +81,7 @@ func resourceApplicationLoadBalancerActivationDelete(_ context.Context, rd *sche } func resourceApplicationLoadBalancerActivationUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceApplicationLoadBalancerActivationUpdate") if !rd.HasChanges("version", "network") { @@ -102,7 +102,7 @@ func resourceApplicationLoadBalancerActivationUpdate(ctx context.Context, rd *sc } func resourceApplicationLoadBalancerActivationCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceApplicationLoadBalancerActivationCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -214,7 +214,7 @@ Failed to restore previous local schema values. The schema will remain in tainte } func resourceApplicationLoadBalancerActivationRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourceApplicationLoadBalancerActivationRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(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 87d77f707..4e08c4e0a 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/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" "github.com/hashicorp/terraform-plugin-sdk/v2/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 a10c820e2..5205f8be2 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,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/jinzhu/copier" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go index 9cff1f69a..d2ff3e3a4 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go @@ -8,32 +8,43 @@ import ( "reflect" "strconv" "strings" + "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" "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" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -var cloudletIDs = map[string]int{ - "ER": 0, - "VP": 1, - "FR": 3, - "IG": 4, - "AP": 5, - "AS": 6, - "CD": 7, - "IV": 8, - "ALB": 9, - "MMB": 10, - "MMA": 11, -} +var ( + // DeletionPolicyPollInterval is the default poll interval for delete policy retries + DeletionPolicyPollInterval = time.Second * 10 + + // DeletionPolicyTimeout is the default timeout for the policy deletion + DeletionPolicyTimeout = time.Minute * 90 + + cloudletIDs = map[string]int{ + "ER": 0, + "VP": 1, + "FR": 3, + "IG": 4, + "AP": 5, + "AS": 6, + "CD": 7, + "IV": 8, + "ALB": 9, + "MMB": 10, + "MMA": 11, + } +) func resourceCloudletsPolicy() *schema.Resource { return &schema.Resource{ @@ -127,7 +138,7 @@ func EnforceMatchRulesChange(_ context.Context, diff *schema.ResourceDiff, _ int } func resourcePolicyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -210,7 +221,7 @@ func resourcePolicyCreate(ctx context.Context, d *schema.ResourceData, m interfa } func resourcePolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyRead") ctx = session.ContextWithOptions( ctx, @@ -260,7 +271,7 @@ func resourcePolicyRead(ctx context.Context, d *schema.ResourceData, m interface } func resourcePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyUpdate") ctx = session.ContextWithOptions( ctx, @@ -373,7 +384,7 @@ func resourcePolicyUpdate(ctx context.Context, d *schema.ResourceData, m interfa } func resourcePolicyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyDelete") ctx = session.ContextWithOptions( ctx, @@ -397,26 +408,34 @@ func resourcePolicyDelete(ctx context.Context, d *schema.ResourceData, m interfa return diag.FromErr(err) } } - if err := client.RemovePolicy(ctx, cloudlets.RemovePolicyRequest{PolicyID: policyID}); err != nil { - statusErr := new(cloudlets.Error) - if errors.As(err, &statusErr) && - strings.Contains(statusErr.Detail, "Unable to delete policy because an activation for this policy is still pending") { - return diag.Diagnostics{ - diag.Diagnostic{ - Severity: diag.Error, - Summary: "Unable to remove policy", - Detail: "Policy could not be removed because some activations are still pending. Please try again later.", - }, + + deletionTimeoutCtx, cancel := context.WithTimeout(ctx, DeletionPolicyTimeout) + defer cancel() + + activationPending := true + for activationPending { + select { + case <-time.After(DeletionPolicyPollInterval): + if err = client.RemovePolicy(ctx, cloudlets.RemovePolicyRequest{PolicyID: policyID}); err != nil { + statusErr := new(cloudlets.Error) + // if error does not contain information about pending activations, return it as it is not expected + if errors.As(err, &statusErr) && !strings.Contains(statusErr.Detail, "Unable to delete policy because an activation for this policy is still pending") { + return diag.Errorf("remove policy error: %s", err) + } + continue } + activationPending = false + case <-deletionTimeoutCtx.Done(): + return diag.Errorf("retry timeout reached: %s", ctx.Err()) } - return diag.FromErr(err) } d.SetId("") + return nil } func resourcePolicyImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyImport") logger.Debugf("Import Policy") @@ -485,7 +504,7 @@ func diffSuppressMatchRules(_, old, new string, _ *schema.ResourceData) bool { } func diffMatchRules(old, new string) bool { - logger := akamai.Log("Cloudlets", "diffMatchRules") + logger := logger.Get("Cloudlets", "diffMatchRules") if old == new { return true } diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go index d94559215..9d9d04eed 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go @@ -12,10 +12,10 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -94,7 +94,7 @@ var ( ) func resourcePolicyActivationDelete(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyActivationDelete") logger.Debug("Deleting cloudlets policy activation") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) @@ -157,7 +157,7 @@ func resourcePolicyActivationDelete(ctx context.Context, rd *schema.ResourceData } func resourcePolicyActivationUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyActivationUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) @@ -269,7 +269,7 @@ func resourcePolicyActivationUpdate(ctx context.Context, rd *schema.ResourceData } func resourcePolicyActivationCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyActivationCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -380,7 +380,7 @@ func resourcePolicyActivationCreate(ctx context.Context, rd *schema.ResourceData } func resourcePolicyActivationRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Cloudlets", "resourcePolicyActivationRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(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 7f591b94a..3c6a4b934 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go index fab960a5c..32ffa5c12 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go @@ -6,8 +6,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cloudlets" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cloudlets" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/jinzhu/copier" @@ -142,7 +142,7 @@ func TestResourcePolicy(t *testing.T) { return &versionUpdate } - expectRemovePolicy = func(_ *testing.T, client *cloudlets.Mock, policyID int64, numVersions int) { + expectRemovePolicy = func(_ *testing.T, client *cloudlets.Mock, policyID int64, numVersions, numDeleteRetries int) { var versionList []cloudlets.PolicyVersion for i := 1; i <= numVersions; i++ { versionList = append(versionList, cloudlets.PolicyVersion{PolicyID: policyID, Version: int64(i)}) @@ -158,8 +158,14 @@ func TestResourcePolicy(t *testing.T) { Version: ver.Version, }).Return(nil).Once() } + + pendingError := &cloudlets.Error{Detail: "Unable to delete policy because an activation for this policy is still pending"} + if numDeleteRetries != 0 { + client.On("RemovePolicy", mock.Anything, cloudlets.RemovePolicyRequest{PolicyID: policyID}).Return(pendingError).Times(numDeleteRetries) + } client.On("RemovePolicy", mock.Anything, cloudlets.RemovePolicyRequest{PolicyID: policyID}).Return(nil).Once() } + expectImportPolicy = func(_ *testing.T, client *cloudlets.Mock, policyID int64, policyName string, numVersions int) { var versionList []cloudlets.PolicyVersion for i := 1; i <= numVersions; i++ { @@ -232,7 +238,7 @@ func TestResourcePolicy(t *testing.T) { policy = expectUpdatePolicy(t, client, policy, "test_policy_updated") version = expectCreatePolicyVersion(t, client, policy.PolicyID, version, matchRules[:1]) expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, policy.PolicyID, 2) + expectRemovePolicy(t, client, policy.PolicyID, 2, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -260,6 +266,59 @@ func TestResourcePolicy(t *testing.T) { client.AssertExpectations(t) }) + t.Run("policy lifecycle and delete retries", func(t *testing.T) { + testDir := "testdata/TestResPolicy/lifecycle" + + client := new(cloudlets.Mock) + matchRules := cloudlets.MatchRules{ + &cloudlets.MatchRuleER{ + Name: "r1", + Type: "erMatchRule", + UseRelativeURL: "copy_scheme_hostname", + StatusCode: 301, + RedirectURL: "/ddd", + MatchURL: "abc.com", + UseIncomingSchemeAndHost: true, + }, + &cloudlets.MatchRuleER{ + Name: "r3", + Type: "erMatchRule", + Matches: []cloudlets.MatchCriteriaER{ + { + MatchType: "hostname", + MatchValue: "3333.dom", + MatchOperator: "equals", + CaseSensitive: true, + }, + }, + UseRelativeURL: "copy_scheme_hostname", + StatusCode: 307, + RedirectURL: "/abc/sss", + UseIncomingSchemeAndHost: true, + }, + } + policy, version := expectCreatePolicy(t, client, 2, "test_policy", matchRules) + expectReadPolicy(t, client, policy, version, 2) + expectRemovePolicy(t, client, policy.PolicyID, 1, 1) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString(fmt.Sprintf("%s/policy_create.tf", testDir)), + Check: checkPolicyAttributes(policyAttributes{ + name: "test_policy", + version: "1", + matchRulesPath: fmt.Sprintf("%s/match_rules/match_rules_create.json", testDir), + }), + }, + }, + }) + }) + client.AssertExpectations(t) + }) + t.Run("policy lifecycle with update existing version", func(t *testing.T) { testDir := "testdata/TestResPolicy/lifecycle" @@ -296,7 +355,7 @@ func TestResourcePolicy(t *testing.T) { policy = expectUpdatePolicy(t, client, policy, "test_policy_updated") version = expectUpdatePolicyVersion(t, client, policy.PolicyID, version, matchRules[:1]) expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -359,7 +418,7 @@ func TestResourcePolicy(t *testing.T) { expectReadPolicy(t, client, policy, version, 3) policy = expectUpdatePolicy(t, client, policy, "test_policy_updated") expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -422,7 +481,7 @@ func TestResourcePolicy(t *testing.T) { expectReadPolicy(t, client, policy, version, 3) version = expectUpdatePolicyVersion(t, client, policy.PolicyID, version, matchRules[:1]) expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -485,7 +544,7 @@ func TestResourcePolicy(t *testing.T) { expectReadPolicy(t, client, policy, version, 3) version = expectUpdatePolicyVersion(t, client, policy.PolicyID, version, matchRules[:1]) expectReadPolicy(t, client, policy, version, 4) - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) warningsJSON, err := warningsToJSON(version.Warnings) require.NoError(t, err) @@ -552,7 +611,7 @@ func TestResourcePolicy(t *testing.T) { expectReadPolicy(t, client, policy, version, 3) version = expectUpdatePolicyVersion(t, client, policy.PolicyID, version, cloudlets.MatchRules{}) expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -586,7 +645,7 @@ func TestResourcePolicy(t *testing.T) { client := new(cloudlets.Mock) policy, version := expectCreatePolicy(t, client, 2, "test_policy", nil) expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProviderFactories: testAccProviders, @@ -681,7 +740,7 @@ func TestResourcePolicy(t *testing.T) { PolicyID: 2, Version: 1, }).Return(nil, fmt.Errorf("UpdatePolicyVersionError")) - expectRemovePolicy(t, client, 2, 0) + expectRemovePolicy(t, client, 2, 0, 0) } testCases := []struct { @@ -731,7 +790,7 @@ func TestResourcePolicy(t *testing.T) { client := new(cloudlets.Mock) policy, _ := expectCreatePolicy(t, client, 2, "test_policy", nil) client.On("GetPolicy", mock.Anything, cloudlets.GetPolicyRequest{PolicyID: policy.PolicyID}).Return(nil, fmt.Errorf("oops")) - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProviderFactories: testAccProviders, @@ -756,7 +815,7 @@ func TestResourcePolicy(t *testing.T) { PolicyID: policy.PolicyID, Version: version.Version, }).Return(nil, fmt.Errorf("oops")) - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProviderFactories: testAccProviders, @@ -811,7 +870,7 @@ func TestResourcePolicy(t *testing.T) { }, PolicyID: policy.PolicyID, }).Return(nil, fmt.Errorf("oops")).Once() - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -878,7 +937,7 @@ func TestResourcePolicy(t *testing.T) { PolicyID: policy.PolicyID, Version: version.Version, }).Return(nil, fmt.Errorf("UpdatePolicyVersionError")).Once() - expectRemovePolicy(t, client, policy.PolicyID, 1) + expectRemovePolicy(t, client, policy.PolicyID, 1, 0) return } @@ -975,7 +1034,7 @@ func TestResourcePolicy(t *testing.T) { policy, version := expectCreatePolicy(t, client, 2, "test_policy", matchRules) expectReadPolicy(t, client, policy, version, 3) expectImportPolicy(t, client, 2, "test_policy", 1) - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -1005,7 +1064,7 @@ func TestResourcePolicy(t *testing.T) { expectReadPolicy(t, client, policy, version, 2) client.On("ListPolicies", mock.Anything, cloudlets.ListPoliciesRequest{PageSize: tools.IntPtr(1000), Offset: 0}). Return([]cloudlets.Policy{}, nil).Once() - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -1033,7 +1092,7 @@ func TestResourcePolicy(t *testing.T) { policy, version := expectCreatePolicy(t, client, 2, "test_policy", nil) expectReadPolicy(t, client, policy, version, 2) expectImportPolicy(t, client, 2, "test_policy", 0) - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -1060,7 +1119,7 @@ func TestResourcePolicy(t *testing.T) { policy, version := expectCreatePolicy(t, client, 2, "test_policy", nil) expectReadPolicy(t, client, policy, version, 2) - expectRemovePolicy(t, client, 2, 1) + expectRemovePolicy(t, client, 2, 1, 0) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ diff --git a/pkg/providers/cps/cps.go b/pkg/providers/cps/cps.go index d023322eb..255f35523 100644 --- a/pkg/providers/cps/cps.go +++ b/pkg/providers/cps/cps.go @@ -1,10 +1,7 @@ -//go:build all || cps -// +build all cps - package cps -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/cps/data_akamai_cps_csr.go b/pkg/providers/cps/data_akamai_cps_csr.go index 470bca1bb..6155398ec 100644 --- a/pkg/providers/cps/data_akamai_cps_csr.go +++ b/pkg/providers/cps/data_akamai_cps_csr.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - toolsCPS "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + toolsCPS "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -40,7 +40,7 @@ func dataSourceCPSCSR() *schema.Resource { } func dataCPSCSRRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "dataCPSCSRRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/cps/data_akamai_cps_csr_test.go b/pkg/providers/cps/data_akamai_cps_csr_test.go index 577141b07..6ef201022 100644 --- a/pkg/providers/cps/data_akamai_cps_csr_test.go +++ b/pkg/providers/cps/data_akamai_cps_csr_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/cps/data_akamai_cps_deployments.go b/pkg/providers/cps/data_akamai_cps_deployments.go index 43bdd685c..35df7ff6b 100644 --- a/pkg/providers/cps/data_akamai_cps_deployments.go +++ b/pkg/providers/cps/data_akamai_cps_deployments.go @@ -4,10 +4,10 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -57,7 +57,7 @@ func dataSourceDeployments() *schema.Resource { } func dataSourceDeploymentsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "dataSourceDeploymentsRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/cps/data_akamai_cps_deployments_test.go b/pkg/providers/cps/data_akamai_cps_deployments_test.go index 3419b230a..ff9055105 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/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" "github.com/hashicorp/terraform-plugin-sdk/v2/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 602c1a607..842b98b81 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollment.go +++ b/pkg/providers/cps/data_akamai_cps_enrollment.go @@ -4,11 +4,11 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - cpstools "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + cpstools "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -303,7 +303,7 @@ func dataSourceCPSEnrollment() *schema.Resource { } func dataCPSEnrollmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "dataCPSEnrollmentRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/cps/data_akamai_cps_enrollment_test.go b/pkg/providers/cps/data_akamai_cps_enrollment_test.go index e629d1066..d1ee24716 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/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/cps/data_akamai_cps_enrollments.go b/pkg/providers/cps/data_akamai_cps_enrollments.go index 871463d34..afe9bacdd 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollments.go +++ b/pkg/providers/cps/data_akamai_cps_enrollments.go @@ -3,11 +3,11 @@ package cps import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - cpstools "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + cpstools "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -266,7 +266,7 @@ func dataSourceCPSEnrollments() *schema.Resource { } func dataCPSEnrollmentsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "dataCPSEnrollmentsRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/cps/data_akamai_cps_enrollments_test.go b/pkg/providers/cps/data_akamai_cps_enrollments_test.go index 52c36aa3d..78075ad1d 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollments_test.go +++ b/pkg/providers/cps/data_akamai_cps_enrollments_test.go @@ -6,8 +6,8 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/cps/data_akamai_cps_warnings.go b/pkg/providers/cps/data_akamai_cps_warnings.go index 438307617..cf86795bd 100644 --- a/pkg/providers/cps/data_akamai_cps_warnings.go +++ b/pkg/providers/cps/data_akamai_cps_warnings.go @@ -3,7 +3,7 @@ package cps import ( "context" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -24,7 +24,7 @@ func dataSourceCPSWarnings() *schema.Resource { } func dataCPSWarningsRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "dataCPSWarningsRead") if err := d.Set("warnings", warningMap); err != nil { diff --git a/pkg/providers/cps/enrollments.go b/pkg/providers/cps/enrollments.go index ae7331e53..11825de43 100644 --- a/pkg/providers/cps/enrollments.go +++ b/pkg/providers/cps/enrollments.go @@ -9,12 +9,12 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - cpstools "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + cpstools "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -350,7 +350,7 @@ func newChallenge(c *cps.Challenge, dv *cps.DV) challenge { } func enrollmentDelete(ctx context.Context, d *schema.ResourceData, m interface{}, functionName string) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", functionName) // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -383,7 +383,7 @@ func readAttrs(enrollment *cps.Enrollment, d *schema.ResourceData) (map[string]i return nil, err } for _, san := range enrollment.CSR.SANS { - if enrollment.ValidationType == "dv" && (sansFromSchema.Len() == 0 || !sansFromSchema.Contains(enrollment.CSR.CN)) && san == enrollment.CSR.CN { + if (sansFromSchema.Len() == 0 || !sansFromSchema.Contains(enrollment.CSR.CN)) && san == enrollment.CSR.CN { continue } sans = append(sans, san) diff --git a/pkg/providers/cps/enrollments_mocks.go b/pkg/providers/cps/enrollments_mocks.go index 5d4529d87..db62cea8f 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/v6/pkg/cps" +import "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/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 ac28a7f44..6c334ba32 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/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/cps/provider.go b/pkg/providers/cps/provider.go index 168be8569..56ed749b1 100644 --- a/pkg/providers/cps/provider.go +++ b/pkg/providers/cps/provider.go @@ -4,35 +4,34 @@ package cps import ( "sync" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers cps resources and data sources + Subprovider struct { client cps.CPS } - // Option is a cps provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -42,65 +41,37 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{}, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_cps_csr": dataSourceCPSCSR(), - "akamai_cps_deployments": dataSourceDeployments(), - "akamai_cps_enrollment": dataSourceCPSEnrollment(), - "akamai_cps_enrollments": dataSourceCPSEnrollments(), - "akamai_cps_warnings": dataSourceCPSWarnings(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_cps_dv_enrollment": resourceCPSDVEnrollment(), - "akamai_cps_dv_validation": resourceCPSDVValidation(), - "akamai_cps_third_party_enrollment": resourceCPSThirdPartyEnrollment(), - "akamai_cps_upload_certificate": resourceCPSUploadCertificate(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c cps.CPS) Option { - return func(p *provider) { +func withClient(c cps.CPS) option { + return func(p *Subprovider) { p.client = c } } // Client returns the CPS interface -func (p *provider) Client(meta akamai.OperationMeta) cps.CPS { +func (p *Subprovider) Client(meta meta.Meta) cps.CPS { if p.client != nil { return p.client } return cps.Client(meta.Session()) } -func (p *provider) Name() string { - return "cps" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for cps +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_cps_dv_enrollment": resourceCPSDVEnrollment(), + "akamai_cps_dv_validation": resourceCPSDVValidation(), + "akamai_cps_third_party_enrollment": resourceCPSThirdPartyEnrollment(), + "akamai_cps_upload_certificate": resourceCPSUploadCertificate(), + } } -func (p *provider) Configure(_ log.Interface, _ *schema.ResourceData) diag.Diagnostics { - return nil +// DataSources returns terraform data sources for cps +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_cps_csr": dataSourceCPSCSR(), + "akamai_cps_deployments": dataSourceDeployments(), + "akamai_cps_enrollment": dataSourceCPSEnrollment(), + "akamai_cps_enrollments": dataSourceCPSEnrollments(), + "akamai_cps_warnings": dataSourceCPSWarnings(), + } } diff --git a/pkg/providers/cps/provider_test.go b/pkg/providers/cps/provider_test.go index 97c595858..a2aa662f8 100644 --- a/pkg/providers/cps/provider_test.go +++ b/pkg/providers/cps/provider_test.go @@ -8,39 +8,34 @@ import ( "sync" "testing" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var testAccProviders map[string]func() (*schema.Provider, error) - var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go b/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go index 07eb1b244..9b3ce16a5 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go @@ -8,11 +8,12 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - cpstools "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + cpstools "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "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" @@ -91,12 +92,6 @@ func resourceCPSDVEnrollment() *schema.Resource { Elem: csr, Description: "Certificate signing request generated during enrollment creation", }, - "enable_multi_stacked_certificates": { - Type: schema.TypeBool, - Optional: true, - Deprecated: "Deprecated, don't use; always false", - Description: "Enable Dual-Stacked certificate deployment for enrollment", - }, "network_configuration": { Type: schema.TypeSet, Required: true, @@ -204,10 +199,12 @@ func resourceCPSDVEnrollment() *schema.Resource { if !diff.HasChange("sans") { return nil } - domainsToValidate := []interface{}{map[string]interface{}{"domain": diff.Get("common_name").(string)}} + domainsToValidate := []interface{}{map[string]interface{}{ + "domain": strings.ToLower(diff.Get("common_name").(string)), + }} if sans, ok := diff.Get("sans").(*schema.Set); ok { for _, san := range sans.List() { - domain := map[string]interface{}{"domain": san.(string)} + domain := map[string]interface{}{"domain": strings.ToLower(san.(string))} domainsToValidate = append(domainsToValidate, domain) } } @@ -223,7 +220,7 @@ func resourceCPSDVEnrollment() *schema.Resource { } func resourceCPSDVEnrollmentCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSDVEnrollmentCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -307,6 +304,11 @@ func resourceCPSDVEnrollmentCreate(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } + // save ClientMutualAuthentication and unset it in enrollment request struct + // create request must not have it set; in case its not nil, we will run update later to add it + clientMutualAuthentication := enrollment.NetworkConfiguration.ClientMutualAuthentication + enrollment.NetworkConfiguration.ClientMutualAuthentication = nil + req := cps.CreateEnrollmentRequest{ Enrollment: enrollment, ContractID: strings.TrimPrefix(contractID, "ctr_"), @@ -322,17 +324,29 @@ func resourceCPSDVEnrollmentCreate(ctx context.Context, d *schema.ResourceData, if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - if err = waitForVerification(ctx, logger, client, res.ID, acknowledgeWarnings, nil); err != nil { - return diag.FromErr(err) + + // when clientMutualAuthentication was provided, insert it back to enrollment and send the update request + if clientMutualAuthentication != nil { + logger.Debug("Updating ClientMutualAuthentication configuration") + enrollment.NetworkConfiguration.ClientMutualAuthentication = clientMutualAuthentication + req := cps.UpdateEnrollmentRequest{ + EnrollmentID: res.ID, + Enrollment: enrollment, + AllowCancelPendingChanges: tools.BoolPtr(true), + } + _, err := client.UpdateEnrollment(ctx, req) + if err != nil { + return diag.FromErr(err) + } } - if err != nil { + if err = waitForVerification(ctx, logger, client, res.ID, acknowledgeWarnings, nil); err != nil { return diag.FromErr(err) } return resourceCPSDVEnrollmentRead(ctx, d, m) } func resourceCPSDVEnrollmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSDVEnrollmentRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -437,7 +451,7 @@ func resourceCPSDVEnrollmentRead(ctx context.Context, d *schema.ResourceData, m } func resourceCPSDVEnrollmentUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSDVEnrollmentUpdate") ctx = session.ContextWithOptions( ctx, @@ -559,7 +573,7 @@ func resourceCPSDVEnrollmentDelete(ctx context.Context, d *schema.ResourceData, } func resourceCPSDVEnrollmentImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSDVEnrollmentImport") // create a context with logging for api calls ctx = session.ContextWithOptions( 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 baf518766..494017a7c 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,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/jinzhu/copier" @@ -493,6 +494,213 @@ func TestResourceDVEnrollment(t *testing.T) { client.AssertExpectations(t) }) + t.Run("create enrollment, MTLS", func(t *testing.T) { + PollForChangeStatusInterval = 1 * time.Millisecond + client := &cps.Mock{} + enrollment := cps.Enrollment{ + AdminContact: &cps.Contact{ + AddressLineOne: "150 Broadway", + City: "Cambridge", + Country: "US", + Email: "r1d1@akamai.com", + FirstName: "R1", + LastName: "D1", + OrganizationName: "Akamai", + Phone: "123123123", + PostalCode: "12345", + Region: "MA", + }, + CertificateChainType: "default", + CertificateType: "san", + CSR: &cps.CSR{ + C: "US", + CN: "test.akamai.com", + L: "Cambridge", + O: "Akamai", + OU: "WebEx", + ST: "MA", + }, + EnableMultiStackedCertificates: false, + NetworkConfiguration: &cps.NetworkConfiguration{ + DisallowedTLSVersions: []string{"TLSv1", "TLSv1_1"}, + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + MustHaveCiphers: "ak-akamai-default", + OCSPStapling: "on", + PreferredCiphers: "ak-akamai-default", + QuicEnabled: false, + SecureNetwork: "enhanced-tls", + SNIOnly: true, + }, + Org: &cps.Org{ + AddressLineOne: "150 Broadway", + City: "Cambridge", + Country: "US", + Name: "Akamai", + Phone: "321321321", + PostalCode: "12345", + Region: "MA", + }, + RA: "lets-encrypt", + SignatureAlgorithm: "SHA-256", + TechContact: &cps.Contact{ + AddressLineOne: "150 Broadway", + City: "Cambridge", + Country: "US", + Email: "r2d2@akamai.com", + FirstName: "R2", + LastName: "D2", + OrganizationName: "Akamai", + Phone: "123123123", + PostalCode: "12345", + Region: "MA", + }, + ValidationType: "dv", + } + + client.On("CreateEnrollment", + mock.Anything, + cps.CreateEnrollmentRequest{ + Enrollment: enrollment, + ContractID: "1", + }, + ).Return(&cps.CreateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/2"}, + }, nil).Once() + + var enrollmentUpdate cps.Enrollment + require.NoError(t, copier.CopyWithOption(&enrollmentUpdate, enrollment, copier.Option{DeepCopy: true, IgnoreEmpty: true})) + enrollmentUpdate.NetworkConfiguration.ClientMutualAuthentication = &cps.ClientMutualAuthentication{ + AuthenticationOptions: &cps.AuthenticationOptions{ + OCSP: &cps.OCSP{ + Enabled: tools.BoolPtr(true), + }, + SendCAListToClient: tools.BoolPtr(false), + }, + SetID: "12345", + } + client.On("UpdateEnrollment", + mock.Anything, + cps.UpdateEnrollmentRequest{ + EnrollmentID: 1, + Enrollment: enrollmentUpdate, + AllowCancelPendingChanges: tools.BoolPtr(true), + }, + ).Return(&cps.UpdateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/3"}, + }, nil).Once() + + enrollmentUpdate.Location = "/cps/v2/enrollments/1" + enrollmentUpdate.PendingChanges = []cps.PendingChange{ + { + Location: "/cps/v2/enrollments/1/changes/3", + ChangeType: "new-certificate", + }, + } + var enrollmentGet cps.Enrollment + require.NoError(t, copier.CopyWithOption(&enrollmentGet, enrollmentUpdate, copier.Option{DeepCopy: true})) + enrollmentGet.CSR.SANS = []string{enrollmentUpdate.CSR.CN} + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Once() + + // first verification loop, invalid status + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: "pre-verification-safety-checks", + }, + }, nil).Once() + + // second verification loop, valid status, empty allowed input array + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: statusCoordinateDomainValidation, + }, + }, nil).Once() + + // final verification loop, everything in place + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{{Type: "lets-encrypt-challenges"}}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: statusCoordinateDomainValidation, + }, + }, nil).Once() + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Times(2) + + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{{Type: "lets-encrypt-challenges"}}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: statusCoordinateDomainValidation, + }, + }, nil).Times(2) + + client.On("GetChangeLetsEncryptChallenges", mock.Anything, cps.GetChangeRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.DVArray{DV: []cps.DV{ + { + Challenges: []cps.Challenge{ + {FullPath: "_acme-challenge.test.akamai.com", ResponseBody: "abc123", Type: "http-01", Status: "pending"}, + {FullPath: "_acme-challenge.test.akamai.com", ResponseBody: "abc123", Type: "dns-01", Status: "pending"}, + }, + Domain: "test.akamai.com", + ValidationStatus: "IN_PROGRESS", + }, + }}, nil).Times(2) + + allowCancel := true + + client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ + EnrollmentID: 1, + AllowCancelPendingChanges: &allowCancel, + }).Return(&cps.RemoveEnrollmentResponse{ + Enrollment: "1", + }, nil).Once() + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResDVEnrollment/client_mutual_auth/create_enrollment.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("akamai_cps_dv_enrollment.dv", "contract_id", "ctr_1"), + resource.TestCheckResourceAttr("akamai_cps_dv_enrollment.dv", "network_configuration.0.client_mutual_authentication.0.set_id", "12345"), + resource.TestCheckResourceAttr("akamai_cps_dv_enrollment.dv", "network_configuration.0.client_mutual_authentication.0.ocsp_enabled", "true"), + resource.TestCheckResourceAttr("akamai_cps_dv_enrollment.dv", "network_configuration.0.client_mutual_authentication.0.send_ca_list_to_client", "false"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) t.Run("lifecycle test with common name not empty, present in sans", func(t *testing.T) { PollForChangeStatusInterval = 1 * time.Millisecond diff --git a/pkg/providers/cps/resource_akamai_cps_dv_validation.go b/pkg/providers/cps/resource_akamai_cps_dv_validation.go index e9a7771eb..edc8d44a2 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_validation.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_validation.go @@ -8,11 +8,11 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - cpstools "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + cpstools "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -52,7 +52,7 @@ func resourceCPSDVValidation() *schema.Resource { } func resourceCPSDVValidationCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSDVValidationCreate") ctx = session.ContextWithOptions( ctx, @@ -141,7 +141,7 @@ func resourceCPSDVValidationCreate(ctx context.Context, d *schema.ResourceData, } func resourceCPSDVValidationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSDVValidationRead") ctx = session.ContextWithOptions( ctx, 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 e28dae121..2a495636a 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" "github.com/hashicorp/terraform-plugin-sdk/v2/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 9424d5c12..489b28a28 100644 --- a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go +++ b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go @@ -7,11 +7,12 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - cpstools "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + cpstools "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "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" @@ -169,7 +170,7 @@ func supressSignatureAlgorithm(_ string, oldValue, newValue string, d *schema.Re } func resourceCPSThirdPartyEnrollmentCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSThirdPartyEnrollmentCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -193,6 +194,11 @@ func resourceCPSThirdPartyEnrollmentCreate(ctx context.Context, d *schema.Resour return diag.FromErr(err) } + // save ClientMutualAuthentication and unset it in enrollment request struct + // create request must not have it set; in case its not nil, we will run update later to add it + clientMutualAuthentication := enrollment.NetworkConfiguration.ClientMutualAuthentication + enrollment.NetworkConfiguration.ClientMutualAuthentication = nil + req := cps.CreateEnrollmentRequest{ Enrollment: *enrollment, ContractID: strings.TrimPrefix(contractID, "ctr_"), @@ -204,6 +210,21 @@ func resourceCPSThirdPartyEnrollmentCreate(ctx context.Context, d *schema.Resour } d.SetId(strconv.Itoa(res.ID)) + // when clientMutualAuthentication was provided, insert it back to enrollment and send the update request + if clientMutualAuthentication != nil { + logger.Debug("Updating ClientMutualAuthentication configuration") + enrollment.NetworkConfiguration.ClientMutualAuthentication = clientMutualAuthentication + req := cps.UpdateEnrollmentRequest{ + EnrollmentID: res.ID, + Enrollment: *enrollment, + AllowCancelPendingChanges: tools.BoolPtr(true), + } + _, err := client.UpdateEnrollment(ctx, req) + if err != nil { + return diag.FromErr(err) + } + } + acknowledgeWarnings, err := tf.GetBoolValue("acknowledge_pre_verification_warnings", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) @@ -221,7 +242,7 @@ func resourceCPSThirdPartyEnrollmentCreate(ctx context.Context, d *schema.Resour } func resourceCPSThirdPartyEnrollmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSThirdPartyEnrollmentRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -260,7 +281,7 @@ func resourceCPSThirdPartyEnrollmentRead(ctx context.Context, d *schema.Resource } func resourceCPSThirdPartyEnrollmentUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSThirdPartyEnrollmentUpdate") ctx = session.ContextWithOptions( ctx, @@ -399,7 +420,7 @@ func resourceCPSThirdPartyEnrollmentDelete(ctx context.Context, d *schema.Resour } func resourceCPSThirdPartyEnrollmentImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSThirdPartyEnrollmentImport") // create a context with logging for api calls ctx = session.ContextWithOptions( 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 c9f777aef..b974dd692 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,20 +6,20 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/jinzhu/copier" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" ) func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("lifecycle test", func(t *testing.T) { PollForChangeStatusInterval = 1 * time.Millisecond client := &cps.Mock{} - enrollment := getSimpleEnrollment() + enrollment := newEnrollment() client.On("CreateEnrollment", mock.Anything, @@ -82,16 +82,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). Return(&enrollment, nil).Times(3) - var enrollmentUpdate cps.Enrollment - err := copier.CopyWithOption(&enrollmentUpdate, enrollment, copier.Option{DeepCopy: true}) - require.NoError(t, err) - enrollmentUpdate.AdminContact.FirstName = "R5" - enrollmentUpdate.AdminContact.LastName = "D5" - enrollmentUpdate.CSR.SANS = []string{"san2.test.akamai.com", "san.test.akamai.com"} - enrollmentUpdate.NetworkConfiguration.DNSNameSettings.DNSNames = []string{"san2.test.akamai.com", "san.test.akamai.com"} - enrollmentUpdate.Location = "" - enrollmentUpdate.PendingChanges = nil - enrollmentUpdate.SignatureAlgorithm = "SHA-1" + enrollmentUpdate := newEnrollment( + WithBase(&enrollment), + WithUpdateFunc(func(e *cps.Enrollment) { + e.AdminContact.FirstName = "R5" + e.AdminContact.LastName = "D5" + e.CSR.SANS = []string{"san2.test.akamai.com", "san.test.akamai.com"} + e.NetworkConfiguration.DNSNameSettings.DNSNames = []string{"san2.test.akamai.com", "san.test.akamai.com"} + e.Location = "" + e.PendingChanges = nil + e.SignatureAlgorithm = "SHA-1" + }), + ) + allowCancel := true client.On("UpdateEnrollment", mock.Anything, @@ -106,15 +109,12 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollmentUpdate.Location = "/cps/v2/enrollments/1" - enrollmentUpdate.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment( + WithBase(&enrollmentUpdate), + WithPendingChangeID(2), + ) client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollmentUpdate, nil).Times(3) + Return(&enrollmentGet, nil).Times(3) client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -156,76 +156,141 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { client.AssertExpectations(t) }) + t.Run("lifecycle test update sans add cn", func(t *testing.T) { + PollForChangeStatusInterval = 1 * time.Millisecond + client := &cps.Mock{} + commonName := "test.akamai.com" + enrollment := newEnrollment( + WithCN(commonName), + WithEmptySans, + ) + + client.On("CreateEnrollment", + mock.Anything, + cps.CreateEnrollmentRequest{ + Enrollment: enrollment, + ContractID: "1", + }, + ).Return(&cps.CreateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/2"}, + }, nil).Once() + + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Once() + + // first verification loop, invalid status + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: "pre-verification-safety-checks", + }, + }, nil).Once() + + // second verification loop, valid status, empty allowed input array + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: statusCoordinateDomainValidation, + }, + }, nil).Once() + + // final verification loop, everything in place + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{{Type: "third-party-certificate"}}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: waitUploadThirdParty, + }, + }, nil).Once() + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Times(3) + + enrollmentUpdate := newEnrollment( + WithBase(&enrollment), + WithSans(commonName), + ) + + allowCancel := true + client.On("UpdateEnrollment", + mock.Anything, + cps.UpdateEnrollmentRequest{ + Enrollment: enrollmentUpdate, + EnrollmentID: 1, + AllowCancelPendingChanges: &allowCancel, + }, + ).Return(&cps.UpdateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/2"}, + }, nil).Once() + + enrollmentGetUpdate := newEnrollment(WithBase(&enrollmentUpdate), WithPendingChangeID(2)) + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGetUpdate, nil).Times(3) + + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{{Type: "third-party-certificate"}}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: waitUploadThirdParty, + }, + }, nil).Once() + + client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ + EnrollmentID: 1, + AllowCancelPendingChanges: &allowCancel, + }).Return(&cps.RemoveEnrollmentResponse{ + Enrollment: "1", + }, nil).Once() + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/create_enrollment.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("akamai_cps_third_party_enrollment.third_party", "contract_id", "ctr_1"), + ), + }, + { + Config: loadFixtureString("testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/update_enrollment.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("akamai_cps_third_party_enrollment.third_party", "contract_id", "ctr_1"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) t.Run("create enrollment, empty sans", func(t *testing.T) { PollForChangeStatusInterval = 1 * time.Millisecond client := &cps.Mock{} - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - ChangeManagement: false, - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DisallowedTLSVersions: []string{"TLSv1", "TLSv1_1"}, - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - MustHaveCiphers: "ak-akamai-default", - OCSPStapling: "on", - PreferredCiphers: "ak-akamai-default", - QuicEnabled: false, - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + + enrollment := newEnrollment(WithEmptySans) client.On("CreateEnrollment", mock.Anything, @@ -239,15 +304,8 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } - var enrollmentGet cps.Enrollment - require.NoError(t, copier.CopyWithOption(&enrollmentGet, enrollment, copier.Option{DeepCopy: true})) + enrollmentGet := newEnrollment(WithEmptySans, WithPendingChangeID(2)) + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). Return(&enrollmentGet, nil).Once() @@ -315,79 +373,129 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { client.AssertExpectations(t) }) + t.Run("create enrollment, MTLS", func(t *testing.T) { + PollForChangeStatusInterval = 1 * time.Millisecond + client := &cps.Mock{} + enrollment := newEnrollment(WithEmptySans) + + client.On("CreateEnrollment", + mock.Anything, + cps.CreateEnrollmentRequest{ + Enrollment: enrollment, + ContractID: "1", + }, + ).Return(&cps.CreateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/2"}, + }, nil).Once() + + enrollmentUpdate := newEnrollment( + WithBase(&enrollment), + withMTLS(cps.ClientMutualAuthentication{ + AuthenticationOptions: &cps.AuthenticationOptions{ + OCSP: &cps.OCSP{ + Enabled: tools.BoolPtr(true), + }, + SendCAListToClient: tools.BoolPtr(false), + }, + SetID: "12345", + }), + ) + + client.On("UpdateEnrollment", + mock.Anything, + cps.UpdateEnrollmentRequest{ + EnrollmentID: 1, + Enrollment: enrollmentUpdate, + AllowCancelPendingChanges: tools.BoolPtr(true), + }, + ).Return(&cps.UpdateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/3"}, + }, nil).Once() + + enrollmentGet := newEnrollment( + WithBase(&enrollmentUpdate), + WithPendingChangeID(3), + ) + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Once() + + // first verification loop, invalid status + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: "pre-verification-safety-checks", + }, + }, nil).Once() + + // second verification loop, valid status, empty allowed input array + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: statusCoordinateDomainValidation, + }, + }, nil).Once() + + // final verification loop, everything in place + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 3, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{{Type: "third-party-certificate"}}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: waitUploadThirdParty, + }, + }, nil).Once() + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Times(2) + + allowCancel := true + + client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ + EnrollmentID: 1, + AllowCancelPendingChanges: &allowCancel, + }).Return(&cps.RemoveEnrollmentResponse{ + Enrollment: "1", + }, nil).Once() + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResThirdPartyEnrollment/client_mutual_auth/create_enrollment.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("akamai_cps_third_party_enrollment.third_party", "contract_id", "ctr_1"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) t.Run("lifecycle test with common name not empty, present in sans", func(t *testing.T) { PollForChangeStatusInterval = 1 * time.Millisecond client := &cps.Mock{} commonName := "test.akamai.com" - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - ChangeManagement: false, - CSR: &cps.CSR{ - C: "US", - CN: commonName, - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - SANS: []string{commonName, "san.test.akamai.com"}, - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DisallowedTLSVersions: []string{"TLSv1", "TLSv1_1"}, - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - DNSNames: []string{commonName, "san.test.akamai.com"}, - }, - Geography: "core", - MustHaveCiphers: "ak-akamai-default", - OCSPStapling: "on", - PreferredCiphers: "ak-akamai-default", - QuicEnabled: false, - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithCN(commonName), + WithSans(commonName, "san.test.akamai.com"), + ) client.On("CreateEnrollment", mock.Anything, @@ -401,15 +509,10 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() // first verification loop, invalid status client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ @@ -448,7 +551,7 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { }, nil).Once() client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Times(4) + Return(&enrollmentGet, nil).Times(4) allowCancel := true client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ @@ -480,6 +583,105 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { client.AssertExpectations(t) }) + t.Run("lifecycle test with common name not empty, not present in sans", func(t *testing.T) { + PollForChangeStatusInterval = 1 * time.Millisecond + client := &cps.Mock{} + commonName := "test.akamai.com" + enrollment := newEnrollment( + WithCN(commonName), + WithSans("san.test.akamai.com"), + ) + + client.On("CreateEnrollment", + mock.Anything, + cps.CreateEnrollmentRequest{ + Enrollment: enrollment, + ContractID: "1", + }, + ).Return(&cps.CreateEnrollmentResponse{ + ID: 1, + Enrollment: "/cps/v2/enrollments/1", + Changes: []string{"/cps/v2/enrollments/1/changes/2"}, + }, nil).Once() + + enrollmentGet := newEnrollment( + WithBase(&enrollment), + WithPendingChangeID(2), + WithSans(commonName, "san.test.akamai.com"), + ) + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Once() + + // first verification loop, invalid status + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: "pre-verification-safety-checks", + }, + }, nil).Once() + + // second verification loop, valid status, empty allowed input array + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: statusCoordinateDomainValidation, + }, + }, nil).Once() + + // final verification loop, everything in place + client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ + EnrollmentID: 1, + ChangeID: 2, + }).Return(&cps.Change{ + AllowedInput: []cps.AllowedInput{{Type: "third-party-certificate"}}, + StatusInfo: &cps.StatusInfo{ + State: "awaiting-input", + Status: waitUploadThirdParty, + }, + }, nil).Once() + + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). + Return(&enrollmentGet, nil).Times(4) + + allowCancel := true + client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ + EnrollmentID: 1, + AllowCancelPendingChanges: &allowCancel, + }).Return(&cps.RemoveEnrollmentResponse{ + Enrollment: "1", + }, nil).Once() + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResThirdPartyEnrollment/lifecycle_no_cn_in_sans/create_enrollment.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("akamai_cps_third_party_enrollment.third_party", "contract_id", "ctr_1"), + ), + }, + { + Config: loadFixtureString("testdata/TestResThirdPartyEnrollment/lifecycle_no_cn_in_sans/create_enrollment.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("akamai_cps_third_party_enrollment.third_party", "contract_id", "ctr_1"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) t.Run("set challenges arrays to empty if no allowedInput found", func(t *testing.T) { client := &cps.Mock{} @@ -497,15 +699,10 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -519,7 +716,7 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { }, nil).Once() client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Times(2) + Return(&enrollmentGet, nil).Times(2) allowCancel := true client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ @@ -548,66 +745,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("update with acknowledge warnings change, no enrollment update", func(t *testing.T) { client := &cps.Mock{} - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -693,66 +843,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("acknowledge warnings", func(t *testing.T) { client := &cps.Mock{} PollForChangeStatusInterval = 1 * time.Millisecond - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -766,15 +869,9 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -820,7 +917,7 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { }, nil).Once() client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Twice() + Return(&enrollmentGet, nil).Twice() allowCancel := true client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ @@ -849,72 +946,7 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("create enrollment, allow duplicate common name", func(t *testing.T) { PollForChangeStatusInterval = 1 * time.Millisecond client := &cps.Mock{} - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - ChangeManagement: false, - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DisallowedTLSVersions: []string{"TLSv1", "TLSv1_1"}, - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - MustHaveCiphers: "ak-akamai-default", - OCSPStapling: "on", - PreferredCiphers: "ak-akamai-default", - QuicEnabled: false, - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment(WithEmptySans) client.On("CreateEnrollment", mock.Anything, @@ -929,15 +961,8 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } - var enrollmentGet cps.Enrollment - require.NoError(t, copier.CopyWithOption(&enrollmentGet, enrollment, copier.Option{DeepCopy: true})) + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) + client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). Return(&enrollmentGet, nil).Once() @@ -1010,66 +1035,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("verification failed with warnings, no acknowledgement", func(t *testing.T) { client := &cps.Mock{} PollForChangeStatusInterval = 1 * time.Millisecond - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -1083,15 +1061,9 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -1135,66 +1107,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("create enrollment returns an error", func(t *testing.T) { client := &cps.Mock{} PollForChangeStatusInterval = 1 * time.Millisecond - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -1222,66 +1147,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("auto approve warnings - all warnings on the list to auto approve", func(t *testing.T) { client := &cps.Mock{} PollForChangeStatusInterval = 1 * time.Millisecond - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -1295,15 +1173,9 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -1349,7 +1221,7 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { }, nil).Once() client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Twice() + Return(&enrollmentGet, nil).Twice() allowCancel := true client.On("RemoveEnrollment", mock.Anything, cps.RemoveEnrollmentRequest{ @@ -1379,66 +1251,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("auto approve warnings - some warnings not on the list to auto approve", func(t *testing.T) { client := &cps.Mock{} PollForChangeStatusInterval = 1 * time.Millisecond - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -1452,15 +1277,9 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -1504,66 +1323,19 @@ func TestResourceThirdPartyEnrollment(t *testing.T) { t.Run("auto approve warnings - some warnings are unknown", func(t *testing.T) { client := &cps.Mock{} PollForChangeStatusInterval = 1 * time.Millisecond - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) client.On("CreateEnrollment", mock.Anything, @@ -1631,67 +1403,20 @@ func TestResourceThirdPartyEnrollmentImport(t *testing.T) { t.Run("import", func(t *testing.T) { client := &cps.Mock{} id := "1,ctr_1" + enrollment := newEnrollment( + WithEmptySans, + WithUpdateFunc(func(e *cps.Enrollment) { + e.NetworkConfiguration = &cps.NetworkConfiguration{ + DNSNameSettings: &cps.DNSNameSettings{ + CloneDNSNames: false, + }, + Geography: "core", + SecureNetwork: "enhanced-tls", + SNIOnly: true, + } + }), + ) - enrollment := cps.Enrollment{ - AdminContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r1d1@akamai.com", - FirstName: "R1", - LastName: "D1", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - CertificateChainType: "default", - CertificateType: "third-party", - CSR: &cps.CSR{ - C: "US", - CN: "test.akamai.com", - L: "Cambridge", - O: "Akamai", - OU: "WebEx", - ST: "MA", - }, - EnableMultiStackedCertificates: true, - NetworkConfiguration: &cps.NetworkConfiguration{ - DNSNameSettings: &cps.DNSNameSettings{ - CloneDNSNames: false, - }, - Geography: "core", - SecureNetwork: "enhanced-tls", - SNIOnly: true, - }, - Org: &cps.Org{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Name: "Akamai", - Phone: "321321321", - PostalCode: "12345", - Region: "MA", - }, - RA: "third-party", - SignatureAlgorithm: "SHA-256", - TechContact: &cps.Contact{ - AddressLineOne: "150 Broadway", - City: "Cambridge", - Country: "US", - Email: "r2d2@akamai.com", - FirstName: "R2", - LastName: "D2", - OrganizationName: "Akamai", - Phone: "123123123", - PostalCode: "12345", - Region: "MA", - }, - ValidationType: "third-party", - ThirdParty: &cps.ThirdParty{ - ExcludeSANS: false, - }, - } client.On("CreateEnrollment", mock.Anything, cps.CreateEnrollmentRequest{ @@ -1704,15 +1429,9 @@ func TestResourceThirdPartyEnrollmentImport(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Once() + Return(&enrollmentGet, nil).Once() client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -1726,7 +1445,7 @@ func TestResourceThirdPartyEnrollmentImport(t *testing.T) { }, nil).Once() client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). - Return(&enrollment, nil).Times(4) + Return(&enrollmentGet, nil).Times(4) client.On("GetChangeStatus", mock.Anything, cps.GetChangeStatusRequest{ EnrollmentID: 1, @@ -1746,6 +1465,7 @@ func TestResourceThirdPartyEnrollmentImport(t *testing.T) { }).Return(&cps.RemoveEnrollmentResponse{ Enrollment: "1", }, nil).Once() + useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProviderFactories: testAccProviders, @@ -1818,17 +1538,7 @@ func TestSuppressingSignatureAlgorithm(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollment.Location = "/cps/v2/enrollments/1" - enrollment.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } - - var enrollmentGet cps.Enrollment - err := copier.CopyWithOption(&enrollmentGet, enrollment, copier.Option{DeepCopy: true}) - require.NoError(t, err) + enrollmentGet := newEnrollment(WithBase(&enrollment), WithPendingChangeID(2)) enrollmentGet.SignatureAlgorithm = "" client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). @@ -1848,16 +1558,17 @@ func TestSuppressingSignatureAlgorithm(t *testing.T) { client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). Return(&enrollmentGet, nil).Times(3) - var enrollmentUpdate cps.Enrollment - err = copier.CopyWithOption(&enrollmentUpdate, enrollment, copier.Option{DeepCopy: true}) - require.NoError(t, err) - enrollmentUpdate.AdminContact.FirstName = "R5" - enrollmentUpdate.AdminContact.LastName = "D5" - enrollmentUpdate.CSR.SANS = []string{"san2.test.akamai.com", "san.test.akamai.com"} - enrollmentUpdate.NetworkConfiguration.DNSNameSettings.DNSNames = []string{"san2.test.akamai.com", "san.test.akamai.com"} - enrollmentUpdate.Location = "" - enrollmentUpdate.PendingChanges = nil - enrollmentUpdate.SignatureAlgorithm = "" + enrollmentUpdate := newEnrollment(WithBase(&enrollment), + WithUpdateFunc(func(e *cps.Enrollment) { + e.AdminContact.FirstName = "R5" + e.AdminContact.LastName = "D5" + e.CSR.SANS = []string{"san2.test.akamai.com", "san.test.akamai.com"} + e.NetworkConfiguration.DNSNameSettings.DNSNames = []string{"san2.test.akamai.com", "san.test.akamai.com"} + e.Location = "" + e.PendingChanges = nil + e.SignatureAlgorithm = "" + }), + ) allowCancel := true client.On("UpdateEnrollment", mock.Anything, @@ -1872,17 +1583,7 @@ func TestSuppressingSignatureAlgorithm(t *testing.T) { Changes: []string{"/cps/v2/enrollments/1/changes/2"}, }, nil).Once() - enrollmentUpdate.Location = "/cps/v2/enrollments/1" - enrollmentUpdate.PendingChanges = []cps.PendingChange{ - { - Location: "/cps/v2/enrollments/1/changes/2", - ChangeType: "new-certificate", - }, - } - - var enrollmentUpdateGet cps.Enrollment - err = copier.CopyWithOption(&enrollmentUpdateGet, enrollmentUpdate, copier.Option{DeepCopy: true}) - require.NoError(t, err) + enrollmentUpdateGet := newEnrollment(WithBase(&enrollmentUpdate), WithPendingChangeID(2)) enrollmentUpdateGet.SignatureAlgorithm = "" client.On("GetEnrollment", mock.Anything, cps.GetEnrollmentRequest{EnrollmentID: 1}). @@ -2000,3 +1701,86 @@ func getSimpleEnrollment() cps.Enrollment { }, } } + +type enrolOpt interface { + apply(*cps.Enrollment) +} + +type withPendingChangeID int + +func (w withPendingChangeID) apply(e *cps.Enrollment) { + e.Location = "/cps/v2/enrollments/1" + e.PendingChanges = []cps.PendingChange{ + { + Location: fmt.Sprintf("/cps/v2/enrollments/1/changes/%d", w), + ChangeType: "new-certificate", + }, + } +} +func WithPendingChangeID(id int) enrolOpt { + return withPendingChangeID(id) +} + +type withCN string + +func (w withCN) apply(e *cps.Enrollment) { + e.CSR.CN = string(w) +} +func WithCN(cn string) enrolOpt { + return withCN(cn) +} + +type withFunc func(*cps.Enrollment) + +func (w withFunc) apply(e *cps.Enrollment) { + w(e) +} +func WithUpdateFunc(f func(*cps.Enrollment)) enrolOpt { + return withFunc(f) +} + +type withMTLS cps.ClientMutualAuthentication + +func (w withMTLS) apply(e *cps.Enrollment) { + e.NetworkConfiguration.ClientMutualAuthentication = (*cps.ClientMutualAuthentication)(&w) +} +func WithMTLS(mtls cps.ClientMutualAuthentication) enrolOpt { + return withMTLS(mtls) +} + +type withBase cps.Enrollment + +func (w withBase) apply(e *cps.Enrollment) { + *e = (cps.Enrollment)(w) +} +func WithBase(e *cps.Enrollment) enrolOpt { + var newEn cps.Enrollment + err := copier.CopyWithOption(&newEn, e, copier.Option{DeepCopy: true, IgnoreEmpty: true}) + if err != nil { + panic(fmt.Sprintln("copier.CopyWithOption failed: ", err)) + } + return withBase(newEn) +} + +type withSans []string + +func (w withSans) apply(e *cps.Enrollment) { + e.CSR.SANS = w + e.NetworkConfiguration.DNSNameSettings.DNSNames = w +} +func WithSans(sans ...string) enrolOpt { + if len(sans) == 0 { + return withSans(nil) + } + return withSans(sans) +} + +var WithEmptySans = WithSans() + +func newEnrollment(opts ...enrolOpt) cps.Enrollment { + enrollment := getSimpleEnrollment() + for _, o := range opts { + o.apply(&enrollment) + } + return enrollment +} diff --git a/pkg/providers/cps/resource_akamai_cps_upload_certificate.go b/pkg/providers/cps/resource_akamai_cps_upload_certificate.go index 2980c1ed9..01887c156 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate.go @@ -8,11 +8,11 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - toolsCPS "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + toolsCPS "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps/tools" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -107,7 +107,7 @@ type attributes struct { } func resourceCPSUploadCertificateCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSUploadCertificateCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -117,7 +117,7 @@ func resourceCPSUploadCertificateCreate(ctx context.Context, d *schema.ResourceD } func resourceCPSUploadCertificateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSUploadCertificateRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -182,7 +182,7 @@ func resourceCPSUploadCertificateRead(ctx context.Context, d *schema.ResourceDat } func resourceCPSUploadCertificateUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSUploadCertificateUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -268,7 +268,7 @@ func resourceCPSUploadCertificateUpdate(ctx context.Context, d *schema.ResourceD } func resourceCPSUploadCertificateDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSUploadCertificateDelete") logger.Debug("Deleting CPS upload certificate configuration") logger.Info("CPS upload certificate deletion - resource will only be removed from local state") @@ -336,8 +336,8 @@ func upsertUploadCertificate(ctx context.Context, d *schema.ResourceData, m inte } // checkUnacknowledgedWarnings checks if there are unacknowledged warnings for a certificate -func checkUnacknowledgedWarnings(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error { - meta := akamai.Meta(i) +func checkUnacknowledgedWarnings(ctx context.Context, diff *schema.ResourceDiff, m interface{}) error { + meta := meta.Must(m) logger := meta.Log("CPS", "checkUnacknowledgedWarnings") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -649,7 +649,7 @@ func getCPSUploadCertificateAttrs(d *schema.ResourceData) (*attributes, error) { } func resourceCPSUploadCertificateImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("CPS", "resourceCPSUploadCertificateImport") ctx = session.ContextWithOptions( ctx, 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 8991930af..9b0a390b1 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go @@ -6,8 +6,8 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/cps/testdata/TestResDVEnrollment/allow_duplicate_cn/create_enrollment.tf b/pkg/providers/cps/testdata/TestResDVEnrollment/allow_duplicate_cn/create_enrollment.tf index 33c55e9e5..03cdab2ba 100644 --- a/pkg/providers/cps/testdata/TestResDVEnrollment/allow_duplicate_cn/create_enrollment.tf +++ b/pkg/providers/cps/testdata/TestResDVEnrollment/allow_duplicate_cn/create_enrollment.tf @@ -40,7 +40,6 @@ resource "akamai_cps_dv_enrollment" "dv" { organizational_unit = "WebEx" state = "MA" } - enable_multi_stacked_certificates = false network_configuration { disallowed_tls_versions = [ "TLSv1", diff --git a/pkg/providers/cps/testdata/TestResDVEnrollment/client_mutual_auth/create_enrollment.tf b/pkg/providers/cps/testdata/TestResDVEnrollment/client_mutual_auth/create_enrollment.tf new file mode 100644 index 000000000..bd0969e33 --- /dev/null +++ b/pkg/providers/cps/testdata/TestResDVEnrollment/client_mutual_auth/create_enrollment.tf @@ -0,0 +1,76 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +resource "akamai_cps_dv_enrollment" "dv" { + contract_id = "ctr_1" + common_name = "test.akamai.com" + secure_network = "enhanced-tls" + sni_only = true + admin_contact { + first_name = "R1" + last_name = "D1" + phone = "123123123" + email = "r1d1@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + tech_contact { + first_name = "R2" + last_name = "D2" + phone = "123123123" + email = "r2d2@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + certificate_chain_type = "default" + csr { + country_code = "US" + city = "Cambridge" + organization = "Akamai" + organizational_unit = "WebEx" + state = "MA" + } + network_configuration { + disallowed_tls_versions = [ + "TLSv1", + "TLSv1_1"] + clone_dns_names = false + geography = "core" + ocsp_stapling = "on" + preferred_ciphers = "ak-akamai-default" + must_have_ciphers = "ak-akamai-default" + quic_enabled = false + client_mutual_authentication { + ocsp_enabled = true + send_ca_list_to_client = false + set_id = "12345" + } + } + signature_algorithm = "SHA-256" + organization { + name = "Akamai" + phone = "321321321" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + postal_code = "12345" + region = "MA" + } +} + +locals { + domains_to_validate = [for dvo in akamai_cps_dv_enrollment.dv.dns_challenges : dvo.full_path] +} + +output "domains_to_validate" { + value = join(",", local.domains_to_validate) +} diff --git a/pkg/providers/cps/testdata/TestResDVEnrollment/empty_sans/create_enrollment.tf b/pkg/providers/cps/testdata/TestResDVEnrollment/empty_sans/create_enrollment.tf index d5d2d81df..30428f70f 100644 --- a/pkg/providers/cps/testdata/TestResDVEnrollment/empty_sans/create_enrollment.tf +++ b/pkg/providers/cps/testdata/TestResDVEnrollment/empty_sans/create_enrollment.tf @@ -39,7 +39,6 @@ resource "akamai_cps_dv_enrollment" "dv" { organizational_unit = "WebEx" state = "MA" } - enable_multi_stacked_certificates = false network_configuration { disallowed_tls_versions = [ "TLSv1", diff --git a/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/create_enrollment.tf b/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/create_enrollment.tf index 1236c65c0..071063423 100644 --- a/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/create_enrollment.tf +++ b/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/create_enrollment.tf @@ -43,7 +43,6 @@ resource "akamai_cps_dv_enrollment" "dv" { preferred_trust_chain = "intermediate-a" state = "MA" } - enable_multi_stacked_certificates = false network_configuration { disallowed_tls_versions = [ "TLSv1", diff --git a/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/update_enrollment.tf b/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/update_enrollment.tf index 25cf8d669..ef3df0cd9 100644 --- a/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/update_enrollment.tf +++ b/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle/update_enrollment.tf @@ -44,7 +44,6 @@ resource "akamai_cps_dv_enrollment" "dv" { preferred_trust_chain = "dst-root-ca-x3" state = "MA" } - enable_multi_stacked_certificates = false network_configuration { disallowed_tls_versions = [ "TLSv1", diff --git a/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle_cn_in_sans/create_enrollment.tf b/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle_cn_in_sans/create_enrollment.tf index 22a91435d..7abe37629 100644 --- a/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle_cn_in_sans/create_enrollment.tf +++ b/pkg/providers/cps/testdata/TestResDVEnrollment/lifecycle_cn_in_sans/create_enrollment.tf @@ -42,7 +42,6 @@ resource "akamai_cps_dv_enrollment" "dv" { organizational_unit = "WebEx" state = "MA" } - enable_multi_stacked_certificates = false network_configuration { disallowed_tls_versions = [ "TLSv1", diff --git a/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/client_mutual_auth/create_enrollment.tf b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/client_mutual_auth/create_enrollment.tf new file mode 100644 index 000000000..b59e2b28c --- /dev/null +++ b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/client_mutual_auth/create_enrollment.tf @@ -0,0 +1,69 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +resource "akamai_cps_third_party_enrollment" "third_party" { + contract_id = "ctr_1" + common_name = "test.akamai.com" + secure_network = "enhanced-tls" + sni_only = true + admin_contact { + first_name = "R1" + last_name = "D1" + phone = "123123123" + email = "r1d1@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + tech_contact { + first_name = "R2" + last_name = "D2" + phone = "123123123" + email = "r2d2@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + certificate_chain_type = "default" + csr { + country_code = "US" + city = "Cambridge" + organization = "Akamai" + organizational_unit = "WebEx" + state = "MA" + } + network_configuration { + disallowed_tls_versions = [ + "TLSv1", + "TLSv1_1" + ] + clone_dns_names = false + geography = "core" + ocsp_stapling = "on" + preferred_ciphers = "ak-akamai-default" + must_have_ciphers = "ak-akamai-default" + quic_enabled = false + client_mutual_authentication { + ocsp_enabled = true + send_ca_list_to_client = false + set_id = "12345" + } + } + signature_algorithm = "SHA-256" + organization { + name = "Akamai" + phone = "321321321" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + postal_code = "12345" + region = "MA" + } +} diff --git a/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_cn_in_sans/create_enrollment.tf b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_cn_in_sans/create_enrollment.tf new file mode 100644 index 000000000..c45d3a62c --- /dev/null +++ b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_cn_in_sans/create_enrollment.tf @@ -0,0 +1,67 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +resource "akamai_cps_third_party_enrollment" "third_party" { + contract_id = "ctr_1" + common_name = "test.akamai.com" + sans = [ + "san.test.akamai.com", + ] + secure_network = "enhanced-tls" + sni_only = true + admin_contact { + first_name = "R1" + last_name = "D1" + phone = "123123123" + email = "r1d1@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + tech_contact { + first_name = "R2" + last_name = "D2" + phone = "123123123" + email = "r2d2@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + certificate_chain_type = "default" + csr { + country_code = "US" + city = "Cambridge" + organization = "Akamai" + organizational_unit = "WebEx" + state = "MA" + } + network_configuration { + disallowed_tls_versions = [ + "TLSv1", + "TLSv1_1" + ] + clone_dns_names = false + geography = "core" + ocsp_stapling = "on" + preferred_ciphers = "ak-akamai-default" + must_have_ciphers = "ak-akamai-default" + quic_enabled = false + } + signature_algorithm = "SHA-256" + organization { + name = "Akamai" + phone = "321321321" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + postal_code = "12345" + region = "MA" + } +} diff --git a/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/create_enrollment.tf b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/create_enrollment.tf new file mode 100644 index 000000000..effa03fac --- /dev/null +++ b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/create_enrollment.tf @@ -0,0 +1,65 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +resource "akamai_cps_third_party_enrollment" "third_party" { + contract_id = "ctr_1" + common_name = "test.akamai.com" + sans = [] + secure_network = "enhanced-tls" + sni_only = true + admin_contact { + first_name = "R1" + last_name = "D1" + phone = "123123123" + email = "r1d1@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + tech_contact { + first_name = "R2" + last_name = "D2" + phone = "123123123" + email = "r2d2@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + certificate_chain_type = "default" + csr { + country_code = "US" + city = "Cambridge" + organization = "Akamai" + organizational_unit = "WebEx" + state = "MA" + } + network_configuration { + disallowed_tls_versions = [ + "TLSv1", + "TLSv1_1" + ] + clone_dns_names = false + geography = "core" + ocsp_stapling = "on" + preferred_ciphers = "ak-akamai-default" + must_have_ciphers = "ak-akamai-default" + quic_enabled = false + } + signature_algorithm = "SHA-256" + organization { + name = "Akamai" + phone = "321321321" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + postal_code = "12345" + region = "MA" + } +} diff --git a/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/update_enrollment.tf b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/update_enrollment.tf new file mode 100644 index 000000000..ca0b31005 --- /dev/null +++ b/pkg/providers/cps/testdata/TestResThirdPartyEnrollment/lifecycle_no_sans/update_enrollment.tf @@ -0,0 +1,67 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +resource "akamai_cps_third_party_enrollment" "third_party" { + contract_id = "ctr_1" + common_name = "test.akamai.com" + sans = [ + "test.akamai.com" + ] + secure_network = "enhanced-tls" + sni_only = true + admin_contact { + first_name = "R1" + last_name = "D1" + phone = "123123123" + email = "r1d1@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + tech_contact { + first_name = "R2" + last_name = "D2" + phone = "123123123" + email = "r2d2@akamai.com" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + organization = "Akamai" + postal_code = "12345" + region = "MA" + } + certificate_chain_type = "default" + csr { + country_code = "US" + city = "Cambridge" + organization = "Akamai" + organizational_unit = "WebEx" + state = "MA" + } + network_configuration { + disallowed_tls_versions = [ + "TLSv1", + "TLSv1_1" + ] + clone_dns_names = false + geography = "core" + ocsp_stapling = "on" + preferred_ciphers = "ak-akamai-default" + must_have_ciphers = "ak-akamai-default" + quic_enabled = false + } + signature_algorithm = "SHA-256" + organization { + name = "Akamai" + phone = "321321321" + address_line_one = "150 Broadway" + city = "Cambridge" + country_code = "US" + postal_code = "12345" + region = "MA" + } +} diff --git a/pkg/providers/cps/tools/enrollment.go b/pkg/providers/cps/tools/enrollment.go index e6f93a619..9e9e6f152 100644 --- a/pkg/providers/cps/tools/enrollment.go +++ b/pkg/providers/cps/tools/enrollment.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/cps" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/cps" + "github.com/akamai/terraform-provider-akamai/v5/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 c39814389..9988c0bda 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/v6/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/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 99459825c..57cb0d13c 100644 --- a/pkg/providers/datastream/connectors.go +++ b/pkg/providers/datastream/connectors.go @@ -4,39 +4,39 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var ( // connectorTypeToResourceName maps ConnectorType to TF resource key - connectorTypeToResourceName = map[datastream.ConnectorType]string{ - datastream.ConnectorTypeAzure: "azure_connector", - datastream.ConnectorTypeDataDog: "datadog_connector", - datastream.ConnectorTypeElasticsearch: "elasticsearch_connector", - datastream.ConnectorTypeGcs: "gcs_connector", - datastream.ConnectorTypeHTTPS: "https_connector", - datastream.ConnectorTypeLoggly: "loggly_connector", - datastream.ConnectorTypeNewRelic: "new_relic_connector", - datastream.ConnectorTypeOracle: "oracle_connector", - datastream.ConnectorTypeS3: "s3_connector", - datastream.ConnectorTypeSplunk: "splunk_connector", - datastream.ConnectorTypeSumoLogic: "sumologic_connector", - } - - connectorMappers = map[datastream.ConnectorType]func(datastream.ConnectorDetails, map[string]interface{}) map[string]interface{}{ - datastream.ConnectorTypeAzure: MapAzureConnector, - datastream.ConnectorTypeDataDog: MapDatadogConnector, - datastream.ConnectorTypeElasticsearch: MapElasticsearchConnector, - datastream.ConnectorTypeGcs: MapGCSConnector, - datastream.ConnectorTypeHTTPS: MapHTTPSConnector, - datastream.ConnectorTypeLoggly: MapLogglyConnector, - datastream.ConnectorTypeNewRelic: MapNewRelicConnector, - datastream.ConnectorTypeOracle: MapOracleConnector, - datastream.ConnectorTypeS3: MapS3Connector, - datastream.ConnectorTypeSplunk: MapSplunkConnector, - datastream.ConnectorTypeSumoLogic: MapSumoLogicConnector, + connectorTypeToResourceName = map[datastream.DestinationType]string{ + datastream.DestinationTypeAzure: "azure_connector", + datastream.DestinationTypeDataDog: "datadog_connector", + datastream.DestinationTypeElasticsearch: "elasticsearch_connector", + datastream.DestinationTypeGcs: "gcs_connector", + datastream.DestinationTypeHTTPS: "https_connector", + datastream.DestinationTypeLoggly: "loggly_connector", + datastream.DestinationTypeNewRelic: "new_relic_connector", + datastream.DestinationTypeOracle: "oracle_connector", + datastream.DestinationTypeS3: "s3_connector", + datastream.DestinationTypeSplunk: "splunk_connector", + datastream.DestinationTypeSumoLogic: "sumologic_connector", + } + + connectorMappers = map[datastream.DestinationType]func(datastream.Destination, map[string]interface{}) map[string]interface{}{ + datastream.DestinationTypeAzure: MapAzureConnector, + datastream.DestinationTypeDataDog: MapDatadogConnector, + datastream.DestinationTypeElasticsearch: MapElasticsearchConnector, + datastream.DestinationTypeGcs: MapGCSConnector, + datastream.DestinationTypeHTTPS: MapHTTPSConnector, + datastream.DestinationTypeLoggly: MapLogglyConnector, + datastream.DestinationTypeNewRelic: MapNewRelicConnector, + datastream.DestinationTypeOracle: MapOracleConnector, + datastream.DestinationTypeS3: MapS3Connector, + datastream.DestinationTypeSplunk: MapSplunkConnector, + datastream.DestinationTypeSumoLogic: MapSumoLogicConnector, } connectorGetters = map[string]func(map[string]interface{}) datastream.AbstractConnector{ @@ -55,14 +55,10 @@ var ( ) // ConnectorToMap converts ConnectorDetails struct to map of properties -func ConnectorToMap(connectors []datastream.ConnectorDetails, d *schema.ResourceData) (string, map[string]interface{}, error) { - // api returned empty list of connectors - if len(connectors) != 1 { - return "", nil, nil - } +func ConnectorToMap(connector datastream.Destination, d *schema.ResourceData) (string, map[string]interface{}, error) { - connectorDetails := connectors[0] - connectorType := connectorDetails.ConnectorType + connectorDetails := connector + connectorType := connectorDetails.DestinationType resourceKey, ok := connectorTypeToResourceName[connectorType] if !ok { return "", nil, fmt.Errorf("cannot find resource name for connector type: %s", connectorType) @@ -91,7 +87,7 @@ func ConnectorToMap(connectors []datastream.ConnectorDetails, d *schema.Resource } // GetConnectors builds Connectors list -func GetConnectors(d *schema.ResourceData, keys []string) ([]datastream.AbstractConnector, error) { +func GetConnectors(d *schema.ResourceData, keys []string) (datastream.AbstractConnector, error) { // check which connector is present in .tf file connectorName, connectorResource, err := tf.GetExactlyOneOf(d, keys) if err != nil { @@ -114,7 +110,7 @@ func GetConnectors(d *schema.ResourceData, keys []string) ([]datastream.Abstract } connector := connectorResourceGetter(connectorProperties) - return []datastream.AbstractConnector{connector}, nil + return connector, nil } // GetS3Connector builds S3Connector structure @@ -122,7 +118,7 @@ func GetS3Connector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.S3Connector{ AccessKey: props["access_key"].(string), Bucket: props["bucket"].(string), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), Path: props["path"].(string), Region: props["region"].(string), SecretAccessKey: props["secret_access_key"].(string), @@ -130,13 +126,12 @@ func GetS3Connector(props map[string]interface{}) datastream.AbstractConnector { } // MapS3Connector selects fields needed for S3Connector -func MapS3Connector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapS3Connector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "access_key": "", "bucket": c.Bucket, "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "path": c.Path, "region": c.Region, "secret_access_key": "", @@ -150,20 +145,19 @@ func GetAzureConnector(props map[string]interface{}) datastream.AbstractConnecto return &datastream.AzureConnector{ AccessKey: props["access_key"].(string), AccountName: props["account_name"].(string), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), ContainerName: props["container_name"].(string), Path: props["path"].(string), } } // MapAzureConnector selects fields needed for AzureConnector -func MapAzureConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapAzureConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "access_key": "", "account_name": c.AccountName, "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "container_name": c.ContainerName, "path": c.Path, } @@ -174,27 +168,26 @@ func MapAzureConnector(c datastream.ConnectorDetails, state map[string]interface // GetDatadogConnector builds DatadogConnector structure func GetDatadogConnector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.DatadogConnector{ - AuthToken: props["auth_token"].(string), - CompressLogs: props["compress_logs"].(bool), - ConnectorName: props["connector_name"].(string), - Service: props["service"].(string), - Source: props["source"].(string), - Tags: props["tags"].(string), - URL: props["url"].(string), + AuthToken: props["auth_token"].(string), + CompressLogs: props["compress_logs"].(bool), + DisplayName: props["display_name"].(string), + Service: props["service"].(string), + Source: props["source"].(string), + Tags: props["tags"].(string), + Endpoint: props["endpoint"].(string), } } // MapDatadogConnector selects fields needed for DatadogConnector -func MapDatadogConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapDatadogConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ - "auth_token": "", - "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, - "service": c.Service, - "source": c.Source, - "tags": c.Tags, - "url": c.URL, + "auth_token": "", + "compress_logs": c.CompressLogs, + "display_name": c.DisplayName, + "service": c.Service, + "source": c.Source, + "tags": c.Tags, + "endpoint": c.Endpoint, } setNonNilItemsFromState(state, rv, "auth_token") return rv @@ -204,11 +197,11 @@ func MapDatadogConnector(c datastream.ConnectorDetails, state map[string]interfa func GetSplunkConnector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.SplunkConnector{ CompressLogs: props["compress_logs"].(bool), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), CustomHeaderName: props["custom_header_name"].(string), CustomHeaderValue: props["custom_header_value"].(string), EventCollectorToken: props["event_collector_token"].(string), - URL: props["url"].(string), + Endpoint: props["endpoint"].(string), TLSHostname: props["tls_hostname"].(string), CACert: props["ca_cert"].(string), ClientCert: props["client_cert"].(string), @@ -217,15 +210,14 @@ func GetSplunkConnector(props map[string]interface{}) datastream.AbstractConnect } // MapSplunkConnector selects fields needed for SplunkConnector -func MapSplunkConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapSplunkConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "custom_header_name": c.CustomHeaderName, "custom_header_value": c.CustomHeaderValue, "event_collector_token": "", - "url": c.URL, + "endpoint": c.Endpoint, "tls_hostname": c.TLSHostname, "ca_cert": "", "client_cert": "", @@ -243,7 +235,7 @@ func MapSplunkConnector(c datastream.ConnectorDetails, state map[string]interfac func GetGCSConnector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.GCSConnector{ Bucket: props["bucket"].(string), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), Path: props["path"].(string), PrivateKey: props["private_key"].(string), ProjectID: props["project_id"].(string), @@ -252,12 +244,11 @@ func GetGCSConnector(props map[string]interface{}) datastream.AbstractConnector } // MapGCSConnector selects fields needed for GCSConnector -func MapGCSConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapGCSConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "bucket": c.Bucket, "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "path": c.Path, "private_key": "", "project_id": c.ProjectID, @@ -272,12 +263,12 @@ func GetHTTPSConnector(props map[string]interface{}) datastream.AbstractConnecto return &datastream.CustomHTTPSConnector{ AuthenticationType: datastream.AuthenticationType(props["authentication_type"].(string)), CompressLogs: props["compress_logs"].(bool), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), ContentType: props["content_type"].(string), CustomHeaderName: props["custom_header_name"].(string), CustomHeaderValue: props["custom_header_value"].(string), Password: props["password"].(string), - URL: props["url"].(string), + Endpoint: props["endpoint"].(string), UserName: props["user_name"].(string), TLSHostname: props["tls_hostname"].(string), CACert: props["ca_cert"].(string), @@ -287,17 +278,16 @@ func GetHTTPSConnector(props map[string]interface{}) datastream.AbstractConnecto } // MapHTTPSConnector selects fields needed for CustomHTTPSConnector -func MapHTTPSConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapHTTPSConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "authentication_type": c.AuthenticationType, "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "content_type": c.ContentType, "custom_header_name": c.CustomHeaderName, "custom_header_value": c.CustomHeaderValue, "password": "", - "url": c.URL, + "endpoint": c.Endpoint, "user_name": "", "tls_hostname": c.TLSHostname, "ca_cert": "", @@ -317,7 +307,7 @@ func GetSumoLogicConnector(props map[string]interface{}) datastream.AbstractConn return &datastream.SumoLogicConnector{ CollectorCode: props["collector_code"].(string), CompressLogs: props["compress_logs"].(bool), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), ContentType: props["content_type"].(string), CustomHeaderName: props["custom_header_name"].(string), CustomHeaderValue: props["custom_header_value"].(string), @@ -326,12 +316,11 @@ func GetSumoLogicConnector(props map[string]interface{}) datastream.AbstractConn } // MapSumoLogicConnector selects fields needed for SumoLogicConnector -func MapSumoLogicConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapSumoLogicConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "collector_code": "", "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "content_type": c.ContentType, "custom_header_name": c.CustomHeaderName, "custom_header_value": c.CustomHeaderValue, @@ -346,7 +335,7 @@ func GetOracleConnector(props map[string]interface{}) datastream.AbstractConnect return &datastream.OracleCloudStorageConnector{ AccessKey: props["access_key"].(string), Bucket: props["bucket"].(string), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), Namespace: props["namespace"].(string), Path: props["path"].(string), Region: props["region"].(string), @@ -355,13 +344,12 @@ func GetOracleConnector(props map[string]interface{}) datastream.AbstractConnect } // MapOracleConnector selects fields needed for OracleCloudStorageConnector -func MapOracleConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapOracleConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "access_key": "", "bucket": c.Bucket, "compress_logs": c.CompressLogs, - "connector_id": c.ConnectorID, - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "namespace": c.Namespace, "path": c.Path, "region": c.Region, @@ -375,7 +363,7 @@ func MapOracleConnector(c datastream.ConnectorDetails, state map[string]interfac func GetLogglyConnector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.LogglyConnector{ AuthToken: props["auth_token"].(string), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), Endpoint: props["endpoint"].(string), Tags: props["tags"].(string), ContentType: props["content_type"].(string), @@ -385,10 +373,10 @@ func GetLogglyConnector(props map[string]interface{}) datastream.AbstractConnect } // MapLogglyConnector selects fields needed for LogglyConnector -func MapLogglyConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapLogglyConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "auth_token": "", - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "endpoint": c.Endpoint, "tags": c.Tags, "content_type": c.ContentType, @@ -403,7 +391,7 @@ func MapLogglyConnector(c datastream.ConnectorDetails, state map[string]interfac func GetNewRelicConnector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.NewRelicConnector{ AuthToken: props["auth_token"].(string), - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), Endpoint: props["endpoint"].(string), ContentType: props["content_type"].(string), CustomHeaderName: props["custom_header_name"].(string), @@ -412,10 +400,10 @@ func GetNewRelicConnector(props map[string]interface{}) datastream.AbstractConne } // MapNewRelicConnector selects fields needed for NewRelicConnector -func MapNewRelicConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapNewRelicConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ "auth_token": "", - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "endpoint": c.Endpoint, "content_type": c.ContentType, "custom_header_name": c.CustomHeaderName, @@ -428,7 +416,7 @@ func MapNewRelicConnector(c datastream.ConnectorDetails, state map[string]interf // GetElasticsearchConnector builds ElasticsearchConnector structure func GetElasticsearchConnector(props map[string]interface{}) datastream.AbstractConnector { return &datastream.ElasticsearchConnector{ - ConnectorName: props["connector_name"].(string), + DisplayName: props["display_name"].(string), Endpoint: props["endpoint"].(string), IndexName: props["index_name"].(string), UserName: props["user_name"].(string), @@ -444,9 +432,9 @@ func GetElasticsearchConnector(props map[string]interface{}) datastream.Abstract } // MapElasticsearchConnector selects fields needed for ElasticsearchConnector -func MapElasticsearchConnector(c datastream.ConnectorDetails, state map[string]interface{}) map[string]interface{} { +func MapElasticsearchConnector(c datastream.Destination, state map[string]interface{}) map[string]interface{} { rv := map[string]interface{}{ - "connector_name": c.ConnectorName, + "display_name": c.DisplayName, "endpoint": c.Endpoint, "index_name": c.IndexName, "user_name": "", @@ -474,3 +462,10 @@ func setNonNilItemsFromState(state map[string]interface{}, target map[string]int } } } + +// GetConnectorNameWithOutFilePrefixSuffix Returns destination name which does not contain the file prefix and suffix +func GetConnectorNameWithOutFilePrefixSuffix(d *schema.ResourceData, keys []string) string { + + connectorName, _, _ := tf.GetExactlyOneOf(d, keys) + return connectorName +} diff --git a/pkg/providers/datastream/connectors_test.go b/pkg/providers/datastream/connectors_test.go index a92280bef..8cb80d489 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/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" ) @@ -16,7 +16,7 @@ var resourceSchema = map[string]*schema.Schema{ Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, }, @@ -33,27 +33,12 @@ func TestConnectorToMap(t *testing.T) { } tests := map[string]struct { - connectorDetails []datastream.ConnectorDetails + connectorDetails datastream.Destination resourceMap map[string]interface{} expectedResult }{ "empty connector details": { - connectorDetails: []datastream.ConnectorDetails{}, - expectedResult: expectedResult{ - key: "", - props: nil, - error: "", - }, - }, - "more than one connector": { - connectorDetails: []datastream.ConnectorDetails{ - { - ConnectorType: datastream.ConnectorTypeS3, - }, - { - ConnectorType: datastream.ConnectorTypeGcs, - }, - }, + connectorDetails: datastream.Destination{}, expectedResult: expectedResult{ key: "", props: nil, @@ -61,10 +46,9 @@ func TestConnectorToMap(t *testing.T) { }, }, "no resource name for invalid connector type": { - connectorDetails: []datastream.ConnectorDetails{ - { - ConnectorType: datastream.ConnectorType("invalid_connector"), - }, + connectorDetails: datastream.Destination{ + + DestinationType: datastream.DestinationType("invalid_connector"), }, resourceMap: nil, expectedResult: expectedResult{ @@ -72,17 +56,14 @@ func TestConnectorToMap(t *testing.T) { }, }, "no connector in local resource": { - connectorDetails: []datastream.ConnectorDetails{ - { - ConnectorID: 1337, - CompressLogs: true, - ConnectorName: "sumologic connector", - ConnectorType: datastream.ConnectorTypeSumoLogic, - Endpoint: "sumologic endpoint", - ContentType: "application/json", - CustomHeaderName: "custom_header_name", - CustomHeaderValue: "custom_header_value", - }, + connectorDetails: datastream.Destination{ + CompressLogs: true, + DisplayName: "sumologic connector", + DestinationType: datastream.DestinationTypeSumoLogic, + Endpoint: "sumologic endpoint", + ContentType: "application/json", + CustomHeaderName: "custom_header_name", + CustomHeaderValue: "custom_header_value", }, resourceMap: nil, expectedResult: expectedResult{ @@ -90,8 +71,7 @@ func TestConnectorToMap(t *testing.T) { props: map[string]interface{}{ "collector_code": "", "compress_logs": true, - "connector_id": 1337, - "connector_name": "sumologic connector", + "display_name": "sumologic connector", "endpoint": "sumologic endpoint", "content_type": "application/json", "custom_header_name": "custom_header_name", @@ -100,24 +80,21 @@ func TestConnectorToMap(t *testing.T) { }, }, "proper configuration": { - connectorDetails: []datastream.ConnectorDetails{ - { - ConnectorID: 1337, - CompressLogs: true, - ConnectorName: "sumologic connector", - ConnectorType: datastream.ConnectorTypeSumoLogic, - Endpoint: "sumologic endpoint", - ContentType: "application/json", - CustomHeaderName: "custom_header_name", - CustomHeaderValue: "custom_header_value", - }, + connectorDetails: datastream.Destination{ + CompressLogs: true, + DisplayName: "sumologic connector", + DestinationType: datastream.DestinationTypeSumoLogic, + Endpoint: "sumologic endpoint", + ContentType: "application/json", + CustomHeaderName: "custom_header_name", + CustomHeaderValue: "custom_header_value", }, resourceMap: map[string]interface{}{ "sumologic_connector": []interface{}{ map[string]interface{}{ "collector_code": "sumologic_collector_code", "compress_logs": true, - "connector_name": "sumologic connector", + "display_name": "sumologic connector", "endpoint": "sumologic endpoint", "content_type": "application/json", "custom_header_name": "custom_header_name", @@ -130,8 +107,7 @@ func TestConnectorToMap(t *testing.T) { props: map[string]interface{}{ "collector_code": "sumologic_collector_code", "compress_logs": true, - "connector_id": 1337, - "connector_name": "sumologic connector", + "display_name": "sumologic connector", "endpoint": "sumologic endpoint", "content_type": "application/json", "custom_header_name": "custom_header_name", @@ -161,7 +137,7 @@ func TestConnectorToMap(t *testing.T) { func TestGetConnectors(t *testing.T) { tests := map[string]struct { resourceMap map[string]interface{} - expectedResult []datastream.AbstractConnector + expectedResult datastream.AbstractConnector errorMessage string }{ "missing connector definition": { @@ -174,7 +150,7 @@ func TestGetConnectors(t *testing.T) { map[string]interface{}{ "collector_code": "sumologic_collector_code", "compress_logs": true, - "connector_name": "sumologic connector", + "display_name": "sumologic connector", "endpoint": "sumologic endpoint", "content_type": "application/json", "custom_header_name": "custom_header_name", @@ -182,16 +158,14 @@ func TestGetConnectors(t *testing.T) { }, }, }, - expectedResult: []datastream.AbstractConnector{ - &datastream.SumoLogicConnector{ - CollectorCode: "sumologic_collector_code", - CompressLogs: true, - ConnectorName: "sumologic connector", - Endpoint: "sumologic endpoint", - ContentType: "application/json", - CustomHeaderName: "custom_header_name", - CustomHeaderValue: "custom_header_value", - }, + expectedResult: &datastream.SumoLogicConnector{ + CollectorCode: "sumologic_collector_code", + CompressLogs: true, + DisplayName: "sumologic connector", + Endpoint: "sumologic endpoint", + ContentType: "application/json", + CustomHeaderName: "custom_header_name", + CustomHeaderValue: "custom_header_value", }, }, } diff --git a/pkg/providers/datastream/data_akamai_datastream_activation_history.go b/pkg/providers/datastream/data_akamai_datastream_activation_history.go index 306537594..07000cf94 100644 --- a/pkg/providers/datastream/data_akamai_datastream_activation_history.go +++ b/pkg/providers/datastream/data_akamai_datastream_activation_history.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" ) func dataAkamaiDatastreamActivationHistory() *schema.Resource { @@ -22,35 +22,36 @@ func dataAkamaiDatastreamActivationHistory() *schema.Resource { Description: "Identifies the stream", }, "activations": { - Type: schema.TypeSet, + Type: schema.TypeList, Computed: true, - Description: "Provides detailed information about an activation status change for a version of a stream", + Description: "Provides detailed information about an activation history for a version of a stream", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "created_by": { + + "stream_id": { + Type: schema.TypeInt, + Required: true, + Description: "Identifies the stream", + }, + "modified_by": { Type: schema.TypeString, Computed: true, Description: "The username who activated or deactivated the stream", }, - "created_date": { + "modified_date": { Type: schema.TypeString, Computed: true, Description: "The date and time when activation status was modified", }, - "stream_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the stream", - }, - "stream_version_id": { + "stream_version": { Type: schema.TypeInt, Computed: true, Description: "Identifies the version of the stream", }, - "is_active": { - Type: schema.TypeBool, + "status": { + Type: schema.TypeString, Computed: true, - Description: "Whether the version of the stream is active", + Description: "Stream Status", }, }, }, @@ -59,22 +60,21 @@ func dataAkamaiDatastreamActivationHistory() *schema.Resource { } } -func populateSchemaFieldsWithActivationHistory(ac []datastream.ActivationHistoryEntry, d *schema.ResourceData, streamID int) error { +func populateSchemaFieldsWithActivationHistory(ac []datastream.ActivationHistoryEntry, d *schema.ResourceData) error { var activations []map[string]interface{} for _, a := range ac { v := map[string]interface{}{ - "stream_id": a.StreamID, - "stream_version_id": a.StreamVersionID, - "created_by": a.CreatedBy, - "created_date": a.CreatedDate, - "is_active": a.IsActive, + "stream_id": a.StreamID, + "stream_version": a.StreamVersion, + "modified_by": a.ModifiedBy, + "modified_date": a.ModifiedDate, + "status": a.Status, } activations = append(activations, v) } fields := map[string]interface{}{ - "stream_id": streamID, "activations": activations, } @@ -87,7 +87,7 @@ func populateSchemaFieldsWithActivationHistory(ac []datastream.ActivationHistory } func dataAkamaiDatastreamActivationHistoryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) log := meta.Log("DataStream", "dataAkamaiDatastreamActivationHistoryRead") client := inst.Client(meta) @@ -104,7 +104,7 @@ func dataAkamaiDatastreamActivationHistoryRead(ctx context.Context, d *schema.Re return diag.FromErr(err) } - err = populateSchemaFieldsWithActivationHistory(activationHistory, d, streamID) + err = populateSchemaFieldsWithActivationHistory(activationHistory, d) if err != nil { return diag.FromErr(err) } 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 1202526c9..7683d227b 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/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/stretchr/testify/mock" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -24,36 +24,32 @@ func TestDataAkamaiDatastreamActivationHistoryRead(t *testing.T) { configPath: "testdata/TestDataAkamaiDatastreamActivationHistoryRead/activation_history.tf", getActivationHistoryReturn: []datastream.ActivationHistoryEntry{ { - CreatedBy: "user1", - CreatedDate: "16-01-2020 11:07:12 GMT", - IsActive: false, - StreamID: 7050, - StreamVersionID: 2, + ModifiedBy: "user1", + ModifiedDate: "16-01-2020 11:07:12 GMT", + Status: datastream.StreamStatusDeactivated, + StreamID: 7050, + StreamVersion: 2, }, { - CreatedBy: "user2", - CreatedDate: "16-01-2020 09:31:02 GMT", - IsActive: true, - StreamID: 7050, - StreamVersionID: 2, + ModifiedBy: "user2", + ModifiedDate: "16-01-2020 09:31:02 GMT", + Status: datastream.StreamStatusActivated, + StreamID: 7050, + StreamVersion: 2, }, }, checkFuncs: []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "stream_id", "7050"), - - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.#", "2"), - - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.created_by", "user1"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.created_date", "16-01-2020 11:07:12 GMT"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.modified_by", "user1"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.modified_date", "16-01-2020 11:07:12 GMT"), resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.stream_id", "7050"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.stream_version_id", "2"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.is_active", "false"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.stream_version", "2"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.0.status", "DEACTIVATED"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.created_by", "user2"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.created_date", "16-01-2020 09:31:02 GMT"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.modified_by", "user2"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.modified_date", "16-01-2020 09:31:02 GMT"), resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.stream_id", "7050"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.stream_version_id", "2"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.is_active", "true"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.stream_version", "2"), + resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.1.status", "ACTIVATED"), }, }, "validate empty response": { @@ -61,7 +57,6 @@ func TestDataAkamaiDatastreamActivationHistoryRead(t *testing.T) { getActivationHistoryReturn: []datastream.ActivationHistoryEntry{}, checkFuncs: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "stream_id", "7051"), - resource.TestCheckResourceAttr("data.akamai_datastream_activation_history.test", "activations.#", "0"), }, }, "edgegrid error": { diff --git a/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go b/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go index 36641f5af..e403d5a7f 100644 --- a/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go +++ b/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go @@ -5,11 +5,11 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -18,66 +18,53 @@ func dataSourceDatasetFields() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceDatasetFieldsRead, Schema: map[string]*schema.Schema{ - "fields": { - Type: schema.TypeSet, + "product_id": { + Type: schema.TypeString, + Optional: true, + Description: "Identifies the stream", + }, + "dataset_fields": { + Type: schema.TypeList, Computed: true, Description: "Provides information about groups of dataset fields available in a given template", + Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dataset_group_name": { + + "dataset_field_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Identifies the field", + }, + "dataset_field_description": { + Type: schema.TypeString, + Computed: true, + Description: "Describes the data set field", + }, + "dataset_field_json_key": { Type: schema.TypeString, Computed: true, - Description: "A name of the dataset group", + Description: "Specifies the JSON key for the field in a log line", }, - "dataset_group_description": { + "dataset_field_name": { Type: schema.TypeString, Computed: true, - Description: "Describes the dataset group", + Description: "A name of the data set field", }, - "dataset_fields": { - Type: schema.TypeList, + "dataset_field_group": { + Type: schema.TypeString, Computed: true, - Description: "A list of data set fields available within the data set group", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "dataset_field_description": { - Type: schema.TypeString, - Computed: true, - Description: "Describes the data set field", - }, - "dataset_field_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the field", - }, - "dataset_field_json_key": { - Type: schema.TypeString, - Computed: true, - Description: "Specifies the JSON key for the field in a log line", - }, - "dataset_field_name": { - Type: schema.TypeString, - Computed: true, - Description: "A name of the data set field", - }, - }, - }, + Description: "A name of the group for data set field", }, }, }, }, - "template_name": { - Type: schema.TypeString, - Optional: true, - Default: "EDGE_LOGS", - Description: "The name of the data set template that you want to use in your stream configuration", - }, }, } } func dataSourceDatasetFieldsRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("datastream", "dataSourceDatasetFieldsRead") ctx = session.ContextWithOptions( @@ -88,13 +75,18 @@ func dataSourceDatasetFieldsRead(ctx context.Context, rd *schema.ResourceData, m logger.Debug("Listing dataset fields") client := inst.Client(meta) - template, err := tf.GetStringValue("template_name", rd) + productID, err := tf.GetStringValue("product_id", rd) if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - getDatasetFieldsRequest := datastream.GetDatasetFieldsRequest{ - TemplateName: datastream.TemplateName(template), + + var getDatasetFieldsRequest datastream.GetDatasetFieldsRequest + if productID != "" { + getDatasetFieldsRequest = datastream.GetDatasetFieldsRequest{ + ProductID: &productID, + } } + dataSets, err := client.GetDatasetFields(ctx, getDatasetFieldsRequest) if err != nil { return diag.FromErr(err) @@ -102,7 +94,7 @@ func dataSourceDatasetFieldsRead(ctx context.Context, rd *schema.ResourceData, m fields := parseFields(dataSets) - if err := rd.Set("fields", fields); err != nil { + if err := rd.Set("dataset_fields", fields); err != nil { return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) } @@ -113,21 +105,13 @@ func dataSourceDatasetFieldsRead(ctx context.Context, rd *schema.ResourceData, m return nil } -func parseFields(dataSets []datastream.DataSets) []map[string]interface{} { - fields := make([]map[string]interface{}, 0, len(dataSets)) - - for _, dataSet := range dataSets { - data := map[string]interface{}{} - data["dataset_group_name"] = dataSet.DatasetGroupName - data["dataset_group_description"] = dataSet.DatasetGroupDescription - data["dataset_fields"] = parseDatasetFields(dataSet.DatasetFields) - fields = append(fields, data) - } +func parseFields(dataSets *datastream.DataSets) []map[string]interface{} { - return fields + var datasetFields = dataSets.DataSetFields + return parseDatasetFields(datasetFields) } -func parseDatasetFields(datasetFields []datastream.DatasetFields) []map[string]interface{} { +func parseDatasetFields(datasetFields []datastream.DataSetField) []map[string]interface{} { dSFields := make([]map[string]interface{}, 0, len(datasetFields)) for _, dataSetFields := range datasetFields { dataSetFieldsData := map[string]interface{}{} @@ -135,6 +119,7 @@ func parseDatasetFields(datasetFields []datastream.DatasetFields) []map[string]i dataSetFieldsData["dataset_field_id"] = dataSetFields.DatasetFieldID dataSetFieldsData["dataset_field_json_key"] = dataSetFields.DatasetFieldJsonKey dataSetFieldsData["dataset_field_name"] = dataSetFields.DatasetFieldName + dataSetFieldsData["dataset_field_group"] = dataSetFields.DatasetFieldGroup dSFields = append(dSFields, dataSetFieldsData) } return dSFields 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 5ed1064a9..7d8e443dd 100644 --- a/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go +++ b/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go @@ -1,126 +1,94 @@ package datastream import ( - "errors" - "fmt" "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) func TestDataSourceDatasetFieldsRead(t *testing.T) { - normalServerResponse := []datastream.DataSets{ - { - DatasetGroupName: "Log information", - DatasetGroupDescription: "Contains fields that can be used to identify or tag a log line", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1000, - DatasetFieldName: "CP code", - DatasetFieldDescription: "The Content Provider code associated with the request.", - DatasetFieldJsonKey: "cp", - }, - { - DatasetFieldID: 1002, - DatasetFieldName: "Request ID", - DatasetFieldDescription: "The identifier of the request.", - DatasetFieldJsonKey: "reqId", - }, - { - DatasetFieldID: 1100, - DatasetFieldName: "Request time", - DatasetFieldDescription: "The time when the edge server accepted the request from the client.", - DatasetFieldJsonKey: "reqTimeSec", - }, - }, - }, - { - DatasetGroupName: "Message exchange data", - DatasetGroupDescription: "Contains fields representing the exchange of data between Akamai & end user", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1005, - DatasetFieldName: "Bytes", - DatasetFieldDescription: "The content bytes served in the response.", - DatasetFieldJsonKey: "bytes", - }, - { - DatasetFieldID: 1006, - DatasetFieldName: "Client IP", - DatasetFieldDescription: "The IP address of the client.", - DatasetFieldJsonKey: "cliIP", + tests := map[string]struct { + configPath string + getDatasetFieldsReturn *datastream.DataSets + checkFuncs []resource.TestCheckFunc + edgegridError error + withError *regexp.Regexp + }{ + + "validate dataset fields response": { + configPath: "testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_with_product.tf", + getDatasetFieldsReturn: &datastream.DataSets{ + DataSetFields: []datastream.DataSetField{ + { + DatasetFieldID: 1000, + DatasetFieldName: "datasetFieldName_1", + DatasetFieldJsonKey: "datasetFieldJsonKey_1", + DatasetFieldGroup: "datasetFieldGroup_1", + DatasetFieldDescription: "datasetFieldDescription_1", + }, + { + DatasetFieldID: 1001, + DatasetFieldName: "datasetFieldName_2", + DatasetFieldJsonKey: "datasetFieldJsonKey_2", + DatasetFieldGroup: "datasetFieldGroup_2", + DatasetFieldDescription: "datasetFieldDescription_2", + }, + { + DatasetFieldID: 1002, + DatasetFieldName: "datasetFieldName_3", + DatasetFieldJsonKey: "datasetFieldJsonKey_3", + DatasetFieldGroup: "datasetFieldGroup_3", + DatasetFieldDescription: "datasetFieldDescription_3", + }, }, }, - }, - } - normalChecks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.#", "2"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_group_name", "Log information"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_group_description", "Contains fields that can be used to identify or tag a log line"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.0.dataset_field_description", "The Content Provider code associated with the request."), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.0.dataset_field_id", "1000"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.0.dataset_field_json_key", "cp"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.0.dataset_field_name", "CP code"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.1.dataset_field_description", "The identifier of the request."), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.1.dataset_field_id", "1002"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.1.dataset_field_json_key", "reqId"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.1.dataset_field_name", "Request ID"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.2.dataset_field_description", "The time when the edge server accepted the request from the client."), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.2.dataset_field_id", "1100"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.2.dataset_field_json_key", "reqTimeSec"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.0.dataset_fields.2.dataset_field_name", "Request time"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_group_name", "Message exchange data"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_group_description", "Contains fields representing the exchange of data between Akamai & end user"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.0.dataset_field_description", "The content bytes served in the response."), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.0.dataset_field_id", "1005"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.0.dataset_field_json_key", "bytes"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.0.dataset_field_name", "Bytes"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.1.dataset_field_description", "The IP address of the client."), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.1.dataset_field_id", "1006"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.1.dataset_field_json_key", "cliIP"), - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.1.dataset_fields.1.dataset_field_name", "Client IP"), - } - tests := map[string]struct { - configPath string - edgegridData []datastream.DataSets - edgegridError error - checks []resource.TestCheckFunc - withError error - }{ - "EDGE_LOGS template": { - configPath: "testdata/TestDataSourceDatasetFieldsRead/edge_logs.tf", - edgegridData: normalServerResponse, - checks: normalChecks, + checkFuncs: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.#", "3"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.0.dataset_field_description", "datasetFieldDescription_1"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.0.dataset_field_id", "1000"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.0.dataset_field_json_key", "datasetFieldJsonKey_1"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.0.dataset_field_name", "datasetFieldName_1"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.0.dataset_field_group", "datasetFieldGroup_1"), + + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.1.dataset_field_description", "datasetFieldDescription_2"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.1.dataset_field_id", "1001"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.1.dataset_field_json_key", "datasetFieldJsonKey_2"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.1.dataset_field_name", "datasetFieldName_2"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.1.dataset_field_group", "datasetFieldGroup_2"), + + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.2.dataset_field_description", "datasetFieldDescription_3"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.2.dataset_field_id", "1002"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.2.dataset_field_json_key", "datasetFieldJsonKey_3"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.2.dataset_field_name", "datasetFieldName_3"), + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.2.dataset_field_group", "datasetFieldGroup_3"), + }, }, - "no template, EDGE_LOGS by default": { - configPath: "testdata/TestDataSourceDatasetFieldsRead/edge_logs_no_template.tf", - edgegridData: normalServerResponse, - checks: normalChecks, + "no template EDGE_LOGS by default": { + configPath: "testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_default_product.tf", + getDatasetFieldsReturn: &datastream.DataSets{ + DataSetFields: []datastream.DataSetField{}, + }, + checkFuncs: []resource.TestCheckFunc{}, }, "empty server response": { - configPath: "testdata/TestDataSourceDatasetFieldsRead/edge_logs.tf", - edgegridData: []datastream.DataSets{}, - checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "fields.#", "0"), + configPath: "testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_with_product.tf", + getDatasetFieldsReturn: &datastream.DataSets{ + DataSetFields: []datastream.DataSetField{}, + }, + checkFuncs: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("data.akamai_datastream_dataset_fields.test", "dataset_fields.#", "0"), }, - }, - "EDGE_LOGS template: edgegrid error": { - configPath: "testdata/TestDataSourceDatasetFieldsRead/edge_logs.tf", - edgegridError: fmt.Errorf("%w: request failed: %s", datastream.ErrGetDatasetFields, errors.New("500")), - withError: datastream.ErrGetDatasetFields, }, } for name, test := range tests { t.Run(name, func(t *testing.T) { client := &datastream.Mock{} - client.On("GetDatasetFields", mock.Anything, datastream.GetDatasetFieldsRequest{ - TemplateName: datastream.TemplateNameEdgeLogs, - }).Return(test.edgegridData, test.edgegridError) + client.On("GetDatasetFields", mock.Anything, mock.Anything).Return(test.getDatasetFieldsReturn, test.edgegridError) useClient(client, func() { if test.withError == nil { resource.UnitTest(t, resource.TestCase{ @@ -129,7 +97,7 @@ func TestDataSourceDatasetFieldsRead(t *testing.T) { { Config: loadFixtureString(test.configPath), Check: resource.ComposeAggregateTestCheckFunc( - test.checks..., + test.checkFuncs..., ), }, }, @@ -140,7 +108,7 @@ func TestDataSourceDatasetFieldsRead(t *testing.T) { Steps: []resource.TestStep{ { Config: loadFixtureString(test.configPath), - ExpectError: regexp.MustCompile(test.withError.Error()), + ExpectError: test.withError, }, }, }) diff --git a/pkg/providers/datastream/data_akamai_datastreams.go b/pkg/providers/datastream/data_akamai_datastreams.go index b495c0b55..904eaba19 100644 --- a/pkg/providers/datastream/data_akamai_datastreams.go +++ b/pkg/providers/datastream/data_akamai_datastreams.go @@ -4,15 +4,13 @@ import ( "context" "errors" "fmt" - "strconv" - "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -23,85 +21,40 @@ func dataAkamaiDatastreamStreams() *schema.Resource { ReadContext: dataDatastreamStreamsRead, Schema: map[string]*schema.Schema{ "group_id": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: tf.FieldPrefixSuppress("grp_"), - Description: "Limits the returned set to streams belonging to the specified group.", + Type: schema.TypeInt, + Optional: true, + Description: "Identifies the group where the stream is created.", }, - "streams": { - Type: schema.TypeList, + "streams_details": { + Type: schema.TypeSet, Computed: true, - Description: "The latest versions of the stream configurations.", + Description: "List of streams", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "activation_status": { - Type: schema.TypeString, - Computed: true, - Description: "The activation status of the stream.", - }, - "archived": { - Type: schema.TypeBool, - Computed: true, - Description: "Whether the stream is archived.", - }, - "connectors": { - Type: schema.TypeString, - Computed: true, - Description: "The connector where the stream sends logs.", - }, - "contract_id": { - Type: schema.TypeString, - Computed: true, - Description: "Identifies the contract that the stream is associated with.", - }, - "created_by": { + "stream_name": { Type: schema.TypeString, Computed: true, - Description: "The username who created the stream.", + Description: "The name of the stream.", }, - "created_date": { - Type: schema.TypeString, + "stream_id": { + Type: schema.TypeInt, Computed: true, - Description: "The date and time when the stream was created.", + Description: "Identifies the stream.", }, - "current_version_id": { + "stream_version": { Type: schema.TypeInt, Computed: true, Description: "Identifies the current version of the stream.", }, - "errors": { - Type: schema.TypeList, - Computed: true, - Description: "Objects that may indicate stream failure errors", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "detail": { - Type: schema.TypeString, - Computed: true, - Description: "A message informing about the status of the failed stream.", - }, - "title": { - Type: schema.TypeString, - Computed: true, - Description: "A descriptive label for the type of error.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Identifies the error type.", - }, - }, - }, - }, "group_id": { Type: schema.TypeInt, Computed: true, Description: "Identifies the group where the stream is created.", }, - "group_name": { + "contract_id": { Type: schema.TypeString, Computed: true, - Description: "The group name where the stream is created.", + Description: "Identifies the contract that the stream is associated with.", }, "properties": { Type: schema.TypeList, @@ -122,25 +75,41 @@ func dataAkamaiDatastreamStreams() *schema.Resource { }, }, }, - "stream_id": { + "latest_version": { Type: schema.TypeInt, Computed: true, - Description: "Identifies the stream.", + Description: "Identifies the latestVersion version of the stream.", }, - "stream_name": { + "product_id": { Type: schema.TypeString, Computed: true, - Description: "The name of the stream.", + Description: "The productId.", }, - "stream_type_name": { + "stream_status": { Type: schema.TypeString, Computed: true, - Description: "Specifies the type of the data stream.", + Description: "The activation status of the stream.", }, - "stream_version_id": { - Type: schema.TypeInt, + + "created_by": { + Type: schema.TypeString, + Computed: true, + Description: "The username who created the stream.", + }, + "created_date": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time when the stream was created.", + }, + "modified_by": { + Type: schema.TypeString, Computed: true, - Description: "Identifies the version of the stream.", + Description: "The username who activated or deactivated the stream", + }, + "modified_date": { + Type: schema.TypeString, + Computed: true, + Description: "The date and time when activation status was modified", }, }, }, @@ -150,7 +119,7 @@ func dataAkamaiDatastreamStreams() *schema.Resource { } func dataDatastreamStreamsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("datastream", "dataDatastreamStreamsRead") ctx = session.ContextWithOptions( @@ -160,21 +129,17 @@ func dataDatastreamStreamsRead(ctx context.Context, d *schema.ResourceData, m in client := inst.Client(meta) - groupIDStr, err := tf.GetStringValue("group_id", d) + groupIDInt, err := tf.GetIntValue("group_id", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } req := datastream.ListStreamsRequest{} resID := "akamai_datastreams" - if groupIDStr != "" { - groupID, err := strconv.Atoi(strings.TrimPrefix(groupIDStr, "grp_")) - if err != nil { - return diag.FromErr(err) - } - - req.GroupID = tools.IntPtr(groupID) - resID = fmt.Sprintf("%s_%d", resID, groupID) + if groupIDInt != 0 { + + req.GroupID = tools.IntPtr(groupIDInt) + resID = fmt.Sprintf("%s_%d", resID, groupIDInt) } streams, err := client.ListStreams(ctx, req) @@ -183,9 +148,11 @@ func dataDatastreamStreamsRead(ctx context.Context, d *schema.ResourceData, m in } logger.Debugf("Fetched %d streams", len(streams)) - attrs := map[string]interface{}{"streams": createStreamsAttrs(streams)} - if err = tf.SetAttrs(d, attrs); err != nil { - return diag.FromErr(err) + + attrs := createStreamsAttrs(streams) + + if err := d.Set("streams_details", attrs); err != nil { + return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) } d.SetId(resID) @@ -196,41 +163,25 @@ func createStreamsAttrs(streams []datastream.StreamDetails) []interface{} { streamsAttrs := make([]interface{}, 0, len(streams)) for _, stream := range streams { streamsAttrs = append(streamsAttrs, map[string]interface{}{ - "activation_status": stream.ActivationStatus, - "archived": stream.Archived, - "connectors": stream.Connectors, - "contract_id": stream.ContractID, - "created_by": stream.CreatedBy, - "created_date": stream.CreatedDate, - "current_version_id": stream.CurrentVersionID, - "errors": createErrorsAttrs(stream.Errors), - "group_id": stream.GroupID, - "group_name": stream.GroupName, - "properties": createPropertiesAttrs(stream.Properties), - "stream_id": stream.StreamID, - "stream_name": stream.StreamName, - "stream_type_name": stream.StreamTypeName, - "stream_version_id": stream.StreamVersionID, + "stream_status": stream.StreamStatus, + "contract_id": stream.ContractID, + "created_by": stream.CreatedBy, + "created_date": stream.CreatedDate, + "modified_by": stream.ModifiedBy, + "modified_date": stream.ModifiedDate, + "group_id": stream.GroupID, + "latest_version": stream.LatestVersion, + "product_id": stream.ProductID, + "properties": createPropertiesAttrs(stream.Properties), + "stream_id": stream.StreamID, + "stream_name": stream.StreamName, + "stream_version": stream.StreamVersion, }) } return streamsAttrs } -func createErrorsAttrs(errors []datastream.Errors) []interface{} { - errorAttrs := make([]interface{}, 0, len(errors)) - - for _, errDetails := range errors { - errorAttrs = append(errorAttrs, map[string]interface{}{ - "detail": errDetails.Detail, - "title": errDetails.Title, - "type": errDetails.Type, - }) - } - - return errorAttrs -} - func createPropertiesAttrs(properties []datastream.Property) []interface{} { propertyAttrs := make([]interface{}, 0, len(properties)) diff --git a/pkg/providers/datastream/data_akamai_datastreams_test.go b/pkg/providers/datastream/data_akamai_datastreams_test.go index c7f026be1..a1ac06168 100644 --- a/pkg/providers/datastream/data_akamai_datastreams_test.go +++ b/pkg/providers/datastream/data_akamai_datastreams_test.go @@ -6,55 +6,43 @@ import ( "strconv" "testing" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" - - "github.com/stretchr/testify/mock" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/stretchr/testify/mock" ) var ( streamList = []datastream.StreamDetails{ { - ActivationStatus: datastream.ActivationStatusDeactivated, - Archived: false, - Connectors: "S3-S1", - ContractID: "1-ABCDE", - CreatedBy: "user1", - CreatedDate: "14-07-2020 07:07:40 GMT", - CurrentVersionID: 2, - Errors: []datastream.Errors{ - { - Detail: "Contact technical support.", - Title: "Activation/Deactivation Error", - Type: "ACTIVATION_ERROR", - }, - }, - GroupID: 1234, - GroupName: "Default Group", + StreamID: 1, + StreamName: "Stream1", + StreamStatus: datastream.StreamStatusDeactivated, + StreamVersion: 2, + LatestVersion: 2, + GroupID: 1234, + ContractID: "1-ABCDE", + ProductID: "P-1234", + CreatedBy: "user1", + CreatedDate: "14-07-2020 07:07:40 GMT", Properties: []datastream.Property{ { PropertyID: 13371337, PropertyName: "property_name_1", }, }, - StreamID: 1, - StreamName: "Stream1", - StreamTypeName: "Logs - Raw", - StreamVersionID: 2, }, { - ActivationStatus: datastream.ActivationStatusActivated, - Archived: true, - Connectors: "S3-S2", - ContractID: "2-ABCDE", - CreatedBy: "user2", - CreatedDate: "24-07-2020 07:07:40 GMT", - CurrentVersionID: 3, - Errors: nil, - GroupID: 4321, - GroupName: "Default Group", + StreamID: 2, + StreamName: "Stream2", + StreamStatus: datastream.StreamStatusActivated, + StreamVersion: 3, + LatestVersion: 3, + GroupID: 4321, + ContractID: "2-ABCDE", + ProductID: "P-1234", + CreatedBy: "user2", + CreatedDate: "24-07-2020 07:07:40 GMT", Properties: []datastream.Property{ { PropertyID: 23372337, @@ -65,10 +53,6 @@ var ( PropertyName: "property_name_3", }, }, - StreamID: 2, - StreamName: "Stream2", - StreamTypeName: "Logs - Raw", - StreamVersionID: 3, }, } @@ -82,7 +66,7 @@ func TestDataDatastreams(t *testing.T) { }{ "list streams": { init: func(t *testing.T, m *datastream.Mock) { - m.On("ListStreams", mock.Anything, datastream.ListStreamsRequest{}). + m.On("ListStreams", mock.Anything, mock.Anything). Return(streamList, nil) }, steps: []resource.TestStep{ @@ -123,7 +107,7 @@ func TestDataDatastreams(t *testing.T) { steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDataDatastreams/list_streams_with_groupid_with_invalid_prefix.tf"), - ExpectError: regexp.MustCompile("invalid syntax"), + ExpectError: regexp.MustCompile("Invalid reference"), }, }, }, @@ -141,7 +125,7 @@ func TestDataDatastreams(t *testing.T) { }, "could not fetch stream list": { init: func(t *testing.T, m *datastream.Mock) { - m.On("ListStreams", mock.Anything, datastream.ListStreamsRequest{}). + m.On("ListStreams", mock.Anything, mock.Anything). Return(nil, fmt.Errorf("failed to get stream list")).Once() }, steps: []resource.TestStep{ @@ -171,48 +155,28 @@ func TestDataDatastreams(t *testing.T) { func streamsChecks(details []datastream.StreamDetails) resource.TestCheckFunc { checks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("data.akamai_datastreams.test", "streams.#", strconv.Itoa(len(details))), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", "streams_details.#", strconv.Itoa(len(details))), } for idx, stream := range details { - attrName := func(attr string) string { return fmt.Sprintf("streams.%d.%s", idx, attr) } + attrName := func(attr string) string { return fmt.Sprintf("streams_details.%d.%s", idx, attr) } testCheck := resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("activation_status"), string(stream.ActivationStatus)), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("archived"), strconv.FormatBool(stream.Archived)), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("connectors"), stream.Connectors), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_id"), strconv.FormatInt(stream.StreamID, 10)), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_name"), stream.StreamName), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_version"), strconv.FormatInt(stream.StreamVersion, 10)), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("group_id"), strconv.Itoa(stream.GroupID)), resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("contract_id"), stream.ContractID), + propertiesCheck(attrName("properties"), stream.Properties), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("latest_version"), strconv.FormatInt(stream.LatestVersion, 10)), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("product_id"), stream.ProductID), + resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_status"), string(stream.StreamStatus)), resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("created_by"), stream.CreatedBy), resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("created_date"), stream.CreatedDate), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("current_version_id"), strconv.FormatInt(stream.CurrentVersionID, 10)), - errorChecks(attrName("errors"), stream.Errors), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("group_id"), strconv.Itoa(stream.GroupID)), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("group_name"), stream.GroupName), - propertiesCheck(attrName("properties"), stream.Properties), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_id"), strconv.FormatInt(stream.StreamID, 10)), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_name"), stream.StreamName), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_type_name"), stream.StreamTypeName), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("stream_version_id"), strconv.FormatInt(stream.StreamVersionID, 10)), ) checks = append(checks, testCheck) } return resource.ComposeAggregateTestCheckFunc(checks...) } -func errorChecks(key string, errors []datastream.Errors) resource.TestCheckFunc { - checks := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("data.akamai_datastreams.test", fmt.Sprintf("%s.#", key), strconv.Itoa(len(errors))), - } - for idx, errDetails := range errors { - attrName := func(attr string) string { return fmt.Sprintf("%s.%d.%s", key, idx, attr) } - testCheck := []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("detail"), errDetails.Detail), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("title"), errDetails.Title), - resource.TestCheckResourceAttr("data.akamai_datastreams.test", attrName("type"), errDetails.Type), - } - checks = append(checks, testCheck...) - } - return resource.ComposeAggregateTestCheckFunc(checks...) -} - func propertiesCheck(key string, properties []datastream.Property) resource.TestCheckFunc { checks := []resource.TestCheckFunc{ resource.TestCheckResourceAttr("data.akamai_datastreams.test", fmt.Sprintf("%s.#", key), strconv.Itoa(len(properties))), diff --git a/pkg/providers/datastream/datastream.go b/pkg/providers/datastream/datastream.go index 768c39582..becedf3a0 100644 --- a/pkg/providers/datastream/datastream.go +++ b/pkg/providers/datastream/datastream.go @@ -1,10 +1,7 @@ -//go:build all || datastream -// +build all datastream - package datastream -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/datastream/provider.go b/pkg/providers/datastream/provider.go index f03e7e309..252dec826 100644 --- a/pkg/providers/datastream/provider.go +++ b/pkg/providers/datastream/provider.go @@ -4,34 +4,33 @@ package datastream import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers datastream resources and data sources + Subprovider struct { client datastream.DS } - // Option is a ds provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -41,60 +40,32 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{}, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_datastream_activation_history": dataAkamaiDatastreamActivationHistory(), - "akamai_datastream_dataset_fields": dataSourceDatasetFields(), - "akamai_datastreams": dataAkamaiDatastreamStreams(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_datastream": resourceDatastream(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c datastream.DS) Option { - return func(p *provider) { +func withClient(c datastream.DS) option { + return func(p *Subprovider) { p.client = c } } // Client returns the ds interface -func (p *provider) Client(meta akamai.OperationMeta) datastream.DS { +func (p *Subprovider) Client(meta meta.Meta) datastream.DS { if p.client != nil { return p.client } return datastream.Client(meta.Session()) } -func (p *provider) Name() string { - return "datastream" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for datastream +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_datastream": resourceDatastream(), + } } -func (p *provider) Configure(_ log.Interface, _ *schema.ResourceData) diag.Diagnostics { - return nil +// DataSources returns terraform data sources for datastream +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_datastream_activation_history": dataAkamaiDatastreamActivationHistory(), + "akamai_datastream_dataset_fields": dataSourceDatasetFields(), + "akamai_datastreams": dataAkamaiDatastreamStreams(), + } } diff --git a/pkg/providers/datastream/provider_test.go b/pkg/providers/datastream/provider_test.go index 4b1d68f74..1dbbaa297 100644 --- a/pkg/providers/datastream/provider_test.go +++ b/pkg/providers/datastream/provider_test.go @@ -8,8 +8,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -18,28 +19,22 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/datastream/resource_akamai_datastream.go b/pkg/providers/datastream/resource_akamai_datastream.go index 5783b4436..90b99d0f0 100644 --- a/pkg/providers/datastream/resource_akamai_datastream.go +++ b/pkg/providers/datastream/resource_akamai_datastream.go @@ -8,11 +8,12 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -87,7 +88,12 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Required: true, Description: "Defining if stream should be active or not", }, - "config": { + "collect_midgress": { + Type: schema.TypeBool, + Optional: true, + Description: "Identifies if stream needs to collect midgress data", + }, + "delivery_configuration": { Type: schema.TypeSet, MinItems: 1, MaxItems: 1, @@ -111,7 +117,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Computed: true, Description: "The date and time when the stream was created", }, - "dataset_fields_ids": { + "dataset_fields": { Type: schema.TypeList, Required: true, DiffSuppressFunc: isOrderDifferent, @@ -120,7 +126,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ }, Description: "A list of data set fields selected from the associated template that the stream monitors in logs. The order of the identifiers define how the value for these fields appear in the log lines", }, - "email_ids": { + "notification_emails": { Type: schema.TypeList, Optional: true, Elem: &schema.Schema{ @@ -135,11 +141,6 @@ var datastreamResourceSchema = map[string]*schema.Schema{ DiffSuppressFunc: tf.FieldPrefixSuppress("grp_"), Description: "Identifies the group that has access to the product and for which the stream configuration was created", }, - "group_name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the user group for which the stream was created", - }, "modified_by": { Type: schema.TypeString, Computed: true, @@ -160,12 +161,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Computed: true, Description: "The ID of the product for which the stream was created", }, - "product_name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the product for which the stream was created", - }, - "property_ids": { + "properties": { Type: schema.TypeList, Required: true, Elem: &schema.Schema{ @@ -179,26 +175,21 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Required: true, Description: "The name of the stream", }, - "stream_type": { - Type: schema.TypeString, - Required: true, - Description: "Specifies the type of the data stream", - }, - "stream_version_id": { + "stream_version": { Type: schema.TypeInt, Computed: true, Description: "Identifies the configuration version of the stream", }, - "template_name": { - Type: schema.TypeString, - Required: true, - Description: "The name of the template associated with the stream", + "latest_version": { + Type: schema.TypeInt, + Computed: true, + Description: "Identifies the latest active configuration version of the stream", }, "s3_connector": { Type: schema.TypeSet, MaxItems: 1, ExactlyOneOf: ExactlyOneConnectorRule, - Optional: true, + Optional: true, //To DO it should be mandatory Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "access_key": { @@ -217,12 +208,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Computed: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -268,12 +254,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Computed: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -309,12 +290,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -337,7 +313,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Description: "The tags of the Datadog connector", }, - "url": { + "endpoint": { Type: schema.TypeString, Required: true, Description: "The Datadog endpoint where logs will be stored", @@ -357,12 +333,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -383,7 +354,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Sensitive: true, Description: "The Event Collector token associated with Splunk account", }, - "url": { + "endpoint": { Type: schema.TypeString, Required: true, Description: "The raw event Splunk URL where logs will be stored", @@ -439,12 +410,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Computed: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -495,12 +461,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -527,7 +488,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Sensitive: true, Description: "Password set for custom HTTPS endpoint for authentication", }, - "url": { + "endpoint": { Type: schema.TypeString, Required: true, Description: "URL where logs will be stored", @@ -575,10 +536,9 @@ var datastreamResourceSchema = map[string]*schema.Schema{ }, }, "sumologic_connector": { - Type: schema.TypeSet, - MaxItems: 1, - Optional: true, - DiffSuppressFunc: urlSuppressor("endpoint"), + Type: schema.TypeSet, + MaxItems: 1, + Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "collector_code": { @@ -593,11 +553,6 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, "content_type": { Type: schema.TypeString, Optional: true, @@ -613,7 +568,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Description: "The custom header's contents passed with the request to the destination", }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -648,12 +603,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Computed: true, Description: "Indicates whether the logs should be compressed", }, - "connector_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Identifies the connector associated with the stream", - }, - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector", @@ -688,7 +638,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector.", @@ -733,7 +683,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector.", @@ -773,7 +723,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "connector_name": { + "display_name": { Type: schema.TypeString, Required: true, Description: "The name of the connector.", @@ -855,7 +805,7 @@ var datastreamResourceSchema = map[string]*schema.Schema{ var configResource = &schema.Resource{ Schema: map[string]*schema.Schema{ - "delimiter": { + "field_delimiter": { Type: schema.TypeString, Optional: true, Description: "A delimiter that you use to separate data set fields in log lines", @@ -872,7 +822,7 @@ var configResource = &schema.Resource{ Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "time_in_sec": { + "interval_in_secs": { Type: schema.TypeInt, Required: true, Description: "The time in seconds after which the system bundles log lines into a file and sends it to a destination", @@ -897,7 +847,7 @@ var configResource = &schema.Resource{ } func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Datastream", "resourceDatastreamCreate") ctx = session.ContextWithOptions( @@ -913,11 +863,7 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - configSet, err := tf.GetSetValue("config", d) - if err != nil { - return diag.FromErr(err) - } - config, err := GetConfig(configSet) + collectMidgress, err := tf.GetBoolValue("collect_midgress", d) if err != nil { return diag.FromErr(err) } @@ -928,19 +874,25 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int } contractID = strings.TrimPrefix(contractID, "ctr_") - datasetFieldsIDsList, err := tf.GetListValue("dataset_fields_ids", d) + datasetFieldsIDsList, err := tf.GetListValue("dataset_fields", d) + if err != nil { return diag.FromErr(err) } - datasetFieldsIDs := InterfaceSliceToIntSlice(datasetFieldsIDsList) + datasetFieldsIDs := DatasetFieldListToDatasetFields(datasetFieldsIDsList) + + emailIDsList, err := tf.GetListValue("notification_emails", d) - emailIDsList, err := tf.GetListValue("email_ids", d) if err != nil { if !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } } - emailIDs := strings.Join(InterfaceSliceToStringSlice(emailIDsList), ",") + emailIDs := InterfaceSliceToStringSlice(emailIDsList) + + if len(emailIDs) == 0 { + emailIDs = nil + } groupIDStr, err := tf.GetStringValue("group_id", d) if err != nil { @@ -951,7 +903,7 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - propertyIDsList, err := tf.GetListValue("property_ids", d) + propertyIDsList, err := tf.GetListValue("properties", d) if err != nil { return diag.FromErr(err) } @@ -965,37 +917,39 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - streamTypeStr, err := tf.GetStringValue("stream_type", d) + connectors, err := GetConnectors(d, ExactlyOneConnectorRule) if err != nil { return diag.FromErr(err) } - streamType := datastream.StreamType(streamTypeStr) - templateNameStr, err := tf.GetStringValue("template_name", d) + deliveryConfigSet, err := tf.GetSetValue("delivery_configuration", d) + if err != nil { + return diag.FromErr(err) + } + config, err := GetConfig(deliveryConfigSet) if err != nil { return diag.FromErr(err) } - templateName := datastream.TemplateName(templateNameStr) + var httpsBaseConnectorName = GetConnectorNameWithOutFilePrefixSuffix(d, ConnectorsWithoutFilenameOptionsConfig) - connectors, err := GetConnectors(d, ExactlyOneConnectorRule) + config, err = FilePrefixSuffixSet(httpsBaseConnectorName, config) if err != nil { return diag.FromErr(err) } req := datastream.CreateStreamRequest{ StreamConfiguration: datastream.StreamConfiguration{ - ActivateNow: active, - Config: *config, - Connectors: connectors, - ContractID: contractID, - DatasetFieldIDs: datasetFieldsIDs, - EmailIDs: emailIDs, - GroupID: &groupID, - PropertyIDs: propertyIDs, - StreamName: streamName, - StreamType: streamType, - TemplateName: templateName, + CollectMidgress: collectMidgress, + DeliveryConfiguration: *config, + Destination: connectors, + ContractID: contractID, + DatasetFields: datasetFieldsIDs, + NotificationEmails: emailIDs, + GroupID: groupID, + Properties: propertyIDs, + StreamName: streamName, }, + Activate: active, } res, err := client.CreateStream(ctx, req) @@ -1003,11 +957,11 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - streamID := res.StreamVersionKey.StreamID + streamID := res.StreamID d.SetId(strconv.FormatInt(streamID, 10)) if active { - _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusActivated) + _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusActivated) if err != nil { return diag.FromErr(err) } @@ -1016,8 +970,19 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return resourceDatastreamRead(ctx, d, m) } +// FilePrefixSuffixSet is used to set the blank value for prefix and suffix for https based destination as https based destination does not support prefix and suffix +func FilePrefixSuffixSet(httpsBaseConnectorName string, config *datastream.DeliveryConfiguration) (*datastream.DeliveryConfiguration, error) { + + if tools.ContainsString(ConnectorsWithoutFilenameOptionsConfig, httpsBaseConnectorName) { + + config.UploadFilePrefix = "" + config.UploadFileSuffix = "" + } + return config, nil +} + func resourceDatastreamRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Datastream", "resourceDatastreamRead") ctx = session.ContextWithOptions( @@ -1042,33 +1007,26 @@ func resourceDatastreamRead(ctx context.Context, d *schema.ResourceData, m inter attrs := make(map[string]interface{}) - attrs["active"] = streamDetails.ActivationStatus == datastream.ActivationStatusActivated + attrs["active"] = streamDetails.StreamStatus == datastream.StreamStatusActivated + attrs["collect_midgress"] = streamDetails.CollectMidgress attrs["contract_id"] = streamDetails.ContractID attrs["created_by"] = streamDetails.CreatedBy attrs["created_date"] = streamDetails.CreatedDate - attrs["dataset_fields_ids"] = DataSetFieldsToList(streamDetails.Datasets) + attrs["dataset_fields"] = DataSetFieldsToList(streamDetails.DatasetFields) attrs["contract_id"] = streamDetails.ContractID - attrs["email_ids"] = strings.Split(streamDetails.EmailIDs, ",") - var emailIDs []string - if streamDetails.EmailIDs != "" { - emailIDs = strings.Split(streamDetails.EmailIDs, ",") - } - attrs["email_ids"] = emailIDs + attrs["notification_emails"] = streamDetails.NotificationEmails + attrs["latest_version"] = streamDetails.LatestVersion attrs["group_id"] = strconv.Itoa(streamDetails.GroupID) - attrs["group_name"] = streamDetails.GroupName attrs["modified_by"] = streamDetails.ModifiedBy attrs["modified_date"] = streamDetails.ModifiedDate attrs["papi_json"] = StreamIDToPapiJSON(streamDetails.StreamID) attrs["product_id"] = streamDetails.ProductID - attrs["product_name"] = streamDetails.ProductName - attrs["property_ids"] = PropertyToList(streamDetails.Properties) + attrs["properties"] = PropertyToList(streamDetails.Properties) attrs["stream_name"] = streamDetails.StreamName - attrs["stream_type"] = streamDetails.StreamType - attrs["stream_version_id"] = streamDetails.StreamVersionID - attrs["template_name"] = streamDetails.TemplateName + attrs["stream_version"] = streamDetails.StreamVersion - connectorKey, connectorProps, err := ConnectorToMap(streamDetails.Connectors, d) + connectorKey, connectorProps, err := ConnectorToMap(streamDetails.Destination, d) if err != nil { return diag.FromErr(err) } @@ -1084,12 +1042,12 @@ func resourceDatastreamRead(ctx context.Context, d *schema.ResourceData, m inter // we have to take into account the fact that terraform would still see the change between remote (no prefixes set) // and local state (default prefixes set), so we have to ensure that local state has the default prefix/suffix set as well // here we insert default values to satisfy terraform diff - streamDetails.Config.UploadFilePrefix = DefaultUploadFilePrefix - streamDetails.Config.UploadFileSuffix = DefaultUploadFileSuffix + streamDetails.DeliveryConfiguration.UploadFilePrefix = DefaultUploadFilePrefix + streamDetails.DeliveryConfiguration.UploadFileSuffix = DefaultUploadFileSuffix } } - attrs["config"] = ConfigToSet(streamDetails.Config) + attrs["delivery_configuration"] = ConfigToSet(streamDetails.DeliveryConfiguration) err = tf.SetAttrs(d, attrs) if err != nil { @@ -1100,7 +1058,7 @@ func resourceDatastreamRead(ctx context.Context, d *schema.ResourceData, m inter } func resourceDatastreamUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Datastream", "resourceDatastreamUpdate") ctx = session.ContextWithOptions( @@ -1118,14 +1076,14 @@ func resourceDatastreamUpdate(ctx context.Context, d *schema.ResourceData, m int // it is not possible to edit stream while it is (de)activating currentStreamStatus, err := waitForStreamStatusChange(ctx, client, streamID, - datastream.ActivationStatusDeactivated, - datastream.ActivationStatusActivated, - datastream.ActivationStatusInactive, + datastream.StreamStatusDeactivated, + datastream.StreamStatusActivated, + datastream.StreamStatusInactive, ) if err != nil { return diag.FromErr(err) } - isStreamActive := *currentStreamStatus == datastream.ActivationStatusActivated + isStreamActive := *currentStreamStatus == datastream.StreamStatusActivated var newActive bool if d.HasChange("active") { @@ -1144,14 +1102,14 @@ func resourceDatastreamUpdate(ctx context.Context, d *schema.ResourceData, m int // stream is active and should be still active // update details - err = updateStream(ctx, client, logger, streamID, d) + err = updateStream(ctx, client, logger, streamID, d, isStreamActive) if err != nil { return diag.FromErr(err) } // wait until stream is activated because updating active stream causes its reactivation logger.Debugf("waiting for stream #%d activation", streamID) - _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusActivated) + _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusActivated) if err != nil { return diag.FromErr(err) } @@ -1166,20 +1124,21 @@ func resourceDatastreamUpdate(ctx context.Context, d *schema.ResourceData, m int // wait until stream is deactivated logger.Debugf("waiting for stream #%d deactivation", streamID) - _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusDeactivated) + _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusDeactivated) if err != nil { return diag.FromErr(err) } // update details (no waiting needed because stream is inactive) - err = updateStream(ctx, client, logger, streamID, d) + err = updateStream(ctx, client, logger, streamID, d, false) if err != nil { return diag.FromErr(err) } } } else { // update details (no waiting needed because stream is inactive) - err = updateStream(ctx, client, logger, streamID, d) + + err = updateStream(ctx, client, logger, streamID, d, isStreamActive) if err != nil { return diag.FromErr(err) } @@ -1195,7 +1154,7 @@ func resourceDatastreamUpdate(ctx context.Context, d *schema.ResourceData, m int // wait until stream is deactivated logger.Debugf("waiting for stream #%d activation", streamID) - _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusActivated) + _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusActivated) if err != nil { return diag.FromErr(err) } @@ -1205,38 +1164,31 @@ func resourceDatastreamUpdate(ctx context.Context, d *schema.ResourceData, m int return resourceDatastreamRead(ctx, d, m) } -func updateStream(ctx context.Context, client datastream.DS, logger log.Interface, streamID int64, d *schema.ResourceData) error { +func updateStream(ctx context.Context, client datastream.DS, logger log.Interface, streamID int64, d *schema.ResourceData, isStreamActive bool) error { // if some configuration details changed if d.HasChangeExcept("active") { - configSet, err := tf.GetSetValue("config", d) - if err != nil { - return err - } - config, err := GetConfig(configSet) - if err != nil { - return err - } contractID, err := tf.GetStringValue("contract_id", d) if err != nil { return err } - datasetFieldsIDsList, err := tf.GetListValue("dataset_fields_ids", d) + datasetFieldsIDsList, err := tf.GetListValue("dataset_fields", d) if err != nil { return err } - datasetFieldsIDs := InterfaceSliceToIntSlice(datasetFieldsIDsList) + datasetFieldsIDs := DatasetFieldListToDatasetFields(datasetFieldsIDsList) - emailIDsList, err := tf.GetListValue("email_ids", d) + emailIDsList, err := tf.GetListValue("notification_emails", d) if err != nil { if !errors.Is(err, tf.ErrNotFound) { return err } } - emailIDs := strings.Join(InterfaceSliceToStringSlice(emailIDsList), ",") + emailIDs := InterfaceSliceToStringSlice(emailIDsList) + + propertyIDsList, err := tf.GetListValue("properties", d) - propertyIDsList, err := tf.GetListValue("property_ids", d) if err != nil { return err } @@ -1250,19 +1202,28 @@ func updateStream(ctx context.Context, client datastream.DS, logger log.Interfac return err } - streamTypeStr, err := tf.GetStringValue("stream_type", d) + collectMidgress, err := tf.GetBoolValue("collect_midgress", d) if err != nil { return err } - streamType := datastream.StreamType(streamTypeStr) - templateNameStr, err := tf.GetStringValue("template_name", d) + connectors, err := GetConnectors(d, ExactlyOneConnectorRule) if err != nil { return err } - templateName := datastream.TemplateName(templateNameStr) - connectors, err := GetConnectors(d, ExactlyOneConnectorRule) + configSet, err := tf.GetSetValue("delivery_configuration", d) + if err != nil { + return err + } + config, err := GetConfig(configSet) + if err != nil { + return err + } + + var httpsBaseConnectorName = GetConnectorNameWithOutFilePrefixSuffix(d, ConnectorsWithoutFilenameOptionsConfig) + + config, err = FilePrefixSuffixSet(httpsBaseConnectorName, config) if err != nil { return err } @@ -1270,17 +1231,16 @@ func updateStream(ctx context.Context, client datastream.DS, logger log.Interfac req := datastream.UpdateStreamRequest{ StreamID: streamID, StreamConfiguration: datastream.StreamConfiguration{ - ActivateNow: false, - Config: *config, - Connectors: connectors, - ContractID: contractID, - DatasetFieldIDs: datasetFieldsIDs, - EmailIDs: emailIDs, - PropertyIDs: propertyIDs, - StreamName: streamName, - StreamType: streamType, - TemplateName: templateName, + CollectMidgress: collectMidgress, + DeliveryConfiguration: *config, + Destination: connectors, + ContractID: contractID, + DatasetFields: datasetFieldsIDs, + NotificationEmails: emailIDs, + Properties: propertyIDs, + StreamName: streamName, }, + Activate: isStreamActive, } _, err = client.UpdateStream(ctx, req) @@ -1302,12 +1262,12 @@ func deactivateStream(ctx context.Context, client datastream.DS, logger log.Inte } logger.Debugf("waiting for the stream #%d to be deactivated", streamID) - _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusDeactivated) + _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusDeactivated) return err } func activateStream(ctx context.Context, client datastream.DS, logger log.Interface, streamID int64) error { - logger.Debug("activating stream") + logger.Info("activating stream") _, err := client.ActivateStream(ctx, datastream.ActivateStreamRequest{ StreamID: streamID, }) @@ -1316,12 +1276,12 @@ func activateStream(ctx context.Context, client datastream.DS, logger log.Interf } logger.Debugf("waiting for the stream #%d to be activated", streamID) - _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusActivated) + _, err = waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusActivated) return err } func resourceDatastreamDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Datastream", "resourceDatastreamDelete") ctx = session.ContextWithOptions( @@ -1344,7 +1304,7 @@ func resourceDatastreamDelete(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - activationStatus := streamDetails.ActivationStatus + activationStatus := streamDetails.StreamStatus // if status == activating - wait, deactivate, wait, delete // if status == activated - deactivate, wait, delete @@ -1352,17 +1312,17 @@ func resourceDatastreamDelete(ctx context.Context, d *schema.ResourceData, m int // if status == deactivated/inactive - delete // if stream is activating we have to wait until activation finishes - if activationStatus == datastream.ActivationStatusActivating { - _, err := waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusActivated) + if activationStatus == datastream.StreamStatusActivating { + _, err := waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusActivated) if err != nil { return diag.FromErr(err) } - activationStatus = datastream.ActivationStatusActivated + activationStatus = datastream.StreamStatusActivated } // if stream is active - deactivate it - if activationStatus == datastream.ActivationStatusActivated { + if activationStatus == datastream.StreamStatusActivated { _, err := client.DeactivateStream(ctx, datastream.DeactivateStreamRequest{ StreamID: streamID, }) @@ -1370,22 +1330,22 @@ func resourceDatastreamDelete(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - activationStatus = datastream.ActivationStatusDeactivating + activationStatus = datastream.StreamStatusDeactivating } // if stream is deactivating phase - wait until it completes - if activationStatus == datastream.ActivationStatusDeactivating { - _, err := waitForStreamStatusChange(ctx, client, streamID, datastream.ActivationStatusDeactivated) + if activationStatus == datastream.StreamStatusDeactivating { + _, err := waitForStreamStatusChange(ctx, client, streamID, datastream.StreamStatusDeactivated) if err != nil { return diag.FromErr(err) } - activationStatus = datastream.ActivationStatusDeactivated + activationStatus = datastream.StreamStatusDeactivated } // if stream is inactive - delete it - if activationStatus == datastream.ActivationStatusDeactivated || activationStatus == datastream.ActivationStatusInactive { - _, err := client.DeleteStream(ctx, datastream.DeleteStreamRequest{ + if activationStatus == datastream.StreamStatusDeactivated || activationStatus == datastream.StreamStatusInactive { + err := client.DeleteStream(ctx, datastream.DeleteStreamRequest{ StreamID: streamID, }) @@ -1398,8 +1358,8 @@ func resourceDatastreamDelete(ctx context.Context, d *schema.ResourceData, m int return nil } -func waitForStreamStatusChange(ctx context.Context, client datastream.DS, streamID int64, expectedStatuses ...datastream.ActivationStatus) (*datastream.ActivationStatus, error) { - expectedStatusesMap := map[datastream.ActivationStatus]bool{} +func waitForStreamStatusChange(ctx context.Context, client datastream.DS, streamID int64, expectedStatuses ...datastream.StreamStatus) (*datastream.StreamStatus, error) { + expectedStatusesMap := map[datastream.StreamStatus]bool{} for _, status := range expectedStatuses { expectedStatusesMap[status] = true } @@ -1413,8 +1373,8 @@ func waitForStreamStatusChange(ctx context.Context, client datastream.DS, stream return nil, err } - _, ok := expectedStatusesMap[streamDetails.ActivationStatus] - for ; !ok; _, ok = expectedStatusesMap[streamDetails.ActivationStatus] { + _, ok := expectedStatusesMap[streamDetails.StreamStatus] + for ; !ok; _, ok = expectedStatusesMap[streamDetails.StreamStatus] { select { case <-time.After(PollForActivationStatusChangeInterval): streamDetails, err = client.GetStream(ctx, getStreamReq) @@ -1427,83 +1387,19 @@ func waitForStreamStatusChange(ctx context.Context, client datastream.DS, stream } } - return &streamDetails.ActivationStatus, nil -} - -func urlSuppressor(keyToSuppress string) schema.SchemaDiffSuppressFunc { - return func(resourceKey string, _, _ string, d *schema.ResourceData) bool { - logger := akamai.Log("DataStream", "urlSuppressor") - - // do not suppress when creating the resource - if d.Id() == "" { - logger.Infof("%s creating resource", resourceKey) - return false - } - - resourceKeyTokens := strings.Split(resourceKey, ".") // connector_name.ID.propertyName - connectorName := resourceKeyTokens[0] - if !d.HasChange(connectorName) { - logger.Infof("%s hasn't changed", connectorName) - return false - } - - oldConnectorObj, newConnectorObj := d.GetChange(connectorName) - oldSet, newSet := oldConnectorObj.(*schema.Set), newConnectorObj.(*schema.Set) - if oldSet.Len() != 1 || newSet.Len() != 1 { - return false - } - - oldElem, oldOk := oldSet.List()[0].(map[string]interface{}) - newElem, newOk := newSet.List()[0].(map[string]interface{}) - if !newOk || !oldOk { - return false - } - - // trim url - newElem[keyToSuppress] = strings.TrimRight(newElem[keyToSuppress].(string), "/?") - - // skip computed properties because they cannot be set - propertiesToSkip := map[string]bool{ - "connector_id": true, - } - - // do the comparison - for propertyName, oldVal := range oldElem { - if _, ok := propertiesToSkip[propertyName]; ok { - continue - } - newVal, ok := newElem[propertyName] - // if property does not exist in old element, do not suppress change - if !ok { - logger.Debug("Change detected") - return false - } - - logger.Debugf("Comparing %s - [%v] and [%v]", propertyName, newVal, oldVal) - - // if values are different, do not suppress change - if newVal != oldVal { - logger.Debug("Change detected") - return false - } - } - - // all values are the same, suppress the change - logger.Debug("No change detected") - return true - } + return &streamDetails.StreamStatus, nil } func isOrderDifferent(_, oldIDValue, newIDValue string, d *schema.ResourceData) bool { - key := "dataset_fields_ids" + key := "dataset_fields" - logger := akamai.Log("DataStream", "isOrderDifferent") + logger := logger.Get("DataStream", "isOrderDifferent") defaultDiff := func() bool { return oldIDValue == newIDValue } - configSet, err := tf.GetSetValue("config", d) + configSet, err := tf.GetSetValue("delivery_configuration", d) if err != nil { logger.Warn("unable to get config for datastream") return defaultDiff() @@ -1586,7 +1482,7 @@ func validateConfig(_ context.Context, d *schema.ResourceDiff, _ interface{}) er return nil } - configResource, exists := d.GetOkExists("config") + configResource, exists := d.GetOkExists("delivery_configuration") if !exists { return nil } diff --git a/pkg/providers/datastream/resource_akamai_datastream_test.go b/pkg/providers/datastream/resource_akamai_datastream_test.go index e27a15f25..edc267408 100644 --- a/pkg/providers/datastream/resource_akamai_datastream_test.go +++ b/pkg/providers/datastream/resource_akamai_datastream_test.go @@ -8,8 +8,10 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/tools" + "github.com/stretchr/testify/require" + "github.com/tj/assert" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -25,77 +27,163 @@ func TestResourceStream(t *testing.T) { PollForActivationStatusChangeInterval = 1 * time.Millisecond streamConfiguration := datastream.StreamConfiguration{ - ActivateNow: true, - Config: datastream.Config{ + CollectMidgress: false, + DeliveryConfiguration: datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: "pre", UploadFileSuffix: "suf", }, - Connectors: []datastream.AbstractConnector{ + Destination: datastream.AbstractConnector( &datastream.S3Connector{ AccessKey: "s3_test_access_key", Bucket: "s3_test_bucket", - ConnectorName: "s3_test_connector_name", + DisplayName: "s3_test_connector_name", Path: "s3_test_path", Region: "s3_test_region", SecretAccessKey: "s3_test_secret_key", }, + ), + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, + { + DatasetFieldID: 1002, + }, + { + DatasetFieldID: 2000, + }, + { + DatasetFieldID: 2001, + }, }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001, 1002, 2000, 2001}, - EmailIDs: "test_email1@akamai.com,test_email2@akamai.com", - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1, 2, 3}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, + NotificationEmails: []string{"test_email1@akamai.com", "test_email2@akamai.com"}, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, + }, + { + PropertyID: 2, + }, + { + PropertyID: 3, + }, + }, + StreamName: "test_stream", } createStreamRequest := datastream.CreateStreamRequest{ StreamConfiguration: streamConfiguration, + Activate: true, } - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamName: streamConfiguration.StreamName, + StreamID: streamID, + StreamVersion: 1, + GroupID: streamConfiguration.GroupID, + ContractID: streamConfiguration.ContractID, + NotificationEmails: streamConfiguration.NotificationEmails, + Properties: []datastream.Property{ + { + PropertyID: 1, + PropertyName: "property_1", + }, + { + PropertyID: 2, + PropertyName: "property_2", + }, + { + PropertyID: 3, + PropertyName: "property_3", + }, }, + DatasetFields: []datastream.DataSetField{ + { + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", + }, + { + DatasetFieldID: 1002, + DatasetFieldName: "dataset_field_name_2", + DatasetFieldDescription: "dataset_field_desc_2", + }, + { + DatasetFieldID: 2000, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", + }, + { + DatasetFieldID: 2001, + DatasetFieldName: "dataset_field_name_2", + DatasetFieldDescription: "dataset_field_desc_2", + }, + }, + Destination: datastream.Destination{ + Bucket: "s3_test_bucket", + DestinationType: datastream.DestinationTypeS3, + DisplayName: "s3_test_connector_name", + Path: "s3_test_path", + Region: "s3_test_region", + }, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + LatestVersion: 1, + ProductID: "Download_Delivery", + CreatedBy: "johndoe", + CreatedDate: "10-07-2020 12:19:02 GMT", + StreamStatus: datastream.StreamStatusActivating, + ModifiedBy: "janesmith", + ModifiedDate: "15-07-2020 05:51:52 GMT", } updateStreamRequest := datastream.UpdateStreamRequest{ StreamID: 12321, + Activate: true, StreamConfiguration: datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: "prefix_updated", UploadFileSuffix: "suf_updated", }, - Connectors: []datastream.AbstractConnector{ + Destination: datastream.AbstractConnector( &datastream.S3Connector{ AccessKey: "s3_test_access_key", Bucket: "s3_test_bucket_updated", - ConnectorName: "s3_test_connector_name_updated", + DisplayName: "s3_test_connector_name_updated", Path: "s3_test_path", Region: "s3_test_region", SecretAccessKey: "s3_test_secret_key", }, + ), + ContractID: streamConfiguration.ContractID, + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 2000, + }, + { + DatasetFieldID: 1002, + }, + { + DatasetFieldID: 2001, + }, + { + DatasetFieldID: 1001, + }, }, - ContractID: streamConfiguration.ContractID, - DatasetFieldIDs: []int{2000, 1002, 2001, 1001}, - EmailIDs: "test_email1_updated@akamai.com,test_email2@akamai.com", - PropertyIDs: streamConfiguration.PropertyIDs, - StreamName: "test_stream_with_updated", - StreamType: streamConfiguration.StreamType, - TemplateName: streamConfiguration.TemplateName, + NotificationEmails: []string{"test_email1_updated@akamai.com", "test_email2@akamai.com"}, + Properties: streamConfiguration.Properties, + StreamName: "test_stream_with_updated", }, } @@ -105,66 +193,45 @@ func TestResourceStream(t *testing.T) { } getStreamResponseActivated := &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusActivated, - Config: streamConfiguration.Config, - Connectors: []datastream.ConnectorDetails{ - { - Bucket: "s3_test_bucket", - ConnectorType: datastream.ConnectorTypeS3, - ConnectorName: "s3_test_connector_name", - Path: "s3_test_path", - Region: "s3_test_region", - }, + StreamStatus: datastream.StreamStatusActivated, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + Destination: datastream.Destination{ + Bucket: "s3_test_bucket", + DestinationType: datastream.DestinationTypeS3, + DisplayName: "s3_test_connector_name", + Path: "s3_test_path", + Region: "s3_test_region", }, ContractID: streamConfiguration.ContractID, CreatedBy: "johndoe", CreatedDate: "10-07-2020 12:19:02 GMT", - Datasets: []datastream.DataSets{ + DatasetFields: []datastream.DataSetField{ { - DatasetGroupName: "group_name_1", - DatasetGroupDescription: "group_desc_1", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - DatasetFieldName: "dataset_field_name_1", - DatasetFieldDescription: "dataset_field_desc_1", - Order: 0, - }, - { - DatasetFieldID: 1002, - DatasetFieldName: "dataset_field_name_2", - DatasetFieldDescription: "dataset_field_desc_2", - Order: 1, - }, - }, + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, { - DatasetGroupName: "group_name_2", - DatasetGroupDescription: "group_desc_2", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 2000, - DatasetFieldName: "dataset_field_name_1", - DatasetFieldDescription: "dataset_field_desc_1", - Order: 2, - }, - { - DatasetFieldID: 2001, - DatasetFieldName: "dataset_field_name_2", - DatasetFieldDescription: "dataset_field_desc_2", - Order: 3, - }, - }, + DatasetFieldID: 1002, + DatasetFieldName: "dataset_field_name_2", + DatasetFieldDescription: "dataset_field_desc_2", + }, + { + DatasetFieldID: 2000, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", + }, + { + DatasetFieldID: 2001, + DatasetFieldName: "dataset_field_name_2", + DatasetFieldDescription: "dataset_field_desc_2", }, }, - EmailIDs: streamConfiguration.EmailIDs, - Errors: nil, - GroupID: *streamConfiguration.GroupID, - GroupName: "Default Group-1-ABCDE", - ModifiedBy: "janesmith", - ModifiedDate: "15-07-2020 05:51:52 GMT", - ProductID: "Download_Delivery", - ProductName: "Download Delivery", + NotificationEmails: streamConfiguration.NotificationEmails, + GroupID: streamConfiguration.GroupID, + ModifiedBy: "janesmith", + ModifiedDate: "15-07-2020 05:51:52 GMT", + ProductID: "Download_Delivery", Properties: []datastream.Property{ { PropertyID: 1, @@ -179,86 +246,67 @@ func TestResourceStream(t *testing.T) { PropertyName: "property_3", }, }, - StreamID: updateStreamResponse.StreamVersionKey.StreamID, - StreamName: streamConfiguration.StreamName, - StreamType: streamConfiguration.StreamType, - StreamVersionID: updateStreamResponse.StreamVersionKey.StreamVersionID, - TemplateName: streamConfiguration.TemplateName, + StreamID: updateStreamResponse.StreamID, + StreamName: streamConfiguration.StreamName, + StreamVersion: updateStreamResponse.StreamVersion, } getStreamResponseStreamActivating := modifyResponse(*getStreamResponseActivated, func(r *datastream.DetailedStreamVersion) { - r.ActivationStatus = datastream.ActivationStatusActivating + r.StreamStatus = datastream.StreamStatusActivating }) getStreamResponseStreamActivatingAfterUpdate := modifyResponse(*getStreamResponseActivated, func(r *datastream.DetailedStreamVersion) { - r.Config = datastream.Config{ - Delimiter: updateStreamRequest.StreamConfiguration.Config.Delimiter, - Format: updateStreamRequest.StreamConfiguration.Config.Format, - Frequency: updateStreamRequest.StreamConfiguration.Config.Frequency, - UploadFilePrefix: updateStreamRequest.StreamConfiguration.Config.UploadFilePrefix, - UploadFileSuffix: updateStreamRequest.StreamConfiguration.Config.UploadFileSuffix, + r.DeliveryConfiguration = datastream.DeliveryConfiguration{ + Delimiter: updateStreamRequest.StreamConfiguration.DeliveryConfiguration.Delimiter, + Format: updateStreamRequest.StreamConfiguration.DeliveryConfiguration.Format, + Frequency: updateStreamRequest.StreamConfiguration.DeliveryConfiguration.Frequency, + UploadFilePrefix: updateStreamRequest.StreamConfiguration.DeliveryConfiguration.UploadFilePrefix, + UploadFileSuffix: updateStreamRequest.StreamConfiguration.DeliveryConfiguration.UploadFileSuffix, } - r.EmailIDs = updateStreamRequest.StreamConfiguration.EmailIDs + r.NotificationEmails = updateStreamRequest.StreamConfiguration.NotificationEmails r.StreamName = updateStreamRequest.StreamConfiguration.StreamName - r.Connectors = []datastream.ConnectorDetails{ + r.Destination = datastream.Destination{ + + Bucket: "s3_test_bucket_updated", + DestinationType: datastream.DestinationTypeS3, + DisplayName: "s3_test_connector_name_updated", + Path: "s3_test_path", + Region: "s3_test_region", + } + r.DatasetFields = []datastream.DataSetField{ { - Bucket: "s3_test_bucket_updated", - ConnectorType: datastream.ConnectorTypeS3, - ConnectorName: "s3_test_connector_name_updated", - Path: "s3_test_path", - Region: "s3_test_region", + DatasetFieldID: 2000, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, - } - r.Datasets = []datastream.DataSets{ { - DatasetGroupName: "group_name_1", - DatasetGroupDescription: "group_desc_1", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - DatasetFieldName: "dataset_field_name_1", - DatasetFieldDescription: "dataset_field_desc_1", - Order: 3, - }, - { - DatasetFieldID: 1002, - DatasetFieldName: "dataset_field_name_2", - DatasetFieldDescription: "dataset_field_desc_2", - Order: 1, - }, - }, + DatasetFieldID: 1002, + DatasetFieldName: "dataset_field_name_2", + DatasetFieldDescription: "dataset_field_desc_2", }, { - DatasetGroupName: "group_name_2", - DatasetGroupDescription: "group_desc_2", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 2000, - DatasetFieldName: "dataset_field_name_1", - DatasetFieldDescription: "dataset_field_desc_1", - Order: 0, - }, - { - DatasetFieldID: 2001, - DatasetFieldName: "dataset_field_name_2", - DatasetFieldDescription: "dataset_field_desc_2", - Order: 2, - }, - }, + DatasetFieldID: 2001, + DatasetFieldName: "dataset_field_name_2", + DatasetFieldDescription: "dataset_field_desc_2", + }, + { + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, } }) getStreamResponseStreamActivatedAfterUpdate := modifyResponse(*getStreamResponseStreamActivatingAfterUpdate, func(r *datastream.DetailedStreamVersion) { - r.ActivationStatus = datastream.ActivationStatusActivated + r.StreamStatus = datastream.StreamStatusActivated }) getStreamResponseDeactivating := modifyResponse(*getStreamResponseStreamActivatedAfterUpdate, func(r *datastream.DetailedStreamVersion) { - r.ActivationStatus = datastream.ActivationStatusDeactivating + r.StreamStatus = datastream.StreamStatusDeactivating }) getStreamResponseDeactivated := modifyResponse(*getStreamResponseStreamActivatedAfterUpdate, func(r *datastream.DetailedStreamVersion) { - r.ActivationStatus = datastream.ActivationStatusDeactivated + r.StreamStatus = datastream.StreamStatusDeactivated }) getStreamRequest := datastream.GetStreamRequest{ @@ -299,15 +347,13 @@ func TestResourceStream(t *testing.T) { client.On("DeleteStream", mock.Anything, datastream.DeleteStreamRequest{ StreamID: streamID, - }).Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil).Once() + }).Return(' ', nil).Once() client.On("DeactivateStream", mock.Anything, datastream.DeactivateStreamRequest{ StreamID: 12321, - }).Return(&datastream.DeactivateStreamResponse{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, + }).Return(&datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, }, nil).Once() // for waitForStreamStatusChange @@ -329,31 +375,30 @@ func TestResourceStream(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "id", strconv.FormatInt(streamID, 10)), resource.TestCheckResourceAttr("akamai_datastream.s", "active", "true"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.delimiter", string(datastream.DelimiterTypeSpace)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.format", string(datastream.FormatTypeStructured)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.upload_file_prefix", "pre"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.upload_file_suffix", "suf"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.frequency.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.frequency.0.time_in_sec", "30"), + resource.TestCheckResourceAttr("akamai_datastream.s", "collect_midgress", "false"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.field_delimiter", string(datastream.DelimiterTypeSpace)), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.format", string(datastream.FormatTypeStructured)), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.upload_file_prefix", "pre"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.upload_file_suffix", "suf"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.frequency.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.frequency.0.interval_in_secs", "30"), resource.TestCheckResourceAttr("akamai_datastream.s", "contract_id", "test_contract"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.#", "4"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.0", "1001"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.1", "1002"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.2", "2000"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.3", "2001"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.#", "2"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.0", "test_email1@akamai.com"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.1", "test_email2@akamai.com"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.#", "4"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.0", "1001"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.1", "1002"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.2", "2000"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.3", "2001"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.#", "2"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.0", "test_email1@akamai.com"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.1", "test_email2@akamai.com"), resource.TestCheckResourceAttr("akamai_datastream.s", "group_id", "1337"), - resource.TestCheckResourceAttr("akamai_datastream.s", "property_ids.#", "3"), + resource.TestCheckResourceAttr("akamai_datastream.s", "properties.#", "3"), resource.TestCheckResourceAttr("akamai_datastream.s", "stream_name", "test_stream"), - resource.TestCheckResourceAttr("akamai_datastream.s", "stream_type", string(datastream.StreamTypeRawLogs)), - resource.TestCheckResourceAttr("akamai_datastream.s", "template_name", string(datastream.TemplateNameEdgeLogs)), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.access_key", "s3_test_access_key"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.bucket", "s3_test_bucket"), - resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.connector_name", "s3_test_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.display_name", "s3_test_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.path", "s3_test_path"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.region", "s3_test_region"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.secret_access_key", "s3_test_secret_key"), @@ -364,31 +409,30 @@ func TestResourceStream(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "id", strconv.FormatInt(streamID, 10)), resource.TestCheckResourceAttr("akamai_datastream.s", "active", "true"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.delimiter", string(datastream.DelimiterTypeSpace)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.format", string(datastream.FormatTypeStructured)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.upload_file_prefix", "prefix_updated"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.upload_file_suffix", "suf_updated"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.frequency.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.frequency.0.time_in_sec", "30"), + resource.TestCheckResourceAttr("akamai_datastream.s", "collect_midgress", "false"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.field_delimiter", string(datastream.DelimiterTypeSpace)), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.format", string(datastream.FormatTypeStructured)), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.upload_file_prefix", "prefix_updated"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.upload_file_suffix", "suf_updated"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.frequency.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.frequency.0.interval_in_secs", "30"), resource.TestCheckResourceAttr("akamai_datastream.s", "contract_id", "test_contract"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.#", "4"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.0", "2000"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.1", "1002"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.2", "2001"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.3", "1001"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.#", "2"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.0", "test_email1_updated@akamai.com"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.1", "test_email2@akamai.com"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.#", "4"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.0", "2000"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.1", "1002"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.2", "2001"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.3", "1001"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.#", "2"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.0", "test_email1_updated@akamai.com"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.1", "test_email2@akamai.com"), resource.TestCheckResourceAttr("akamai_datastream.s", "group_id", "1337"), - resource.TestCheckResourceAttr("akamai_datastream.s", "property_ids.#", "3"), + resource.TestCheckResourceAttr("akamai_datastream.s", "properties.#", "3"), resource.TestCheckResourceAttr("akamai_datastream.s", "stream_name", "test_stream_with_updated"), - resource.TestCheckResourceAttr("akamai_datastream.s", "stream_type", string(datastream.StreamTypeRawLogs)), - resource.TestCheckResourceAttr("akamai_datastream.s", "template_name", string(datastream.TemplateNameEdgeLogs)), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.access_key", "s3_test_access_key"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.bucket", "s3_test_bucket_updated"), - resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.connector_name", "s3_test_connector_name_updated"), + resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.display_name", "s3_test_connector_name_updated"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.path", "s3_test_path"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.region", "s3_test_region"), resource.TestCheckResourceAttr("akamai_datastream.s", "s3_connector.0.secret_access_key", "s3_test_secret_key"), @@ -421,88 +465,115 @@ func TestResourceUpdate(t *testing.T) { UpdateStreamActive: true, }, } - - streamConfigurationFactory := func(activateNow bool) datastream.StreamConfiguration { - return datastream.StreamConfiguration{ - ActivateNow: activateNow, - Config: datastream.Config{ - Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), - Format: datastream.FormatTypeStructured, - Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, - }, - UploadFilePrefix: "pre", - UploadFileSuffix: "suf", + streamConfiguration := datastream.StreamConfiguration{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ + Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), + Format: datastream.FormatTypeStructured, + Frequency: datastream.Frequency{ + IntervalInSeconds: datastream.IntervalInSeconds30, }, - Connectors: []datastream.AbstractConnector{ - &datastream.OracleCloudStorageConnector{ - AccessKey: "access_key", - Bucket: "bucket", - ConnectorName: "connector_name", - Namespace: "namespace", - Path: "path", - Region: "region", - SecretAccessKey: "secret_access_key", - }, - }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001}, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, - } + UploadFilePrefix: "pre", + UploadFileSuffix: "suf", + }, + Destination: datastream.AbstractConnector( + &datastream.OracleCloudStorageConnector{ + AccessKey: "access_key", + Bucket: "bucket", + DisplayName: "display_name", + Namespace: "namespace", + Path: "path", + Region: "region", + SecretAccessKey: "secret_access_key", + }, + ), + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, + }, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, + }, + }, + StreamName: "test_stream", + } + streamConfigurationFactory := func() datastream.StreamConfiguration { + return streamConfiguration } createStreamRequestFactory := func(activateNow bool) datastream.CreateStreamRequest { return datastream.CreateStreamRequest{ - StreamConfiguration: streamConfigurationFactory(activateNow), + StreamConfiguration: streamConfigurationFactory(), + Activate: activateNow, } } - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 2, + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamName: streamConfiguration.StreamName, + StreamID: streamID, + StreamVersion: 2, + GroupID: streamConfiguration.GroupID, + ContractID: streamConfiguration.ContractID, + Properties: []datastream.Property{ + { + PropertyID: 1, + PropertyName: "property_1", + }, }, + DatasetFields: []datastream.DataSetField{ + { + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", + }, + }, + Destination: datastream.Destination{ + DestinationType: datastream.DestinationTypeOracle, + Bucket: "bucket", + DisplayName: "display_name", + Namespace: "namespace", + Path: "path", + Region: "region", + }, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + LatestVersion: 2, + ProductID: "Download_Delivery", + CreatedBy: "johndoe", + CreatedDate: "10-07-2020 12:19:02 GMT", + StreamStatus: datastream.StreamStatusActivating, + ModifiedBy: "janesmith", + ModifiedDate: "15-07-2020 05:51:52 GMT", } - responseFactory := func(activationStatus datastream.ActivationStatus) *datastream.DetailedStreamVersion { + responseFactory := func(activationStatus datastream.StreamStatus) *datastream.DetailedStreamVersion { return &datastream.DetailedStreamVersion{ - ActivationStatus: activationStatus, - Config: datastream.Config{ + StreamStatus: activationStatus, + DeliveryConfiguration: datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: "pre", UploadFileSuffix: "suf", }, - Connectors: []datastream.ConnectorDetails{ - { - Bucket: "bucket", - ConnectorName: "connector_name", - ConnectorType: datastream.ConnectorTypeOracle, - Namespace: "namespace", - Path: "path", - Region: "region", - }, + Destination: datastream.Destination{ + Bucket: "bucket", + DisplayName: "display_name", + DestinationType: datastream.DestinationTypeOracle, + Namespace: "namespace", + Path: "path", + Region: "region", }, ContractID: "test_contract", - Datasets: []datastream.DataSets{ + DatasetFields: []datastream.DataSetField{ { - DatasetGroupName: "group_name_1", - DatasetGroupDescription: "group_desc_1", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - DatasetFieldName: "dataset_field_name_1", - DatasetFieldDescription: "dataset_field_desc_1", - Order: 0, - }, - }, + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, }, GroupID: 1337, @@ -512,33 +583,33 @@ func TestResourceUpdate(t *testing.T) { PropertyName: "property_1", }, }, - StreamID: streamID, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - StreamVersionID: 1, - TemplateName: datastream.TemplateNameEdgeLogs, + StreamID: streamID, + StreamName: "test_stream", + StreamVersion: 1, + LatestVersion: 1, + ProductID: "API_Acceleration", } } commonChecks := resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "id", strconv.FormatInt(streamID, 10)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.delimiter", string(datastream.DelimiterTypeSpace)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.format", string(datastream.FormatTypeStructured)), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.upload_file_prefix", "pre"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.upload_file_suffix", "suf"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.frequency.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "config.0.frequency.0.time_in_sec", "30"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.field_delimiter", string(datastream.DelimiterTypeSpace)), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.format", string(datastream.FormatTypeStructured)), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.upload_file_prefix", "pre"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.upload_file_suffix", "suf"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.frequency.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "delivery_configuration.0.frequency.0.interval_in_secs", "30"), resource.TestCheckResourceAttr("akamai_datastream.s", "contract_id", "test_contract"), - resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields_ids.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "dataset_fields.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "group_id", "1337"), - resource.TestCheckResourceAttr("akamai_datastream.s", "property_ids.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "properties.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "stream_name", "test_stream"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.access_key", "access_key"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.bucket", "bucket"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.compress_logs", "false"), - resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.namespace", "namespace"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.path", "path"), resource.TestCheckResourceAttr("akamai_datastream.s", "oracle_connector.0.region", "region"), @@ -546,7 +617,7 @@ func TestResourceUpdate(t *testing.T) { ) type mockConfig struct { - status datastream.ActivationStatus + status datastream.StreamStatus repeats int } @@ -570,14 +641,14 @@ func TestResourceUpdate(t *testing.T) { createStreamFilenameSuffix = "active" configureMock(m, []mockConfig{ - {status: datastream.ActivationStatusActivating, repeats: 1}, - {status: datastream.ActivationStatusActivated, repeats: 5}, + {status: datastream.StreamStatusActivating, repeats: 1}, + {status: datastream.StreamStatusActivated, repeats: 5}, }...) } else { createStreamFilenameSuffix = "inactive" configureMock(m, []mockConfig{ - {status: datastream.ActivationStatusInactive, repeats: 6}, + {status: datastream.StreamStatusInactive, repeats: 6}, }...) } @@ -586,20 +657,20 @@ func TestResourceUpdate(t *testing.T) { if test.CreateStreamActive { configureMock(m, []mockConfig{ - {status: datastream.ActivationStatusActivated, repeats: 2}, - {status: datastream.ActivationStatusActivating, repeats: 1}, - {status: datastream.ActivationStatusActivated, repeats: 3}, + {status: datastream.StreamStatusActivated, repeats: 2}, + {status: datastream.StreamStatusActivating, repeats: 1}, + {status: datastream.StreamStatusActivated, repeats: 3}, }...) } else { m.On("ActivateStream", mock.Anything, mock.Anything). - Return(&datastream.ActivateStreamResponse{ - StreamVersionKey: updateStreamResponse.StreamVersionKey, + Return(&datastream.DetailedStreamVersion{ + StreamVersion: updateStreamResponse.StreamVersion, }, nil). Once() configureMock(m, []mockConfig{ - {status: datastream.ActivationStatusActivating, repeats: 1}, - {status: datastream.ActivationStatusActivated, repeats: 5}, + {status: datastream.StreamStatusActivating, repeats: 1}, + {status: datastream.StreamStatusActivated, repeats: 5}, }...) } } else { @@ -607,28 +678,28 @@ func TestResourceUpdate(t *testing.T) { if test.CreateStreamActive { configureMock(m, []mockConfig{ - {status: datastream.ActivationStatusActivated, repeats: 2}, - {status: datastream.ActivationStatusDeactivating, repeats: 1}, - {status: datastream.ActivationStatusDeactivated, repeats: 4}, + {status: datastream.StreamStatusActivated, repeats: 2}, + {status: datastream.StreamStatusDeactivating, repeats: 1}, + {status: datastream.StreamStatusDeactivated, repeats: 4}, }...) } } // DeleteStream method will deactivate the stream m.On("DeactivateStream", mock.Anything, mock.Anything). - Return(&datastream.DeactivateStreamResponse{ - StreamVersionKey: updateStreamResponse.StreamVersionKey, + Return(&datastream.DetailedStreamVersion{ + StreamVersion: updateStreamResponse.StreamVersion, }, nil). Once() // waitForStreamStatusChange in DeleteStream configureMock(m, []mockConfig{ - {status: datastream.ActivationStatusDeactivating, repeats: 1}, - {status: datastream.ActivationStatusDeactivated, repeats: 1}, + {status: datastream.StreamStatusDeactivating, repeats: 1}, + {status: datastream.StreamStatusDeactivated, repeats: 1}, }...) m.On("DeleteStream", mock.Anything, mock.Anything). - Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil). + Return(' ', nil). Once() useClient(m, func() { @@ -658,168 +729,6 @@ func TestResourceUpdate(t *testing.T) { } } -func TestEmailIDs(t *testing.T) { - streamConfiguration := datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ - Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), - Format: datastream.FormatTypeStructured, - Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, - }, - UploadFilePrefix: DefaultUploadFilePrefix, - UploadFileSuffix: DefaultUploadFileSuffix, - }, - Connectors: []datastream.AbstractConnector{ - &datastream.SplunkConnector{ - CompressLogs: false, - ConnectorName: "splunk_test_connector_name", - EventCollectorToken: "splunk_event_collector_token", - URL: "splunk_url", - }, - }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001}, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, - } - - createStreamRequestFactory := func(emailIDs string) datastream.CreateStreamRequest { - streamConfigurationWithEmailIDs := streamConfiguration - if emailIDs != "" { - streamConfigurationWithEmailIDs.EmailIDs = emailIDs - } - return datastream.CreateStreamRequest{ - StreamConfiguration: streamConfigurationWithEmailIDs, - } - } - - responseFactory := func(emailIDs string) *datastream.DetailedStreamVersion { - return &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusInactive, - Config: streamConfiguration.Config, - Connectors: []datastream.ConnectorDetails{ - { - ConnectorType: datastream.ConnectorTypeSplunk, - CompressLogs: false, - ConnectorName: "splunk_test_connector_name", - URL: "splunk_url", - }, - }, - ContractID: streamConfiguration.ContractID, - Datasets: []datastream.DataSets{ - { - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - Order: 0, - }, - }, - }, - }, - EmailIDs: emailIDs, - GroupID: *streamConfiguration.GroupID, - Properties: []datastream.Property{ - { - PropertyID: 1, - PropertyName: "property_1", - }, - }, - StreamID: streamID, - StreamName: streamConfiguration.StreamName, - StreamType: streamConfiguration.StreamType, - StreamVersionID: 2, - TemplateName: streamConfiguration.TemplateName, - } - } - - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, - } - - getStreamRequest := datastream.GetStreamRequest{ - StreamID: streamID, - } - - tests := map[string]struct { - Filename string - Response *datastream.DetailedStreamVersion - EmailIDs string - TestChecks []resource.TestCheckFunc - }{ - "two emails": { - Filename: "two_emails.tf", - EmailIDs: "test_email1@akamai.com,test_email2@akamai.com", - TestChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.#", "2"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.0", "test_email1@akamai.com"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.1", "test_email2@akamai.com"), - }, - }, - "one email": { - Filename: "one_email.tf", - EmailIDs: "test_email1@akamai.com", - TestChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.0", "test_email1@akamai.com"), - }, - }, - "empty email": { - Filename: "empty_email_ids.tf", - EmailIDs: "", - TestChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.#", "0"), - }, - }, - "no email_ids field": { - Filename: "no_email_ids.tf", - EmailIDs: "", - TestChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttr("akamai_datastream.s", "email_ids.#", "0"), - }, - }, - } - - for name, test := range tests { - t.Run(name, func(t *testing.T) { - client := &datastream.Mock{} - - createStreamRequest := createStreamRequestFactory(test.EmailIDs) - client.On("CreateStream", mock.Anything, createStreamRequest). - Return(updateStreamResponse, nil) - - getStreamResponse := responseFactory(test.EmailIDs) - client.On("GetStream", mock.Anything, getStreamRequest). - Return(getStreamResponse, nil) - - client.On("DeleteStream", mock.Anything, datastream.DeleteStreamRequest{ - StreamID: streamID, - }).Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil) - - useClient(client, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{ - { - Config: loadFixtureString(fmt.Sprintf("testdata/TestResourceStream/email_ids/%s", test.Filename)), - Check: resource.ComposeTestCheckFunc(test.TestChecks...), - }, - }, - }) - - client.AssertExpectations(t) - }) - }) - } - -} - func TestResourceStreamErrors(t *testing.T) { tests := map[string]struct { tfFile string @@ -949,52 +858,245 @@ func TestResourceStreamCustomDiff(t *testing.T) { } } +func TestEmailIDs(t *testing.T) { + streamConfiguration := datastream.StreamConfiguration{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ + Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), + Format: datastream.FormatTypeStructured, + Frequency: datastream.Frequency{ + IntervalInSeconds: datastream.IntervalInSeconds30, + }, + // UploadFilePrefix: DefaultUploadFilePrefix, + // UploadFileSuffix: DefaultUploadFileSuffix, + }, + Destination: datastream.AbstractConnector( + &datastream.SplunkConnector{ + CompressLogs: false, + DisplayName: "splunk_test_connector_name", + EventCollectorToken: "splunk_event_collector_token", + Endpoint: "splunk_url", + }, + ), + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, + }, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, + }, + }, + StreamName: "test_stream", + } + + createStreamRequestFactory := func(emailIDs []string) datastream.CreateStreamRequest { + streamConfigurationWithEmailIDs := streamConfiguration + if emailIDs != nil && len(emailIDs) != 0 { + streamConfigurationWithEmailIDs.NotificationEmails = emailIDs + } + return datastream.CreateStreamRequest{ + StreamConfiguration: streamConfigurationWithEmailIDs, + Activate: false, + } + } + + responseFactory := func(emailIDs []string) *datastream.DetailedStreamVersion { + return &datastream.DetailedStreamVersion{ + StreamStatus: datastream.StreamStatusInactive, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + Destination: datastream.Destination{ + DestinationType: datastream.DestinationTypeSplunk, + CompressLogs: false, + DisplayName: "splunk_test_connector_name", + Endpoint: "splunk_url", + }, + ContractID: streamConfiguration.ContractID, + DatasetFields: []datastream.DataSetField{ + { + DatasetFieldID: 1001, + }, + }, + NotificationEmails: emailIDs, + GroupID: streamConfiguration.GroupID, + Properties: []datastream.Property{ + { + PropertyID: 1, + PropertyName: "property_1", + }, + }, + StreamID: streamID, + StreamName: streamConfiguration.StreamName, + StreamVersion: 2, + } + } + + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, + } + + getStreamRequest := datastream.GetStreamRequest{ + StreamID: streamID, + } + + tests := map[string]struct { + Filename string + Response *datastream.DetailedStreamVersion + EmailIDs []string + TestChecks []resource.TestCheckFunc + }{ + "two emails": { + Filename: "two_emails.tf", + EmailIDs: []string{"test_email1@akamai.com", "test_email2@akamai.com"}, + TestChecks: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.#", "2"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.0", "test_email1@akamai.com"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.1", "test_email2@akamai.com"), + }, + }, + "one email": { + Filename: "one_email.tf", + EmailIDs: []string{"test_email1@akamai.com"}, + TestChecks: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.#", "1"), + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.0", "test_email1@akamai.com"), + }, + }, + "empty email": { + Filename: "empty_email_ids.tf", + EmailIDs: []string{}, + TestChecks: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.#", "0"), + }, + }, + "no email_ids field": { + Filename: "no_email_ids.tf", + EmailIDs: []string{}, + TestChecks: []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("akamai_datastream.s", "notification_emails.#", "0"), + }, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &datastream.Mock{} + + createStreamRequest := createStreamRequestFactory(test.EmailIDs) + client.On("CreateStream", mock.Anything, createStreamRequest). + Return(updateStreamResponse, nil) + + getStreamResponse := responseFactory(test.EmailIDs) + client.On("GetStream", mock.Anything, getStreamRequest). + Return(getStreamResponse, nil) + + client.On("DeleteStream", mock.Anything, datastream.DeleteStreamRequest{ + StreamID: streamID, + }).Return(' ', nil) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString(fmt.Sprintf("testdata/TestResourceStream/email_ids/%s", test.Filename)), + Check: resource.ComposeTestCheckFunc(test.TestChecks...), + }, + }, + }) + + client.AssertExpectations(t) + }) + }) + } + +} + func TestDatasetIDsDiff(t *testing.T) { tests := map[string]struct { preConfig string - fileDatasetIdsOrder []int + fileDatasetIdsOrder []datastream.DatasetFieldID serverDatasetIdsOrder []int format datastream.FormatType expectNonEmptyPlan bool }{ - "order mixed in json config": { - preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config.tf", - fileDatasetIdsOrder: []int{1001, 1002}, + "no order mixed in json config": { + preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config.tf", + fileDatasetIdsOrder: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, { + DatasetFieldID: 1002, + }, + }, serverDatasetIdsOrder: []int{1002, 1001}, format: datastream.FormatTypeJson, expectNonEmptyPlan: false, }, "id change in json config": { - preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config.tf", - fileDatasetIdsOrder: []int{1001, 1002}, + preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config.tf", + fileDatasetIdsOrder: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, { + DatasetFieldID: 1002, + }, + }, serverDatasetIdsOrder: []int{1002, 1003}, format: datastream.FormatTypeJson, expectNonEmptyPlan: true, }, "duplicates in server side json config": { - preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config.tf", - fileDatasetIdsOrder: []int{1001, 1002}, + preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config.tf", + fileDatasetIdsOrder: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, { + DatasetFieldID: 1002, + }, + }, serverDatasetIdsOrder: []int{1002, 1002}, format: datastream.FormatTypeJson, expectNonEmptyPlan: true, }, "duplicates in incoming json config": { - preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config_duplicates.tf", - fileDatasetIdsOrder: []int{1002, 1002}, + preConfig: "testdata/TestResourceStream/dataset_ids_diff/json_config_duplicates.tf", + fileDatasetIdsOrder: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1002, + }, { + DatasetFieldID: 1002, + }, + }, serverDatasetIdsOrder: []int{1001, 1002}, format: datastream.FormatTypeJson, expectNonEmptyPlan: true, }, - "order mixed in structured config": { - preConfig: "testdata/TestResourceStream/dataset_ids_diff/structured_config.tf", - fileDatasetIdsOrder: []int{1001, 1002}, + "no order mixed in structured config": { + preConfig: "testdata/TestResourceStream/dataset_ids_diff/structured_config.tf", + fileDatasetIdsOrder: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, { + DatasetFieldID: 1002, + }, + }, serverDatasetIdsOrder: []int{1002, 1001}, format: datastream.FormatTypeStructured, expectNonEmptyPlan: true, }, "id change in structured config": { - preConfig: "testdata/TestResourceStream/dataset_ids_diff/structured_config.tf", - fileDatasetIdsOrder: []int{1001, 1002}, + preConfig: "testdata/TestResourceStream/dataset_ids_diff/structured_config.tf", + fileDatasetIdsOrder: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, { + DatasetFieldID: 1002, + }, + }, serverDatasetIdsOrder: []int{1002, 1003}, format: datastream.FormatTypeStructured, expectNonEmptyPlan: true, @@ -1004,45 +1106,44 @@ func TestDatasetIDsDiff(t *testing.T) { for name, test := range tests { streamConfiguration := datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ + + DeliveryConfiguration: datastream.DeliveryConfiguration{ Format: test.format, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, - UploadFilePrefix: DefaultUploadFilePrefix, - UploadFileSuffix: DefaultUploadFileSuffix, }, - Connectors: []datastream.AbstractConnector{ + Destination: datastream.AbstractConnector( &datastream.SplunkConnector{ CompressLogs: false, - ConnectorName: "splunk_test_connector_name", + DisplayName: "splunk_test_connector_name", EventCollectorToken: "splunk_event_collector_token", - URL: "splunk_url", + Endpoint: "splunk_url", + }, + ), + ContractID: "test_contract", + DatasetFields: test.fileDatasetIdsOrder, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, }, }, - ContractID: "test_contract", - DatasetFieldIDs: test.fileDatasetIdsOrder, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, + StreamName: "test_stream", } if test.format == datastream.FormatTypeStructured { - streamConfiguration.Config.Delimiter = datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace) + streamConfiguration.DeliveryConfiguration.Delimiter = datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace) } createStreamRequest := datastream.CreateStreamRequest{ StreamConfiguration: streamConfiguration, + Activate: false, } - createStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, + createStreamResponse := &datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, } getStreamRequest := datastream.GetStreamRequest{ @@ -1050,43 +1151,33 @@ func TestDatasetIDsDiff(t *testing.T) { } getStreamResponse := &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusInactive, - Config: streamConfiguration.Config, - Connectors: []datastream.ConnectorDetails{ - { - ConnectorType: datastream.ConnectorTypeSplunk, - CompressLogs: false, - ConnectorName: "splunk_test_connector_name", - URL: "splunk_url", - }, + StreamStatus: datastream.StreamStatusInactive, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + Destination: datastream.Destination{ + DestinationType: datastream.DestinationTypeSplunk, + CompressLogs: false, + DisplayName: "splunk_test_connector_name", + Endpoint: "splunk_url", }, ContractID: streamConfiguration.ContractID, - Datasets: []datastream.DataSets{ + DatasetFields: []datastream.DataSetField{ { - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: test.serverDatasetIdsOrder[0], - Order: 0, - }, - { - DatasetFieldID: test.serverDatasetIdsOrder[1], - Order: 1, - }, - }, + DatasetFieldID: test.serverDatasetIdsOrder[0], + }, + { + DatasetFieldID: test.serverDatasetIdsOrder[1], }, }, - GroupID: *streamConfiguration.GroupID, + GroupID: streamConfiguration.GroupID, Properties: []datastream.Property{ { PropertyID: 1, PropertyName: "property_1", }, }, - StreamID: streamID, - StreamName: streamConfiguration.StreamName, - StreamType: streamConfiguration.StreamType, - StreamVersionID: 2, - TemplateName: streamConfiguration.TemplateName, + StreamID: streamID, + StreamName: streamConfiguration.StreamName, + StreamVersion: 2, } deleteStreamRequest := datastream.DeleteStreamRequest{ @@ -1103,7 +1194,7 @@ func TestDatasetIDsDiff(t *testing.T) { Return(getStreamResponse, nil).Times(3) client.On("DeleteStream", mock.Anything, deleteStreamRequest). - Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil) + Return(' ', nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -1113,9 +1204,9 @@ func TestDatasetIDsDiff(t *testing.T) { Config: loadFixtureString(test.preConfig), ExpectNonEmptyPlan: test.expectNonEmptyPlan, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_datastream.splunk_stream", "dataset_fields_ids.#", "2"), - resource.TestCheckResourceAttr("akamai_datastream.splunk_stream", "dataset_fields_ids.0", strconv.Itoa(test.serverDatasetIdsOrder[0])), - resource.TestCheckResourceAttr("akamai_datastream.splunk_stream", "dataset_fields_ids.1", strconv.Itoa(test.serverDatasetIdsOrder[1])), + resource.TestCheckResourceAttr("akamai_datastream.splunk_stream", "dataset_fields.#", "2"), + resource.TestCheckResourceAttr("akamai_datastream.splunk_stream", "dataset_fields.0", strconv.Itoa(test.serverDatasetIdsOrder[0])), + resource.TestCheckResourceAttr("akamai_datastream.splunk_stream", "dataset_fields.1", strconv.Itoa(test.serverDatasetIdsOrder[1])), ), }, }, @@ -1130,64 +1221,65 @@ func TestDatasetIDsDiff(t *testing.T) { func TestCustomHeaders(t *testing.T) { streamConfiguration := datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ Format: datastream.FormatTypeJson, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, + }, + //UploadFilePrefix: DefaultUploadFilePrefix, + //UploadFileSuffix: DefaultUploadFileSuffix, + }, + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, + }, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, }, - UploadFilePrefix: DefaultUploadFilePrefix, - UploadFileSuffix: DefaultUploadFileSuffix, }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001}, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, + StreamName: "test_stream", } createStreamRequestFactory := func(connector datastream.AbstractConnector) datastream.CreateStreamRequest { streamConfigurationWithConnector := streamConfiguration - streamConfigurationWithConnector.Connectors = []datastream.AbstractConnector{ + streamConfigurationWithConnector.Destination = datastream.AbstractConnector( connector, - } + ) return datastream.CreateStreamRequest{ StreamConfiguration: streamConfigurationWithConnector, + Activate: false, } } - responseFactory := func(connector datastream.ConnectorDetails) *datastream.DetailedStreamVersion { + responseFactory := func(connector datastream.Destination) *datastream.DetailedStreamVersion { return &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusInactive, - Config: streamConfiguration.Config, - Connectors: []datastream.ConnectorDetails{ + StreamStatus: datastream.StreamStatusInactive, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + Destination: datastream.Destination( connector, - }, + ), ContractID: streamConfiguration.ContractID, - Datasets: []datastream.DataSets{ + DatasetFields: []datastream.DataSetField{ { - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - Order: 0, - }, - }, + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, }, - GroupID: *streamConfiguration.GroupID, + GroupID: streamConfiguration.GroupID, Properties: []datastream.Property{ { PropertyID: 1, PropertyName: "property_1", }, }, - StreamID: streamID, - StreamName: streamConfiguration.StreamName, - StreamType: streamConfiguration.StreamType, - StreamVersionID: 2, - TemplateName: streamConfiguration.TemplateName, + StreamID: streamID, + StreamName: streamConfiguration.StreamName, + StreamVersion: 2, } } @@ -1195,16 +1287,14 @@ func TestCustomHeaders(t *testing.T) { StreamID: streamID, } - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, } tests := map[string]struct { Filename string - Response datastream.ConnectorDetails + Response datastream.Destination Connector datastream.AbstractConnector TestChecks []resource.TestCheckFunc }{ @@ -1212,26 +1302,26 @@ func TestCustomHeaders(t *testing.T) { Filename: "custom_headers_splunk.tf", Connector: &datastream.SplunkConnector{ CompressLogs: false, - ConnectorName: "splunk_test_connector_name", + DisplayName: "splunk_test_connector_name", EventCollectorToken: "splunk_event_collector_token", - URL: "splunk_url", + Endpoint: "splunk_url", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSplunk, + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeSplunk, CompressLogs: false, - ConnectorName: "splunk_test_connector_name", - URL: "splunk_url", + DisplayName: "splunk_test_connector_name", + Endpoint: "splunk_url", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.compress_logs", "false"), - resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.connector_name", "splunk_test_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.display_name", "splunk_test_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.event_collector_token", "splunk_event_collector_token"), - resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.url", "splunk_url"), + resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.endpoint", "splunk_url"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.custom_header_name", "custom_header_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.custom_header_value", "custom_header_value"), }, @@ -1241,20 +1331,20 @@ func TestCustomHeaders(t *testing.T) { Connector: &datastream.CustomHTTPSConnector{ AuthenticationType: datastream.AuthenticationTypeBasic, CompressLogs: true, - ConnectorName: "HTTPS connector name", + DisplayName: "HTTPS connector name", Password: "password", - URL: "https_connector_url", + Endpoint: "https_connector_url", UserName: "username", ContentType: "content_type", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeHTTPS, + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeHTTPS, AuthenticationType: datastream.AuthenticationTypeBasic, CompressLogs: true, - ConnectorName: "HTTPS connector name", - URL: "https_connector_url", + DisplayName: "HTTPS connector name", + Endpoint: "https_connector_url", ContentType: "content_type", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", @@ -1262,12 +1352,12 @@ func TestCustomHeaders(t *testing.T) { TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.authentication_type", "BASIC"), - resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.connector_name", "HTTPS connector name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.display_name", "HTTPS connector name"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.compress_logs", "true"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.content_type", "content_type"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.custom_header_name", "custom_header_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.custom_header_value", "custom_header_value"), - resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.url", "https_connector_url"), + resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.endpoint", "https_connector_url"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.user_name", "username"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.password", "password"), }, @@ -1277,16 +1367,16 @@ func TestCustomHeaders(t *testing.T) { Connector: &datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "Sumologic connector name", + DisplayName: "Sumologic connector name", Endpoint: "endpoint", ContentType: "content_type", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, CompressLogs: true, - ConnectorName: "Sumologic connector name", + DisplayName: "Sumologic connector name", Endpoint: "endpoint", ContentType: "content_type", CustomHeaderName: "custom_header_name", @@ -1295,7 +1385,7 @@ func TestCustomHeaders(t *testing.T) { TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "Sumologic connector name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "Sumologic connector name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.compress_logs", "true"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.content_type", "content_type"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.custom_header_name", "custom_header_name"), @@ -1306,7 +1396,7 @@ func TestCustomHeaders(t *testing.T) { "loggly": { Filename: "custom_headers_loggly.tf", Connector: &datastream.LogglyConnector{ - ConnectorName: "loggly_connector_name", + DisplayName: "loggly_connector_name", Endpoint: "endpoint", AuthToken: "auth_token", Tags: "tag1,tag2,tag3", @@ -1314,9 +1404,9 @@ func TestCustomHeaders(t *testing.T) { CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeLoggly, - ConnectorName: "loggly_connector_name", + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeLoggly, + DisplayName: "loggly_connector_name", Endpoint: "endpoint", Tags: "tag1,tag2,tag3", ContentType: "content_type", @@ -1325,7 +1415,7 @@ func TestCustomHeaders(t *testing.T) { }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "loggly_connector.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "loggly_connector.0.connector_name", "loggly_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "loggly_connector.0.display_name", "loggly_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "loggly_connector.0.endpoint", "endpoint"), resource.TestCheckResourceAttr("akamai_datastream.s", "loggly_connector.0.auth_token", "auth_token"), resource.TestCheckResourceAttr("akamai_datastream.s", "loggly_connector.0.tags", "tag1,tag2,tag3"), @@ -1337,16 +1427,16 @@ func TestCustomHeaders(t *testing.T) { "new_relic": { Filename: "custom_headers_new_relic.tf", Connector: &datastream.NewRelicConnector{ - ConnectorName: "new_relic_connector_name", + DisplayName: "new_relic_connector_name", Endpoint: "endpoint", AuthToken: "auth_token", ContentType: "content_type", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeNewRelic, - ConnectorName: "new_relic_connector_name", + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeNewRelic, + DisplayName: "new_relic_connector_name", Endpoint: "endpoint", ContentType: "content_type", CustomHeaderName: "custom_header_name", @@ -1354,7 +1444,7 @@ func TestCustomHeaders(t *testing.T) { }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "new_relic_connector.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "new_relic_connector.0.connector_name", "new_relic_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "new_relic_connector.0.display_name", "new_relic_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "new_relic_connector.0.endpoint", "endpoint"), resource.TestCheckResourceAttr("akamai_datastream.s", "new_relic_connector.0.auth_token", "auth_token"), resource.TestCheckResourceAttr("akamai_datastream.s", "new_relic_connector.0.content_type", "content_type"), @@ -1365,7 +1455,7 @@ func TestCustomHeaders(t *testing.T) { "elasticsearch": { Filename: "custom_headers_elasticsearch.tf", Connector: &datastream.ElasticsearchConnector{ - ConnectorName: "elasticsearch_connector_name", + DisplayName: "elasticsearch_connector_name", Endpoint: "endpoint", IndexName: "index_name", UserName: "user_name", @@ -1374,9 +1464,9 @@ func TestCustomHeaders(t *testing.T) { CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeElasticsearch, - ConnectorName: "elasticsearch_connector_name", + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeElasticsearch, + DisplayName: "elasticsearch_connector_name", Endpoint: "endpoint", IndexName: "index_name", ContentType: "content_type", @@ -1385,7 +1475,7 @@ func TestCustomHeaders(t *testing.T) { }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.connector_name", "elasticsearch_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.display_name", "elasticsearch_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.endpoint", "endpoint"), resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.content_type", "content_type"), resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.custom_header_name", "custom_header_name"), @@ -1408,7 +1498,7 @@ func TestCustomHeaders(t *testing.T) { client.On("DeleteStream", mock.Anything, datastream.DeleteStreamRequest{ StreamID: streamID, - }).Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil) + }).Return(' ', nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -1431,64 +1521,65 @@ func TestMTLS(t *testing.T) { streamID := int64(12321) streamConfiguration := datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ Format: datastream.FormatTypeJson, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, + }, + //UploadFilePrefix: DefaultUploadFilePrefix, + //UploadFileSuffix: DefaultUploadFileSuffix, + }, + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, }, - UploadFilePrefix: DefaultUploadFilePrefix, - UploadFileSuffix: DefaultUploadFileSuffix, }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001}, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, + }, + }, + StreamName: "test_stream", } createStreamRequestFactory := func(connector datastream.AbstractConnector) datastream.CreateStreamRequest { streamConfigurationWithConnector := streamConfiguration - streamConfigurationWithConnector.Connectors = []datastream.AbstractConnector{ + streamConfigurationWithConnector.Destination = datastream.AbstractConnector( connector, - } + ) return datastream.CreateStreamRequest{ StreamConfiguration: streamConfigurationWithConnector, + Activate: false, } } - responseFactory := func(connector datastream.ConnectorDetails) *datastream.DetailedStreamVersion { + responseFactory := func(connector datastream.Destination) *datastream.DetailedStreamVersion { return &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusInactive, - Config: streamConfiguration.Config, - Connectors: []datastream.ConnectorDetails{ + StreamStatus: datastream.StreamStatusInactive, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + Destination: datastream.Destination( connector, - }, + ), ContractID: streamConfiguration.ContractID, - Datasets: []datastream.DataSets{ + DatasetFields: []datastream.DataSetField{ { - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - Order: 0, - }, - }, + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, }, - GroupID: *streamConfiguration.GroupID, + GroupID: streamConfiguration.GroupID, Properties: []datastream.Property{ { PropertyID: 1, PropertyName: "property_1", }, }, - StreamID: streamID, - StreamName: streamConfiguration.StreamName, - StreamType: streamConfiguration.StreamType, - StreamVersionID: 2, - TemplateName: streamConfiguration.TemplateName, + StreamID: streamID, + StreamName: streamConfiguration.StreamName, + StreamVersion: 2, } } @@ -1496,16 +1587,14 @@ func TestMTLS(t *testing.T) { StreamID: streamID, } - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, } tests := map[string]struct { Filename string - Response datastream.ConnectorDetails + Response datastream.Destination Connector datastream.AbstractConnector TestChecks []resource.TestCheckFunc }{ @@ -1513,28 +1602,28 @@ func TestMTLS(t *testing.T) { Filename: "mtls_splunk.tf", Connector: &datastream.SplunkConnector{ CompressLogs: false, - ConnectorName: "splunk_test_connector_name", + DisplayName: "splunk_test_connector_name", EventCollectorToken: "splunk_event_collector_token", - URL: "splunk_url", + Endpoint: "splunk_url", TLSHostname: "tls_hostname", CACert: "ca_cert", ClientCert: "client_cert", ClientKey: "client_key", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSplunk, - CompressLogs: false, - ConnectorName: "splunk_test_connector_name", - URL: "splunk_url", - TLSHostname: "tls_hostname", - MTLS: "Enabled", + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeSplunk, + CompressLogs: false, + DisplayName: "splunk_test_connector_name", + Endpoint: "splunk_url", + TLSHostname: "tls_hostname", + MTLS: "Enabled", }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.compress_logs", "false"), - resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.connector_name", "splunk_test_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.display_name", "splunk_test_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.event_collector_token", "splunk_event_collector_token"), - resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.url", "splunk_url"), + resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.endpoint", "splunk_url"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.tls_hostname", "tls_hostname"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.ca_cert", "ca_cert"), resource.TestCheckResourceAttr("akamai_datastream.s", "splunk_connector.0.client_cert", "client_cert"), @@ -1547,9 +1636,9 @@ func TestMTLS(t *testing.T) { Connector: &datastream.CustomHTTPSConnector{ AuthenticationType: datastream.AuthenticationTypeBasic, CompressLogs: true, - ConnectorName: "HTTPS connector name", + DisplayName: "HTTPS connector name", Password: "password", - URL: "https_connector_url", + Endpoint: "https_connector_url", UserName: "username", ContentType: "content_type", TLSHostname: "tls_hostname", @@ -1557,12 +1646,12 @@ func TestMTLS(t *testing.T) { ClientCert: "client_cert", ClientKey: "client_key", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeHTTPS, + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeHTTPS, AuthenticationType: datastream.AuthenticationTypeBasic, CompressLogs: true, - ConnectorName: "HTTPS connector name", - URL: "https_connector_url", + DisplayName: "HTTPS connector name", + Endpoint: "https_connector_url", ContentType: "content_type", TLSHostname: "tls_hostname", MTLS: "Enabled", @@ -1570,10 +1659,10 @@ func TestMTLS(t *testing.T) { TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.authentication_type", "BASIC"), - resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.connector_name", "HTTPS connector name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.display_name", "HTTPS connector name"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.compress_logs", "true"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.content_type", "content_type"), - resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.url", "https_connector_url"), + resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.endpoint", "https_connector_url"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.user_name", "username"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.password", "password"), resource.TestCheckResourceAttr("akamai_datastream.s", "https_connector.0.tls_hostname", "tls_hostname"), @@ -1586,30 +1675,30 @@ func TestMTLS(t *testing.T) { "elasticsearch_mtls": { Filename: "mtls_elasticsearch.tf", Connector: &datastream.ElasticsearchConnector{ - ConnectorName: "elasticsearch_connector_name", - Endpoint: "endpoint", - IndexName: "index_name", - UserName: "user_name", - Password: "password", - ContentType: "content_type", - TLSHostname: "tls_hostname", - CACert: "ca_cert", - ClientCert: "client_cert", - ClientKey: "client_key", - }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeElasticsearch, - CompressLogs: true, - ConnectorName: "elasticsearch_connector_name", - Endpoint: "endpoint", - IndexName: "index_name", - ContentType: "content_type", - TLSHostname: "tls_hostname", - MTLS: "Enabled", + DisplayName: "elasticsearch_connector_name", + Endpoint: "endpoint", + IndexName: "index_name", + UserName: "user_name", + Password: "password", + ContentType: "content_type", + TLSHostname: "tls_hostname", + CACert: "ca_cert", + ClientCert: "client_cert", + ClientKey: "client_key", + }, + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeElasticsearch, + CompressLogs: true, + DisplayName: "elasticsearch_connector_name", + Endpoint: "endpoint", + IndexName: "index_name", + ContentType: "content_type", + TLSHostname: "tls_hostname", + MTLS: "Enabled", }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.#", "1"), - resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.connector_name", "elasticsearch_connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.display_name", "elasticsearch_connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.content_type", "content_type"), resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.endpoint", "endpoint"), resource.TestCheckResourceAttr("akamai_datastream.s", "elasticsearch_connector.0.index_name", "index_name"), @@ -1638,7 +1727,7 @@ func TestMTLS(t *testing.T) { client.On("DeleteStream", mock.Anything, datastream.DeleteStreamRequest{ StreamID: streamID, - }).Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil) + }).Return(' ', nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -1657,36 +1746,43 @@ func TestMTLS(t *testing.T) { } } +/* commenting this as it is not required in V2 func TestUrlSuppressor(t *testing.T) { streamConfigurationFactory := func(connector datastream.AbstractConnector) datastream.StreamConfiguration { return datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: "ak", UploadFileSuffix: "ds", }, - Connectors: []datastream.AbstractConnector{ + Destination: datastream.AbstractConnector( connector, + ), + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001}, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, + }, + }, + StreamName: "test_stream", } } createStreamRequestFactory := func(connector datastream.AbstractConnector) datastream.CreateStreamRequest { return datastream.CreateStreamRequest{ StreamConfiguration: streamConfigurationFactory(connector), + Activate: false, } } @@ -1695,43 +1791,32 @@ func TestUrlSuppressor(t *testing.T) { StreamID: streamID, StreamConfiguration: streamConfigurationFactory(connector), } - req.StreamConfiguration.GroupID = nil + req.StreamConfiguration.GroupID = 1337 return req } - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, } - responseFactory := func(connector datastream.ConnectorDetails) *datastream.DetailedStreamVersion { + responseFactory := func(connector datastream.Destination) *datastream.DetailedStreamVersion { return &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusInactive, - Config: datastream.Config{ + StreamStatus: datastream.StreamStatusInactive, + DeliveryConfiguration: datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, }, - Connectors: []datastream.ConnectorDetails{ - connector, - }, - ContractID: "test_contract", - Datasets: []datastream.DataSets{ + Destination: connector, + ContractID: "test_contract", + DatasetFields: []datastream.DataSetField{ { - DatasetGroupName: "group_name_1", - DatasetGroupDescription: "group_desc_1", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - DatasetFieldName: "dataset_field_name_1", - DatasetFieldDescription: "dataset_field_desc_1", - Order: 0, - }, - }, + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, }, GroupID: 1337, @@ -1741,11 +1826,9 @@ func TestUrlSuppressor(t *testing.T) { PropertyName: "property_1", }, }, - StreamID: streamID, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - StreamVersionID: 1, - TemplateName: datastream.TemplateNameEdgeLogs, + StreamID: streamID, + StreamName: "test_stream", + StreamVersion: 1, } } @@ -1758,16 +1841,16 @@ func TestUrlSuppressor(t *testing.T) { m.On("CreateStream", mock.Anything, createStreamRequestFactory(&datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint/?/?", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, - CompressLogs: true, - ConnectorName: "connector_name", - Endpoint: "endpoint", //api returns stripped url + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, + CompressLogs: true, + DisplayName: "display_name", + Endpoint: "endpoint", //api returns stripped url }), nil) }, Steps: []resource.TestStep{ @@ -1775,7 +1858,7 @@ func TestUrlSuppressor(t *testing.T) { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/idempotency/create_stream.tf"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.endpoint", "endpoint"), ), }, @@ -1790,31 +1873,31 @@ func TestUrlSuppressor(t *testing.T) { m.On("CreateStream", mock.Anything, createStreamRequestFactory(&datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, - CompressLogs: true, - ConnectorName: "connector_name", - Endpoint: "endpoint", + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, + CompressLogs: true, + DisplayName: "display_name", + Endpoint: "endpoint", }), nil).Times(3) m.On("UpdateStream", mock.Anything, updateStreamRequestFactory(&datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint_updated", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, - CompressLogs: true, - ConnectorName: "connector_name", - Endpoint: "endpoint_updated", + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, + CompressLogs: true, + DisplayName: "display_name", + Endpoint: "endpoint_updated", }), nil) }, Steps: []resource.TestStep{ @@ -1822,7 +1905,7 @@ func TestUrlSuppressor(t *testing.T) { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/update_endpoint_field/create_stream.tf"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.endpoint", "endpoint"), ), }, @@ -1830,7 +1913,7 @@ func TestUrlSuppressor(t *testing.T) { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/update_endpoint_field/update_stream.tf"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.endpoint", "endpoint_updated"), ), }, @@ -1841,32 +1924,32 @@ func TestUrlSuppressor(t *testing.T) { m.On("CreateStream", mock.Anything, createStreamRequestFactory(&datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, - CompressLogs: true, - ConnectorName: "connector_name", - Endpoint: "endpoint", + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, + CompressLogs: true, + DisplayName: "display_name", + Endpoint: "endpoint", }), nil).Times(3) m.On("UpdateStream", mock.Anything, updateStreamRequestFactory(&datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint", CustomHeaderName: "custom_header_name", CustomHeaderValue: "custom_header_value", @@ -1877,7 +1960,7 @@ func TestUrlSuppressor(t *testing.T) { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/adding_fields/create_stream.tf"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.endpoint", "endpoint"), ), }, @@ -1885,7 +1968,7 @@ func TestUrlSuppressor(t *testing.T) { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/adding_fields/update_stream.tf"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.endpoint", "endpoint"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.custom_header_name", "custom_header_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.custom_header_value", "custom_header_value"), @@ -1902,29 +1985,29 @@ func TestUrlSuppressor(t *testing.T) { m.On("CreateStream", mock.Anything, createStreamRequestFactory(&datastream.SumoLogicConnector{ CollectorCode: "collector_code", CompressLogs: true, - ConnectorName: "connector_name", + DisplayName: "display_name", Endpoint: "endpoint", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeSumoLogic, - CompressLogs: true, - ConnectorName: "connector_name", - Endpoint: "endpoint", + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeSumoLogic, + CompressLogs: true, + DisplayName: "display_name", + Endpoint: "endpoint", }), nil).Times(3) m.On("UpdateStream", mock.Anything, updateStreamRequestFactory(&datastream.DatadogConnector{ - AuthToken: "auth_token", - ConnectorName: "connector_name", - URL: "url", + AuthToken: "auth_token", + DisplayName: "display_name", + Endpoint: "endpoint", })).Return(updateStreamResponse, nil) m.On("GetStream", mock.Anything, mock.Anything). - Return(responseFactory(datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeDataDog, - ConnectorName: "connector_name", - URL: "url", + Return(responseFactory(datastream.Destination{ + DestinationType: datastream.DestinationTypeDataDog, + DisplayName: "display_name", + Endpoint: "endpoint", }), nil) }, Steps: []resource.TestStep{ @@ -1932,16 +2015,16 @@ func TestUrlSuppressor(t *testing.T) { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/change_connector/create_stream.tf"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.collector_code", "collector_code"), - resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "sumologic_connector.0.endpoint", "endpoint"), ), }, { Config: loadFixtureString("testdata/TestResourceStream/urlSuppressor/change_connector/update_stream.tf"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_datastream.s", "datadog_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "datadog_connector.0.display_name", "display_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "datadog_connector.0.auth_token", "auth_token"), - resource.TestCheckResourceAttr("akamai_datastream.s", "datadog_connector.0.url", "url"), + resource.TestCheckResourceAttr("akamai_datastream.s", "datadog_connector.0.endpoint", "endpoint"), ), }, { @@ -1959,7 +2042,7 @@ func TestUrlSuppressor(t *testing.T) { m.On("DeleteStream", mock.Anything, datastream.DeleteStreamRequest{ StreamID: streamID, - }).Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil) + }).Return(' ', nil) useClient(m, func() { resource.UnitTest(t, resource.TestCase{ @@ -1971,68 +2054,69 @@ func TestUrlSuppressor(t *testing.T) { }) }) } -} +}*/ func TestConnectors(t *testing.T) { streamConfiguration := datastream.StreamConfiguration{ - ActivateNow: false, - Config: datastream.Config{ + DeliveryConfiguration: datastream.DeliveryConfiguration{ Format: datastream.FormatTypeJson, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: DefaultUploadFilePrefix, UploadFileSuffix: DefaultUploadFileSuffix, }, - ContractID: "test_contract", - DatasetFieldIDs: []int{1001}, - GroupID: tools.IntPtr(1337), - PropertyIDs: []int{1}, - StreamName: "test_stream", - StreamType: datastream.StreamTypeRawLogs, - TemplateName: datastream.TemplateNameEdgeLogs, + ContractID: "test_contract", + DatasetFields: []datastream.DatasetFieldID{ + { + DatasetFieldID: 1001, + }, + }, + GroupID: 1337, + Properties: []datastream.PropertyID{ + { + PropertyID: 1, + }, + }, + StreamName: "test_stream", } createStreamRequestFactory := func(connector datastream.AbstractConnector) datastream.CreateStreamRequest { streamConfigurationWithConnector := streamConfiguration - streamConfigurationWithConnector.Connectors = []datastream.AbstractConnector{ + streamConfigurationWithConnector.Destination = datastream.AbstractConnector( connector, - } + ) return datastream.CreateStreamRequest{ StreamConfiguration: streamConfigurationWithConnector, + Activate: false, } } - responseFactory := func(connector datastream.ConnectorDetails) *datastream.DetailedStreamVersion { + responseFactory := func(connector datastream.Destination) *datastream.DetailedStreamVersion { return &datastream.DetailedStreamVersion{ - ActivationStatus: datastream.ActivationStatusInactive, - Config: streamConfiguration.Config, - Connectors: []datastream.ConnectorDetails{ + StreamStatus: datastream.StreamStatusInactive, + DeliveryConfiguration: streamConfiguration.DeliveryConfiguration, + Destination: datastream.Destination( connector, - }, + ), ContractID: streamConfiguration.ContractID, - Datasets: []datastream.DataSets{ + DatasetFields: []datastream.DataSetField{ { - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1001, - Order: 0, - }, - }, + DatasetFieldID: 1001, + DatasetFieldName: "dataset_field_name_1", + DatasetFieldDescription: "dataset_field_desc_1", }, }, - GroupID: *streamConfiguration.GroupID, + GroupID: streamConfiguration.GroupID, Properties: []datastream.Property{ { PropertyID: 1, PropertyName: "property_1", }, }, - StreamID: streamID, - StreamName: streamConfiguration.StreamName, - StreamType: streamConfiguration.StreamType, - StreamVersionID: 2, - TemplateName: streamConfiguration.TemplateName, + StreamID: streamID, + StreamName: streamConfiguration.StreamName, + StreamVersion: 2, } } @@ -2040,16 +2124,14 @@ func TestConnectors(t *testing.T) { StreamID: streamID, } - updateStreamResponse := &datastream.StreamUpdate{ - StreamVersionKey: datastream.StreamVersionKey{ - StreamID: streamID, - StreamVersionID: 1, - }, + updateStreamResponse := &datastream.DetailedStreamVersion{ + StreamID: streamID, + StreamVersion: 1, } tests := map[string]struct { Filename string - Response datastream.ConnectorDetails + Response datastream.Destination Connector datastream.AbstractConnector TestChecks []resource.TestCheckFunc }{ @@ -2058,22 +2140,22 @@ func TestConnectors(t *testing.T) { Connector: &datastream.AzureConnector{ AccessKey: "access_key", AccountName: "account_name", - ConnectorName: "connector_name", + DisplayName: "connector_name", ContainerName: "container_name", Path: "path", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeAzure, - AccountName: "account_name", - ConnectorName: "connector_name", - ContainerName: "container_name", - Path: "path", + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeAzure, + AccountName: "account_name", + DisplayName: "connector_name", + ContainerName: "container_name", + Path: "path", }, TestChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.0.account_name", "account_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.0.compress_logs", "false"), - resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.0.display_name", "connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.0.container_name", "container_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "azure_connector.0.path", "path"), }, @@ -2082,16 +2164,16 @@ func TestConnectors(t *testing.T) { Filename: "gcs.tf", Connector: &datastream.GCSConnector{ Bucket: "bucket", - ConnectorName: "connector_name", + DisplayName: "connector_name", Path: "path", PrivateKey: "private_key", ProjectID: "project_id", ServiceAccountName: "service_account_name", }, - Response: datastream.ConnectorDetails{ - ConnectorType: datastream.ConnectorTypeGcs, + Response: datastream.Destination{ + DestinationType: datastream.DestinationTypeGcs, Bucket: "bucket", - ConnectorName: "connector_name", + DisplayName: "connector_name", Path: "path", ProjectID: "project_id", ServiceAccountName: "service_account_name", @@ -2100,7 +2182,7 @@ func TestConnectors(t *testing.T) { resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.#", "1"), resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.bucket", "bucket"), resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.compress_logs", "false"), - resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.connector_name", "connector_name"), + resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.display_name", "connector_name"), resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.path", "path"), resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.project_id", "project_id"), resource.TestCheckResourceAttr("akamai_datastream.s", "gcs_connector.0.service_account_name", "service_account_name"), @@ -2118,7 +2200,7 @@ func TestConnectors(t *testing.T) { client.On("GetStream", mock.Anything, getStreamRequest). Return(responseFactory(test.Response), nil) - client.On("DeleteStream", mock.Anything, mock.Anything).Return(&datastream.DeleteStreamResponse{Message: "Success"}, nil) + client.On("DeleteStream", mock.Anything, mock.Anything).Return(' ', nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -2136,3 +2218,37 @@ func TestConnectors(t *testing.T) { }) } } + +func TestEmptyFilePrefixSuffixSetForHttpsDestination(t *testing.T) { + + configurationOfPrefixSuffixNotSupportedDest := datastream.DeliveryConfiguration{ + Format: datastream.FormatTypeJson, + Frequency: datastream.Frequency{ + IntervalInSeconds: datastream.IntervalInSeconds30, + }, + UploadFilePrefix: DefaultUploadFilePrefix, + UploadFileSuffix: DefaultUploadFileSuffix, + } + + result, err := FilePrefixSuffixSet(`splunk_connector`, &configurationOfPrefixSuffixNotSupportedDest) + require.NoError(t, err) + assert.Equal(t, "", result.UploadFilePrefix) + assert.Equal(t, "", result.UploadFileSuffix) +} + +func TestFilePrefixSuffixSetForObjectStorageDestination(t *testing.T) { + + configurationOfPrefixSuffixSupportedDest := datastream.DeliveryConfiguration{ + Format: datastream.FormatTypeJson, + Frequency: datastream.Frequency{ + IntervalInSeconds: datastream.IntervalInSeconds30, + }, + UploadFilePrefix: "pre", + UploadFileSuffix: "suf", + } + + result, err := FilePrefixSuffixSet(`azure_connector`, &configurationOfPrefixSuffixSupportedDest) + require.NoError(t, err) + assert.Equal(t, configurationOfPrefixSuffixSupportedDest.UploadFilePrefix, result.UploadFilePrefix) + assert.Equal(t, configurationOfPrefixSuffixSupportedDest.UploadFileSuffix, result.UploadFileSuffix) +} diff --git a/pkg/providers/datastream/stream.go b/pkg/providers/datastream/stream.go index 59b655765..373040371 100644 --- a/pkg/providers/datastream/stream.go +++ b/pkg/providers/datastream/stream.go @@ -2,24 +2,23 @@ package datastream import ( "fmt" - "sort" "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // GetConfig builds Config structure -func GetConfig(set *schema.Set) (*datastream.Config, error) { +func GetConfig(set *schema.Set) (*datastream.DeliveryConfiguration, error) { if set.Len() != 1 { - return nil, fmt.Errorf("missing config definition") + return nil, fmt.Errorf("missing delivery configuration definition") } configList := set.List() configMap, ok := configList[0].(map[string]interface{}) if !ok { - return nil, fmt.Errorf("config has invalid structure") + return nil, fmt.Errorf("delivery configuration has invalid structure") } frequencySet, ok := configMap["frequency"] @@ -33,11 +32,11 @@ func GetConfig(set *schema.Set) (*datastream.Config, error) { } var delimiterPtr *datastream.DelimiterType - if delimiterStr := configMap["delimiter"].(string); delimiterStr != "" { + if delimiterStr := configMap["field_delimiter"].(string); delimiterStr != "" { delimiterPtr = datastream.DelimiterTypePtr(datastream.DelimiterType(delimiterStr)) } - return &datastream.Config{ + return &datastream.DeliveryConfiguration{ Delimiter: delimiterPtr, Format: datastream.FormatType(configMap["format"].(string)), Frequency: *frequency, @@ -47,14 +46,14 @@ func GetConfig(set *schema.Set) (*datastream.Config, error) { } // ConfigToSet converts Config struct to set -func ConfigToSet(cfg datastream.Config) []map[string]interface{} { +func ConfigToSet(cfg datastream.DeliveryConfiguration) []map[string]interface{} { delimiter := *datastream.DelimiterTypePtr("") if cfg.Delimiter != nil { delimiter = *cfg.Delimiter } return []map[string]interface{}{{ - "delimiter": string(delimiter), + "field_delimiter": string(delimiter), "format": string(cfg.Format), "frequency": FrequencyToSet(cfg.Frequency), "upload_file_prefix": cfg.UploadFilePrefix, @@ -75,14 +74,14 @@ func GetFrequency(set *schema.Set) (*datastream.Frequency, error) { } return &datastream.Frequency{ - TimeInSec: datastream.TimeInSec(freqMap["time_in_sec"].(int)), + IntervalInSeconds: datastream.IntervalInSeconds(freqMap["interval_in_secs"].(int)), }, nil } // FrequencyToSet converts Frequency struct to map func FrequencyToSet(freq datastream.Frequency) []map[string]interface{} { return []map[string]interface{}{{ - "time_in_sec": int(freq.TimeInSec), + "interval_in_secs": int(freq.IntervalInSeconds), }} } @@ -95,7 +94,18 @@ func InterfaceSliceToIntSlice(list []interface{}) []int { return intList } -// InterfaceSliceToStringSlice converts schema.Set to slice of ints +// DatasetFieldListToDatasetFields converts schema.Set to slice of DatasetFieldId +func DatasetFieldListToDatasetFields(list []interface{}) []datastream.DatasetFieldID { + + datasetFields := make([]datastream.DatasetFieldID, 0) + + for _, v := range list { + datasetFields = append(datasetFields, datastream.DatasetFieldID{DatasetFieldID: v.(int)}) + } + 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 { @@ -104,21 +114,12 @@ func InterfaceSliceToStringSlice(list []interface{}) []string { return stringList } -// DataSetFieldsToList converts slice of DataSets to slice of ints -func DataSetFieldsToList(dataSets []datastream.DataSets) []int { - datasetFields := make([]datastream.DatasetFields, 0) - - for _, datasetGroup := range dataSets { - datasetFields = append(datasetFields, datasetGroup.DatasetFields...) - } - - sort.Slice(datasetFields, func(i, j int) bool { - return datasetFields[i].Order < datasetFields[j].Order - }) +// DataSetFieldsToList converts slice of dataSetFields to slice of ints +func DataSetFieldsToList(dataSetFields []datastream.DataSetField) []int { - ids := make([]int, 0, len(datasetFields)) + ids := make([]int, 0, len(dataSetFields)) - for _, field := range datasetFields { + for _, field := range dataSetFields { ids = append(ids, field.DatasetFieldID) } @@ -137,15 +138,15 @@ func PropertyToList(properties []datastream.Property) []string { } // GetPropertiesList converts propertyIDs with and without "prp_" prefix to slice of ints -func GetPropertiesList(properties []interface{}) ([]int, error) { - ids := make([]int, 0, len(properties)) +func GetPropertiesList(properties []interface{}) ([]datastream.PropertyID, error) { + ids := make([]datastream.PropertyID, 0, len(properties)) for _, property := range properties { propertyID, err := strconv.Atoi(strings.TrimPrefix(property.(string), "prp_")) if err != nil { return nil, err } - ids = append(ids, propertyID) + ids = append(ids, datastream.PropertyID{PropertyID: propertyID}) } return ids, nil diff --git a/pkg/providers/datastream/stream_test.go b/pkg/providers/datastream/stream_test.go index e0ece7268..b1def6e74 100644 --- a/pkg/providers/datastream/stream_test.go +++ b/pkg/providers/datastream/stream_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/tj/assert" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -19,11 +19,11 @@ func TestGetConfig(t *testing.T) { tests := map[string]struct { configElements *schema.Set expectedErrorMsg string - expectedResult datastream.Config + expectedResult datastream.DeliveryConfiguration }{ "empty set": { configElements: newSet(), - expectedErrorMsg: "missing config", + expectedErrorMsg: "missing delivery configuration", }, "invalid config type": { configElements: newSet(1), @@ -32,7 +32,7 @@ func TestGetConfig(t *testing.T) { "missing frequency": { configElements: newSet( map[string]interface{}{ - "delimiter": "SPACE", + "field_delimiter": "SPACE", "format": "STRUCTURED", "upload_file_prefix": "pre", "upload_file_suffix": "suf", @@ -42,22 +42,22 @@ func TestGetConfig(t *testing.T) { "proper config": { configElements: newSet( map[string]interface{}{ - "delimiter": "SPACE", - "format": "STRUCTURED", + "field_delimiter": "SPACE", + "format": "STRUCTURED", "frequency": newSet( map[string]interface{}{ - "time_in_sec": 30, + "interval_in_secs": 30, }, ), "upload_file_prefix": "pre", "upload_file_suffix": "suf", }, ), - expectedResult: datastream.Config{ + expectedResult: datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: "pre", UploadFileSuffix: "suf", @@ -79,22 +79,22 @@ func TestGetConfig(t *testing.T) { } func TestConfigToSet(t *testing.T) { - config := datastream.Config{ + config := datastream.DeliveryConfiguration{ Delimiter: datastream.DelimiterTypePtr(datastream.DelimiterTypeSpace), Format: datastream.FormatTypeStructured, Frequency: datastream.Frequency{ - TimeInSec: datastream.TimeInSec30, + IntervalInSeconds: datastream.IntervalInSeconds30, }, UploadFilePrefix: "pre", UploadFileSuffix: "suf", } expected := []map[string]interface{}{ { - "delimiter": "SPACE", - "format": "STRUCTURED", + "field_delimiter": "SPACE", + "format": "STRUCTURED", "frequency": []map[string]interface{}{ { - "time_in_sec": 30, + "interval_in_secs": 30, }, }, "upload_file_prefix": "pre", @@ -123,11 +123,11 @@ func TestGetFrequency(t *testing.T) { "proper frequency": { frequencyElements: newSet( map[string]interface{}{ - "time_in_sec": 60, + "interval_in_secs": 60, }, ), expectedResult: datastream.Frequency{ - TimeInSec: datastream.TimeInSec60, + IntervalInSeconds: datastream.IntervalInSeconds60, }, }, } @@ -147,11 +147,11 @@ func TestGetFrequency(t *testing.T) { func TestFrequencyToSet(t *testing.T) { frequency := datastream.Frequency{ - TimeInSec: datastream.TimeInSec60, + IntervalInSeconds: datastream.IntervalInSeconds60, } expected := []map[string]interface{}{ { - "time_in_sec": 60, + "interval_in_secs": 60, }, } @@ -204,44 +204,30 @@ func TestInterfaceSliceToStringSlice(t *testing.T) { } func TestDataSetFieldsToList(t *testing.T) { - datasets := []datastream.DataSets{ - { - DatasetGroupName: "group1", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 1000, - Order: 3, - }, - { - DatasetFieldID: 1002, - Order: 5, - }, - { - DatasetFieldID: 1100, - Order: 1, - }, + + datasets := datastream.DataSets{ + DataSetFields: []datastream.DataSetField{ + { + DatasetFieldID: 1000, }, - }, - { - DatasetGroupName: "group2", - DatasetFields: []datastream.DatasetFields{ - { - DatasetFieldID: 2000, - Order: 4, - }, - { - DatasetFieldID: 2002, - Order: 0, - }, - { - DatasetFieldID: 2100, - Order: 2, - }, + { + DatasetFieldID: 1002, + }, + { + DatasetFieldID: 1100, + }, + { + DatasetFieldID: 2000, + }, + { + DatasetFieldID: 2002, + }, + { + DatasetFieldID: 2100, }, }, } - - assert.Equal(t, []int{2002, 1100, 2100, 1000, 2000, 1002}, DataSetFieldsToList(datasets)) + assert.Equal(t, []int{1000, 1002, 1100, 2000, 2002, 2100}, DataSetFieldsToList(datasets.DataSetFields)) } func TestPropertyToList(t *testing.T) { @@ -275,5 +261,9 @@ func TestGetPropertiesList(t *testing.T) { result, err := GetPropertiesList(properties) require.NoError(t, err) - assert.Equal(t, []int{1, 2, 3, 4, 5}, result) + propertyIds := make([]int, len(result)) + for i := 0; i < len(result); i++ { + propertyIds[i] = result[i].PropertyID + } + assert.Equal(t, []int{1, 2, 3, 4, 5}, propertyIds) } diff --git a/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_invalid_prefix.tf b/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_invalid_prefix.tf index e58d04afa..f3c163fb7 100644 --- a/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_invalid_prefix.tf +++ b/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_invalid_prefix.tf @@ -3,5 +3,5 @@ provider "akamai" { } data "akamai_datastreams" "test" { - group_id = "asdf_1234" + group_id = g1234 } \ No newline at end of file diff --git a/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_prefix.tf b/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_prefix.tf index c3b0f530c..50158f805 100644 --- a/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_prefix.tf +++ b/pkg/providers/datastream/testdata/TestDataDatastreams/list_streams_with_groupid_with_prefix.tf @@ -3,5 +3,5 @@ provider "akamai" { } data "akamai_datastreams" "test" { - group_id = "grp_1234" + group_id = 1234 } \ No newline at end of file diff --git a/pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/edge_logs_no_template.tf b/pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_default_product.tf similarity index 100% rename from pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/edge_logs_no_template.tf rename to pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_default_product.tf diff --git a/pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/edge_logs.tf b/pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_with_product.tf similarity index 76% rename from pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/edge_logs.tf rename to pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_with_product.tf index 3dbc5e530..a9c3cee3d 100644 --- a/pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/edge_logs.tf +++ b/pkg/providers/datastream/testdata/TestDataSourceDatasetFieldsRead/list_dataset_fields_with_product.tf @@ -3,5 +3,5 @@ provider "akamai" { } data "akamai_datastream_dataset_fields" "test" { - template_name = "EDGE_LOGS" + product_id = "PROD_1" } \ No newline at end of file diff --git a/pkg/providers/datastream/testdata/TestResourceStream/connectors/azure.tf b/pkg/providers/datastream/testdata/TestResourceStream/connectors/azure.tf index 7fdfcdfa3..ef063eb7d 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/connectors/azure.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/connectors/azure.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" azure_connector { access_key = "access_key" account_name = "account_name" - connector_name = "connector_name" + display_name = "connector_name" container_name = "container_name" path = "path" } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/connectors/gcs.tf b/pkg/providers/datastream/testdata/TestResourceStream/connectors/gcs.tf index 94f66d16d..b55269511 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/connectors/gcs.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/connectors/gcs.tf @@ -4,28 +4,26 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" gcs_connector { bucket = "bucket" - connector_name = "connector_name" + display_name = "connector_name" path = "path" private_key = "private_key" project_id = "project_id" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff1.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff1.tf index 6d458dcf2..ee8feeb92 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff1.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff1.tf @@ -4,39 +4,37 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "sumologic_collector_code" - connector_name = "sumologic_connector_name" + display_name = "sumologic_connector_name" endpoint = "sumologic_endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff2.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff2.tf index 46527411b..c3e738518 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff2.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff2.tf @@ -4,38 +4,36 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "sumologic_collector_code" - connector_name = "sumologic_connector_name" + display_name = "sumologic_connector_name" endpoint = "sumologic_endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff3.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff3.tf index 08bf359e4..ea6bd4274 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff3.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff3.tf @@ -4,38 +4,36 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "sumologic_collector_code" - connector_name = "sumologic_connector_name" + display_name = "sumologic_connector_name" endpoint = "sumologic_endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff4.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff4.tf index c2ed7a1d6..d3a9267e3 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff4.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff4.tf @@ -4,40 +4,38 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff5.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff5.tf index e310ae8e5..667fcd874 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff5.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff5.tf @@ -4,39 +4,37 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff6.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff6.tf index 4910b36a9..0dbbe71cd 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff6.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff6.tf @@ -4,39 +4,37 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff7.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff7.tf index edce8e6e0..5a07b16b3 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff7.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff7.tf @@ -4,37 +4,35 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "sumologic_collector_code" - connector_name = "sumologic_connector_name" + display_name = "sumologic_connector_name" endpoint = "sumologic_endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff8.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff8.tf index 689e2e22d..dbbed4b7d 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff8.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_diff/custom_diff8.tf @@ -4,38 +4,36 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_elasticsearch.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_elasticsearch.tf index 8e0050b61..2392664a0 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_elasticsearch.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_elasticsearch.tf @@ -4,27 +4,25 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" elasticsearch_connector { - connector_name = "elasticsearch_connector_name" + display_name = "elasticsearch_connector_name" endpoint = "endpoint" index_name = "index_name" user_name = "user_name" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_https.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_https.tf index 9010c868f..b3913ac70 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_https.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_https.tf @@ -4,33 +4,31 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" https_connector { authentication_type = "BASIC" - connector_name = "HTTPS connector name" + display_name = "HTTPS connector name" compress_logs = true content_type = "content_type" custom_header_name = "custom_header_name" custom_header_value = "custom_header_value" - url = "https_connector_url" + endpoint = "https_connector_url" user_name = "username" password = "password" } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_loggly.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_loggly.tf index 0cd5b93bf..feb697f0b 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_loggly.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_loggly.tf @@ -4,27 +4,25 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" loggly_connector { - connector_name = "loggly_connector_name" + display_name = "loggly_connector_name" endpoint = "endpoint" auth_token = "auth_token" tags = "tag1,tag2,tag3" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_new_relic.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_new_relic.tf index 59c7b4102..e40ce4a6d 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_new_relic.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_new_relic.tf @@ -4,27 +4,25 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" new_relic_connector { - connector_name = "new_relic_connector_name" + display_name = "new_relic_connector_name" endpoint = "endpoint" auth_token = "auth_token" content_type = "content_type" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_splunk.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_splunk.tf index c68377355..b8b2b56c9 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_splunk.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_splunk.tf @@ -4,30 +4,28 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" custom_header_name = "custom_header_name" custom_header_value = "custom_header_value" } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_sumologic.tf b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_sumologic.tf index 4da3200bf..ced438904 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_sumologic.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/custom_headers/custom_headers_sumologic.tf @@ -4,28 +4,26 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "Sumologic connector name" + display_name = "Sumologic connector name" compress_logs = true content_type = "content_type" custom_header_name = "custom_header_name" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config.tf b/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config.tf index 269769e88..2668e38ee 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config.tf @@ -4,26 +4,24 @@ provider "akamai" { resource "akamai_datastream" "splunk_stream" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } - contract_id = "test_contract" - dataset_fields_ids = [1001, 1002] + contract_id = "test_contract" + dataset_fields = [1001, 1002] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + group_id = 1337 + properties = [1] + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config_duplicates.tf b/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config_duplicates.tf index 99c9c5070..8c83590f7 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config_duplicates.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/json_config_duplicates.tf @@ -4,26 +4,24 @@ provider "akamai" { resource "akamai_datastream" "splunk_stream" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } - contract_id = "test_contract" - dataset_fields_ids = [1002, 1002] + contract_id = "test_contract" + dataset_fields = [1002, 1002] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + group_id = 1337 + properties = [1] + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/structured_config.tf b/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/structured_config.tf index 5f0fe3c1f..d1f5ac5ad 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/structured_config.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/dataset_ids_diff/structured_config.tf @@ -4,27 +4,25 @@ provider "akamai" { resource "akamai_datastream" "splunk_stream" { active = false - config { - format = "STRUCTURED" - delimiter = "SPACE" + delivery_configuration { + format = "STRUCTURED" + field_delimiter = "SPACE" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } - contract_id = "test_contract" - dataset_fields_ids = [1001, 1002] + contract_id = "test_contract" + dataset_fields = [1001, 1002] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + group_id = 1337 + properties = [1] + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/empty_email_ids.tf b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/empty_email_ids.tf index 51a24c72b..9f4c3a4c2 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/empty_email_ids.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/empty_email_ids.tf @@ -4,31 +4,29 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] - email_ids = [] - group_id = 1337 - property_ids = [ + notification_emails = [] + group_id = 1337 + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/no_email_ids.tf b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/no_email_ids.tf index d55efebba..2164d9244 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/no_email_ids.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/no_email_ids.tf @@ -4,30 +4,28 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/one_email.tf b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/one_email.tf index a36f15e27..6f5fc9d47 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/one_email.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/one_email.tf @@ -4,33 +4,31 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/two_emails.tf b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/two_emails.tf index 38fe2ddaa..839db9eb3 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/email_ids/two_emails.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/email_ids/two_emails.tf @@ -4,34 +4,32 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/errors/internal_server_error/internal_server_error.tf b/pkg/providers/datastream/testdata/TestResourceStream/errors/internal_server_error/internal_server_error.tf index c2ed7a1d6..d3a9267e3 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/errors/internal_server_error/internal_server_error.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/errors/internal_server_error/internal_server_error.tf @@ -4,40 +4,38 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/errors/invalid_email/invalid_email.tf b/pkg/providers/datastream/testdata/TestResourceStream/errors/invalid_email/invalid_email.tf index b253fecc2..27c18e07b 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/errors/invalid_email/invalid_email.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/errors/invalid_email/invalid_email.tf @@ -4,40 +4,38 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/errors/missing_required_argument/missing_required_argument.tf b/pkg/providers/datastream/testdata/TestResourceStream/errors/missing_required_argument/missing_required_argument.tf index c16b95ef4..aca71b0db 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/errors/missing_required_argument/missing_required_argument.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/errors/missing_required_argument/missing_required_argument.tf @@ -4,39 +4,37 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/errors/stream_name_not_unique/stream_name_not_unique.tf b/pkg/providers/datastream/testdata/TestResourceStream/errors/stream_name_not_unique/stream_name_not_unique.tf index c2ed7a1d6..d3a9267e3 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/errors/stream_name_not_unique/stream_name_not_unique.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/errors/stream_name_not_unique/stream_name_not_unique.tf @@ -4,40 +4,38 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1000, 1001, 1002 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] group_id = 1337 - property_ids = [ + properties = [ 1, 2, 3 ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/create_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/create_stream.tf old mode 100644 new mode 100755 index 467a8941d..d49757bfa --- a/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/create_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/create_stream.tf @@ -4,38 +4,34 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } contract_id = "test_contract" - dataset_fields_ids = [ + + dataset_fields = [ 1001, 1002, 2000, 2001 ] - email_ids = [ + notification_emails = [ "test_email1@akamai.com", "test_email2@akamai.com", ] - group_id = 1337 - property_ids = [ - 1, - 2, - 3 - ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + group_id = 1337 + properties = [1, 2, 3] + + stream_name = "test_stream" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket" - connector_name = "s3_test_connector_name" + display_name = "s3_test_connector_name" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/update_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/update_stream.tf index 86106cb36..5262b533f 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/update_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/lifecycle/update_stream.tf @@ -4,38 +4,33 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "prefix_updated" upload_file_suffix = "suf_updated" } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 2000, 1002, 2001, 1001 ] - email_ids = [ + notification_emails = [ "test_email1_updated@akamai.com", "test_email2@akamai.com", ] - group_id = 1337 - property_ids = [ - 1, - 2, - 3 - ] - stream_name = "test_stream_with_updated" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + group_id = 1337 + properties = [1, 2, 3] + + stream_name = "test_stream_with_updated" s3_connector { access_key = "s3_test_access_key" bucket = "s3_test_bucket_updated" - connector_name = "s3_test_connector_name_updated" + display_name = "s3_test_connector_name_updated" path = "s3_test_path" region = "s3_test_region" secret_access_key = "s3_test_secret_key" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_elasticsearch.tf b/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_elasticsearch.tf index ee0bead7f..edf37f5c0 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_elasticsearch.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_elasticsearch.tf @@ -4,35 +4,33 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" elasticsearch_connector { - connector_name = "elasticsearch_connector_name" - endpoint = "endpoint" - index_name = "index_name" - user_name = "user_name" - password = "password" - content_type = "content_type" - tls_hostname = "tls_hostname" - ca_cert = "ca_cert" - client_cert = "client_cert" - client_key = "client_key" + display_name = "elasticsearch_connector_name" + endpoint = "endpoint" + index_name = "index_name" + user_name = "user_name" + password = "password" + content_type = "content_type" + tls_hostname = "tls_hostname" + ca_cert = "ca_cert" + client_cert = "client_cert" + client_key = "client_key" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_https.tf b/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_https.tf index 0badc56ec..c0c0f6ed0 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_https.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_https.tf @@ -4,31 +4,29 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" https_connector { authentication_type = "BASIC" - connector_name = "HTTPS connector name" + display_name = "HTTPS connector name" compress_logs = true content_type = "content_type" - url = "https_connector_url" + endpoint = "https_connector_url" user_name = "username" password = "password" tls_hostname = "tls_hostname" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_splunk.tf b/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_splunk.tf index 8becab18e..802374dd7 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_splunk.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/mtls/mtls_splunk.tf @@ -4,30 +4,28 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { + delivery_configuration { format = "JSON" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" splunk_connector { compress_logs = false - connector_name = "splunk_test_connector_name" + display_name = "splunk_test_connector_name" event_collector_token = "splunk_event_collector_token" - url = "splunk_url" + endpoint = "splunk_url" tls_hostname = "tls_hostname" ca_cert = "ca_cert" client_cert = "client_cert" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_active.tf b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_active.tf index 9aa470f28..c20bd2b5f 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_active.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_active.tf @@ -4,28 +4,26 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } - contract_id = "test_contract" - dataset_fields_ids = [1001] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + contract_id = "test_contract" + dataset_fields = [1001] + group_id = 1337 + properties = [1] + stream_name = "test_stream" oracle_connector { access_key = "access_key" bucket = "bucket" - connector_name = "connector_name" + display_name = "display_name" namespace = "namespace" path = "path" region = "region" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_inactive.tf b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_inactive.tf index be9e40906..82b72c636 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_inactive.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/create_stream_inactive.tf @@ -4,28 +4,26 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } - contract_id = "test_contract" - dataset_fields_ids = [1001] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + contract_id = "test_contract" + dataset_fields = [1001] + group_id = 1337 + properties = [1] + stream_name = "test_stream" oracle_connector { access_key = "access_key" bucket = "bucket" - connector_name = "connector_name" + display_name = "display_name" namespace = "namespace" path = "path" region = "region" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_active.tf b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_active.tf index 9aa470f28..c20bd2b5f 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_active.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_active.tf @@ -4,28 +4,26 @@ provider "akamai" { resource "akamai_datastream" "s" { active = true - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } - contract_id = "test_contract" - dataset_fields_ids = [1001] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + contract_id = "test_contract" + dataset_fields = [1001] + group_id = 1337 + properties = [1] + stream_name = "test_stream" oracle_connector { access_key = "access_key" bucket = "bucket" - connector_name = "connector_name" + display_name = "display_name" namespace = "namespace" path = "path" region = "region" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_inactive.tf b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_inactive.tf index be9e40906..82b72c636 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_inactive.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/update_resource/update_stream_inactive.tf @@ -4,28 +4,26 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } upload_file_prefix = "pre" upload_file_suffix = "suf" } - contract_id = "test_contract" - dataset_fields_ids = [1001] - group_id = 1337 - property_ids = [1] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + contract_id = "test_contract" + dataset_fields = [1001] + group_id = 1337 + properties = [1] + stream_name = "test_stream" oracle_connector { access_key = "access_key" bucket = "bucket" - connector_name = "connector_name" + display_name = "display_name" namespace = "namespace" path = "path" region = "region" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/create_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/create_stream.tf index d2215d053..bd0ff93e5 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/create_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/create_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + connector_name = "display_name" endpoint = "endpoint" } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/update_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/update_stream.tf index 415f6f066..5290ab6d4 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/update_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/adding_fields/update_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + display_name = "display_name" endpoint = "endpoint" custom_header_name = "custom_header_name" custom_header_value = "custom_header_value" diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/create_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/create_stream.tf index d2215d053..0c537f6e6 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/create_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/create_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + display_name = "display_name" endpoint = "endpoint" } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/update_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/update_stream.tf index dd541bc68..8d46e9bdb 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/update_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/change_connector/update_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" datadog_connector { - auth_token = "auth_token" - connector_name = "connector_name" - url = "url" + auth_token = "auth_token" + display_name = "display_name" + endpoint = "endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/create_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/create_stream.tf index 09b50edec..1f6c727e8 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/create_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/create_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + display_name = "display_name" endpoint = "endpoint/?/?" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/update_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/update_stream.tf index 9e0ebeb5f..8518c4a5d 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/update_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/idempotency/update_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + display_name = "display_name" endpoint = "endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/create_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/create_stream.tf index 9e0ebeb5f..8518c4a5d 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/create_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/create_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + display_name = "display_name" endpoint = "endpoint" } } diff --git a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/update_stream.tf b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/update_stream.tf index c3dc0564c..4e3a5ebda 100644 --- a/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/update_stream.tf +++ b/pkg/providers/datastream/testdata/TestResourceStream/urlSuppressor/update_endpoint_field/update_stream.tf @@ -4,29 +4,27 @@ provider "akamai" { resource "akamai_datastream" "s" { active = false - config { - delimiter = "SPACE" - format = "STRUCTURED" + delivery_configuration { + field_delimiter = "SPACE" + format = "STRUCTURED" frequency { - time_in_sec = 30 + interval_in_secs = 30 } } contract_id = "test_contract" - dataset_fields_ids = [ + dataset_fields = [ 1001 ] group_id = 1337 - property_ids = [ + properties = [ 1, ] - stream_name = "test_stream" - stream_type = "RAW_LOGS" - template_name = "EDGE_LOGS" + stream_name = "test_stream" sumologic_connector { collector_code = "collector_code" - connector_name = "connector_name" + display_name = "display_name" endpoint = "endpoint_updated" } } diff --git a/pkg/providers/dns/data_authorities_set.go b/pkg/providers/dns/data_authorities_set.go index 8c1868e87..e1bb87724 100644 --- a/pkg/providers/dns/data_authorities_set.go +++ b/pkg/providers/dns/data_authorities_set.go @@ -6,9 +6,9 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,7 +31,7 @@ func dataSourceAuthoritiesSet() *schema.Resource { } func dataSourceAuthoritiesSetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "dataSourceDNSAuthoritiesRead") // create a context with logging for api calls ctx = session.ContextWithOptions( diff --git a/pkg/providers/dns/data_authorities_set_test.go b/pkg/providers/dns/data_authorities_set_test.go index 8759ff0e4..2c8741903 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/v6/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -27,7 +27,6 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { @@ -53,7 +52,6 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { @@ -77,7 +75,6 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { diff --git a/pkg/providers/dns/data_dns_record_set.go b/pkg/providers/dns/data_dns_record_set.go index 0c244dcb7..46ca6bd1c 100644 --- a/pkg/providers/dns/data_dns_record_set.go +++ b/pkg/providers/dns/data_dns_record_set.go @@ -7,9 +7,9 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -44,7 +44,7 @@ func dataSourceDNSRecordSet() *schema.Resource { } func dataSourceDNSRecordSetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "dataSourceDNSRecordSetRead") // create a context with logging for api calls ctx = session.ContextWithOptions( diff --git a/pkg/providers/dns/data_dns_record_set_test.go b/pkg/providers/dns/data_dns_record_set_test.go index 63743040e..16d7bc36d 100644 --- a/pkg/providers/dns/data_dns_record_set_test.go +++ b/pkg/providers/dns/data_dns_record_set_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -30,7 +30,6 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { @@ -63,7 +62,6 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { diff --git a/pkg/providers/dns/dns.go b/pkg/providers/dns/dns.go index e136d88be..a8f1284d9 100644 --- a/pkg/providers/dns/dns.go +++ b/pkg/providers/dns/dns.go @@ -1,10 +1,7 @@ -//go:build all || dns -// +build all dns - package dns -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/dns/provider.go b/pkg/providers/dns/provider.go index e44037c15..eac1dae49 100644 --- a/pkg/providers/dns/provider.go +++ b/pkg/providers/dns/provider.go @@ -2,150 +2,66 @@ package dns import ( - "errors" - "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/config" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers dns resources and data sources + Subprovider struct { client dns.DNS } - // Option is a dns provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider() akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider() *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} }) return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{ - "dns_section": { - Optional: true, - Type: schema.TypeString, - Default: "default", - Deprecated: akamai.NoticeDeprecatedUseAlias("dns_section"), - }, - "dns": { - Optional: true, - Type: schema.TypeSet, - Elem: config.Options("dns"), - MaxItems: 1, - Deprecated: akamai.NoticeDeprecatedUseAlias("dns"), - }, - }, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_authorities_set": dataSourceAuthoritiesSet(), - "akamai_dns_record_set": dataSourceDNSRecordSet(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_dns_zone": resourceDNSv2Zone(), - "akamai_dns_record": resourceDNSv2Record(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c dns.DNS) Option { - return func(p *provider) { +func withClient(c dns.DNS) option { + return func(p *Subprovider) { p.client = c } } // Client returns the DNS interface -func (p *provider) Client(meta akamai.OperationMeta) dns.DNS { +func (p *Subprovider) Client(meta meta.Meta) dns.DNS { if p.client != nil { return p.client } return dns.Client(meta.Session()) } -func getConfigDNSV2Service(d *schema.ResourceData) error { - var inlineConfig *schema.Set - for _, key := range []string{"dns", "config"} { - opt, err := tf.GetSetValue(key, d) - if err != nil { - if !errors.Is(err, tf.ErrNotFound) { - return err - } - continue - } - if inlineConfig != nil { - return fmt.Errorf("only one inline config section can be defined") - } - inlineConfig = opt +// Resources returns terraform resources for imadnsging +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_dns_zone": resourceDNSv2Zone(), + "akamai_dns_record": resourceDNSv2Record(), } - if err := d.Set("config", inlineConfig); err != nil { - return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } - - for _, s := range tf.FindStringValues(d, "dns_section", "config_section") { - if s != "default" && s != "" { - if err := d.Set("config_section", s); err != nil { - return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } - break - } - } - - return nil -} - -func (p *provider) Name() string { - return "dns" -} - -// DNSProviderVersion update version string anytime provider adds new features -const DNSProviderVersion string = "v0.8.3" - -func (p *provider) Version() string { - return DNSProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema } -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap -} - -func (p *provider) Configure(log log.Interface, d *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - if err := getConfigDNSV2Service(d); err != nil { - return diag.FromErr(err) +// DataSources returns terraform data sources for dns +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_authorities_set": dataSourceAuthoritiesSet(), + "akamai_dns_record_set": dataSourceDNSRecordSet(), } - return nil } diff --git a/pkg/providers/dns/provider_test.go b/pkg/providers/dns/provider_test.go index 70ef78364..9bd7f5b14 100644 --- a/pkg/providers/dns/provider_test.go +++ b/pkg/providers/dns/provider_test.go @@ -7,8 +7,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -16,17 +17,17 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) @@ -49,16 +50,6 @@ func useClient(client dns.DNS, f func()) { f() } -func TestProvider(t *testing.T) { - if err := inst.Provider.InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - -func testAccPreCheck(_ *testing.T) { - -} - type data struct { data map[string]interface{} } diff --git a/pkg/providers/dns/resource_akamai_dns_record.go b/pkg/providers/dns/resource_akamai_dns_record.go index 4f19a5f33..af54690ec 100644 --- a/pkg/providers/dns/resource_akamai_dns_record.go +++ b/pkg/providers/dns/resource_akamai_dns_record.go @@ -15,12 +15,13 @@ import ( "sync" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -96,8 +97,9 @@ func getResourceDNSRecordSchema() map[string]*schema.Schema { Required: true, }, "active": { - Type: schema.TypeBool, - Optional: true, + Type: schema.TypeBool, + Optional: true, + Deprecated: "Field 'active' has been deprecated. Setting it has no effect", }, "target": { Type: schema.TypeList, @@ -385,7 +387,7 @@ func dnsRecordFieldTrimQuoteSuppress(_, old, new string, _ *schema.ResourceData) // Suppress check for type_value. Mnemonic config comes back as numeric func dnsRecordTypeValueSuppress(_, _, _ string, d *schema.ResourceData) bool { - logger := akamai.Log("[Akamai DNS]", "dnsRecordTypeValueSuppress") + logger := logger.Get("[Akamai DNS]", "dnsRecordTypeValueSuppress") oldv, newv := d.GetChange("type_value") oldVal, ok := oldv.(int) if !ok { @@ -420,7 +422,7 @@ func dnsRecordTypeValueSuppress(_, _, _ string, d *schema.ResourceData) bool { // DiffSuppresFunc to handle quoted TXT Rdata strings possibly containing escaped quotes func dnsRecordTargetSuppress(key, oldTarget, newTarget string, d *schema.ResourceData) bool { - logger := akamai.Log("[Akamai DNS]", "dnsRecordTargetSuppress") + logger := logger.Get("[Akamai DNS]", "dnsRecordTargetSuppress") //new value (and length) for target is not known during plan if strings.HasSuffix(key, ".#") && newTarget == "" { @@ -593,7 +595,7 @@ func getRecordLock(recordType string) *sync.Mutex { return recordCreateLock[recordType] } -func bumpSoaSerial(ctx context.Context, d *schema.ResourceData, meta akamai.OperationMeta, zone, host string, logger log.Interface) (*dns.RecordBody, error) { +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") if err != nil { @@ -616,7 +618,7 @@ func bumpSoaSerial(ctx context.Context, d *schema.ResourceData, meta akamai.Oper } // Record op function -func execFunc(ctx context.Context, meta akamai.OperationMeta, 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 { @@ -636,7 +638,7 @@ func execFunc(ctx context.Context, meta akamai.OperationMeta, fn string, rec *dn return e } -func executeRecordFunction(ctx context.Context, meta akamai.OperationMeta, 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 @@ -686,7 +688,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte // this prevents lost data if you are using a counter/dynamic variables // in your config.tf which might overwrite each other - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSRecordCreate") logger.Info("Record Create.") // create a context with logging for api calls @@ -840,7 +842,7 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte // this prevents lost data if you are using a counter/dynamic variables // in your config.tf which might overwrite each other - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSRecordUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -994,7 +996,7 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte //nolint:gocyclo func resourceDNSRecordRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSRecordRead") logger.Info("Record Read") // create a context with logging for api calls @@ -1229,7 +1231,7 @@ func validateSOARecord(d *schema.ResourceData, logger log.Interface) bool { } func resourceDNSRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSRecordImport") // create a context with logging for api calls @@ -1314,7 +1316,7 @@ func resourceDNSRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.R } func resourceDNSRecordDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSRecordUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -1410,7 +1412,7 @@ func padCoordinates(str string, logger log.Interface) string { return fmt.Sprintf("%s %s %s %s %s %s %s %s %sm %sm %sm %sm", latD, latM, latS, latDir, longD, longM, longS, longDir, padvalue(altitude, logger), padvalue(size, logger), padvalue(horizPrecision, logger), padvalue(vertPrecision, logger)) } -func bindRecord(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, logger log.Interface) (dns.RecordBody, error) { +func bindRecord(ctx context.Context, meta meta.Meta, d *schema.ResourceData, logger log.Interface) (dns.RecordBody, error) { var host, recordType string var err error @@ -1445,7 +1447,7 @@ func bindRecord(ctx context.Context, meta akamai.OperationMeta, d *schema.Resour } //nolint:gocyclo -func newRecordCreate(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, recordType string, target []interface{}, host string, ttl int, logger log.Interface) (dns.RecordBody, error) { +func newRecordCreate(ctx context.Context, meta meta.Meta, d *schema.ResourceData, recordType string, target []interface{}, host string, ttl int, logger log.Interface) (dns.RecordBody, error) { var recordCreate dns.RecordBody switch recordType { case RRTypeAfsdb: diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index 1ae846857..93c5d65d3 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -5,8 +5,8 @@ import ( "net/http" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" @@ -85,7 +85,6 @@ func TestResDnsRecord(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { @@ -198,7 +197,6 @@ func TestResDnsRecord(t *testing.T) { useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { diff --git a/pkg/providers/dns/resource_akamai_dns_zone.go b/pkg/providers/dns/resource_akamai_dns_zone.go index 3be07ee64..18d0e9a6a 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone.go +++ b/pkg/providers/dns/resource_akamai_dns_zone.go @@ -11,11 +11,11 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -120,7 +120,7 @@ func resourceDNSv2Zone() *schema.Resource { func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSZoneCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -233,7 +233,7 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte func resourceDNSv2ZoneRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSZoneRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -322,7 +322,7 @@ func resourceDNSv2ZoneUpdate(ctx context.Context, d *schema.ResourceData, m inte var diags diag.Diagnostics hostname := d.Get("zone").(string) - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSZoneUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -397,7 +397,7 @@ func resourceDNSv2ZoneUpdate(ctx context.Context, d *schema.ResourceData, m inte // Import Zone. Id is the zone func resourceDNSv2ZoneImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { hostname := d.Id() - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSZoneImport") // create a context with logging for api calls ctx := context.TODO() @@ -448,7 +448,7 @@ func resourceDNSv2ZoneDelete(_ context.Context, d *schema.ResourceData, m interf if err != nil { return diag.FromErr(err) } - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("AkamaiDNS", "resourceDNSZoneDelete") logger.WithField("zone", hostname).Info("Zone Delete") // Ignore for Unit test Lifecycle @@ -644,7 +644,7 @@ func checkDNSv2Zone(d tf.ResourceDataFetcher) error { } // Util func to create SOA and NS records -func checkZoneSOAandNSRecords(ctx context.Context, meta akamai.OperationMeta, zone *dns.ZoneResponse, logger log.Interface) error { +func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.ZoneResponse, logger log.Interface) error { logger.Debugf("Checking SOA and NS records exist for zone %s", zone.Zone) var resp *dns.RecordSetResponse var err error diff --git a/pkg/providers/dns/resource_akamai_dns_zone_test.go b/pkg/providers/dns/resource_akamai_dns_zone_test.go index 6d4c1923d..e5d5ee4d7 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone_test.go +++ b/pkg/providers/dns/resource_akamai_dns_zone_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/dns" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -77,7 +77,6 @@ func TestResDnsZone(t *testing.T) { }() useClient(client, func() { resource.UnitTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { diff --git a/pkg/providers/edgeworkers/bundle_hash.go b/pkg/providers/edgeworkers/bundle_hash.go index 1d6057cc5..c2439aba6 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" ) type bundleFile struct { diff --git a/pkg/providers/edgeworkers/bundle_hash_test.go b/pkg/providers/edgeworkers/bundle_hash_test.go index 5c57dce1d..14e35c218 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/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 750ef0ea7..1bd96365b 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go @@ -4,10 +4,10 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -49,7 +49,7 @@ func dataSourceEdgeKVGroupItems() *schema.Resource { } func dataEdgeKVGroupItems(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "dataEdgeKVGroupItems") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) 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 27db382bc..32196de8b 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go @@ -4,8 +4,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 cd09e1678..2fd494443 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go @@ -4,10 +4,10 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -44,7 +44,7 @@ func dataSourceEdgeKVGroups() *schema.Resource { } func dataEdgeKVGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "dataEdgeKVGroupsRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go b/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go index aec850e2e..23032a7dc 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go @@ -4,8 +4,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/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 2080f4f6c..8b112a113 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker.go @@ -10,10 +10,10 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -70,7 +70,7 @@ func dataSourceEdgeWorker() *schema.Resource { } func dataEdgeWorkerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "dataEdgeWorkerRead") ctx = session.ContextWithOptions( diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go index 479789630..2733907a7 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go @@ -4,10 +4,10 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -47,7 +47,7 @@ func dataSourceEdgeWorkerActivation() *schema.Resource { } func dataEdgeWorkerActivationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "dataEdgeWorkerActivationsRead") ctx = session.ContextWithOptions( diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go index 7bac4bad9..e54c2b5fc 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" "github.com/hashicorp/terraform-plugin-sdk/v2/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 db3859e74..6d31485cc 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworkers_property_rules.go b/pkg/providers/edgeworkers/data_akamai_edgeworkers_property_rules.go index 9fefedc04..1a8784ded 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworkers_property_rules.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworkers_property_rules.go @@ -6,8 +6,8 @@ import ( "encoding/json" "strconv" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,7 +31,7 @@ func dataSourceEdgeworkersPropertyRules() *schema.Resource { } func dataEdgeworkersPropertyRulesRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) log := meta.Log("Edgeworkers", "dataEdgeworkersPropertyRulesRead") log.Debug("Generating EdgeWorker rules JSON") diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go index a857d1d73..c1546756d 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go @@ -5,10 +5,10 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func dataSourceEdgeworkersResourceTier() *schema.Resource { } func dataEdgeworkersResourceTierRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) log := meta.Log("Edgeworkers", "dataEdgeworkersResourceTierRead") log.Debug("Reading Resource Tier") 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 139217b1f..c046228ae 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/edgeworkers/edgeworkers.go b/pkg/providers/edgeworkers/edgeworkers.go index 71f66e556..e8105bb5d 100644 --- a/pkg/providers/edgeworkers/edgeworkers.go +++ b/pkg/providers/edgeworkers/edgeworkers.go @@ -1,10 +1,7 @@ -//go:build all || edgeworkers -// +build all edgeworkers - package edgeworkers -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/edgeworkers/provider.go b/pkg/providers/edgeworkers/provider.go index 1d2c5b85c..33e22b653 100644 --- a/pkg/providers/edgeworkers/provider.go +++ b/pkg/providers/edgeworkers/provider.go @@ -4,34 +4,33 @@ package edgeworkers import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers edgeworkers resources and data sources + Subprovider struct { client edgeworkers.Edgeworkers } - // Option is a edgeworkers provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -41,66 +40,38 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{}, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_edgekv_group_items": dataSourceEdgeKVGroupItems(), - "akamai_edgekv_groups": dataSourceEdgeKVGroups(), - "akamai_edgeworkers_resource_tier": dataSourceEdgeworkersResourceTier(), - "akamai_edgeworkers_property_rules": dataSourceEdgeworkersPropertyRules(), - "akamai_edgeworker": dataSourceEdgeWorker(), - "akamai_edgeworker_activation": dataSourceEdgeWorkerActivation(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_edgekv": resourceEdgeKV(), - "akamai_edgekv_group_items": resourceEdgeKVGroupItems(), - "akamai_edgeworkers_activation": resourceEdgeworkersActivation(), - "akamai_edgeworker": resourceEdgeWorker(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c edgeworkers.Edgeworkers) Option { - return func(p *provider) { +func withClient(c edgeworkers.Edgeworkers) option { + return func(p *Subprovider) { p.client = c } } // Client returns the edgeworkers interface -func (p *provider) Client(meta akamai.OperationMeta) edgeworkers.Edgeworkers { +func (p *Subprovider) Client(meta meta.Meta) edgeworkers.Edgeworkers { if p.client != nil { return p.client } return edgeworkers.Client(meta.Session()) } -func (p *provider) Name() string { - return "edgeworkers" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for edgeworkers +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_edgekv": resourceEdgeKV(), + "akamai_edgekv_group_items": resourceEdgeKVGroupItems(), + "akamai_edgeworkers_activation": resourceEdgeworkersActivation(), + "akamai_edgeworker": resourceEdgeWorker(), + } } -func (p *provider) Configure(_ log.Interface, _ *schema.ResourceData) diag.Diagnostics { - return nil +// DataSources returns terraform data sources for edgeworkers +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_edgekv_group_items": dataSourceEdgeKVGroupItems(), + "akamai_edgekv_groups": dataSourceEdgeKVGroups(), + "akamai_edgeworkers_resource_tier": dataSourceEdgeworkersResourceTier(), + "akamai_edgeworkers_property_rules": dataSourceEdgeworkersPropertyRules(), + "akamai_edgeworker": dataSourceEdgeWorker(), + "akamai_edgeworker_activation": dataSourceEdgeWorkerActivation(), + } } diff --git a/pkg/providers/edgeworkers/provider_test.go b/pkg/providers/edgeworkers/provider_test.go index eb031887d..707da4445 100644 --- a/pkg/providers/edgeworkers/provider_test.go +++ b/pkg/providers/edgeworkers/provider_test.go @@ -8,8 +8,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -18,28 +19,22 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv.go b/pkg/providers/edgeworkers/resource_akamai_edgekv.go index cbf0ce941..2d4d317db 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv.go @@ -7,11 +7,11 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -107,7 +107,7 @@ func resourceEdgeKV() *schema.Resource { } func resourceEdgeKVCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -192,7 +192,7 @@ func resourceEdgeKVCreate(ctx context.Context, rd *schema.ResourceData, m interf } func resourceEdgeKVRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -238,7 +238,7 @@ func resourceEdgeKVRead(ctx context.Context, rd *schema.ResourceData, m interfac } func resourceEdgeKVUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -296,7 +296,7 @@ func resourceEdgeKVUpdate(ctx context.Context, rd *schema.ResourceData, m interf } func resourceEdgeKVDelete(_ context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVDelete") logger.Debug("Deleting EdgeKV namespace configuration") logger.Info("EdgeKV namespace deletion is highly discouraged - resource will only be removed from local state") diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go index 7a3053cab..81e084b25 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go @@ -7,11 +7,11 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -61,7 +61,7 @@ func resourceEdgeKVGroupItems() *schema.Resource { } func resourceEdgeKVGroupItemsCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVGroupItemsCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -104,7 +104,7 @@ func resourceEdgeKVGroupItemsCreate(ctx context.Context, rd *schema.ResourceData } func resourceEdgeKVGroupItemsRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVGroupItemsRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -148,7 +148,7 @@ func resourceEdgeKVGroupItemsRead(ctx context.Context, rd *schema.ResourceData, } func resourceEdgeKVGroupItemsUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVGroupItemsUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -243,7 +243,7 @@ func resourceEdgeKVGroupItemsUpdate(ctx context.Context, rd *schema.ResourceData } func resourceEdgeKVGroupItemsDelete(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeKV", "resourceEdgeKVGroupItemsDelete") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) 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 151aa77fe..51ceb72c9 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go index 39cf11f84..167e3f921 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go @@ -11,13 +11,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" ) func Test_populateEKV(t *testing.T) { diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go index 2f8373a4f..e249c002f 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go @@ -14,11 +14,11 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "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" @@ -93,7 +93,7 @@ func resourceEdgeWorker() *schema.Resource { } func resourceEdgeWorkerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "resourceEdgeWorkerCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -167,7 +167,7 @@ func resourceEdgeWorkerCreate(ctx context.Context, d *schema.ResourceData, m int } func resourceEdgeWorkerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "resourceEdgeWorkerRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -226,7 +226,7 @@ func resourceEdgeWorkerRead(ctx context.Context, d *schema.ResourceData, m inter } func resourceEdgeWorkerUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "resourceEdgeWorkerUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -314,7 +314,7 @@ func resourceEdgeWorkerUpdate(ctx context.Context, d *schema.ResourceData, m int } func resourceEdgeWorkerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "resourceEdgeWorkerDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -460,7 +460,7 @@ func convertWarningsToListOfStrings(res *edgeworkers.ValidateBundleResponse) ([] } func resourceEdgeWorkerImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "resourceEdgeWorkerImport") logger.Debug("Importing EdgeWorker version") @@ -509,7 +509,7 @@ func resourceEdgeWorkerImport(ctx context.Context, d *schema.ResourceData, m int } func bundleHashCustomDiff(_ context.Context, diff *schema.ResourceDiff, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("EdgeWorkers", "bundleHashCustomDiff") allSetComputed := func(fields ...string) error { diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go index dd477ef59..aa1c3bb86 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go index 353348ffe..7554a50d9 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go @@ -9,11 +9,11 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -83,7 +83,7 @@ var ( ) func resourceEdgeworkersActivationCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Edgeworkers", "resourceEdgeworkersActivationCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -94,7 +94,7 @@ func resourceEdgeworkersActivationCreate(ctx context.Context, rd *schema.Resourc } func resourceEdgeworkersActivationRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Edgeworkers", "resourceEdgeworkersActivationRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -131,7 +131,7 @@ func resourceEdgeworkersActivationRead(ctx context.Context, rd *schema.ResourceD } func resourceEdgeworkersActivationUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Edgeworkers", "resourceEdgeworkersActivationUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -142,7 +142,7 @@ func resourceEdgeworkersActivationUpdate(ctx context.Context, rd *schema.Resourc } func resourceEdgeworkersActivationDelete(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Edgeworkers", "resourceEdgeworkersActivationDelete") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -207,7 +207,7 @@ func resourceEdgeworkersActivationDelete(ctx context.Context, rd *schema.Resourc } func resourceEdgeworkersActivationImport(_ context.Context, rd *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Edgeworkers", "resourceEdgeworkersActivationImport") logger.Debug("Importing edgeworker") @@ -513,7 +513,7 @@ func sortDeactivationsByDate(deactivations []edgeworkers.Deactivation) []edgewor // it checks if edgeworker with provided edgeworker_id exists on ForceNew // to avoid deactivating and then failing to activate func checkEdgeworkerExistsOnDiff(ctx context.Context, rd *schema.ResourceDiff, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Edgeworkers", "checkEdgeworkerExistsOnDiff") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go index 6fbea00e4..cfc4a1eb7 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/v6/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgeworkers" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_datacenter.go index e9cb9f021..06842fc00 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter.go @@ -4,10 +4,10 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -142,7 +142,7 @@ func dataSourceGTMDatacenter() *schema.Resource { } func dataGTMDatacenterRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "dataGTMDatacenterRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go index 55313bfc7..607340e0e 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters.go b/pkg/providers/gtm/data_akamai_gtm_datacenters.go index 4f9478858..f86b1ded5 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters.go @@ -3,9 +3,9 @@ package gtm import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -149,7 +149,7 @@ func dataSourceGTMDatacenters() *schema.Resource { } func dataGTMDatacentersRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "dataGTMDatacentersRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go index 552e97625..0bf982dc9 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go index b187606d7..49f124009 100644 --- a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -46,7 +46,7 @@ func dataSourceGTMDefaultDatacenter() *schema.Resource { } func dataSourceGTMDefaultDatacenterRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "dataSourceGTMDefaultDatacenterRead") // create a context with logging for api calls 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 2c7387f4f..b35af394c 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/gtm.go b/pkg/providers/gtm/gtm.go index 925421278..39c51c630 100644 --- a/pkg/providers/gtm/gtm.go +++ b/pkg/providers/gtm/gtm.go @@ -1,10 +1,7 @@ -//go:build all || gtm -// +build all gtm - package gtm -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/gtm/provider.go b/pkg/providers/gtm/provider.go index b2a54ce3b..d3b202aa2 100644 --- a/pkg/providers/gtm/provider.go +++ b/pkg/providers/gtm/provider.go @@ -2,156 +2,72 @@ package gtm import ( - "errors" - "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/config" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers gtm resources and data sources + Subprovider struct { client gtm.GTM } - // Option is a gtm provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider() akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider() *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} }) return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{ - "gtm_section": { - Optional: true, - Type: schema.TypeString, - Default: "default", - Deprecated: akamai.NoticeDeprecatedUseAlias("gtm_section"), - }, - "gtm": { - Optional: true, - Type: schema.TypeSet, - Elem: config.Options("gtm"), - MaxItems: 1, - Deprecated: akamai.NoticeDeprecatedUseAlias("gtm"), - }, - }, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_gtm_datacenter": dataSourceGTMDatacenter(), - "akamai_gtm_datacenters": dataSourceGTMDatacenters(), - "akamai_gtm_default_datacenter": dataSourceGTMDefaultDatacenter(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_gtm_domain": resourceGTMv1Domain(), - "akamai_gtm_property": resourceGTMv1Property(), - "akamai_gtm_datacenter": resourceGTMv1Datacenter(), - "akamai_gtm_resource": resourceGTMv1Resource(), - "akamai_gtm_asmap": resourceGTMv1ASmap(), - "akamai_gtm_geomap": resourceGTMv1Geomap(), - "akamai_gtm_cidrmap": resourceGTMv1Cidrmap(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c gtm.GTM) Option { - return func(p *provider) { +func withClient(c gtm.GTM) option { + return func(p *Subprovider) { p.client = c } } // Client returns the DNS interface -func (p *provider) Client(meta akamai.OperationMeta) gtm.GTM { +func (p *Subprovider) Client(meta meta.Meta) gtm.GTM { if p.client != nil { return p.client } return gtm.Client(meta.Session()) } -func getConfigGTMV1Service(d *schema.ResourceData) error { - var inlineConfig *schema.Set - for _, key := range []string{"gtm", "config"} { - opt, err := tf.GetSetValue(key, d) - if err != nil { - if !errors.Is(err, tf.ErrNotFound) { - return err - } - continue - } - if inlineConfig != nil { - return fmt.Errorf("only one inline config section can be defined") - } - inlineConfig = opt +// Resources returns terraform resources for gtm +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_gtm_domain": resourceGTMv1Domain(), + "akamai_gtm_property": resourceGTMv1Property(), + "akamai_gtm_datacenter": resourceGTMv1Datacenter(), + "akamai_gtm_resource": resourceGTMv1Resource(), + "akamai_gtm_asmap": resourceGTMv1ASmap(), + "akamai_gtm_geomap": resourceGTMv1Geomap(), + "akamai_gtm_cidrmap": resourceGTMv1Cidrmap(), } - if err := d.Set("config", inlineConfig); err != nil { - return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } - - for _, s := range tf.FindStringValues(d, "gtm_section", "config_section") { - if s != "default" && s != "" { - if err := d.Set("config_section", s); err != nil { - return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } - break - } - } - - return nil -} - -func (p *provider) Name() string { - return "gtm" -} - -// GTMProviderVersion update version string anytime provider adds new features -const GTMProviderVersion string = "v0.8.3" - -func (p *provider) Version() string { - return GTMProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema } -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap -} - -func (p *provider) Configure(log log.Interface, d *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - if err := getConfigGTMV1Service(d); err != nil { - return nil +// DataSources returns terraform data sources for gtm +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_gtm_datacenter": dataSourceGTMDatacenter(), + "akamai_gtm_datacenters": dataSourceGTMDatacenters(), + "akamai_gtm_default_datacenter": dataSourceGTMDefaultDatacenter(), } - return nil } diff --git a/pkg/providers/gtm/provider_test.go b/pkg/providers/gtm/provider_test.go index 6949060fb..74d6d6440 100644 --- a/pkg/providers/gtm/provider_test.go +++ b/pkg/providers/gtm/provider_test.go @@ -7,9 +7,10 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -17,28 +18,23 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap.go b/pkg/providers/gtm/resource_akamai_gtm_asmap.go index 63df1b298..270289024 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap.go @@ -6,10 +6,11 @@ import ( "net/http" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -82,7 +83,7 @@ func resourceGTMv1ASmap() *schema.Resource { } // Util method to validate default datacenter and create if necessary -func validateDefaultDC(ctx context.Context, meta akamai.OperationMeta, ddcField []interface{}, domain string) error { +func validateDefaultDC(ctx context.Context, meta meta.Meta, ddcField []interface{}, domain string) error { if len(ddcField) == 0 { return fmt.Errorf("default Datacenter invalid") @@ -124,7 +125,7 @@ func validateDefaultDC(ctx context.Context, meta akamai.OperationMeta, ddcField // Create a new GTM ASmap func resourceGTMv1ASmapCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ASmapCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -210,7 +211,7 @@ func resourceGTMv1ASmapCreate(ctx context.Context, d *schema.ResourceData, m int // read asMap. updates state with entire API result configuration. func resourceGTMv1ASmapRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ASmapRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -241,7 +242,7 @@ func resourceGTMv1ASmapRead(ctx context.Context, d *schema.ResourceData, m inter // Update GTM ASmap func resourceGTMv1ASmapUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ASmapUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -314,7 +315,7 @@ func resourceGTMv1ASmapUpdate(ctx context.Context, d *schema.ResourceData, m int // Import GTM ASmap. func resourceGTMv1ASmapImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ASmapImport") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -347,7 +348,7 @@ func resourceGTMv1ASmapImport(ctx context.Context, d *schema.ResourceData, m int // Delete GTM ASmap. func resourceGTMv1ASmapDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ASmapDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -418,7 +419,7 @@ func resourceGTMv1ASmapDelete(ctx context.Context, d *schema.ResourceData, m int } // Create and populate a new asMap object from asMap data -func populateNewASmapObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) *gtm.AsMap { +func populateNewASmapObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) *gtm.AsMap { asMapName, _ := tf.GetStringValue("name", d) asObj := inst.Client(meta).NewAsMap(ctx, asMapName) @@ -444,7 +445,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASmapState") // walk through all state elements @@ -457,7 +458,7 @@ func populateTerraformASmapState(d *schema.ResourceData, as *gtm.AsMap, m interf // create and populate GTM ASmap Assignments object func populateAsAssignmentsObject(d *schema.ResourceData, as *gtm.AsMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateAsAssignmentsObject") // pull apart List @@ -489,7 +490,7 @@ func populateAsAssignmentsObject(d *schema.ResourceData, as *gtm.AsMap, m interf // create and populate Terraform asMap assignments schema func populateTerraformAsAssignmentsState(d *schema.ResourceData, asm *gtm.AsMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformAsAssignmentsState") var asStateList []map[string]interface{} @@ -509,7 +510,7 @@ func populateTerraformAsAssignmentsState(d *schema.ResourceData, asm *gtm.AsMap, // create and populate GTM ASmap DefaultDatacenter object func populateAsDefaultDCObject(d *schema.ResourceData, as *gtm.AsMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTMv1", "resourceGTMv1ASmapDelete") // pull apart List @@ -535,7 +536,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformAsDefaultDCState") ddcListNew := make([]interface{}, 1) @@ -551,7 +552,7 @@ func populateTerraformAsDefaultDCState(d *schema.ResourceData, as *gtm.AsMap, m // assignmentDiffSuppress is a diff suppress function used in gtm_asmap, gtm_cidrmap and gtm_geomap resources func assignmentDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { - logger := akamai.Log("Akamai GTM", "assignmentDiffSuppress") + logger := logger.Get("Akamai GTM", "assignmentDiffSuppress") oldVal, newVal := d.GetChange("assignment") oldList, ok := oldVal.([]interface{}) @@ -626,7 +627,7 @@ func assignmentDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { // asNumbersEqual checks whether the as_numbers are equal func asNumbersEqual(old, new interface{}) bool { - logger := akamai.Log("Akamai GTM", "asNumbersEqual") + logger := logger.Get("Akamai GTM", "asNumbersEqual") oldVal, ok := old.(*schema.Set) if !ok { diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go index 6df7da654..5f2551599 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go index aff857bd2..e513080b6 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go @@ -4,11 +4,12 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -81,7 +82,7 @@ func resourceGTMv1Cidrmap() *schema.Resource { // Create a new GTM CidrMap func resourceGTMv1CidrMapCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMCidrMapCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -165,7 +166,7 @@ func resourceGTMv1CidrMapCreate(ctx context.Context, d *schema.ResourceData, m i // read cidrMap. updates state with entire API result configuration. func resourceGTMv1CidrMapRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMCidrMapRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -197,7 +198,7 @@ func resourceGTMv1CidrMapRead(ctx context.Context, d *schema.ResourceData, m int // Update GTM CidrMap func resourceGTMv1CidrMapUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMCidrMapUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -269,7 +270,7 @@ func resourceGTMv1CidrMapUpdate(ctx context.Context, d *schema.ResourceData, m i // Import GTM CidrMap. func resourceGTMv1CidrMapImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMCidrMapImport") // create a context with logging for api calls ctx := context.Background() @@ -303,7 +304,7 @@ func resourceGTMv1CidrMapImport(d *schema.ResourceData, m interface{}) ([]*schem // Delete GTM CidrMap. func resourceGTMv1CidrMapDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMCidrMapDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -373,7 +374,7 @@ func resourceGTMv1CidrMapDelete(ctx context.Context, d *schema.ResourceData, m i } // Create and populate a new cidrMap object from cidrMap data -func populateNewCidrMapObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) *gtm.CidrMap { +func populateNewCidrMapObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) *gtm.CidrMap { logger := meta.Log("Akamai GTM", "populateNewCidrMapObject") cidrMapName, err := tf.GetStringValue("name", d) @@ -404,7 +405,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrMapState") // walk through all state elements @@ -418,7 +419,7 @@ func populateTerraformCidrMapState(d *schema.ResourceData, cidr *gtm.CidrMap, m // create and populate GTM CidrMap Assignments object func populateCidrAssignmentsObject(d *schema.ResourceData, cidr *gtm.CidrMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateCidrAssignmentsObject") // pull apart List @@ -449,7 +450,7 @@ func populateCidrAssignmentsObject(d *schema.ResourceData, cidr *gtm.CidrMap, m // create and populate Terraform cidrMap assignments schema func populateTerraformCidrAssignmentsState(d *schema.ResourceData, cidr *gtm.CidrMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrAssignmentsState") objectInventory := make(map[int]*gtm.CidrAssignment, len(cidr.Assignments)) @@ -495,7 +496,7 @@ func populateTerraformCidrAssignmentsState(d *schema.ResourceData, cidr *gtm.Cid // create and populate GTM CidrMap DefaultDatacenter object func populateCidrDefaultDCObject(d *schema.ResourceData, cidr *gtm.CidrMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateCidrDefaultDCObject") // pull apart List @@ -521,7 +522,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrDefaultDCState") ddcListNew := make([]interface{}, 1) @@ -537,7 +538,7 @@ func populateTerraformCidrDefaultDCState(d *schema.ResourceData, cidr *gtm.CidrM // blocksEqual checks whether blocks are equal func blocksEqual(old, new interface{}) bool { - logger := akamai.Log("Akamai GTM", "blocksEqual") + logger := logger.Get("Akamai GTM", "blocksEqual") oldBlocks, ok := old.(*schema.Set) if !ok { diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go index 0dc5f312e..83b34aaef 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go index f434d3fb1..94148e790 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go @@ -8,11 +8,11 @@ import ( "strings" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -159,7 +159,7 @@ var ( // Create a new GTM Datacenter func resourceGTMv1DatacenterCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DatacenterCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -239,7 +239,7 @@ func resourceGTMv1DatacenterCreate(ctx context.Context, d *schema.ResourceData, // 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 resourceGTMv1DatacenterRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DatacenterRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -275,7 +275,7 @@ func resourceGTMv1DatacenterRead(ctx context.Context, d *schema.ResourceData, m // Update GTM Datacenter func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DatacenterUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -348,7 +348,7 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, } func resourceGTMv1DatacenterImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTMv1", "resourceGTMv1DatacenterImport") // create a context with logging for api calls ctx := context.Background() @@ -382,7 +382,7 @@ func resourceGTMv1DatacenterImport(d *schema.ResourceData, m interface{}) ([]*sc // Delete GTM Datacenter. func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DatacenterDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -459,7 +459,7 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, } // Create and populate a new datacenter object from resource data -func populateNewDatacenterObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) (*gtm.Datacenter, error) { +func populateNewDatacenterObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) (*gtm.Datacenter, error) { dcObj := inst.Client(meta).NewDatacenter(ctx) dcObj.DefaultLoadObject = gtm.NewLoadObject() @@ -471,7 +471,7 @@ func populateNewDatacenterObject(ctx context.Context, meta akamai.OperationMeta, // nolint:gocyclo // Populate existing datacenter object from resource data func populateDatacenterObject(d *schema.ResourceData, dc *gtm.Datacenter, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateDatacenterObject") vstr, err := tf.GetStringValue("nickname", d) @@ -645,7 +645,7 @@ func populateDatacenterObject(d *schema.ResourceData, dc *gtm.Datacenter, m inte // Populate Terraform state from provided Datacenter object func populateTerraformDCState(d *schema.ResourceData, dc *gtm.Datacenter, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerrafomDCState") // walk through all state elements diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go index 01838da02..b9ba9e638 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain.go b/pkg/providers/gtm/resource_akamai_gtm_domain.go index 2bccc97c0..44d5e00d4 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain.go @@ -10,10 +10,10 @@ import ( "github.com/hashicorp/go-cty/cty" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -208,7 +208,7 @@ func GetQueryArgs(d *schema.ResourceData) (map[string]string, error) { // Create a new GTM Domain func resourceGTMv1DomainCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DomainCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -310,7 +310,7 @@ func resourceGTMv1DomainCreate(ctx context.Context, d *schema.ResourceData, m in // 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 resourceGTMv1DomainRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DomainRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -337,7 +337,7 @@ func resourceGTMv1DomainRead(ctx context.Context, d *schema.ResourceData, m inte // Update GTM Domain func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DomainUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -421,7 +421,7 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in // Delete GTM Domain. Admin privileges required in current API version. func resourceGTMv1DomainDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DomainDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -510,7 +510,7 @@ func resourceGTMv1DomainDelete(ctx context.Context, d *schema.ResourceData, m in } func resourceGTMv1DomainImport(_ context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1DomainImport") logger.Debugf("Importing GTM Domain: %s", d.Id()) @@ -526,13 +526,13 @@ func resourceGTMv1DomainImport(_ context.Context, d *schema.ResourceData, m inte func validateDomainType(v interface{}, _ cty.Path) diag.Diagnostics { value := strings.ToUpper(v.(string)) if value != "BASIC" && value != "FULL" && value != "WEIGHTED" && value != "STATIC" && value != "FAILOVER-ONLY" { - return diag.Errorf(("type must be basic, full, weighted, static, or failover-only")) + return diag.Errorf("type must be basic, full, weighted, static, or failover-only") } return nil } // Create and populate a new domain object from resource data -func populateNewDomainObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) (*gtm.Domain, error) { +func populateNewDomainObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) (*gtm.Domain, error) { name, _ := tf.GetStringValue("name", d) domObj := inst.Client(meta).NewDomain(ctx, name, d.Get("type").(string)) @@ -545,7 +545,7 @@ func populateNewDomainObject(ctx context.Context, meta akamai.OperationMeta, d * // nolint:gocyclo // Populate existing domain object from resource data func populateDomainObject(d *schema.ResourceData, dom *gtm.Domain, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateDomainObject") domainName, err := tf.GetStringValue("name", d) @@ -721,7 +721,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformState") for stateKey, stateValue := range map[string]interface{}{ @@ -766,7 +766,7 @@ func populateTerraformState(d *schema.ResourceData, dom *gtm.Domain, m interface // 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 := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTMv1", "waitForCompletion") var defaultInterval = 5 * time.Second diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go index 27c30c47b..fd0bab327 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap.go b/pkg/providers/gtm/resource_akamai_gtm_geomap.go index 0af4014d4..bb3ee10ac 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap.go @@ -4,11 +4,12 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -82,7 +83,7 @@ func resourceGTMv1Geomap() *schema.Resource { // Create a new GTM GeoMap func resourceGTMv1GeomapCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1GeomapCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -170,7 +171,7 @@ func resourceGTMv1GeomapCreate(ctx context.Context, d *schema.ResourceData, m in // read geoMap. updates state with entire API result configuration. func resourceGTMv1GeomapRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1GeomapRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -202,7 +203,7 @@ func resourceGTMv1GeomapRead(ctx context.Context, d *schema.ResourceData, m inte // Update GTM GeoMap func resourceGTMv1GeomapUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1GeomapUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -278,7 +279,7 @@ func resourceGTMv1GeomapUpdate(ctx context.Context, d *schema.ResourceData, m in // Import GTM GeoMap. func resourceGTMv1GeomapImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1GeomapImport") // create a context with logging for api calls ctx := context.Background() @@ -313,7 +314,7 @@ func resourceGTMv1GeomapImport(d *schema.ResourceData, m interface{}) ([]*schema // Delete GTM GeoMap. func resourceGTMv1GeomapDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1GeomapDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -386,7 +387,7 @@ func resourceGTMv1GeomapDelete(ctx context.Context, d *schema.ResourceData, m in } // Create and populate a new geoMap object from geoMap data -func populateNewGeoMapObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) *gtm.GeoMap { +func populateNewGeoMapObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) *gtm.GeoMap { name, _ := tf.GetStringValue("name", d) geoObj := inst.Client(meta).NewGeoMap(ctx, name) @@ -410,7 +411,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoMapState") // walk through all state elements @@ -423,7 +424,7 @@ func populateTerraformGeoMapState(d *schema.ResourceData, geo *gtm.GeoMap, m int // create and populate GTM GeoMap Assignments object func populateGeoAssignmentsObject(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateGeoAssignmentsObject") // pull apart List @@ -458,7 +459,7 @@ func populateGeoAssignmentsObject(d *schema.ResourceData, geo *gtm.GeoMap, m int // create and populate Terraform geoMap assignments schema func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoAssignmentsState") objectInventory := make(map[int]*gtm.GeoAssignment, len(geo.Assignments)) @@ -505,7 +506,7 @@ func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GeoMa // create and populate GTM GeoMap DefaultDatacenter object func populateGeoDefaultDCObject(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateGeoDefaultDCObject") // pull apart List @@ -528,7 +529,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{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoDefault") ddcListNew := make([]interface{}, 1) @@ -544,7 +545,7 @@ func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GeoMap, // countriesEqual checks whether countries are equal func countriesEqual(old, new interface{}) bool { - logger := akamai.Log("Akamai GTM", "countriesEqual") + logger := logger.Get("Akamai GTM", "countriesEqual") oldCountries, ok := old.(*schema.Set) if !ok { diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go index 7b5b90fe6..a31dab7e1 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 7df2d34bc..2215ef9ec 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -7,13 +7,15 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "golang.org/x/exp/slices" ) func resourceGTMv1Property() *schema.Resource { @@ -22,6 +24,7 @@ func resourceGTMv1Property() *schema.Resource { ReadContext: resourceGTMv1PropertyRead, UpdateContext: resourceGTMv1PropertyUpdate, DeleteContext: resourceGTMv1PropertyDelete, + CustomizeDiff: validateTestObject, Importer: &schema.ResourceImporter{ State: resourceGTMv1PropertyImport, }, @@ -239,7 +242,7 @@ func resourceGTMv1Property() *schema.Resource { }, "test_object": { Type: schema.TypeString, - Required: true, + Optional: true, }, "request_string": { Type: schema.TypeString, @@ -349,6 +352,46 @@ func parseResourceStringID(id string) (string, string, error) { } +// validateTestObject checks if `test_object` is provided when `test_object_protocol` is set to `HTTP`, `HTTPS` or `FTP` +func validateTestObject(_ context.Context, d *schema.ResourceDiff, m interface{}) error { + meta := meta.Must(m) + logger := meta.Log("Akamai GTM", "validateTestObject") + logger.Debug("Validating test_object") + + livenessTestRaw, ok := d.GetOkExists("liveness_test") + if !ok { + return nil + } + + livenessTest, ok := livenessTestRaw.([]interface{}) + if !ok { + return fmt.Errorf("could not cast the value of type %T to []interface{}", livenessTest) + } + + requiredWith := []string{"HTTP", "HTTPS", "FTP"} + + for _, itemRaw := range livenessTest { + item, ok := itemRaw.(map[string]interface{}) + if !ok { + return fmt.Errorf("could not cast the value of type %T to map[string]interface{}", item) + } + testObjectProtocol, ok := item["test_object_protocol"].(string) + if !ok { + return fmt.Errorf("could not cast the value of type %T to string", testObjectProtocol) + } + testObject, ok := item["test_object"].(string) + if !ok { + return fmt.Errorf("could not cast the value of type %T to string", testObject) + } + + if slices.Contains(requiredWith, testObjectProtocol) && testObject == "" { + return fmt.Errorf("attribute 'test_object' is required when 'test_object_protocol' is set to 'HTTP', 'HTTPS' or 'FTP'") + } + } + + return nil +} + // validateTTL is a SchemaValidateDiagFunc to validate dynamic_ttl and static_ttl. func validateTTL(v interface{}, path cty.Path) diag.Diagnostics { schemaFieldName, err := tf.GetSchemaFieldNameFromPath(path) @@ -376,7 +419,7 @@ func validateTTL(v interface{}, path cty.Path) diag.Diagnostics { // Create a new GTM Property func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1PropertyCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -457,7 +500,7 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m // 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 { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1PropertyRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -483,7 +526,7 @@ func resourceGTMv1PropertyRead(ctx context.Context, d *schema.ResourceData, m in // Update GTM Property func resourceGTMv1PropertyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1PropertyUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -544,7 +587,7 @@ func resourceGTMv1PropertyUpdate(ctx context.Context, d *schema.ResourceData, m // Import GTM Property. func resourceGTMv1PropertyImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1PropertyImport") // create a context with logging for api calls ctx := context.Background() @@ -577,7 +620,7 @@ func resourceGTMv1PropertyImport(d *schema.ResourceData, m interface{}) ([]*sche // Delete GTM Property. func resourceGTMv1PropertyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1PropertyDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -635,7 +678,7 @@ func resourceGTMv1PropertyDelete(ctx context.Context, d *schema.ResourceData, m // nolint:gocyclo // Populate existing property object from resource data func populatePropertyObject(ctx context.Context, d *schema.ResourceData, prop *gtm.Property, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populatePropertyObject") vstr, err := tf.GetStringValue("name", d) @@ -841,7 +884,7 @@ func populatePropertyObject(ctx context.Context, d *schema.ResourceData, prop *g } // Create and populate a new property object from resource data -func populateNewPropertyObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) (*gtm.Property, error) { +func populateNewPropertyObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) (*gtm.Property, error) { name, _ := tf.GetStringValue("name", d) propObj := inst.Client(meta).NewProperty(ctx, name) @@ -855,7 +898,7 @@ func populateNewPropertyObject(ctx context.Context, meta akamai.OperationMeta, d // Populate Terraform state from provided Property object func populateTerraformPropertyState(d *schema.ResourceData, prop *gtm.Property, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformPropertyState") for stateKey, stateValue := range map[string]interface{}{ @@ -908,7 +951,7 @@ func populateTerraformPropertyState(d *schema.ResourceData, prop *gtm.Property, // create and populate GTM Property TrafficTargets object func populateTrafficTargetObject(ctx context.Context, d *schema.ResourceData, prop *gtm.Property, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTrafficTargetObject") // pull apart List @@ -939,7 +982,7 @@ func populateTrafficTargetObject(ctx context.Context, d *schema.ResourceData, pr // create and populate Terraform traffic_targets schema func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.Property, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformTrafficTargetState") objectInventory := make(map[int]*gtm.TrafficTarget, len(prop.TrafficTargets)) @@ -983,7 +1026,7 @@ func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.Prope } // Populate existing static_rr_sets object from resource data -func populateStaticRRSetObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, prop *gtm.Property) { +func populateStaticRRSetObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, prop *gtm.Property) { // pull apart List staticSetList, err := tf.GetInterfaceArrayValue("static_rr_set", d) @@ -1009,7 +1052,7 @@ func populateStaticRRSetObject(ctx context.Context, meta akamai.OperationMeta, d // create and populate Terraform static_rr_sets schema func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.Property, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformStaticRRSetState") objectInventory := make(map[string]*gtm.StaticRRSet, len(prop.StaticRRSets)) @@ -1050,7 +1093,7 @@ func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.Propert } // Populate existing Liveness test object from resource data -func populateLivenessTestObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, prop *gtm.Property) { +func populateLivenessTestObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, prop *gtm.Property) { liveTestList, err := tf.GetInterfaceArrayValue("liveness_test", d) if err == nil { @@ -1100,7 +1143,7 @@ func populateLivenessTestObject(ctx context.Context, meta akamai.OperationMeta, // create and populate Terraform liveness_test schema func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.Property, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformLivenessTestState") objectInventory := make(map[string]*gtm.LivenessTest, len(prop.LivenessTests)) @@ -1199,7 +1242,7 @@ func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.Proper } func convertStringToInterfaceList(stringList []string, m interface{}) []interface{} { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTMv1", "convertStringToInterfaceList") logger.Debugf("String List: %v", stringList) @@ -1214,7 +1257,7 @@ func convertStringToInterfaceList(stringList []string, m interface{}) []interfac // Util method to reconcile list configs. Type agnostic. Goal: maintain order of tf list config func reconcileTerraformLists(terraList []interface{}, newList []interface{}, m interface{}) []interface{} { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTMv1", "reconcileTerraformLists") logger.Debugf("Existing Terra List: %v", terraList) @@ -1242,7 +1285,7 @@ func reconcileTerraformLists(terraList []interface{}, newList []interface{}, m i } func trafficTargetDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { - logger := akamai.Log("Akamai GTM", "trafficTargetDiffSuppress") + logger := logger.Get("Akamai GTM", "trafficTargetDiffSuppress") oldTarget, newTarget := d.GetChange("traffic_target") oldTrafficTarget, ok := oldTarget.([]interface{}) @@ -1290,7 +1333,7 @@ func trafficTargetDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { // serversEqual checks whether provided sets of ip addresses contain the same entries func serversEqual(old, new interface{}) bool { - logger := akamai.Log("Akamai GTM", "serversEqual") + logger := logger.Get("Akamai GTM", "serversEqual") oldServers, ok := old.(*schema.Set) if !ok { diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 22f5db161..0e1aafef0 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -304,6 +304,162 @@ func TestResGtmProperty(t *testing.T) { client.AssertExpectations(t) }) + t.Run("test_object_protocol different than HTTP, HTTPS or FTP", func(t *testing.T) { + client := >m.Mock{} + + getCall := client.On("GetProperty", + mock.Anything, + mock.AnythingOfType("string"), + mock.AnythingOfType("string"), + ).Return(nil, >m.Error{ + StatusCode: http.StatusNotFound, + }) + + resp := gtm.PropertyResponse{} + resp.Resource = &prop + resp.Status = &pendingResponseStatus + client.On("CreateProperty", + mock.Anything, + mock.AnythingOfType("*gtm.Property"), + mock.AnythingOfType("string"), + ).Return(&resp, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Property), nil} + }) + + client.On("NewProperty", + mock.Anything, + mock.AnythingOfType("string"), + mock.AnythingOfType("string"), + ).Return(>m.Property{ + Name: "tfexample_prop_1", + }) + + client.On("GetDomainStatus", + mock.Anything, + mock.AnythingOfType("string"), + ).Return(&completeResponseStatus, nil) + + client.On("NewTrafficTarget", + mock.Anything, + ).Return(>m.TrafficTarget{}) + + client.On("NewStaticRRSet", + mock.Anything, + ).Return(>m.StaticRRSet{}) + + liveCall := client.On("NewLivenessTest", + mock.Anything, + mock.AnythingOfType("string"), + mock.AnythingOfType("string"), + mock.AnythingOfType("int"), + mock.AnythingOfType("float32"), + ) + + liveCall.RunFn = func(args mock.Arguments) { + liveCall.ReturnArguments = mock.Arguments{ + >m.LivenessTest{ + Name: args.String(1), + TestObjectProtocol: args.String(2), + TestInterval: args.Int(3), + TestTimeout: args.Get(4).(float32), + }, + } + } + + client.On("UpdateProperty", + mock.Anything, + mock.AnythingOfType("*gtm.Property"), + mock.AnythingOfType("string"), + ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Property), nil} + }) + + client.On("DeleteProperty", + mock.Anything, + mock.AnythingOfType("*gtm.Property"), + mock.AnythingOfType("string"), + ).Return(&completeResponseStatus, nil) + + dataSourceName := "akamai_gtm_property.tfexample_prop_1" + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResGtmProperty/test_object/test_object_not_required.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(dataSourceName, "name", "tfexample_prop_1"), + resource.TestCheckResourceAttr(dataSourceName, "type", "weighted-round-robin"), + ), + }, + { + Config: loadFixtureString("testdata/TestResGtmProperty/update_basic.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(dataSourceName, "name", "tfexample_prop_1"), + resource.TestCheckResourceAttr(dataSourceName, "type", "weighted-round-robin"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("create property with test_object_protocol set to 'FTP' - test_object required error", func(t *testing.T) { + client := >m.Mock{} + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResGtmProperty/test_object/test_object_protocol_ftp.tf"), + ExpectError: regexp.MustCompile(`Error: attribute 'test_object' is required when 'test_object_protocol' is set to 'HTTP', 'HTTPS' or 'FTP'`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("create property with test_object_protocol set to 'HTTP' - test_object required error", func(t *testing.T) { + client := >m.Mock{} + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResGtmProperty/test_object/test_object_protocol_http.tf"), + ExpectError: regexp.MustCompile(`Error: attribute 'test_object' is required when 'test_object_protocol' is set to 'HTTP', 'HTTPS' or 'FTP'`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("create property with test_object_protocol set to 'HTTPS' - test_object required error", func(t *testing.T) { + client := >m.Mock{} + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProviderFactories: testAccProviders, + Steps: []resource.TestStep{ + { + Config: loadFixtureString("testdata/TestResGtmProperty/test_object/test_object_protocol_https.tf"), + ExpectError: regexp.MustCompile(`Error: attribute 'test_object' is required when 'test_object_protocol' is set to 'HTTP', 'HTTPS' or 'FTP'`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) } func TestResourceGTMTrafficTargetOrder(t *testing.T) { diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource.go b/pkg/providers/gtm/resource_akamai_gtm_resource.go index 470ece0b2..86bb01ff1 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource.go @@ -6,10 +6,11 @@ import ( "fmt" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -117,7 +118,7 @@ func resourceGTMv1Resource() *schema.Resource { // Create a new GTM Resource func resourceGTMv1ResourceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ResourceCreate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -192,7 +193,7 @@ func resourceGTMv1ResourceCreate(ctx context.Context, d *schema.ResourceData, m // read resource. updates state with entire API result configuration. func resourceGTMv1ResourceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ResourceRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -224,7 +225,7 @@ func resourceGTMv1ResourceRead(ctx context.Context, d *schema.ResourceData, m in // Update GTM Resource func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ResourceUpdate") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -301,7 +302,7 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m // Import GTM Resource. func resourceGTMv1ResourceImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ResourceImport") // create a context with logging for api calls ctx := context.Background() @@ -332,7 +333,7 @@ func resourceGTMv1ResourceImport(d *schema.ResourceData, m interface{}) ([]*sche // Delete GTM Resource. func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ResourceDelete") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -405,7 +406,7 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m } // Create and populate a new resource object from resource data -func populateNewResourceObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, m interface{}) (*gtm.Resource, error) { +func populateNewResourceObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, m interface{}) (*gtm.Resource, error) { name, _ := tf.GetStringValue("name", d) rsrcObj := inst.Client(meta).NewResource(ctx, name) @@ -419,7 +420,7 @@ func populateNewResourceObject(ctx context.Context, meta akamai.OperationMeta, d // nolint:gocyclo // Populate existing resource object from resource data func populateResourceObject(ctx context.Context, d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "resourceGTMv1ResourceDelete") vstr, err := tf.GetStringValue("name", d) @@ -527,7 +528,7 @@ func populateResourceObject(ctx context.Context, d *schema.ResourceData, rsrc *g // Populate Terraform state from provided Resource object func populateTerraformResourceState(d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformResourceState") logger.Debugf("Entering populateTerraformResourceState") @@ -555,7 +556,7 @@ func populateTerraformResourceState(d *schema.ResourceData, rsrc *gtm.Resource, } // create and populate GTM Resource ResourceInstances object -func populateResourceInstancesObject(ctx context.Context, meta akamai.OperationMeta, d *schema.ResourceData, rsrc *gtm.Resource) { +func populateResourceInstancesObject(ctx context.Context, meta meta.Meta, d *schema.ResourceData, rsrc *gtm.Resource) { logger := meta.Log("Akamai GTM", "populateResourceInstancesObject") // pull apart List @@ -587,7 +588,7 @@ func populateResourceInstancesObject(ctx context.Context, meta akamai.OperationM // create and populate Terraform resource_instances schema func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformResourceInstancesState") riObjectInventory := make(map[int]*gtm.ResourceInstance, len(rsrc.ResourceInstances)) @@ -638,7 +639,7 @@ func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.R } func resourceInstanceDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { - logger := akamai.Log("Akamai GTM", "resourceInstanceDiffSuppress") + logger := logger.Get("Akamai GTM", "resourceInstanceDiffSuppress") oldRes, newRes := d.GetChange("resource_instance") oldList, ok := oldRes.([]interface{}) @@ -690,7 +691,7 @@ func resourceInstanceDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { // loadServersEqual checks whether load_servers are equal func loadServersEqual(oldVal, newVal interface{}) bool { - logger := akamai.Log("Akamai GTM", "loadServersEqual") + logger := logger.Get("Akamai GTM", "loadServersEqual") oldServers, ok := oldVal.(*schema.Set) if !ok { diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go index 4e06036a1..3228949a2 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/v6/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/gtm" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_not_required.tf b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_not_required.tf new file mode 100644 index 000000000..c79e9ae7a --- /dev/null +++ b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_not_required.tf @@ -0,0 +1,68 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +locals { + gtmTestDomain = "gtm_terra_testdomain.akadns.net" +} + +resource "akamai_gtm_property" "tfexample_prop_1" { + domain = local.gtmTestDomain + name = "tfexample_prop_1" + type = "weighted-round-robin" + score_aggregation_type = "median" + handout_limit = 5 + handout_mode = "normal" + traffic_target { + datacenter_id = 3131 + enabled = true + weight = 200 + servers = ["1.2.3.9"] + handout_cname = "test" + } + + liveness_test { + name = "lt5" + test_interval = 40 + test_object_protocol = "SNMP" + test_timeout = 30 + answers_required = false + disable_nonstandard_port_warning = false + error_penalty = 0 + http_error3xx = false + http_error4xx = false + http_error5xx = false + disabled = false + http_header { + name = "test_name" + value = "test_value" + } + peer_certificate_verification = false + recursion_requested = false + request_string = "" + resource_type = "" + response_string = "" + ssl_client_certificate = "" + ssl_client_private_key = "" + test_object_password = "" + test_object_port = 1 + test_object_username = "" + timeout_penalty = 0 + } + liveness_test { + name = "lt2" + test_interval = 30 + test_object_protocol = "HTTP" + test_timeout = 20 + test_object = "/junk" + } + static_rr_set { + type = "MX" + ttl = 300 + rdata = ["100 test_e"] + } + failover_delay = 0 + failback_delay = 0 + wait_on_complete = false +} + diff --git a/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_ftp.tf b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_ftp.tf new file mode 100644 index 000000000..f75b31db3 --- /dev/null +++ b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_ftp.tf @@ -0,0 +1,68 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +locals { + gtmTestDomain = "gtm_terra_testdomain.akadns.net" +} + +resource "akamai_gtm_property" "tfexample_prop_1" { + domain = local.gtmTestDomain + name = "tfexample_prop_1" + type = "weighted-round-robin" + score_aggregation_type = "median" + handout_limit = 5 + handout_mode = "normal" + traffic_target { + datacenter_id = 3131 + enabled = true + weight = 200 + servers = ["1.2.3.9"] + handout_cname = "test" + } + + liveness_test { + name = "lt5" + test_interval = 40 + test_object_protocol = "FTP" + test_timeout = 30 + answers_required = false + disable_nonstandard_port_warning = false + error_penalty = 0 + http_error3xx = false + http_error4xx = false + http_error5xx = false + disabled = false + http_header { + name = "test_name" + value = "test_value" + } + peer_certificate_verification = false + recursion_requested = false + request_string = "" + resource_type = "" + response_string = "" + ssl_client_certificate = "" + ssl_client_private_key = "" + test_object_password = "" + test_object_port = 1 + test_object_username = "" + timeout_penalty = 0 + } + liveness_test { + name = "lt2" + test_interval = 30 + test_object_protocol = "HTTP" + test_timeout = 20 + test_object = "/junk" + } + static_rr_set { + type = "MX" + ttl = 300 + rdata = ["100 test_e"] + } + failover_delay = 0 + failback_delay = 0 + wait_on_complete = false +} + diff --git a/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_http.tf b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_http.tf new file mode 100644 index 000000000..f75b31db3 --- /dev/null +++ b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_http.tf @@ -0,0 +1,68 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +locals { + gtmTestDomain = "gtm_terra_testdomain.akadns.net" +} + +resource "akamai_gtm_property" "tfexample_prop_1" { + domain = local.gtmTestDomain + name = "tfexample_prop_1" + type = "weighted-round-robin" + score_aggregation_type = "median" + handout_limit = 5 + handout_mode = "normal" + traffic_target { + datacenter_id = 3131 + enabled = true + weight = 200 + servers = ["1.2.3.9"] + handout_cname = "test" + } + + liveness_test { + name = "lt5" + test_interval = 40 + test_object_protocol = "FTP" + test_timeout = 30 + answers_required = false + disable_nonstandard_port_warning = false + error_penalty = 0 + http_error3xx = false + http_error4xx = false + http_error5xx = false + disabled = false + http_header { + name = "test_name" + value = "test_value" + } + peer_certificate_verification = false + recursion_requested = false + request_string = "" + resource_type = "" + response_string = "" + ssl_client_certificate = "" + ssl_client_private_key = "" + test_object_password = "" + test_object_port = 1 + test_object_username = "" + timeout_penalty = 0 + } + liveness_test { + name = "lt2" + test_interval = 30 + test_object_protocol = "HTTP" + test_timeout = 20 + test_object = "/junk" + } + static_rr_set { + type = "MX" + ttl = 300 + rdata = ["100 test_e"] + } + failover_delay = 0 + failback_delay = 0 + wait_on_complete = false +} + diff --git a/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_https.tf b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_https.tf new file mode 100644 index 000000000..f75b31db3 --- /dev/null +++ b/pkg/providers/gtm/testdata/TestResGtmProperty/test_object/test_object_protocol_https.tf @@ -0,0 +1,68 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +locals { + gtmTestDomain = "gtm_terra_testdomain.akadns.net" +} + +resource "akamai_gtm_property" "tfexample_prop_1" { + domain = local.gtmTestDomain + name = "tfexample_prop_1" + type = "weighted-round-robin" + score_aggregation_type = "median" + handout_limit = 5 + handout_mode = "normal" + traffic_target { + datacenter_id = 3131 + enabled = true + weight = 200 + servers = ["1.2.3.9"] + handout_cname = "test" + } + + liveness_test { + name = "lt5" + test_interval = 40 + test_object_protocol = "FTP" + test_timeout = 30 + answers_required = false + disable_nonstandard_port_warning = false + error_penalty = 0 + http_error3xx = false + http_error4xx = false + http_error5xx = false + disabled = false + http_header { + name = "test_name" + value = "test_value" + } + peer_certificate_verification = false + recursion_requested = false + request_string = "" + resource_type = "" + response_string = "" + ssl_client_certificate = "" + ssl_client_private_key = "" + test_object_password = "" + test_object_port = 1 + test_object_username = "" + timeout_penalty = 0 + } + liveness_test { + name = "lt2" + test_interval = 30 + test_object_protocol = "HTTP" + test_timeout = 20 + test_object = "/junk" + } + static_rr_set { + type = "MX" + ttl = 300 + rdata = ["100 test_e"] + } + failover_delay = 0 + failback_delay = 0 + wait_on_complete = false +} + diff --git a/pkg/providers/iam/data_akamai_iam_contact_types.go b/pkg/providers/iam/data_akamai_iam_contact_types.go index 0c2e45d4b..59a8e025a 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -25,7 +25,7 @@ func dataSourceIAMContactTypes() *schema.Resource { } func dataIAMContactTypesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMContactTypesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) 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 fe64394e1..4fb362207 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types_test.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types_test.go @@ -5,11 +5,11 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" ) func TestDataContactTypes(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_countries.go b/pkg/providers/iam/data_akamai_iam_countries.go index 1eea77aad..1a597101a 100644 --- a/pkg/providers/iam/data_akamai_iam_countries.go +++ b/pkg/providers/iam/data_akamai_iam_countries.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -25,7 +25,7 @@ func dataSourceIAMCountries() *schema.Resource { } func dataIAMCountriesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMCountriesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/data_akamai_iam_countries_test.go b/pkg/providers/iam/data_akamai_iam_countries_test.go index 3e2d84344..c3a6d08d7 100644 --- a/pkg/providers/iam/data_akamai_iam_countries_test.go +++ b/pkg/providers/iam/data_akamai_iam_countries_test.go @@ -5,11 +5,11 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" ) func TestDataCountries(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_grantable_roles.go b/pkg/providers/iam/data_akamai_iam_grantable_roles.go index 687a65738..c9150de72 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles.go @@ -3,9 +3,9 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -44,7 +44,7 @@ func dataSourceIAMGrantableRoles() *schema.Resource { } func dataIAMGrantableRolesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMGrantableRolesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) 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 3898dc1a8..5e8a8cfeb 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go @@ -5,10 +5,10 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/mock" ) func TestGrantableRoles(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index b120138dc..5c9c9b818 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -74,7 +74,7 @@ func nestedGroupsSchema(depth int) *schema.Schema { } func dataIAMGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMGroupsRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/data_akamai_iam_groups_test.go b/pkg/providers/iam/data_akamai_iam_groups_test.go index b63f1de98..ac0edada8 100644 --- a/pkg/providers/iam/data_akamai_iam_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_groups_test.go @@ -10,14 +10,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" ) func TestDataGroups(t *testing.T) { t.Run("groups can nest 50 levels deep", func(t *testing.T) { - assert.Equal(t, 50, groupsNestingDepth(inst.DataSourcesMap["akamai_iam_groups"]), "incorrect nesting depth") + assert.Equal(t, 50, groupsNestingDepth(dataSourceIAMGroups()), "incorrect nesting depth") }) t.Run("happy path", func(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_roles.go b/pkg/providers/iam/data_akamai_iam_roles.go index e1c737840..aac13bf8f 100644 --- a/pkg/providers/iam/data_akamai_iam_roles.go +++ b/pkg/providers/iam/data_akamai_iam_roles.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -70,7 +70,7 @@ func dataSourceIAMRoles() *schema.Resource { } func dataIAMRolesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMRolesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/data_akamai_iam_roles_test.go b/pkg/providers/iam/data_akamai_iam_roles_test.go index 5d1204e4f..c467ad4d0 100644 --- a/pkg/providers/iam/data_akamai_iam_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_roles_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/iam/data_akamai_iam_states.go b/pkg/providers/iam/data_akamai_iam_states.go index f9aca6562..e10479535 100644 --- a/pkg/providers/iam/data_akamai_iam_states.go +++ b/pkg/providers/iam/data_akamai_iam_states.go @@ -3,9 +3,9 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,7 +31,7 @@ func dataSourceIAMStates() *schema.Resource { } func dataIAMStatesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMStatesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/data_akamai_iam_states_test.go b/pkg/providers/iam/data_akamai_iam_states_test.go index d63a2c1f4..ceee5df90 100644 --- a/pkg/providers/iam/data_akamai_iam_states_test.go +++ b/pkg/providers/iam/data_akamai_iam_states_test.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - iam "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" ) func TestDataStates(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_supported_langs.go b/pkg/providers/iam/data_akamai_iam_supported_langs.go index 4e014b34a..4afb2f24a 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -25,7 +25,7 @@ func dataSourceIAMLanguages() *schema.Resource { } func dataIAMLanguagesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMLanguagesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) 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 2c3acbca2..cfaa48c7a 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs_test.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs_test.go @@ -5,11 +5,11 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" ) func TestDataSupportedLangs(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_timeout_policies.go b/pkg/providers/iam/data_akamai_iam_timeout_policies.go index 06e8a5145..711f6e10e 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -25,7 +25,7 @@ func dataSourceIAMTimeoutPolicies() *schema.Resource { } func dataIAMTimeoutPoliciesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMTimeoutPoliciesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) 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 34598fafb..a561bb1e6 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go @@ -6,10 +6,10 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" ) func TestDataTimeoutPolicies(t *testing.T) { diff --git a/pkg/providers/iam/data_akamai_iam_timezones.go b/pkg/providers/iam/data_akamai_iam_timezones.go index 5fe5797e3..279753a4e 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones.go +++ b/pkg/providers/iam/data_akamai_iam_timezones.go @@ -3,9 +3,9 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -49,7 +49,7 @@ func dataSourceIAMTimezones() *schema.Resource { } func dataIAMTimezonesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "dataIAMTimezonesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/data_akamai_iam_timezones_test.go b/pkg/providers/iam/data_akamai_iam_timezones_test.go index 0a7bba999..748edd32f 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones_test.go +++ b/pkg/providers/iam/data_akamai_iam_timezones_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/iam/iam.go b/pkg/providers/iam/iam.go index 6cb273bcd..d077d8193 100644 --- a/pkg/providers/iam/iam.go +++ b/pkg/providers/iam/iam.go @@ -1,10 +1,7 @@ -//go:build all || iam -// +build all iam - package iam -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 816735b6c..7468575da 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -4,102 +4,73 @@ package iam import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers IAM resources and data sources + Subprovider struct { client iam.IAM } - // Option is a iam provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider() akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider() *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} }) return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{}, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_iam_contact_types": dataSourceIAMContactTypes(), - "akamai_iam_countries": dataSourceIAMCountries(), - "akamai_iam_grantable_roles": dataSourceIAMGrantableRoles(), - "akamai_iam_groups": dataSourceIAMGroups(), - "akamai_iam_roles": dataSourceIAMRoles(), - "akamai_iam_states": dataSourceIAMStates(), - "akamai_iam_supported_langs": dataSourceIAMLanguages(), - "akamai_iam_timeout_policies": dataSourceIAMTimeoutPolicies(), - "akamai_iam_timezones": dataSourceIAMTimezones(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_iam_blocked_user_properties": resourceIAMBlockedUserProperties(), - "akamai_iam_group": resourceIAMGroup(), - "akamai_iam_role": resourceIAMRole(), - "akamai_iam_user": resourceIAMUser(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c iam.IAM) Option { - return func(p *provider) { +func withClient(c iam.IAM) option { + return func(p *Subprovider) { p.client = c } } // Client returns the DNS interface -func (p *provider) Client(meta akamai.OperationMeta) iam.IAM { +func (p *Subprovider) Client(meta meta.Meta) iam.IAM { if p.client != nil { return p.client } return iam.Client(meta.Session()) } -func (p *provider) Name() string { - return "iam" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for IAM +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_iam_blocked_user_properties": resourceIAMBlockedUserProperties(), + "akamai_iam_group": resourceIAMGroup(), + "akamai_iam_role": resourceIAMRole(), + "akamai_iam_user": resourceIAMUser(), + } } -func (p *provider) Configure(_ log.Interface, _ *schema.ResourceData) diag.Diagnostics { - return nil +// DataSources returns terraform data sources for IAM +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_iam_contact_types": dataSourceIAMContactTypes(), + "akamai_iam_countries": dataSourceIAMCountries(), + "akamai_iam_grantable_roles": dataSourceIAMGrantableRoles(), + "akamai_iam_groups": dataSourceIAMGroups(), + "akamai_iam_roles": dataSourceIAMRoles(), + "akamai_iam_states": dataSourceIAMStates(), + "akamai_iam_supported_langs": dataSourceIAMLanguages(), + "akamai_iam_timeout_policies": dataSourceIAMTimeoutPolicies(), + "akamai_iam_timezones": dataSourceIAMTimezones(), + } } diff --git a/pkg/providers/iam/provider_test.go b/pkg/providers/iam/provider_test.go index c721eb286..3b0ed870e 100644 --- a/pkg/providers/iam/provider_test.go +++ b/pkg/providers/iam/provider_test.go @@ -8,38 +8,33 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var testAccProviders map[string]func() (*schema.Provider, error) - var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex 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 11665ab46..268d02a06 100644 --- a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go +++ b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go @@ -6,10 +6,10 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -48,7 +48,7 @@ func resourceIAMBlockedUserProperties() *schema.Resource { } func resourceIAMBlockedUserPropertiesCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMBlockedUserPropertiesCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -101,7 +101,7 @@ func resourceIAMBlockedUserPropertiesCreate(ctx context.Context, d *schema.Resou } func resourceIAMBlockedUserPropertiesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMBlockedUserPropertiesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -144,7 +144,7 @@ func resourceIAMBlockedUserPropertiesRead(ctx context.Context, d *schema.Resourc } func resourceIAMBlockedUserPropertiesUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMBlockedUserPropertiesUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -180,7 +180,7 @@ func resourceIAMBlockedUserPropertiesUpdate(ctx context.Context, d *schema.Resou } func resourceIAMBlockedUserPropertiesDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMBlockedUserPropertiesDelete") logger.Debug("Deleting blocked user properties") @@ -194,7 +194,7 @@ func resourceIAMBlockedUserPropertiesDelete(_ context.Context, _ *schema.Resourc } func resourceIAMBlockedUserPropertiesImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMBlockedUserPropertiesImport") logger.Debug("Importing blocked user properties") 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 a8c891c5a..6d86628cf 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/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/iam/resource_akamai_iam_group.go b/pkg/providers/iam/resource_akamai_iam_group.go index e0baf22f9..e4f7495fe 100644 --- a/pkg/providers/iam/resource_akamai_iam_group.go +++ b/pkg/providers/iam/resource_akamai_iam_group.go @@ -4,10 +4,10 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -44,7 +44,7 @@ func resourceIAMGroup() *schema.Resource { } func resourceIAMGroupCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMGroupCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -72,7 +72,7 @@ func resourceIAMGroupCreate(ctx context.Context, rd *schema.ResourceData, m inte } func resourceIAMGroupRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMGroupRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -105,7 +105,7 @@ func resourceIAMGroupRead(ctx context.Context, rd *schema.ResourceData, m interf } func resourceIAMGroupUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMGroupUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -142,7 +142,7 @@ func resourceIAMGroupUpdate(ctx context.Context, rd *schema.ResourceData, m inte } func resourceIAMGroupDelete(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMGroupDelete") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/resource_akamai_iam_group_test.go b/pkg/providers/iam/resource_akamai_iam_group_test.go index 1524ac3f5..13ae87ec2 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/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/iam/resource_akamai_iam_role.go b/pkg/providers/iam/resource_akamai_iam_role.go index 1dc97517c..77830a8dd 100644 --- a/pkg/providers/iam/resource_akamai_iam_role.go +++ b/pkg/providers/iam/resource_akamai_iam_role.go @@ -5,10 +5,10 @@ import ( "sort" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -51,7 +51,7 @@ func resourceIAMRole() *schema.Resource { } func resourceIAMRoleCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMRoleCreate") ctx = session.ContextWithOptions( ctx, @@ -88,7 +88,7 @@ func resourceIAMRoleCreate(ctx context.Context, d *schema.ResourceData, m interf } func resourceIAMRoleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMRoleRead") ctx = session.ContextWithOptions( ctx, @@ -127,7 +127,7 @@ func resourceIAMRoleRead(ctx context.Context, d *schema.ResourceData, m interfac } func resourceIAMRoleUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMRoleUpdate") ctx = session.ContextWithOptions( ctx, @@ -174,7 +174,7 @@ func resourceIAMRoleUpdate(ctx context.Context, d *schema.ResourceData, m interf } func resourceIAMRoleDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMRoleDelete") ctx = session.ContextWithOptions( ctx, diff --git a/pkg/providers/iam/resource_akamai_iam_role_test.go b/pkg/providers/iam/resource_akamai_iam_role_test.go index df375badc..c6485c43c 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/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/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 6884f616f..3b5f036fe 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -9,10 +9,10 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/hashicorp/go-cty/cty" @@ -147,12 +147,6 @@ func resourceIAMUser() *schema.Resource { Computed: true, Description: "A user's `loginId`. Typically, a user's email address", }, - "is_locked": { - Type: schema.TypeBool, - Computed: true, - Description: "The user's lock status", - Deprecated: fmt.Sprintf("The setting %q has been deprecated. Please use %q setting instead", "is_locked", "lock"), - }, "last_login": { Type: schema.TypeString, Computed: true, @@ -184,7 +178,7 @@ func resourceIAMUser() *schema.Resource { } func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMUserCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -259,7 +253,7 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf } func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMUserRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -309,7 +303,6 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "country": user.Country, "contact_type": user.ContactType, "preferred_language": user.PreferredLanguage, - "is_locked": user.IsLocked, "last_login": user.LastLoginDate, "password_expired_after": user.PasswordExpiryDate, "tfa_configured": user.TFAConfigured, @@ -327,7 +320,7 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac } func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMUserUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) @@ -454,7 +447,7 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf } func resourceIAMUserDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMUserDelete") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) client := inst.Client(meta) diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index e1284a616..d623851bb 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/stretchr/testify/assert" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/iam" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -148,7 +148,6 @@ 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", "is_locked", fmt.Sprintf("%t", user.IsLocked)), 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", "tfa_configured", fmt.Sprintf("%t", user.TFAConfigured)), diff --git a/pkg/providers/imaging/data_akamai_imaging_policy_image.go b/pkg/providers/imaging/data_akamai_imaging_policy_image.go index 9eac566c1..4677f6715 100644 --- a/pkg/providers/imaging/data_akamai_imaging_policy_image.go +++ b/pkg/providers/imaging/data_akamai_imaging_policy_image.go @@ -7,10 +7,10 @@ import ( "encoding/json" "io" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/imaging/imagewriter" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/imaging/imagewriter" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func dataImagingPolicyImage() *schema.Resource { } func dataSourceImagingPolicyImageRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "dataPolicyImageRead") logger.Debug("Creating image policy json from schema") policy, err := tf.GetListValue("policy", d) diff --git a/pkg/providers/imaging/data_akamai_imaging_policy_video.go b/pkg/providers/imaging/data_akamai_imaging_policy_video.go index 643c27ffb..4dd91f8ad 100644 --- a/pkg/providers/imaging/data_akamai_imaging_policy_video.go +++ b/pkg/providers/imaging/data_akamai_imaging_policy_video.go @@ -4,10 +4,10 @@ import ( "context" "encoding/json" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/imaging/videowriter" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/imaging/videowriter" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,7 +35,7 @@ func dataImagingPolicyVideo() *schema.Resource { } func dataSourceImagingPolicyVideoRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "dataPolicyVideoRead") logger.Debug("Creating video policy json from schema") policy, err := tf.GetListValue("policy", d) diff --git a/pkg/providers/imaging/imagewriter/convert-image.gen.go b/pkg/providers/imaging/imagewriter/convert-image.gen.go index 727c21eaa..084f91e00 100644 --- a/pkg/providers/imaging/imagewriter/convert-image.gen.go +++ b/pkg/providers/imaging/imagewriter/convert-image.gen.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/imaging/imaging.go b/pkg/providers/imaging/imaging.go index dc090ae4c..606ded9d9 100644 --- a/pkg/providers/imaging/imaging.go +++ b/pkg/providers/imaging/imaging.go @@ -1,10 +1,7 @@ -//go:build all || imaging -// +build all imaging - package imaging -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/imaging/provider.go b/pkg/providers/imaging/provider.go index 60f0d78c4..926b6703c 100644 --- a/pkg/providers/imaging/provider.go +++ b/pkg/providers/imaging/provider.go @@ -4,34 +4,33 @@ package imaging import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers imaging resources and data sources + Subprovider struct { client imaging.Imaging } - // Option is an imaging provider option - Option func(p *provider) + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -41,61 +40,33 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{}, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_imaging_policy_image": dataImagingPolicyImage(), - "akamai_imaging_policy_video": dataImagingPolicyVideo(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_imaging_policy_image": resourceImagingPolicyImage(), - "akamai_imaging_policy_set": resourceImagingPolicySet(), - "akamai_imaging_policy_video": resourceImagingPolicyVideo(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(i imaging.Imaging) Option { - return func(p *provider) { +func withClient(i imaging.Imaging) option { + return func(p *Subprovider) { p.client = i } } // Client returns the Imaging interface -func (p *provider) Client(meta akamai.OperationMeta) imaging.Imaging { +func (p *Subprovider) Client(meta meta.Meta) imaging.Imaging { if p.client != nil { return p.client } return imaging.Client(meta.Session()) } -func (p *provider) Name() string { - return "imaging" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.0.1" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for imaging +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_imaging_policy_image": resourceImagingPolicyImage(), + "akamai_imaging_policy_set": resourceImagingPolicySet(), + "akamai_imaging_policy_video": resourceImagingPolicyVideo(), + } } -func (p *provider) Configure(_ log.Interface, _ *schema.ResourceData) diag.Diagnostics { - return nil +// DataSources returns terraform data sources for imaging +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_imaging_policy_image": dataImagingPolicyImage(), + "akamai_imaging_policy_video": dataImagingPolicyVideo(), + } } diff --git a/pkg/providers/imaging/provider_test.go b/pkg/providers/imaging/provider_test.go index 60eb9fbb8..946ee48c2 100644 --- a/pkg/providers/imaging/provider_test.go +++ b/pkg/providers/imaging/provider_test.go @@ -8,40 +8,35 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) var testAccProviders map[string]func() (*schema.Provider, error) - var testAccProvider *schema.Provider func TestMain(m *testing.M) { PolicyDepth = 4 - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_image.go b/pkg/providers/imaging/resource_akamai_imaging_policy_image.go index a4c61c93c..fe054a1eb 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_image.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_image.go @@ -10,10 +10,11 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -84,7 +85,7 @@ func resourceImagingPolicyImage() *schema.Resource { } func resourcePolicyImageCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyImageCreate") ctx = session.ContextWithOptions( ctx, @@ -155,7 +156,7 @@ func upsertPolicyImage(ctx context.Context, d *schema.ResourceData, m interface{ } func resourcePolicyImageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyImageRead") ctx = session.ContextWithOptions( ctx, @@ -247,7 +248,7 @@ func getPolicyImageJSON(policy *imaging.PolicyInputImage) (string, error) { } func resourcePolicyImageUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyImageUpdate") ctx = session.ContextWithOptions( ctx, @@ -260,7 +261,7 @@ func resourcePolicyImageUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourcePolicyImageDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyImageDelete") ctx = session.ContextWithOptions( ctx, @@ -321,7 +322,7 @@ func resourcePolicyImageDelete(ctx context.Context, d *schema.ResourceData, m in } func resourcePolicyImageImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyImageImport") ctx = session.ContextWithOptions( ctx, @@ -386,7 +387,7 @@ func diffSuppressPolicyImage(_, old, new string, _ *schema.ResourceData) bool { } func equalPolicyImage(old, new string) bool { - logger := akamai.Log("Imaging", "equalPolicyImage") + logger := logger.Get("Imaging", "equalPolicyImage") if old == new { return true } 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 10a42f1fe..9c9a2f218 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go @@ -6,8 +6,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/tj/assert" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_set.go b/pkg/providers/imaging/resource_akamai_imaging_policy_set.go index 40ecadd52..1471ad4b5 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_set.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_set.go @@ -5,10 +5,10 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -52,7 +52,7 @@ func resourceImagingPolicySet() *schema.Resource { } func resourceImagingPolicySetImport(_ context.Context, rd *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourceImagingPolicySetImport") logger.Debugf("Import Policy Set") @@ -75,7 +75,7 @@ func resourceImagingPolicySetImport(_ context.Context, rd *schema.ResourceData, } func resourceImagingPolicySetCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourceImagingPolicySetCreate") ctx = session.ContextWithOptions( ctx, @@ -120,7 +120,7 @@ func resourceImagingPolicySetCreate(ctx context.Context, rd *schema.ResourceData } func resourceImagingPolicySetRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourceImagingPolicySetRead") ctx = session.ContextWithOptions( ctx, @@ -156,7 +156,7 @@ func resourceImagingPolicySetRead(ctx context.Context, rd *schema.ResourceData, } func resourceImagingPolicySetUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourceImagingPolicySetUpdate") ctx = session.ContextWithOptions( ctx, @@ -195,7 +195,7 @@ func resourceImagingPolicySetUpdate(ctx context.Context, rd *schema.ResourceData } func resourceImagingPolicySetDelete(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourceImagingPolicySetDelete") ctx = session.ContextWithOptions( ctx, 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 9aa6e8a3d..c9d3deaf2 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/tj/assert" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_video.go b/pkg/providers/imaging/resource_akamai_imaging_policy_video.go index 8d4f37199..02f62784e 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_video.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_video.go @@ -10,10 +10,11 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -76,7 +77,7 @@ func resourceImagingPolicyVideo() *schema.Resource { } func resourcePolicyVideoCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyVideoCreate") ctx = session.ContextWithOptions( ctx, @@ -148,7 +149,7 @@ func upsertPolicyVideo(ctx context.Context, d *schema.ResourceData, m interface{ } func resourcePolicyVideoRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyVideoRead") ctx = session.ContextWithOptions( ctx, @@ -240,7 +241,7 @@ func getPolicyVideoJSON(policy *imaging.PolicyInputVideo) (string, error) { } func resourcePolicyVideoUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyVideoUpdate") ctx = session.ContextWithOptions( ctx, @@ -253,7 +254,7 @@ func resourcePolicyVideoUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourcePolicyVideoDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyVideoDelete") ctx = session.ContextWithOptions( ctx, @@ -315,7 +316,7 @@ func resourcePolicyVideoDelete(ctx context.Context, d *schema.ResourceData, m in } func resourcePolicyVideoImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("Imaging", "resourcePolicyVideoImport") ctx = session.ContextWithOptions( ctx, @@ -380,7 +381,7 @@ func diffSuppressPolicyVideo(_, old, new string, _ *schema.ResourceData) bool { } func equalPolicyVideo(old, new string) bool { - logger := akamai.Log("Imaging", "equalPolicyVideo") + logger := logger.Get("Imaging", "equalPolicyVideo") if old == new { return true } 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 23e68cd66..0e4698904 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go @@ -6,8 +6,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/imaging/videowriter/convert-video.gen.go b/pkg/providers/imaging/videowriter/convert-video.gen.go index 0432d8e33..df2dcd337 100644 --- a/pkg/providers/imaging/videowriter/convert-video.gen.go +++ b/pkg/providers/imaging/videowriter/convert-video.gen.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/tools" "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 8095b100e..68d414b6c 100644 --- a/pkg/providers/networklists/data_akamai_network_network_lists.go +++ b/pkg/providers/networklists/data_akamai_network_network_lists.go @@ -6,9 +6,9 @@ import ( "errors" "fmt" - network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -65,7 +65,7 @@ func dataSourceNetworkList() *schema.Resource { } func dataSourceNetworkListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "dataSourceNetworkListRead") 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 ee39ef04f..bc4655482 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/v6/pkg/networklists" + network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/networklists/networklists.go b/pkg/providers/networklists/networklists.go index 74eabef0c..8082284e7 100644 --- a/pkg/providers/networklists/networklists.go +++ b/pkg/providers/networklists/networklists.go @@ -1,10 +1,7 @@ -//go:build all || networklists -// +build all networklists - package networklists -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewSubprovider()) } diff --git a/pkg/providers/networklists/provider.go b/pkg/providers/networklists/provider.go index 3e597540f..403df8f7a 100644 --- a/pkg/providers/networklists/provider.go +++ b/pkg/providers/networklists/provider.go @@ -4,36 +4,34 @@ package networklists import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/config" - "github.com/apex/log" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) type ( - provider struct { - *schema.Provider - + // Subprovider gathers networklists resources and data sources + Subprovider struct { client networklists.NTWRKLISTS } - // Option is a networklist provider option - Option func(p *provider) + + option func(p *Subprovider) ) var ( once sync.Once - inst *provider + inst *Subprovider ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { +var _ subprovider.Plugin = &Subprovider{} + +// NewSubprovider returns a core sub provider +func NewSubprovider(opts ...option) *Subprovider { once.Do(func() { - inst = &provider{Provider: Provider()} + inst = &Subprovider{} for _, opt := range opts { opt(inst) @@ -43,99 +41,33 @@ func Subprovider(opts ...Option) akamai.Subprovider { return inst } -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{ - "networklist_section": { - Optional: true, - Type: schema.TypeString, - Default: "default", - Deprecated: akamai.NoticeDeprecatedUseAlias("networklist_section"), - }, - "network": { - Optional: true, - Type: schema.TypeSet, - Elem: config.Options("network"), - }, - }, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_networklist_network_lists": dataSourceNetworkList(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_networklist_activations": resourceActivations(), - "akamai_networklist_description": resourceNetworkListDescription(), - "akamai_networklist_subscription": resourceNetworkListSubscription(), - "akamai_networklist_network_list": resourceNetworkList(), - }, - } - return provider -} - -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c networklists.NTWRKLISTS) Option { - return func(p *provider) { +func withClient(c networklists.NTWRKLISTS) option { + return func(p *Subprovider) { p.client = c } } // Client returns the PAPI interface -func (p *provider) Client(meta akamai.OperationMeta) networklists.NTWRKLISTS { +func (p *Subprovider) Client(meta meta.Meta) networklists.NTWRKLISTS { if p.client != nil { return p.client } return networklists.Client(meta.Session()) } -func getNetworkListV1Service(d *schema.ResourceData) error { - var section string - - for _, s := range tf.FindStringValues(d, "networklist_section", "config_section") { - if s != "default" { - section = s - break - } - } - - if section != "" { - if err := d.Set("config_section", section); err != nil { - return err - } +// Resources returns terraform resources for networklists +func (p *Subprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_networklist_activations": resourceActivations(), + "akamai_networklist_description": resourceNetworkListDescription(), + "akamai_networklist_subscription": resourceNetworkListSubscription(), + "akamai_networklist_network_list": resourceNetworkList(), } - - return nil } -func (p *provider) Name() string { - return "networklists" -} - -// NetworkProviderVersion update version string anytime provider adds new features -const NetworkProviderVersion string = "v1.0.0" - -func (p *provider) Version() string { - return NetworkProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap -} - -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap -} - -func (p *provider) Configure(log log.Interface, d *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - err := getNetworkListV1Service(d) - if err != nil { - return diag.FromErr(err) +// DataSources returns terraform data sources for networklists +func (p *Subprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_networklist_network_lists": dataSourceNetworkList(), } - - return nil } diff --git a/pkg/providers/networklists/provider_test.go b/pkg/providers/networklists/provider_test.go index 9c26a8802..efb5103bd 100644 --- a/pkg/providers/networklists/provider_test.go +++ b/pkg/providers/networklists/provider_test.go @@ -7,8 +7,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -16,28 +17,22 @@ var testAccProviders map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() + testAccProvider = akamai.NewPluginProvider(NewSubprovider())() testAccProviders = map[string]func() (*schema.Provider, error){ "akamai": func() (*schema.Provider, error) { return testAccProvider, nil }, } - if err := akamai.TFTestSetup(); err != nil { + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations.go b/pkg/providers/networklists/resource_akamai_networklist_activations.go index c43b6af3c..b6f42c2ba 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_activations.go +++ b/pkg/providers/networklists/resource_akamai_networklist_activations.go @@ -7,9 +7,9 @@ import ( "sync" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -47,12 +47,6 @@ func resourceActivations() *schema.Resource { Default: "Activation Comments", Description: "Descriptive text to accompany the activation", }, - "activate": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("activate"), - }, "notification_emails": { Type: schema.TypeSet, Required: true, @@ -84,7 +78,7 @@ var ( ) func resourceActivationsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceActivationsCreate") logger.Debug("Creating resource activation") @@ -155,7 +149,7 @@ func createActivation(ctx context.Context, client networklists.NTWRKLISTS, param } func resourceActivationsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceActivationsRead") logger.Debug("Reading resource activation") @@ -190,7 +184,7 @@ func resourceActivationsRead(ctx context.Context, d *schema.ResourceData, m inte } func resourceActivationsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceActivationsUpdate") logger.Debug("Updating resource activation") @@ -251,7 +245,7 @@ func resourceActivationsUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourceActivationsDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("NETWORKLIST", "resourceActivationsDelete") logger.Debug("removing activation from local state") return diag.Diagnostics{ diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations_test.go b/pkg/providers/networklists/resource_akamai_networklist_activations_test.go index 2ccdd4878..33c61f832 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/v6/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list.go b/pkg/providers/networklists/resource_akamai_networklist_network_list.go index 0f82002dd..8982baea1 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list.go @@ -7,9 +7,9 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "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" @@ -99,7 +99,7 @@ func resourceNetworkList() *schema.Resource { } func resourceNetworkListCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListCreate") @@ -212,7 +212,7 @@ func resourceNetworkListCreate(ctx context.Context, d *schema.ResourceData, m in } func resourceNetworkListUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListUpdate") @@ -306,7 +306,7 @@ func resourceNetworkListUpdate(ctx context.Context, d *schema.ResourceData, m in } func resourceNetworkListDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListRemove") @@ -323,7 +323,7 @@ func resourceNetworkListDelete(ctx context.Context, d *schema.ResourceData, m in } func resourceNetworkListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListRead") @@ -513,7 +513,7 @@ func RemoveIndex(hl []string, index int) []string { // value specified in the resources's ID, to ensure that the user has not inadvertently modified the configuration's // value; any such modifications indicate an incorrect understanding of the Update operation. func verifyContractGroupUnchanged(_ context.Context, d *schema.ResourceDiff, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("NETWORKLIST", "VerifyContractGroupUnchanged") if d.HasChange("contract_id") { @@ -542,7 +542,7 @@ func verifyContractGroupUnchanged(_ context.Context, d *schema.ResourceDiff, m i // markSyncPointComputedIfListModified sets 'sync_point' field as new computed // if a new version of network list is expected to be created. func markSyncPointComputedIfListModified(_ context.Context, d *schema.ResourceDiff, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("NETWORKLIST", "MarkSyncPointComputedIfListModified") if d.HasChange("list") { logger.Debug("setting sync_point as new computed") 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 8055a34a9..725b4d247 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go @@ -4,9 +4,9 @@ import ( "context" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +41,7 @@ func resourceNetworkListDescription() *schema.Resource { } func resourceNetworkListDescriptionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListDescriptionRead") @@ -66,7 +66,7 @@ func resourceNetworkListDescriptionDelete(ctx context.Context, d *schema.Resourc } func resourceNetworkListDescriptionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListDescriptionUpdate") 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 fd7ae28b2..35eb54e99 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/v6/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 dcdf589d3..e56bf67e7 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go @@ -5,9 +5,9 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -38,7 +38,7 @@ func resourceNetworkListSubscription() *schema.Resource { } func resourceNetworkListSubscriptionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListSubscriptionRead") @@ -79,7 +79,7 @@ func resourceNetworkListSubscriptionRead(ctx context.Context, d *schema.Resource func resourceNetworkListSubscriptionDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListSubscriptionDelete") @@ -109,7 +109,7 @@ func resourceNetworkListSubscriptionDelete(ctx context.Context, d *schema.Resour } func resourceNetworkListSubscriptionUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) client := inst.Client(meta) logger := meta.Log("NETWORKLIST", "resourceNetworkListSubscriptionUpdate") 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 e09f33b91..14618c8c2 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/v6/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" 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 fdc0c9448..0f1c2f99a 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/networklists" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/property/data_akamai_contracts.go b/pkg/providers/property/data_akamai_contracts.go index 05021c128..48f9fcb40 100644 --- a/pkg/providers/property/data_akamai_contracts.go +++ b/pkg/providers/property/data_akamai_contracts.go @@ -2,11 +2,13 @@ package property import ( "context" + "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + akameta "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -30,7 +32,7 @@ func dataSourceContracts() *schema.Resource { } func dataContractsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := akameta.Must(m) log := meta.Log("PAPI", "dataContractsRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -67,18 +69,20 @@ func dataContractsRead(ctx context.Context, d *schema.ResourceData, m interface{ } // Reusable function to fetch all the contracts accessible through a API token -func getContracts(ctx context.Context, meta akamai.OperationMeta) (*papi.GetContractsResponse, error) { +func getContracts(ctx context.Context, meta akameta.Meta) (*papi.GetContractsResponse, error) { contracts := &papi.GetContractsResponse{} - if err := meta.CacheGet(inst, "contracts", contracts); err != nil { - if !akamai.IsNotFoundError(err) { + if err := cache.Get(cache.BucketName(SubproviderName), "contracts", contracts); err != nil { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { return nil, err } - contracts, err = inst.Client(meta).GetContracts(ctx) + contracts, err = Client(meta).GetContracts(ctx) if err != nil { return nil, err } - if err := meta.CacheSet(inst, "contracts", contracts); err != nil { - return nil, err + if err := cache.Set(cache.BucketName(SubproviderName), "contracts", contracts); err != nil { + if !errors.Is(err, cache.ErrDisabled) { + return nil, err + } } } return contracts, nil diff --git a/pkg/providers/property/data_akamai_contracts_test.go b/pkg/providers/property/data_akamai_contracts_test.go index a2ee74c90..41b504ac3 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/stretchr/testify/mock" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -29,7 +29,7 @@ func TestDataContracts(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataContracts/contracts.tf"), Check: resource.ComposeAggregateTestCheckFunc( diff --git a/pkg/providers/property/data_akamai_cp_code.go b/pkg/providers/property/data_akamai_cp_code.go index 61c9f9bdd..8c0299710 100644 --- a/pkg/providers/property/data_akamai_cp_code.go +++ b/pkg/providers/property/data_akamai_cp_code.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) func dataSourceCPCode() *schema.Resource { @@ -22,35 +22,15 @@ func dataSourceCPCode() *schema.Resource { Required: true, ValidateDiagFunc: tf.IsNotBlank, }, - "contract": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract", "contract_id"}, - ForceNew: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("contract"), - }, "contract_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract", "contract_id"}, - ForceNew: true, - }, - "group": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"group", "group_id"}, - ForceNew: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("group"), + Type: schema.TypeString, + Required: true, + ForceNew: true, }, "group_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"group", "group_id"}, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, }, "product_ids": { Type: schema.TypeList, @@ -62,8 +42,8 @@ func dataSourceCPCode() *schema.Resource { } func dataCPCodeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataCPCodeRead") log.Debug("Read CP Code") @@ -74,29 +54,19 @@ func dataCPCodeRead(ctx context.Context, d *schema.ResourceData, m interface{}) return diag.FromErr(err) } - // load group_id, if not exists, then load group. - if groupID, err = tf.ResolveKeyStringState(d, "group_id", "group"); err != nil { + if groupID, err = tf.GetStringValue("group_id", d); err != nil { return diag.FromErr(err) } - // set group_id/group in state. if err := d.Set("group_id", groupID); err != nil { return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) } - if err := d.Set("group", groupID); err != nil { - return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) - } - // load contract_id, if not exists, then load contract. - if contractID, err = tf.ResolveKeyStringState(d, "contract_id", "contract"); err != nil { + if contractID, err = tf.GetStringValue("contract_id", d); err != nil { return diag.FromErr(err) } - // set contract_id/contract in state. if err := d.Set("contract_id", contractID); err != nil { return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) } - if err := d.Set("contract", contractID); err != nil { - return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) - } cpCode, err := findCPCode(ctx, client, name, contractID, groupID) if err != nil { diff --git a/pkg/providers/property/data_akamai_cp_code_test.go b/pkg/providers/property/data_akamai_cp_code_test.go index e08de4a7b..998ae8fda 100644 --- a/pkg/providers/property/data_akamai_cp_code_test.go +++ b/pkg/providers/property/data_akamai_cp_code_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestDSCPCode(t *testing.T) { @@ -27,14 +27,14 @@ func TestDSCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSCPCode/match_by_name.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_cp_code.test", "id", "234"), resource.TestCheckResourceAttr("data.akamai_cp_code.test", "name", "test cpcode"), - resource.TestCheckResourceAttr("data.akamai_cp_code.test", "group", "grp_test"), - resource.TestCheckResourceAttr("data.akamai_cp_code.test", "contract", "ctr_test"), + resource.TestCheckResourceAttr("data.akamai_cp_code.test", "group_id", "grp_test"), + resource.TestCheckResourceAttr("data.akamai_cp_code.test", "contract_id", "ctr_test"), ), }}, }) @@ -59,14 +59,14 @@ func TestDSCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSCPCode/match_by_name_output_products.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_cp_code.test", "id", "234"), resource.TestCheckResourceAttr("data.akamai_cp_code.test", "name", "test cpcode"), - resource.TestCheckResourceAttr("data.akamai_cp_code.test", "group", "grp_test"), - resource.TestCheckResourceAttr("data.akamai_cp_code.test", "contract", "ctr_test"), + resource.TestCheckResourceAttr("data.akamai_cp_code.test", "group_id", "grp_test"), + resource.TestCheckResourceAttr("data.akamai_cp_code.test", "contract_id", "ctr_test"), resource.TestCheckOutput("product1", "prd_test1"), resource.TestCheckOutput("product2", "prd_test2"), ), @@ -93,14 +93,14 @@ func TestDSCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSCPCode/match_by_full_id.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_cp_code.test", "id", "234"), resource.TestCheckResourceAttr("data.akamai_cp_code.test", "name", "cpc_234"), - resource.TestCheckResourceAttr("data.akamai_cp_code.test", "group", "grp_test"), - resource.TestCheckResourceAttr("data.akamai_cp_code.test", "contract", "ctr_test"), + resource.TestCheckResourceAttr("data.akamai_cp_code.test", "group_id", "grp_test"), + resource.TestCheckResourceAttr("data.akamai_cp_code.test", "contract_id", "ctr_test"), ), }}, }) @@ -125,7 +125,7 @@ func TestDSCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSCPCode/match_by_unprefixed_id.tf"), Check: resource.ComposeAggregateTestCheckFunc( @@ -154,7 +154,7 @@ func TestDSCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSCPCode/match_by_unprefixed_id.tf"), ExpectError: regexp.MustCompile(`cp code not found`), @@ -165,31 +165,6 @@ func TestDSCPCode(t *testing.T) { client.AssertExpectations(t) }) - t.Run("contract collides with contract ID", func(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSCPCode/contract_collides_with_id.tf"), - ExpectError: regexp.MustCompile("only one of `contract,contract_id` can be specified"), - }}, - }) - }) - - t.Run("group collides with group ID", func(t *testing.T) { - client := &papi.Mock{} - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSCPCode/group_collides_with_id.tf"), - ExpectError: regexp.MustCompile("only one of `group,group_id` can be specified"), - }}, - }) - }) - }) - t.Run("group not found in state", func(t *testing.T) { client := &papi.Mock{} client.On("GetCPCodes", @@ -203,8 +178,8 @@ func TestDSCPCode(t *testing.T) { }}, nil).Times(3) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSGroupNotFound/cp_code.tf"), }}, diff --git a/pkg/providers/property/data_akamai_properties.go b/pkg/providers/property/data_akamai_properties.go index a6006b283..3034948fd 100644 --- a/pkg/providers/property/data_akamai_properties.go +++ b/pkg/providers/property/data_akamai_properties.go @@ -6,11 +6,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) func dataSourceProperties() *schema.Resource { @@ -51,7 +51,7 @@ func dataSourceProperties() *schema.Resource { } func dataPropertiesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) log := meta.Log("PAPI", "dataPropertiesRead") // create a context with logging for api calls ctx = session.ContextWithOptions( @@ -117,8 +117,8 @@ func decodeVersion(version interface{}) int { } // Reusable function to fetch all the properties for a given group and contract -func getProperties(ctx context.Context, groupID string, contractID string, meta akamai.OperationMeta) (*papi.GetPropertiesResponse, error) { - client := inst.Client(meta) +func getProperties(ctx context.Context, groupID string, contractID string, meta meta.Meta) (*papi.GetPropertiesResponse, error) { + client := Client(meta) req := papi.GetPropertiesRequest{ ContractID: contractID, GroupID: groupID, diff --git a/pkg/providers/property/data_akamai_properties_search.go b/pkg/providers/property/data_akamai_properties_search.go index e1b3a336b..178da4aa1 100644 --- a/pkg/providers/property/data_akamai_properties_search.go +++ b/pkg/providers/property/data_akamai_properties_search.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) func dataSourcePropertiesSearch() *schema.Resource { @@ -55,8 +55,8 @@ func dataSourcePropertiesSearch() *schema.Resource { } func dataPropertiesSearchRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataPropertiesSearchRead") diff --git a/pkg/providers/property/data_akamai_properties_search_test.go b/pkg/providers/property/data_akamai_properties_search_test.go index 87e7443aa..7c614031d 100644 --- a/pkg/providers/property/data_akamai_properties_search_test.go +++ b/pkg/providers/property/data_akamai_properties_search_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestDSPropertiesSearch(t *testing.T) { @@ -54,7 +54,7 @@ func TestDSPropertiesSearch(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertiesSearch/match_by_hostname.tf"), Check: resource.ComposeAggregateTestCheckFunc( @@ -95,7 +95,7 @@ func TestDSPropertiesSearch(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertiesSearch/match_by_hostname.tf"), ExpectError: regexp.MustCompile("searching for properties"), diff --git a/pkg/providers/property/data_akamai_properties_test.go b/pkg/providers/property/data_akamai_properties_test.go index a3de4873c..33e9d8a77 100644 --- a/pkg/providers/property/data_akamai_properties_test.go +++ b/pkg/providers/property/data_akamai_properties_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestDataProperties(t *testing.T) { @@ -23,7 +23,7 @@ func TestDataProperties(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataProperties/properties.tf"), Check: buildAggregatedTest(properties, "grp_testctr_test", "grp_test", "ctr_test"), @@ -46,7 +46,7 @@ func TestDataProperties(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataProperties/properties_no_group_prefix.tf"), Check: buildAggregatedTest(properties, "grp_testctr_test", "test", "ctr_test"), @@ -69,7 +69,7 @@ func TestDataProperties(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataProperties/properties_no_contract_prefix.tf"), Check: buildAggregatedTest(properties, "grp_testctr_test", "grp_test", "test"), diff --git a/pkg/providers/property/data_akamai_property.go b/pkg/providers/property/data_akamai_property.go index cfa205595..f841ec896 100644 --- a/pkg/providers/property/data_akamai_property.go +++ b/pkg/providers/property/data_akamai_property.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) func dataSourceProperty() *schema.Resource { @@ -35,7 +35,7 @@ func dataSourceProperty() *schema.Resource { } func dataPropertyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) log := meta.Log("PAPI", "dataPropertyRead") log.Debug("Reading Property") @@ -72,8 +72,8 @@ func dataPropertyRead(ctx context.Context, d *schema.ResourceData, m interface{} return nil } -func getRulesForProperty(ctx context.Context, property *papi.Property, meta akamai.OperationMeta) (*papi.GetRuleTreeResponse, error) { - client := inst.Client(meta) +func getRulesForProperty(ctx context.Context, property *papi.Property, meta meta.Meta) (*papi.GetRuleTreeResponse, error) { + client := Client(meta) req := papi.GetRuleTreeRequest{ PropertyID: property.PropertyID, PropertyVersion: property.LatestVersion, diff --git a/pkg/providers/property/data_akamai_property_activation.go b/pkg/providers/property/data_akamai_property_activation.go index 75628f692..b6084894c 100644 --- a/pkg/providers/property/data_akamai_property_activation.go +++ b/pkg/providers/property/data_akamai_property_activation.go @@ -3,10 +3,10 @@ package property import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -71,9 +71,9 @@ var dataSourcePropertyActivationSchema = map[string]*schema.Schema{ } func dataSourcePropertyActivationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "dataSourcePropertyActivationRead") - client := inst.Client(meta) + client := Client(meta) ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) diff --git a/pkg/providers/property/data_akamai_property_activation_test.go b/pkg/providers/property/data_akamai_property_activation_test.go index 0d3182da9..024701b72 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -54,7 +54,7 @@ func TestDataSourcePAPIPropertyActivation(t *testing.T) { }, "check schema property activation - OK": { init: func(m *papi.Mock) { - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Times(5) + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T14:04:05Z"), nil).Times(5) }, steps: []resource.TestStep{ { @@ -111,9 +111,9 @@ func TestDataSourcePAPIPropertyActivation(t *testing.T) { } useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: test.steps, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, + Steps: test.steps, }) }) client.AssertExpectations(t) diff --git a/pkg/providers/property/data_akamai_property_hostnames.go b/pkg/providers/property/data_akamai_property_hostnames.go index ffd4e1b68..a9b70256a 100644 --- a/pkg/providers/property/data_akamai_property_hostnames.go +++ b/pkg/providers/property/data_akamai_property_hostnames.go @@ -7,11 +7,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) func dataSourcePropertyHostnames() *schema.Resource { @@ -63,8 +63,8 @@ func dataSourcePropertyHostnames() *schema.Resource { } func dataPropertyHostnamesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataPropertyHostnamesRead") // create a context with logging for api calls ctx = session.ContextWithOptions( diff --git a/pkg/providers/property/data_akamai_property_hostnames_test.go b/pkg/providers/property/data_akamai_property_hostnames_test.go index d18652484..e3193437d 100644 --- a/pkg/providers/property/data_akamai_property_hostnames_test.go +++ b/pkg/providers/property/data_akamai_property_hostnames_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestDataPropertyHostnames(t *testing.T) { @@ -47,7 +47,7 @@ func TestDataPropertyHostnames(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataPropertyHostnames/property_hostnames.tf"), Check: buildAggregatedHostnamesTest(hostnameItems, "prp_test1", "grp_test", "ctr_test", "prp_test"), @@ -94,7 +94,7 @@ func TestDataPropertyHostnames(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataPropertyHostnames/property_hostnames_no_group_prefix.tf"), Check: buildAggregatedHostnamesTest(hostnameItems, "prp_test1", "test", "ctr_test", "prp_test"), @@ -141,7 +141,7 @@ func TestDataPropertyHostnames(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataPropertyHostnames/property_hostnames_no_contract_prefix.tf"), Check: buildAggregatedHostnamesTest(hostnameItems, "prp_test1", "grp_test", "test", "prp_test"), @@ -188,7 +188,7 @@ func TestDataPropertyHostnames(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDataPropertyHostnames/property_hostnames_no_property_prefix.tf"), Check: buildAggregatedHostnamesTest(hostnameItems, "prp_test1", "grp_test", "ctr_test", "prp_test"), diff --git a/pkg/providers/property/data_akamai_property_include.go b/pkg/providers/property/data_akamai_property_include.go index f34fbbb44..fb53f521d 100644 --- a/pkg/providers/property/data_akamai_property_include.go +++ b/pkg/providers/property/data_akamai_property_include.go @@ -2,114 +2,146 @@ package property import ( "context" + "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "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" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) -func dataSourcePropertyInclude() *schema.Resource { - return &schema.Resource{ - ReadContext: dataPropertyIncludeRead, - Schema: map[string]*schema.Schema{ - "contract_id": { - Type: schema.TypeString, - Required: true, - Description: "Identifies the contract under which the include was created", +var _ datasource.DataSource = &includeDataSource{} +var _ datasource.DataSourceWithConfigure = &includeDataSource{} + +// NewIncludeDataSource returns a new property include data source +func NewIncludeDataSource() datasource.DataSource { + return &includeDataSource{} +} + +// includeDataSource defines the data source implementation for fetching property include information. +type includeDataSource struct { + meta meta.Meta +} + +// includeDataSourceModel describes the data source data model for PropertyIncludeDataSource. +type includeDataSourceModel struct { + ContractID types.String `tfsdk:"contract_id"` + GroupID types.String `tfsdk:"group_id"` + IncludeID types.String `tfsdk:"include_id"` + Name types.String `tfsdk:"name"` + Type types.String `tfsdk:"type"` + LatestVersion types.Int64 `tfsdk:"latest_version"` + StagingVersion types.Int64 `tfsdk:"staging_version"` + ProductionVersion types.Int64 `tfsdk:"production_version"` + ID types.String `tfsdk:"id"` +} + +// Metadata configures data source's meta information +func (d *includeDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_property_include" +} + +// Schema is used to define data source's terraform schema +func (d *includeDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Property Include data source", + Attributes: map[string]schema.Attribute{ + "contract_id": schema.StringAttribute{ + MarkdownDescription: "Identifies the contract under which the include was created", + Required: true, }, - "group_id": { - Type: schema.TypeString, - Required: true, - Description: "Identifies the group under which the include was created", + "group_id": schema.StringAttribute{ + MarkdownDescription: "Identifies the group under which the include was created", + Required: true, }, - "include_id": { - Type: schema.TypeString, - Required: true, - Description: "The unique identifier of the property include", + "include_id": schema.StringAttribute{ + MarkdownDescription: "Identifies the group under which the include was created", + Required: true, }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "A descriptive name for the include", + "name": schema.StringAttribute{ + MarkdownDescription: "A descriptive name for the include", + Computed: true, }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Specifies the type of the include, either 'MICROSERVICES' or 'COMMON_SETTINGS'", + "type": schema.StringAttribute{ + MarkdownDescription: "Specifies the type of the include, either 'MICROSERVICES' or 'COMMON_SETTINGS'", + Computed: true, }, - "latest_version": { - Type: schema.TypeInt, - Computed: true, - Description: "Specifies the most recent version of the include", + "latest_version": schema.Int64Attribute{ + MarkdownDescription: "Specifies the most recent version of the include", + Computed: true, }, - "staging_version": { - Type: schema.TypeInt, - Computed: true, - Description: "The most recent version which was activated to the test network", + "staging_version": schema.Int64Attribute{ + MarkdownDescription: "The most recent version which was activated to the test network", + Computed: true, }, - "production_version": { - Type: schema.TypeInt, - Computed: true, - Description: "The most recent version which was activated to the production network", + "production_version": schema.Int64Attribute{ + MarkdownDescription: "The most recent version which was activated to the production network", + Computed: true, + }, + "id": schema.StringAttribute{ + MarkdownDescription: "Identifier of the data source", + Computed: true, }, }, } } -func dataPropertyIncludeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) - log := meta.Log("PAPI", "dataPropertyIncludeRead") - log.Debug("Reading Property Include") - - contractID, err := tf.GetStringValue("contract_id", d) - if err != nil { - return diag.FromErr(err) +// Configure configures data source at the beginning of the lifecycle +func (d *includeDataSource) 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 } - groupID, err := tf.GetStringValue("group_id", d) - if err != nil { - return diag.FromErr(err) - } + 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), + ) + } + }() - includeID, err := tf.GetStringValue("include_id", d) - if err != nil { - return diag.FromErr(err) + d.meta = meta.Must(req.ProviderData) +} + +// Read is called when the provider must read data source values in order to update state +func (d *includeDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "PropertyIncludeDataSource Read") + + var data includeDataSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return } - include, err := client.GetInclude(ctx, papi.GetIncludeRequest{ - ContractID: contractID, - GroupID: groupID, - IncludeID: includeID, + client := Client(d.meta) + getIncludeResp, err := client.GetInclude(ctx, papi.GetIncludeRequest{ + ContractID: data.ContractID.ValueString(), + GroupID: data.GroupID.ValueString(), + IncludeID: data.IncludeID.ValueString(), }) if err != nil { - return diag.FromErr(err) + resp.Diagnostics.AddError("fetching property include failed", err.Error()) + return } - if len(include.Includes.Items) == 0 { - // this one probably shouldn't ever happen, - return diag.Errorf("empty include response from api") - } - item := include.Includes.Items[0] + include := getIncludeResp.Include - attrs := map[string]interface{}{ - "name": item.IncludeName, - "type": item.IncludeType, - "latest_version": item.LatestVersion, - } - if item.StagingVersion != nil { - attrs["staging_version"] = item.StagingVersion - } - if item.ProductionVersion != nil { - attrs["production_version"] = item.ProductionVersion + data.Name = types.StringValue(include.IncludeName) + data.Type = types.StringValue(string(include.IncludeType)) + data.LatestVersion = types.Int64Value(int64(include.LatestVersion)) + + if include.StagingVersion != nil { + data.StagingVersion = types.Int64Value(int64(*include.StagingVersion)) } - if err = tf.SetAttrs(d, attrs); err != nil { - return diag.FromErr(err) + + if include.ProductionVersion != nil { + data.ProductionVersion = types.Int64Value(int64(*include.ProductionVersion)) } - d.SetId(includeID) - return nil + data.ID = data.IncludeID + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } diff --git a/pkg/providers/property/data_akamai_property_include_activation.go b/pkg/providers/property/data_akamai_property_include_activation.go index c054f202c..83ae4d7af 100644 --- a/pkg/providers/property/data_akamai_property_include_activation.go +++ b/pkg/providers/property/data_akamai_property_include_activation.go @@ -6,9 +6,9 @@ import ( "sort" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -73,8 +73,8 @@ type includeActivationAttrs struct { } func dataPropertyIncludeActivationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataPropertyIncludeActivationRead") log.Debug("Reading Property Include Activation") 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 75cc3a6f4..55fd01763 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -162,8 +162,8 @@ func TestDataPropertyIncludeActivation(t *testing.T) { test.init(t, client, test.attrs) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: loadFixtureString(test.configPath), Check: checkPropertyIncludeActivationAttrs(test.attrs), diff --git a/pkg/providers/property/data_akamai_property_include_parents.go b/pkg/providers/property/data_akamai_property_include_parents.go index 48f67d5cd..bc3af210e 100644 --- a/pkg/providers/property/data_akamai_property_include_parents.go +++ b/pkg/providers/property/data_akamai_property_include_parents.go @@ -4,9 +4,9 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -74,8 +74,8 @@ func dataSourcePropertyIncludeParents() *schema.Resource { } func dataPropertyIncludeParentsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataPropertyIncludeParentsRead") log.Debug("Reading Property Include Parents") 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 832096ae5..35780c739 100644 --- a/pkg/providers/property/data_akamai_property_include_parents_test.go +++ b/pkg/providers/property/data_akamai_property_include_parents_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -159,8 +159,8 @@ func TestDataPropertyIncludeParents(t *testing.T) { } useClient(client, nil, func() { resource.Test(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, + IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString(fmt.Sprintf("testdata/TestDataPropertyIncludeParents/%s", test.givenTF)), Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), diff --git a/pkg/providers/property/data_akamai_property_include_rules.go b/pkg/providers/property/data_akamai_property_include_rules.go index b61941c03..67eb22561 100644 --- a/pkg/providers/property/data_akamai_property_include_rules.go +++ b/pkg/providers/property/data_akamai_property_include_rules.go @@ -5,10 +5,10 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -72,8 +72,8 @@ func dataSourcePropertyIncludeRules() *schema.Resource { } func dataPropertyIncludeRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataPropertyIncludeRulesRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(log)) 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 73b3a860b..fc0a1456e 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -172,8 +172,8 @@ func TestDataPropertyIncludeRules(t *testing.T) { test.init(t, client, test.mockData) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{ { Config: loadFixtureString(test.configPath), diff --git a/pkg/providers/property/data_akamai_property_include_test.go b/pkg/providers/property/data_akamai_property_include_test.go index d071a88dc..1ce99ac2c 100644 --- a/pkg/providers/property/data_akamai_property_include_test.go +++ b/pkg/providers/property/data_akamai_property_include_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/stretchr/testify/mock" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -39,6 +39,13 @@ func TestDataPropertyInclude(t *testing.T) { }, }, }, + Include: papi.Include{ + IncludeName: "inc_name", + IncludeType: "MICROSERVICES", + LatestVersion: 4, + ProductionVersion: tools.IntPtr(3), + StagingVersion: tools.IntPtr(2), + }, }, nil) }, expectedAttributes: map[string]string{ @@ -69,6 +76,13 @@ func TestDataPropertyInclude(t *testing.T) { }, }, }, + Include: papi.Include{ + IncludeName: "inc_name", + IncludeType: "MICROSERVICES", + LatestVersion: 4, + ProductionVersion: nil, + StagingVersion: nil, + }, }, nil) }, expectedAttributes: map[string]string{ @@ -93,21 +107,6 @@ func TestDataPropertyInclude(t *testing.T) { }, expectError: regexp.MustCompile("oops"), }, - "empty include items list in response": { - givenTF: "valid.tf", - init: func(m *papi.Mock) { - m.On("GetInclude", mock.Anything, papi.GetIncludeRequest{ - ContractID: "ctr_1", - GroupID: "grp_1", - IncludeID: "inc_1", - }).Return(&papi.GetIncludeResponse{ - Includes: papi.IncludeItems{ - Items: []papi.Include{}, - }, - }, nil) - }, - expectError: regexp.MustCompile("Error: empty include response from api"), - }, "missing required argument contract_id": { givenTF: "missing_contract_id.tf", expectError: regexp.MustCompile(`The argument "contract_id" is required, but no definition was found`), @@ -136,8 +135,8 @@ func TestDataPropertyInclude(t *testing.T) { } useClient(client, nil, func() { resource.Test(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, + IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString(fmt.Sprintf("testdata/TestDataPropertyInclude/%s", test.givenTF)), Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), diff --git a/pkg/providers/property/data_akamai_property_includes.go b/pkg/providers/property/data_akamai_property_includes.go index 6a6a89b05..183803f45 100644 --- a/pkg/providers/property/data_akamai_property_includes.go +++ b/pkg/providers/property/data_akamai_property_includes.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -109,8 +109,8 @@ type parentPropertyAttr struct { } func dataPropertyIncludesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) log := meta.Log("PAPI", "dataPropertyIncludesRead") log.Debug("Reading property includes") diff --git a/pkg/providers/property/data_akamai_property_includes_test.go b/pkg/providers/property/data_akamai_property_includes_test.go index 20cd931a5..9cad943a4 100644 --- a/pkg/providers/property/data_akamai_property_includes_test.go +++ b/pkg/providers/property/data_akamai_property_includes_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" ) @@ -296,8 +296,8 @@ func TestDataPropertyIncludes(t *testing.T) { test.init(t, client, test.attrs) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: loadFixtureString(test.configPath), Check: checkPropertyIncludesAttrs(test.attrs), diff --git a/pkg/providers/property/data_akamai_property_products.go b/pkg/providers/property/data_akamai_property_products.go index ef16c7a6e..2a6880eb7 100644 --- a/pkg/providers/property/data_akamai_property_products.go +++ b/pkg/providers/property/data_akamai_property_products.go @@ -5,11 +5,11 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -39,13 +39,13 @@ func dataSourcePropertyProducts() *schema.Resource { } func dataPropertyProductsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "dataPropertyProductsRead") // create context with logging ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) contractID, err := tf.GetStringValue("contract_id", d) if err != nil { diff --git a/pkg/providers/property/data_akamai_property_products_test.go b/pkg/providers/property/data_akamai_property_products_test.go index 6e5883f8f..a92b29f0f 100644 --- a/pkg/providers/property/data_akamai_property_products_test.go +++ b/pkg/providers/property/data_akamai_property_products_test.go @@ -8,14 +8,14 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestVerifyProductsDataSourceSchema(t *testing.T) { t.Run("akamai_property_products - test data source required contract", func(t *testing.T) { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: testConfig(""), ExpectError: regexp.MustCompile("The argument \"contract_id\" is required, but no definition was found"), @@ -38,8 +38,8 @@ func TestOutputProductsDataSource(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: testConfig("contract_id = \"ctr_test\""), Check: resource.ComposeTestCheckFunc( diff --git a/pkg/providers/property/data_akamai_property_rule_formats.go b/pkg/providers/property/data_akamai_property_rule_formats.go index b2225d033..2dee037e8 100644 --- a/pkg/providers/property/data_akamai_property_rule_formats.go +++ b/pkg/providers/property/data_akamai_property_rule_formats.go @@ -4,10 +4,9 @@ import ( "context" "fmt" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" ) func dataSourcePropertyRuleFormats() *schema.Resource { @@ -24,8 +23,8 @@ func dataSourcePropertyRuleFormats() *schema.Resource { } func dataPropertyRuleFormatsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) logger := meta.Log("PAPI", "dataPropertyRuleFormatsRead") logger.Debugf("read property rule formats") 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 f1570046d..bd30a44fb 100644 --- a/pkg/providers/property/data_akamai_property_rule_formats_test.go +++ b/pkg/providers/property/data_akamai_property_rule_formats_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func Test_readPropertyRuleFormats(t *testing.T) { @@ -22,7 +22,7 @@ func Test_readPropertyRuleFormats(t *testing.T) { ).Return(&papi.GetRuleFormatsResponse{RuleFormats: ruleFormats}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertyRuleFormats/rule_formats.tf"), Check: resource.ComposeAggregateTestCheckFunc( diff --git a/pkg/providers/property/data_akamai_property_rules.go b/pkg/providers/property/data_akamai_property_rules.go index 25d4b1b27..b8c3454da 100644 --- a/pkg/providers/property/data_akamai_property_rules.go +++ b/pkg/providers/property/data_akamai_property_rules.go @@ -7,10 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) func dataSourcePropertyRules() *schema.Resource { @@ -88,8 +88,8 @@ func isValidRuleFormat(ctx context.Context, client papi.PAPI, format string) (bo } func dataPropertyRulesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) logger := meta.Log("PAPI", "dataPropertyRulesRead") var ( diff --git a/pkg/providers/property/data_akamai_property_rules_builder.go b/pkg/providers/property/data_akamai_property_rules_builder.go index 3c626cfc6..7652c90a3 100644 --- a/pkg/providers/property/data_akamai_property_rules_builder.go +++ b/pkg/providers/property/data_akamai_property_rules_builder.go @@ -7,9 +7,9 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/property/ruleformats" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/property/ruleformats" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -36,7 +36,7 @@ func dataSourcePropertyRulesBuilder() *schema.Resource { } func dataSourcePropertyRulesBuilderRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "dataSourcePropertyRulesBuilderRead") logger.Debug("dataSourcePropertyRulesBuilderRead") diff --git a/pkg/providers/property/data_akamai_property_rules_builder_test.go b/pkg/providers/property/data_akamai_property_rules_builder_test.go index 955317c94..c222bbc1d 100644 --- a/pkg/providers/property/data_akamai_property_rules_builder_test.go +++ b/pkg/providers/property/data_akamai_property_rules_builder_test.go @@ -11,12 +11,12 @@ import ( ) func TestDataPropertyRulesBuilder(t *testing.T) { - t.Run("valid rule with 3 children", func(t *testing.T) { + t.Run("valid rule with 3 children - v2023-01-05", func(t *testing.T) { useClient(nil, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSPropertyRulesBuilder/rules.tf"), + Config: loadFixtureString("testdata/TestDSPropertyRulesBuilder/rules_v2023_01_05.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_property_rules_builder.default", "rule_format", @@ -50,10 +50,49 @@ func TestDataPropertyRulesBuilder(t *testing.T) { }) }) }) + t.Run("valid rule with 3 children - v2023-05-30", func(t *testing.T) { + useClient(nil, nil, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV5ProviderFactories: testAccProviders, + Steps: []resource.TestStep{{ + Config: loadFixtureString("testdata/TestDSPropertyRulesBuilder/rules_v2023_05_30.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_property_rules_builder.default", + "rule_format", + "v2023-05-30"), + testCheckResourceAttrJSON("data.akamai_property_rules_builder.default", + "json", + loadFixtureString("testdata/TestDSPropertyRulesBuilder/default.json")), + + resource.TestCheckResourceAttr("data.akamai_property_rules_builder.content_compression", + "rule_format", + "v2023-05-30"), + testCheckResourceAttrJSON("data.akamai_property_rules_builder.content_compression", + "json", + loadFixtureString("testdata/TestDSPropertyRulesBuilder/content_compression.json")), + + resource.TestCheckResourceAttr("data.akamai_property_rules_builder.static_content", + "rule_format", + "v2023-05-30"), + testCheckResourceAttrJSON("data.akamai_property_rules_builder.static_content", + "json", + loadFixtureString("testdata/TestDSPropertyRulesBuilder/static_content.json")), + + resource.TestCheckResourceAttr("data.akamai_property_rules_builder.dynamic_content", + "rule_format", + "v2023-05-30"), + testCheckResourceAttrJSON("data.akamai_property_rules_builder.dynamic_content", + "json", + loadFixtureString("testdata/TestDSPropertyRulesBuilder/dynamic_content.json")), + ), + }}, + }) + }) + }) t.Run("fails on rule with more than one behavior in one block", func(t *testing.T) { useClient(nil, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertyRulesBuilder/rules_error_too_many_elements.tf"), ExpectError: regexp.MustCompile(`expected 1 element\(s\), got 2`), @@ -64,7 +103,7 @@ func TestDataPropertyRulesBuilder(t *testing.T) { t.Run("fails on rule with is_secure outside default rule", func(t *testing.T) { useClient(nil, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertyRulesBuilder/rules_with_is_secure_outside_default.tf"), ExpectError: regexp.MustCompile(`cannot be used outside 'default' rule: is_secure`), @@ -75,7 +114,7 @@ func TestDataPropertyRulesBuilder(t *testing.T) { t.Run("fails on rule with variable outside default rule", func(t *testing.T) { useClient(nil, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertyRulesBuilder/rules_with_variable_outside_default.tf"), ExpectError: regexp.MustCompile(`cannot be used outside 'default' rule: variable`), diff --git a/pkg/providers/property/data_akamai_property_rules_template.go b/pkg/providers/property/data_akamai_property_rules_template.go index cf3a30b25..af7f66d43 100644 --- a/pkg/providers/property/data_akamai_property_rules_template.go +++ b/pkg/providers/property/data_akamai_property_rules_template.go @@ -21,8 +21,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) func dataSourcePropertyRulesTemplate() *schema.Resource { @@ -152,7 +152,7 @@ func (v variablePopulator) replaceMatchWithVar(template string, varMap map[strin //nolint:gocyclo func dataPropertyRulesTemplateRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "dataPropertyRulesTemplateRead") file, err := tf.GetStringValue("template_file", d) 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 d1c79cc0e..f5fff5ab8 100644 --- a/pkg/providers/property/data_akamai_property_rules_template_test.go +++ b/pkg/providers/property/data_akamai_property_rules_template_test.go @@ -6,8 +6,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/require" "github.com/tj/assert" @@ -18,7 +18,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_map.tf"), @@ -40,7 +40,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_map_ns.tf"), @@ -62,7 +62,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_null_values.tf"), @@ -84,7 +84,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_file.tf"), @@ -106,7 +106,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_file_data_conflict.tf"), @@ -124,7 +124,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_missing_data.tf"), @@ -142,7 +142,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_conflict.tf"), @@ -156,7 +156,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_invalid_type.tf"), @@ -170,7 +170,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_var_not_found.tf"), @@ -184,7 +184,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_invalid_value.tf"), @@ -198,7 +198,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_vars_file_not_found.tf"), @@ -212,7 +212,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_invalid_json.tf"), @@ -226,7 +226,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_file_not_found.tf"), @@ -241,7 +241,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_file_is_empty.tf"), @@ -256,7 +256,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_invalid_snippets_folder_json.tf"), @@ -271,7 +271,7 @@ func TestDataAkamaiPropertyRulesRead(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSRulesTemplate/template_invalid_snippets_only_one_folder_json.tf"), @@ -688,7 +688,7 @@ func TestVariablesNesting(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(test.configPath), @@ -722,7 +722,7 @@ func TestVariablesAndIncludesNestingCyclicDependency(t *testing.T) { client := papi.Mock{} useClient(&client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(test.configPath), diff --git a/pkg/providers/property/data_akamai_property_rules_test.go b/pkg/providers/property/data_akamai_property_rules_test.go index e9c85f00c..de1f31034 100644 --- a/pkg/providers/property/data_akamai_property_rules_test.go +++ b/pkg/providers/property/data_akamai_property_rules_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestDSPropertyRulesRead(t *testing.T) { @@ -50,7 +50,7 @@ func TestDSPropertyRulesRead(t *testing.T) { mockImpl(client) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/ds_property_rules.tf"), @@ -126,7 +126,7 @@ func TestDSPropertyRulesRead(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(test.configFile), @@ -156,7 +156,7 @@ func TestDSPropertyRulesRead(t *testing.T) { mockImpl(client) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/with_versioned_rule_format.tf"), @@ -175,7 +175,7 @@ func TestDSPropertyRulesRead(t *testing.T) { mockImpl(client) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/with_versioned_rule_format.tf"), @@ -190,7 +190,7 @@ func TestDSPropertyRulesRead(t *testing.T) { client := &papi.Mock{} useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/missing_group_id.tf"), @@ -205,7 +205,7 @@ func TestDSPropertyRulesRead(t *testing.T) { client := &papi.Mock{} useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/missing_contract_id.tf"), @@ -220,7 +220,7 @@ func TestDSPropertyRulesRead(t *testing.T) { client := &papi.Mock{} useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/empty_contract_id.tf"), @@ -235,7 +235,7 @@ func TestDSPropertyRulesRead(t *testing.T) { client := &papi.Mock{} useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/empty_group_id.tf"), @@ -258,7 +258,7 @@ func TestDSPropertyRulesRead(t *testing.T) { mockImpl(client) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/ds_property_rules.tf"), @@ -295,7 +295,7 @@ func TestDSPropertyRulesRead(t *testing.T) { mockImpl(client) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestDSPropertyRules/ds_property_rules.tf"), @@ -310,7 +310,7 @@ func TestDSPropertyRulesRead(t *testing.T) { func TestDSPropertyRulesRead_Fail(t *testing.T) { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSPropertyRules/always_fails.tf"), ExpectError: regexp.MustCompile(`Error: provided value cannot be blank`), diff --git a/pkg/providers/property/data_akamai_property_test.go b/pkg/providers/property/data_akamai_property_test.go index 5b00f2dbe..1afd79f67 100644 --- a/pkg/providers/property/data_akamai_property_test.go +++ b/pkg/providers/property/data_akamai_property_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) @@ -243,8 +243,8 @@ func TestDataProperty(t *testing.T) { } useClient(client, nil, func() { resource.Test(t, resource.TestCase{ - IsUnitTest: true, - ProviderFactories: testAccProviders, + IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString(fmt.Sprintf("testdata/TestDataProperty/%s", test.givenTF)), Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), diff --git a/pkg/providers/property/data_property_akamai_contract.go b/pkg/providers/property/data_property_akamai_contract.go index 47b1e3f18..e57eae15d 100644 --- a/pkg/providers/property/data_property_akamai_contract.go +++ b/pkg/providers/property/data_property_akamai_contract.go @@ -7,40 +7,34 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) func dataSourcePropertyContract() *schema.Resource { return &schema.Resource{ ReadContext: dataPropertyContractRead, Schema: map[string]*schema.Schema{ - "group": { - Type: schema.TypeString, - Optional: true, - ExactlyOneOf: []string{"group", "group_id", "group_name"}, - Deprecated: akamai.NoticeDeprecatedUseAlias("group"), - }, "group_id": { Type: schema.TypeString, Optional: true, Computed: true, - ExactlyOneOf: []string{"group", "group_id", "group_name"}, + ExactlyOneOf: []string{"group_id", "group_name"}, }, "group_name": { Type: schema.TypeString, Optional: true, Computed: true, - ExactlyOneOf: []string{"group", "group_id", "group_name"}, + ExactlyOneOf: []string{"group_id", "group_name"}, }, }, } } func dataPropertyContractRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) log := meta.Log("PAPI", "dataPropertyContractRead") @@ -53,23 +47,19 @@ func dataPropertyContractRead(ctx context.Context, d *schema.ResourceData, m int // check if one of group_id/group_name exists. group, err := tf.ResolveKeyStringState(d, "group_id", "group_name") if err != nil { - // if both group_id/group_name not present in the state, check for group. - group, err = tf.GetStringValue("group", d) // If no group found, just return the first contract + if !errors.Is(err, tf.ErrNotFound) { + return diag.FromErr(err) + } + contracts, err := Client(meta).GetContracts(ctx) if err != nil { - if !errors.Is(err, tf.ErrNotFound) { - return diag.FromErr(err) - } - contracts, err := inst.Client(meta).GetContracts(ctx) - if err != nil { - return diag.Errorf("error looking up Contracts for group %v: %s", group, err) - } - if len(contracts.Contracts.Items) == 0 { - return diag.Errorf("%v", ErrNoContractsFound) - } - d.SetId(contracts.Contracts.Items[0].ContractID) - return nil + return diag.Errorf("error looking up Contracts for group %v: %s", group, err) + } + if len(contracts.Contracts.Items) == 0 { + return diag.Errorf("%v", ErrNoContractsFound) } + d.SetId(contracts.Contracts.Items[0].ContractID) + return nil } // Otherwise find the group and return it's first contract diff --git a/pkg/providers/property/data_property_akamai_contract_test.go b/pkg/providers/property/data_property_akamai_contract_test.go index 5756f4881..11396b7a8 100644 --- a/pkg/providers/property/data_property_akamai_contract_test.go +++ b/pkg/providers/property/data_property_akamai_contract_test.go @@ -6,11 +6,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func Test_DSReadContract(t *testing.T) { - t.Run("read contract with group_id in group provided", func(t *testing.T) { + t.Run("read contract with group name and group ID conflict", func(t *testing.T) { client := &papi.Mock{} client.On("GetGroups") client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ @@ -31,112 +31,10 @@ func Test_DSReadContract(t *testing.T) { }}}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_id_in_group.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "id", "ctr_1234"), - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "group_id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "group_name", "Example.com-1-1TJZH5"), - ), - }}, - }) - }) - }) - - t.Run("read contract with group id w/o prefix in group", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - { - GroupID: "grp_12346", - GroupName: "default", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_id_in_group_wo_prefix.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "id", "ctr_1234"), - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "group_id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "group_name", "Example.com-1-1TJZH5"), - ), - }}, - }) - }) - }) - - t.Run("read contract with group name in group", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - { - GroupID: "grp_12346", - GroupName: "default", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_name_in_group.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "id", "ctr_1234"), - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "group_id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_contract.akacontract", "group_name", "Example.com-1-1TJZH5"), - ), - }}, - }) - }) - }) - - t.Run("read contract with group name and group conflict", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - { - GroupID: "grp_12346", - GroupName: "default", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_name_and_group.tf"), - ExpectError: regexp.MustCompile("only one of `group,group_id,group_name` can be specified"), + ExpectError: regexp.MustCompile("only one of `group_id,group_name` can be specified"), }}, }) }) @@ -163,7 +61,7 @@ func Test_DSReadContract(t *testing.T) { }}}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_id.tf"), Check: resource.ComposeAggregateTestCheckFunc( @@ -197,7 +95,7 @@ func Test_DSReadContract(t *testing.T) { }}}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_id_without_prefix.tf"), Check: resource.ComposeAggregateTestCheckFunc( @@ -231,7 +129,7 @@ func Test_DSReadContract(t *testing.T) { }}}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSContractRequired/ds_contract_with_group_name.tf"), Check: resource.ComposeAggregateTestCheckFunc( diff --git a/pkg/providers/property/data_property_akamai_group.go b/pkg/providers/property/data_property_akamai_group.go index 96b6e2a35..bead52bff 100644 --- a/pkg/providers/property/data_property_akamai_group.go +++ b/pkg/providers/property/data_property_akamai_group.go @@ -9,48 +9,31 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/cache" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + akameta "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" ) func dataSourcePropertyGroup() *schema.Resource { return &schema.Resource{ ReadContext: dataPropertyGroupRead, Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"name", "group_name"}, - Deprecated: akamai.NoticeDeprecatedUseAlias("name"), - }, "group_name": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"name", "group_name"}, - }, - "contract": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract", "contract_id"}, - Deprecated: akamai.NoticeDeprecatedUseAlias("contract"), + Type: schema.TypeString, + Required: true, }, "contract_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract", "contract_id"}, + Type: schema.TypeString, + Required: true, }, }, } } func dataPropertyGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := akameta.Must(m) log := meta.Log("PAPI", "dataPropertyGroupRead") // create a context with logging for api calls @@ -59,54 +42,39 @@ func dataPropertyGroupRead(ctx context.Context, d *schema.ResourceData, m interf session.WithContextLog(log), ) - var ( - name string - getDefault bool - ) + var getDefault bool - // check and load group_name, if not exists then check group. - name, err := tf.ResolveKeyStringState(d, "group_name", "name") + groupName, err := tf.GetStringValue("group_name", d) if err != nil { if !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - name = "default" + groupName = "default" getDefault = true } - log.Debugf("[Akamai Property Group] Start Searching for property group records %s ", name) + log.Debugf("[Akamai Property Group] Start Searching for property group records %s ", groupName) groups, err := getGroups(ctx, meta) if err != nil { return diag.FromErr(err) } - - // check and load contract_id, if not exists then check contract. - contractID, err := tf.ResolveKeyStringState(d, "contract_id", "contract") + contractID, err := tf.GetStringValue("contract_id", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { return diag.FromErr(err) } - - group, err := findGroupByName(name, contractID, groups, getDefault) + group, err := findGroupByName(groupName, contractID, groups, getDefault) if err != nil { - return diag.Errorf("%v: %v: %v", ErrLookingUpGroupByName, name, err) + return diag.Errorf("%v: %v: %v", ErrLookingUpGroupByName, groupName, err) } - // set group_name/name in state. if err := d.Set("group_name", group.GroupName); err != nil { return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) } - if err := d.Set("name", group.GroupName); err != nil { - return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) - } if len(group.ContractIDs) != 0 { contractID = group.ContractIDs[0] } - // set contract/contract_id in state. - if err := d.Set("contract", contractID); err != nil { - return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) - } if err := d.Set("contract_id", contractID); err != nil { return diag.Errorf("%v: %s", tf.ErrValueSet, err.Error()) } @@ -173,18 +141,18 @@ func findGroupByName(name, contract string, groups *papi.GetGroupsResponse, isDe return nil, fmt.Errorf("%v: %s", ErrGroupNotInContract, contract) } -func getGroups(ctx context.Context, meta akamai.OperationMeta) (*papi.GetGroupsResponse, error) { +func getGroups(ctx context.Context, meta akameta.Meta) (*papi.GetGroupsResponse, error) { groups := &papi.GetGroupsResponse{} - if err := meta.CacheGet(inst, "groups", groups); err != nil { - if !akamai.IsNotFoundError(err) && !errors.Is(err, akamai.ErrCacheDisabled) { + if err := cache.Get(cache.BucketName(SubproviderName), "groups", groups); err != nil { + if !errors.Is(err, cache.ErrEntryNotFound) && !errors.Is(err, cache.ErrDisabled) { return nil, err } - groups, err = inst.Client(meta).GetGroups(ctx) + groups, err = Client(meta).GetGroups(ctx) if err != nil { return nil, err } - if err := meta.CacheSet(inst, "groups", groups); err != nil { - if !errors.Is(err, akamai.ErrCacheDisabled) { + if err := cache.Set(cache.BucketName(SubproviderName), "groups", groups); err != nil { + if !errors.Is(err, cache.ErrDisabled) { return nil, err } } diff --git a/pkg/providers/property/data_property_akamai_group_test.go b/pkg/providers/property/data_property_akamai_group_test.go index 84cb8b681..a348c7b72 100644 --- a/pkg/providers/property/data_property_akamai_group_test.go +++ b/pkg/providers/property/data_property_akamai_group_test.go @@ -1,77 +1,13 @@ package property import ( - "regexp" "testing" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" ) func Test_DSReadGroup(t *testing.T) { - t.Run("read group with name and contract provided", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSGroup/ds-group-w-name-and-contract.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "group_name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract", "ctr_1234"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract_id", "ctr_1234"), - ), - }}, - }) - }) - }) - - t.Run("read group with name and contract_id provided", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSGroup/ds-group-w-name-and-contract_id.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "group_name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract", "ctr_1234"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract_id", "ctr_1234"), - ), - }}, - }) - }) - }) - t.Run("read group with group_name and contract_id provided", func(t *testing.T) { client := &papi.Mock{} client.On("GetGroups") @@ -87,100 +23,17 @@ func Test_DSReadGroup(t *testing.T) { }}}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSGroup/ds-group-w-group-name-and-contract_id.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_group.akagroup", "id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "group_name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract", "ctr_1234"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract_id", "ctr_1234"), - ), - }}, - }) - }) - }) - - t.Run("read group with group_name and contract provided", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSGroup/ds-group-w-group-name-and-contract.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "id", "grp_12345"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "name", "Example.com-1-1TJZH5"), resource.TestCheckResourceAttr("data.akamai_group.akagroup", "group_name", "Example.com-1-1TJZH5"), - resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract", "ctr_1234"), resource.TestCheckResourceAttr("data.akamai_group.akagroup", "contract_id", "ctr_1234"), ), }}, }) }) }) - - t.Run("read group with group_name and name conflict", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSGroup/ds-group-w-group-name-and-name-conflict.tf"), - ExpectError: regexp.MustCompile("only one of `group_name,name` can be specified"), - }}, - }) - }) - }) - - t.Run("read group with contract_id and contract conflict", func(t *testing.T) { - client := &papi.Mock{} - client.On("GetGroups") - client.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ - AccountID: "act_1-1TJZFB", AccountName: "example.com", - Groups: papi.GroupItems{Items: []*papi.Group{ - { - GroupID: "grp_12345", - GroupName: "Example.com-1-1TJZH5", - ParentGroupID: "grp_parent", - ContractIDs: []string{"ctr_1234"}, - }, - }}}, nil) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestDSGroup/ds-group-w-contract-id-and-contract-conflict.tf"), - ExpectError: regexp.MustCompile("only one of `contract,contract_id` can be specified"), - }}, - }) - }) - }) } diff --git a/pkg/providers/property/data_property_akamai_groups.go b/pkg/providers/property/data_property_akamai_groups.go index 9208bd806..52dd22771 100644 --- a/pkg/providers/property/data_property_akamai_groups.go +++ b/pkg/providers/property/data_property_akamai_groups.go @@ -8,10 +8,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) func dataSourcePropertyMultipleGroups() *schema.Resource { @@ -51,7 +51,7 @@ func dataSourcePropertyMultipleGroups() *schema.Resource { } func dataPropertyMultipleGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "dataPropertyMultipleGroupsRead") // create a context with logging for api calls diff --git a/pkg/providers/property/data_property_akamai_groups_test.go b/pkg/providers/property/data_property_akamai_groups_test.go index 598f4fc67..d9de51a9f 100644 --- a/pkg/providers/property/data_property_akamai_groups_test.go +++ b/pkg/providers/property/data_property_akamai_groups_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestDataSourceMultipleGroups_basic(t *testing.T) { @@ -30,9 +30,9 @@ func TestDataSourceMultipleGroups_basic(t *testing.T) { }}}}, nil) useClient(client, nil, func() { resource.ParallelTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - CheckDestroy: testAccCheckAkamaiMultipleGroupsDestroy, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + CheckDestroy: testAccCheckAkamaiMultipleGroupsDestroy, + IsUnitTest: true, Steps: []resource.TestStep{ { Config: testAccDataSourceMultipleGroupsBasic(), @@ -69,8 +69,8 @@ func TestGroup_ContractNotFoundInState(t *testing.T) { }}}}, nil) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestDSContractRequired/groups.tf"), }}, diff --git a/pkg/providers/property/diff_suppress_funcs.go b/pkg/providers/property/diff_suppress_funcs.go index 2a76a0d0f..c0ac20863 100644 --- a/pkg/providers/property/diff_suppress_funcs.go +++ b/pkg/providers/property/diff_suppress_funcs.go @@ -6,15 +6,15 @@ import ( "reflect" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func diffSuppressRules(_, oldRules, newRules string, _ *schema.ResourceData) bool { rulesEqual, err := rulesJSONEqual(oldRules, newRules) if err != nil { - akamai.Log("PAPI", "diffSuppressRules").Error(err.Error()) + logger.Get("PAPI", "diffSuppressRules").Error(err.Error()) } return rulesEqual diff --git a/pkg/providers/property/diff_suppress_funcs_test.go b/pkg/providers/property/diff_suppress_funcs_test.go index 53eefc8a3..f1ba1ff98 100644 --- a/pkg/providers/property/diff_suppress_funcs_test.go +++ b/pkg/providers/property/diff_suppress_funcs_test.go @@ -3,8 +3,8 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/tj/assert" ) diff --git a/pkg/providers/property/helpers.go b/pkg/providers/property/helpers.go index e62f1c609..226f03b2e 100644 --- a/pkg/providers/property/helpers.go +++ b/pkg/providers/property/helpers.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/helpers_test.go b/pkg/providers/property/helpers_test.go index a0aa7e1ea..11847d1f0 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/property/log_fields.go b/pkg/providers/property/log_fields.go index c167f75ef..592cdc077 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) // Get loggable fields from given arguments diff --git a/pkg/providers/property/property.go b/pkg/providers/property/property.go index 92d6406ad..ee4127c1b 100644 --- a/pkg/providers/property/property.go +++ b/pkg/providers/property/property.go @@ -1,10 +1,11 @@ -//go:build all || property -// +build all property - package property -import "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/registry" +import "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/registry" + +// SubproviderName defines name of the property subprovider +const SubproviderName = "property" func init() { - registry.RegisterProvider(Subprovider()) + registry.RegisterPluginSubprovider(NewPluginSubprovider()) + registry.RegisterFrameworkSubprovider(NewFrameworkSubprovider()) } diff --git a/pkg/providers/property/provider.go b/pkg/providers/property/provider.go index f13625d98..a2a66621d 100644 --- a/pkg/providers/property/provider.go +++ b/pkg/providers/property/provider.go @@ -4,197 +4,107 @@ package property import ( "bytes" "encoding/json" - "errors" "fmt" - "sync" - "github.com/apex/log" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/config" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" ) type ( - provider struct { - *schema.Provider - - client papi.PAPI - - hapiClient hapi.HAPI - } + // PluginSubprovider gathers property resources and data sources written using terraform-plugin-sdk + PluginSubprovider struct{} - // Option is a papi provider option - Option func(p *provider) + // FrameworkSubprovider gathers property resources and data sources written using terraform-plugin-framework + FrameworkSubprovider struct{} ) var ( - once sync.Once - - inst *provider + client papi.PAPI + hapiClient hapi.HAPI ) -// Subprovider returns a core sub provider -func Subprovider(opts ...Option) akamai.Subprovider { - once.Do(func() { - inst = &provider{Provider: Provider()} - - for _, opt := range opts { - opt(inst) - } - }) - - return inst -} +var _ subprovider.Plugin = &PluginSubprovider{} +var _ subprovider.Framework = &FrameworkSubprovider{} -// Provider returns the Akamai terraform.Resource provider. -func Provider() *schema.Provider { - provider := &schema.Provider{ - Schema: map[string]*schema.Schema{ - "papi_section": { - Optional: true, - Type: schema.TypeString, - Default: "default", - Deprecated: akamai.NoticeDeprecatedUseAlias("papi_section"), - }, - "property_section": { - Optional: true, - Type: schema.TypeString, - Default: "default", - Deprecated: akamai.NoticeDeprecatedUseAlias("property_section"), - }, - "property": { - Optional: true, - Type: schema.TypeSet, - Elem: config.Options("property"), - MaxItems: 1, - Deprecated: akamai.NoticeDeprecatedUseAlias("property"), - }, - }, - DataSourcesMap: map[string]*schema.Resource{ - "akamai_contract": dataSourcePropertyContract(), - "akamai_contracts": dataSourceContracts(), - "akamai_cp_code": dataSourceCPCode(), - "akamai_group": dataSourcePropertyGroup(), - "akamai_groups": dataSourcePropertyMultipleGroups(), - "akamai_properties": dataSourceProperties(), - "akamai_properties_search": dataSourcePropertiesSearch(), - "akamai_property": dataSourceProperty(), - "akamai_property_activation": dataSourcePropertyActivation(), - "akamai_property_hostnames": dataSourcePropertyHostnames(), - "akamai_property_include": dataSourcePropertyInclude(), - "akamai_property_include_activation": dataSourcePropertyIncludeActivation(), - "akamai_property_include_parents": dataSourcePropertyIncludeParents(), - "akamai_property_include_rules": dataSourcePropertyIncludeRules(), - "akamai_property_includes": dataSourcePropertyIncludes(), - "akamai_property_products": dataSourcePropertyProducts(), - "akamai_property_rule_formats": dataSourcePropertyRuleFormats(), - "akamai_property_rules": dataSourcePropertyRules(), - "akamai_property_rules_builder": dataSourcePropertyRulesBuilder(), - "akamai_property_rules_template": dataSourcePropertyRulesTemplate(), - }, - ResourcesMap: map[string]*schema.Resource{ - "akamai_cp_code": resourceCPCode(), - "akamai_edge_hostname": resourceSecureEdgeHostName(), - "akamai_property": resourceProperty(), - "akamai_property_activation": resourcePropertyActivation(), - "akamai_property_include": resourcePropertyInclude(), - "akamai_property_include_activation": resourcePropertyIncludeActivation(), - "akamai_property_variables": resourcePropertyVariables(), - }, - } - return provider +// NewPluginSubprovider returns a core SDKv2 based sub provider +func NewPluginSubprovider() *PluginSubprovider { + return &PluginSubprovider{} } -// WithClient sets the client interface function, used for mocking and testing -func WithClient(c papi.PAPI) Option { - return func(p *provider) { - p.client = c - } +// NewFrameworkSubprovider returns a core Framework based sub provider +func NewFrameworkSubprovider() *FrameworkSubprovider { + return &FrameworkSubprovider{} } // Client returns the PAPI interface -func (p *provider) Client(meta akamai.OperationMeta) papi.PAPI { - if p.client != nil { - return p.client +func Client(meta meta.Meta) papi.PAPI { + if client != nil { + return client } return papi.Client(meta.Session()) } // HapiClient returns the HAPI interface -func (p *provider) HapiClient(meta akamai.OperationMeta) hapi.HAPI { - if p.hapiClient != nil { - return p.hapiClient +func HapiClient(meta meta.Meta) hapi.HAPI { + if hapiClient != nil { + return hapiClient } return hapi.Client(meta.Session()) } -func getPAPIV1Service(d *schema.ResourceData) error { - var inlineConfig *schema.Set - for _, key := range []string{"property", "config"} { - opt, err := tf.GetSetValue(key, d) - if err != nil { - if !errors.Is(err, tf.ErrNotFound) { - return err - } - continue - } - if inlineConfig != nil { - return fmt.Errorf("only one inline config section can be defined") - } - inlineConfig = opt - } - if err := d.Set("config", inlineConfig); err != nil { - return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) +// Resources returns terraform resources for property +func (p *PluginSubprovider) Resources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_cp_code": resourceCPCode(), + "akamai_edge_hostname": resourceSecureEdgeHostName(), + "akamai_property": resourceProperty(), + "akamai_property_activation": resourcePropertyActivation(), + "akamai_property_include": resourcePropertyInclude(), + "akamai_property_include_activation": resourcePropertyIncludeActivation(), } - for _, s := range tf.FindStringValues(d, "property_section", "papi_section", "config_section") { - if s != "default" && s != "" { - if err := d.Set("config_section", s); err != nil { - return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } - break - } - } - - return nil } -func (p *provider) Name() string { - return "property" -} - -// ProviderVersion update version string anytime provider adds new features -const ProviderVersion string = "v0.8.3" - -func (p *provider) Version() string { - return ProviderVersion -} - -func (p *provider) Schema() map[string]*schema.Schema { - return p.Provider.Schema -} - -func (p *provider) Resources() map[string]*schema.Resource { - return p.Provider.ResourcesMap +// DataSources returns terraform data sources for property +func (p *PluginSubprovider) DataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "akamai_contract": dataSourcePropertyContract(), + "akamai_contracts": dataSourceContracts(), + "akamai_cp_code": dataSourceCPCode(), + "akamai_group": dataSourcePropertyGroup(), + "akamai_groups": dataSourcePropertyMultipleGroups(), + "akamai_properties": dataSourceProperties(), + "akamai_properties_search": dataSourcePropertiesSearch(), + "akamai_property": dataSourceProperty(), + "akamai_property_activation": dataSourcePropertyActivation(), + "akamai_property_hostnames": dataSourcePropertyHostnames(), + "akamai_property_include_activation": dataSourcePropertyIncludeActivation(), + "akamai_property_include_parents": dataSourcePropertyIncludeParents(), + "akamai_property_include_rules": dataSourcePropertyIncludeRules(), + "akamai_property_includes": dataSourcePropertyIncludes(), + "akamai_property_products": dataSourcePropertyProducts(), + "akamai_property_rule_formats": dataSourcePropertyRuleFormats(), + "akamai_property_rules": dataSourcePropertyRules(), + "akamai_property_rules_builder": dataSourcePropertyRulesBuilder(), + "akamai_property_rules_template": dataSourcePropertyRulesTemplate(), + } } -func (p *provider) DataSources() map[string]*schema.Resource { - return p.Provider.DataSourcesMap +// Resources returns terraform resources for property +func (p *FrameworkSubprovider) Resources() []func() resource.Resource { + return []func() resource.Resource{} } -func (p *provider) Configure(log log.Interface, d *schema.ResourceData) diag.Diagnostics { - log.Debug("START Configure") - - if err := getPAPIV1Service(d); err != nil { - return diag.FromErr(err) +// DataSources returns terraform data sources for property +func (p *FrameworkSubprovider) DataSources() []func() datasource.DataSource { + return []func() datasource.DataSource{ + NewIncludeDataSource, } - - return nil } // compactJSON converts a JSON-encoded byte slice to a compact form (so our JSON fixtures can be readable) diff --git a/pkg/providers/property/provider_test.go b/pkg/providers/property/provider_test.go index 4991dee0e..64a3829e0 100644 --- a/pkg/providers/property/provider_test.go +++ b/pkg/providers/property/provider_test.go @@ -1,6 +1,7 @@ package property import ( + "context" "fmt" "io/ioutil" "log" @@ -8,56 +9,71 @@ import ( "sync" "testing" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/testutils" "github.com/hashicorp/go-hclog" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" + "github.com/hashicorp/terraform-plugin-mux/tf5muxserver" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -var testAccProviders map[string]func() (*schema.Provider, error) +var testAccProviders map[string]func() (tfprotov5.ProviderServer, error) -var testAccProvider *schema.Provider +var testAccPluginProvider *schema.Provider +var testAccFrameworkProvider provider.Provider func TestMain(m *testing.M) { - testAccProvider = akamai.Provider(Subprovider())() - testAccProviders = map[string]func() (*schema.Provider, error){ - "akamai": func() (*schema.Provider, error) { - return testAccProvider, nil + testAccPluginProvider = akamai.NewPluginProvider(NewPluginSubprovider())() + testAccFrameworkProvider = akamai.NewFrameworkProvider(NewFrameworkSubprovider())() + + testAccProviders = map[string]func() (tfprotov5.ProviderServer, error){ + "akamai": func() (tfprotov5.ProviderServer, error) { + ctx := context.Background() + providers := []func() tfprotov5.ProviderServer{ + testAccPluginProvider.GRPCProvider, + providerserver.NewProtocol5( + testAccFrameworkProvider, + ), + } + + muxServer, err := tf5muxserver.NewMuxServer(ctx, providers...) + if err != nil { + return nil, err + } + + return muxServer.ProviderServer(), nil }, } - if err := akamai.TFTestSetup(); err != nil { + + if err := testutils.TFTestSetup(); err != nil { log.Fatal(err) } exitCode := m.Run() - if err := akamai.TFTestTeardown(); err != nil { + if err := testutils.TFTestTeardown(); err != nil { log.Fatal(err) } os.Exit(exitCode) } -func TestProvider(t *testing.T) { - if err := Provider().InternalValidate(); err != nil { - t.Fatalf("err: %s", err) - } -} - // Only allow one test at a time to patch the client via useClient() var clientLock sync.Mutex // useClient swaps out the client on the global instance for the duration of the given func -func useClient(client papi.PAPI, hapiClient hapi.HAPI, f func()) { +func useClient(papiCli papi.PAPI, hapiCli hapi.HAPI, f func()) { clientLock.Lock() - orig := inst.client - inst.client = client + orig := client + client = papiCli - origHapi := inst.hapiClient - inst.hapiClient = hapiClient + origHapi := hapiClient + hapiClient = hapiCli defer func() { - inst.client = orig - inst.hapiClient = origHapi + client = orig + hapiClient = origHapi clientLock.Unlock() }() diff --git a/pkg/providers/property/resource_akamai_cp_code.go b/pkg/providers/property/resource_akamai_cp_code.go index 0a7ec40e4..7251b4fbd 100644 --- a/pkg/providers/property/resource_akamai_cp_code.go +++ b/pkg/providers/property/resource_akamai_cp_code.go @@ -11,10 +11,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) // PAPI CP Code @@ -36,47 +36,21 @@ func resourceCPCode() *schema.Resource { Required: true, ValidateDiagFunc: tf.IsNotBlank, }, - "contract": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("contract"), - StateFunc: addPrefixToState("ctr_"), - }, "contract_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract_id", "contract"}, - StateFunc: addPrefixToState("ctr_"), - }, - "group": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("group"), - StateFunc: addPrefixToState("grp_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("ctr_"), }, "group_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"group_id", "group"}, - StateFunc: addPrefixToState("grp_"), - }, - "product": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("product"), - StateFunc: addPrefixToState("prd_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("grp_"), }, "product_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"product"}, - StateFunc: addPrefixToState("prd_"), + Type: schema.TypeString, + Optional: true, + Computed: true, + StateFunc: addPrefixToState("prd_"), }, }, Timeouts: &schema.ResourceTimeout{ @@ -94,8 +68,8 @@ var ( const cpCodePrefix = "cpc_" func resourceCPCodeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) logger := meta.Log("PAPI", "resourceCPCodeCreate") logger.Debugf("Creating CP Code") @@ -104,16 +78,24 @@ func resourceCPCodeCreate(ctx context.Context, d *schema.ResourceData, m interfa name = got.(string) } - // Schema guarantees product_id/product are strings and one or the other is set - var productID string - if got, ok := d.GetOk("product_id"); ok { - productID = got.(string) - } else { - productID = d.Get("product").(string) + // Schema no longer guarantees that product_id is set, this field is required only for creation + productID, err := tf.GetStringValue("product_id", d) + if err != nil { + return diag.Errorf("`product_id` must be specified for creation") } productID = tools.AddPrefix(productID, "prd_") - contractID, groupID := getContractIDAndGroupID(d) + contractID, err := tf.GetStringValue("contract_id", d) + if err != nil { + return diag.FromErr(err) + } + contractID = tools.AddPrefix(contractID, "ctr_") + + groupID, err := tf.GetStringValue("group_id", d) + if err != nil { + return diag.FromErr(err) + } + groupID = tools.AddPrefix(groupID, "grp_") var cpCodeID string // Because CPCodes can't be deleted, we re-use an existing CPCode if it's there @@ -136,26 +118,30 @@ func resourceCPCodeCreate(ctx context.Context, d *schema.ResourceData, m interfa } func resourceCPCodeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceCPCodeRead") - client := inst.Client(meta) + client := Client(meta) logger.Debugf("Read CP Code") - contractID, groupID := getContractIDAndGroupID(d) + contractID, err := tf.GetStringValue("contract_id", d) + if err != nil { + return diag.FromErr(err) + } + contractID = tools.AddPrefix(contractID, "ctr_") - if err := d.Set("group_id", groupID); err != nil { - return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + groupID, err := tf.GetStringValue("group_id", d) + if err != nil { + return diag.FromErr(err) } - if err := d.Set("group", groupID); err != nil { + groupID = tools.AddPrefix(groupID, "grp_") + + if err := d.Set("group_id", groupID); err != nil { return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } if err := d.Set("contract_id", contractID); err != nil { return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } - if err := d.Set("contract", contractID); err != nil { - return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) - } cpCodeResp, err := client.GetCPCode(ctx, papi.GetCPCodeRequest{ CPCodeID: d.Id(), ContractID: contractID, @@ -174,9 +160,6 @@ func resourceCPCodeRead(ctx context.Context, d *schema.ResourceData, m interface if len(cpCode.ProductIDs) == 0 { return diag.Errorf("Couldn't find product id on the CP Code") } - if err := d.Set("product", cpCode.ProductIDs[0]); err != nil { - return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) - } if err := d.Set("product_id", cpCode.ProductIDs[0]); err != nil { return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } @@ -186,9 +169,9 @@ func resourceCPCodeRead(ctx context.Context, d *schema.ResourceData, m interface } func resourceCPCodeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceCPCodeUpdate") - client := inst.Client(meta) + client := Client(meta) logger.Debugf("Update CP Code") if diags := checkImmutableChanged(d); diags != nil { @@ -196,7 +179,16 @@ func resourceCPCodeUpdate(ctx context.Context, d *schema.ResourceData, m interfa return diags } - contractID, groupID := getContractIDAndGroupID(d) + contractID, err := tf.GetStringValue("contract_id", d) + if err != nil { + return diag.FromErr(err) + } + contractID = tools.AddPrefix(contractID, "ctr_") + groupID, err := tf.GetStringValue("group_id", d) + if err != nil { + return diag.FromErr(err) + } + groupID = tools.AddPrefix(groupID, "grp_") // trimCPCodeID is needed here for backwards compatibility cpCodeID, err := strconv.Atoi(strings.TrimPrefix(d.Id(), cpCodePrefix)) @@ -238,9 +230,9 @@ func resourceCPCodeUpdate(ctx context.Context, d *schema.ResourceData, m interfa } func resourceCPCodeImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceCPCodeImport") - client := inst.Client(meta) + client := Client(meta) logger.Debugf("Import CP Code") parts := strings.Split(d.Id(), ",") @@ -281,9 +273,6 @@ func resourceCPCodeImport(ctx context.Context, d *schema.ResourceData, m interfa if err := d.Set("product_id", cpCode.ProductIDs[0]); err != nil { return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) } - if err := d.Set("product", cpCode.ProductIDs[0]); err != nil { - return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } d.SetId(strings.TrimPrefix(cpCode.ID, cpCodePrefix)) logger.Debugf("Import CP Code: %+v", cpCode) @@ -309,11 +298,8 @@ func createCPCode(ctx context.Context, client papi.PAPI, name, productID, contra func checkImmutableChanged(d *schema.ResourceData) diag.Diagnostics { immutables := []string{ - "contract", "contract_id", - "group", "group_id", - "product", "product_id", } @@ -326,26 +312,6 @@ func checkImmutableChanged(d *schema.ResourceData) diag.Diagnostics { return diags } -func getContractIDAndGroupID(d *schema.ResourceData) (contractID, groupID string) { - // Schema guarantees contract_id/contract are strings and one or the other is set - if got, ok := d.GetOk("contract_id"); ok { - contractID = got.(string) - } else { - contractID = d.Get("contract").(string) - } - contractID = tools.AddPrefix(contractID, "ctr_") - - // Schema guarantees group_id/group are strings and one or the other is set - if got, ok := d.GetOk("group_id"); ok { - groupID = got.(string) - } else { - groupID = d.Get("group").(string) - } - groupID = tools.AddPrefix(groupID, "grp_") - - return -} - func waitForCPCodeNameUpdate(ctx context.Context, client papi.PAPI, contractID, groupID, CPCodeID, updatedName string) error { req := papi.GetCPCodeRequest{CPCodeID: CPCodeID, ContractID: contractID, GroupID: groupID} CPCodeResp, err := client.GetCPCode(ctx, req) diff --git a/pkg/providers/property/resource_akamai_cp_code_test.go b/pkg/providers/property/resource_akamai_cp_code_test.go index 32f391509..041b858d6 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/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" @@ -154,51 +154,14 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestResCPCode/create_new_cp_code.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "group", "grp_1"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_1"), resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_1"), - ), - }}, - }) - }) - }) - - t.Run("create new CP Code with deprecated attributes", func(t *testing.T) { - client := &papi.Mock{} - defer client.AssertExpectations(t) - - // Contains CP Codes known to mock PAPI - CPCodes := []papi.CPCode{} - - // Values are from fixture: - expectGetCPCodes(client, "ctr_1", "grp_1", &CPCodes).Once() - expectCreateCPCode(client, "test cpcode", "prd_1", "ctr_1", "grp_1", &CPCodes) - expectGetCPCode(client, "ctr_1", "grp_1", 0, &CPCodes, nil).Times(2) - - // No mock behavior for delete because there is no delete operation for CP Codes - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestResCPCode/create_new_cp_code_deprecated_attrs.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "group", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_1"), resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_1"), ), }}, @@ -226,17 +189,14 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestResCPCode/use_existing_cp_code.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "group", "grp_test"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_test"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_test"), resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_test"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_test"), resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_test"), ), }}, @@ -265,17 +225,14 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestResCPCode/use_existing_cp_code.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "1"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "group", "grp_test"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_test"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_test"), resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_test"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_test"), resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_test"), ), }}, @@ -304,7 +261,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestResCPCode/use_existing_cp_code.tf"), ExpectError: regexp.MustCompile("Couldn't find product id on the CP Code"), @@ -335,7 +292,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/change_name_step0.tf"), @@ -365,7 +322,7 @@ func TestResCPCode(t *testing.T) { expectGetCPCode(client, "ctr_1", "grp_2", 0, &CPCodes, nil).Times(4) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/import_cp_code.tf"), @@ -378,11 +335,8 @@ func TestResCPCode(t *testing.T) { assert.Len(t, s, 1) rs := s[0] assert.Equal(t, "grp_2", rs.Attributes["group_id"]) - assert.Equal(t, "grp_2", rs.Attributes["group"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) - assert.Equal(t, "ctr_1", rs.Attributes["contract"]) assert.Equal(t, "prd_Web_Accel", rs.Attributes["product_id"]) - assert.Equal(t, "prd_Web_Accel", rs.Attributes["product"]) assert.Equal(t, "0", rs.Attributes["id"]) assert.Equal(t, "test cpcode", rs.Attributes["name"]) return nil @@ -401,7 +355,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/import_cp_code.tf"), @@ -422,7 +376,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/import_cp_code.tf"), @@ -453,7 +407,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/change_name_step0.tf"), @@ -461,30 +415,30 @@ func TestResCPCode(t *testing.T) { resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_1"), ), }, { Config: loadFixtureString("testdata/TestResCPCode/change_immutable.tf"), - ExpectError: regexp.MustCompile(`cp code attribute 'contract' cannot be changed after creation \(immutable\)`), + ExpectError: regexp.MustCompile(`cp code attribute 'contract_id' cannot be changed after creation \(immutable\)`), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_1"), ), }, { Config: loadFixtureString("testdata/TestResCPCode/change_immutable.tf"), - ExpectError: regexp.MustCompile(`cp code attribute 'product' cannot be changed after creation \(immutable\)`), + ExpectError: regexp.MustCompile(`cp code attribute 'product_id' cannot be changed after creation \(immutable\)`), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_1"), ), }, { @@ -494,8 +448,8 @@ func TestResCPCode(t *testing.T) { resource.TestCheckResourceAttr("akamai_cp_code.test", "id", "0"), resource.TestCheckResourceAttr("akamai_cp_code.test", "name", "test cpcode"), resource.TestCheckResourceAttr("akamai_cp_code.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "contract", "ctr_1"), - resource.TestCheckResourceAttr("akamai_cp_code.test", "product", "prd_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "contract_id", "ctr_1"), + resource.TestCheckResourceAttr("akamai_cp_code.test", "product_id", "prd_1"), ), }, }, @@ -521,7 +475,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/change_name_step0.tf"), @@ -558,7 +512,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/change_name_step0.tf"), @@ -608,7 +562,7 @@ func TestResCPCode(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/change_name_step0.tf"), @@ -627,10 +581,10 @@ func TestResCPCode(t *testing.T) { }) t.Run("error when no product and product_id provided", func(t *testing.T) { - expectedErr := regexp.MustCompile("one of `product,product_id` must be specified") + expectedErr := regexp.MustCompile("`product_id` must be specified for creation") resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResCPCode/missing_product.tf"), diff --git a/pkg/providers/property/resource_akamai_edge_hostname.go b/pkg/providers/property/resource_akamai_edge_hostname.go index 3c09902ef..d041b8822 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname.go +++ b/pkg/providers/property/resource_akamai_edge_hostname.go @@ -7,14 +7,16 @@ import ( "fmt" "strings" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" ) func resourceSecureEdgeHostName() *schema.Resource { @@ -31,47 +33,21 @@ func resourceSecureEdgeHostName() *schema.Resource { } var akamaiSecureEdgeHostNameSchema = map[string]*schema.Schema{ - "product": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("product"), - ConflictsWith: []string{"product_id"}, - StateFunc: addPrefixToState("prd_"), - }, "product_id": { Type: schema.TypeString, Optional: true, Computed: true, StateFunc: addPrefixToState("prd_"), }, - "contract": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("contract"), - StateFunc: addPrefixToState("ctr_"), - }, "contract_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract_id", "contract"}, - StateFunc: addPrefixToState("ctr_"), - }, - "group": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("group"), - StateFunc: addPrefixToState("grp_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("ctr_"), }, "group_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"group_id", "group"}, - StateFunc: addPrefixToState("grp_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("grp_"), }, "edge_hostname": { Type: schema.TypeString, @@ -106,59 +82,41 @@ var akamaiSecureEdgeHostNameSchema = map[string]*schema.Schema{ } func resourceSecureEdgeHostNameCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceSecureEdgeHostNameCreate") - client := inst.Client(meta) + client := Client(meta) - // Schema guarantees group_id/group are strings and one or the other is set - var groupID string - if got, ok := d.GetOk("group_id"); ok { - groupID = got.(string) - } else { - groupID = d.Get("group").(string) + groupID, err := tf.GetStringValue("group_id", d) + if err != nil { + return diag.FromErr(err) } groupID = tools.AddPrefix(groupID, "grp_") - // set group/groupID into ResourceData if err := d.Set("group_id", groupID); err != nil { return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) } - if err := d.Set("group", groupID); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) - } - // Schema guarantees contract_id/contract are strings and one or the other is set - var contractID string - if got, ok := d.GetOk("contract_id"); ok { - contractID = got.(string) - } else { - contractID = d.Get("contract").(string) + contractID, err := tf.GetStringValue("contract_id", d) + if err != nil { + return diag.FromErr(err) } contractID = tools.AddPrefix(contractID, "ctr_") - // set contract/contract_id into ResourceData if err := d.Set("contract_id", contractID); err != nil { return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) } - if err := d.Set("contract", contractID); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) - } logger.Debugf("Edgehostnames GROUP = %v", groupID) logger.Debugf("Edgehostnames CONTRACT = %v", contractID) - // Schema no longer guarantees that product_id/product are set, one of them is required only for creation - productID, err := tf.ResolveKeyStringState(d, "product_id", "product") + // Schema no longer guarantees that product_id is set, this field is required only for creation + productID, err := tf.GetStringValue("product_id", d) if err != nil { - return diag.Errorf("one of `%s` must be specified for creation", strings.Join([]string{"product_id", "product"}, ", ")) + return diag.Errorf("`product_id` must be specified for creation") } productID = tools.AddPrefix(productID, "prd_") - // set product/product_id into ResourceData if err := d.Set("product_id", productID); err != nil { return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) } - if err := d.Set("product", productID); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) - } edgeHostnames, err := client.GetEdgeHostnames(ctx, papi.GetEdgeHostnamesRequest{ ContractID: contractID, @@ -231,58 +189,39 @@ func resourceSecureEdgeHostNameCreate(ctx context.Context, d *schema.ResourceDat } func resourceSecureEdgeHostNameRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceSecureEdgeHostNameRead") - client := inst.Client(meta) + client := Client(meta) - // Schema guarantees group_id/group are strings and one or the other is set - var groupID string - if got, ok := d.GetOk("group_id"); ok { - groupID = got.(string) - } else { - groupID = d.Get("group").(string) + groupID, err := tf.GetStringValue("group_id", d) + if err != nil { + return diag.FromErr(err) } groupID = tools.AddPrefix(groupID, "grp_") - // set group/groupID into ResourceData if err := d.Set("group_id", groupID); err != nil { return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) } - if err := d.Set("group", groupID); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) - } - // Schema guarantees contract_id/contract are strings and one or the other is set - var contractID string - if got, ok := d.GetOk("contract_id"); ok { - contractID = got.(string) - } else { - contractID = d.Get("contract").(string) + contractID, err := tf.GetStringValue("contract_id", d) + if err != nil { + return diag.FromErr(err) } contractID = tools.AddPrefix(contractID, "ctr_") // set contract/contract_id into ResourceData if err := d.Set("contract_id", contractID); err != nil { return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) } - if err := d.Set("contract", contractID); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) - } // Schema guarantees product_id/product are strings and one or the other is set var productID string if got, ok := d.GetOk("product_id"); ok { productID = got.(string) - } else { - productID = d.Get("product").(string) } productID = tools.AddPrefix(productID, "prd_") - // set product/product_id into ResourceData if err := d.Set("product_id", productID); err != nil { return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) } - if err := d.Set("product", productID); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error())) - } logger.Debugf("Edgehostnames GROUP = %v", groupID) logger.Debugf("Edgehostnames CONTRACT = %v", contractID) @@ -322,7 +261,7 @@ func resourceSecureEdgeHostNameRead(ctx context.Context, d *schema.ResourceData, } func resourceSecureEdgeHostNameUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceSecureEdgeHostNameUpdate") if d.HasChange("ip_behavior") { @@ -353,7 +292,7 @@ func resourceSecureEdgeHostNameUpdate(ctx context.Context, d *schema.ResourceDat ipBehavior = "IPV6_IPV4_DUALSTACK" } - if _, err = inst.HapiClient(meta).UpdateEdgeHostname(ctx, hapi.UpdateEdgeHostnameRequest{ + if _, err = HapiClient(meta).UpdateEdgeHostname(ctx, hapi.UpdateEdgeHostnameRequest{ DNSZone: dnsZone, RecordName: strings.ReplaceAll(edgeHostname, "."+dnsZone, ""), Comments: fmt.Sprintf("change /ipVersionBehavior to %s", ipBehavior), @@ -381,7 +320,7 @@ Failed to restore previous local schema values. The schema will remain in tainte } func resourceSecureEdgeHostNameDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourceSecureEdgeHostNameDelete") logger.Debug("DELETING") logger.Info("PAPI does not support edge hostname deletion - resource will only be removed from state") @@ -391,8 +330,8 @@ func resourceSecureEdgeHostNameDelete(_ context.Context, d *schema.ResourceData, } func resourceSecureEdgeHostNameImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) - client := inst.Client(meta) + meta := meta.Must(m) + client := Client(meta) parts := strings.Split(d.Id(), ",") if len(parts) < 3 { @@ -412,15 +351,9 @@ func resourceSecureEdgeHostNameImport(ctx context.Context, d *schema.ResourceDat return nil, err } - if err := d.Set("contract", edgehostnameDetails.ContractID); err != nil { - return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } if err := d.Set("contract_id", edgehostnameDetails.ContractID); err != nil { return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) } - if err := d.Set("group", edgehostnameDetails.GroupID); err != nil { - return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) - } if err := d.Set("group_id", edgehostnameDetails.GroupID); err != nil { return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) } @@ -458,7 +391,7 @@ func diffSuppressEdgeHostname(_, oldVal, newVal string, _ *schema.ResourceData) } func suppressEdgeHostnameUseCases(_, oldVal, newVal string, _ *schema.ResourceData) bool { - logger := akamai.Log("PAPI", "suppressEdgeHostnameUseCases") + logger := logger.Get("PAPI", "suppressEdgeHostnameUseCases") if oldVal == newVal { return true } diff --git a/pkg/providers/property/resource_akamai_edge_hostname_test.go b/pkg/providers/property/resource_akamai_edge_hostname_test.go index 59299f039..8ca93fbdf 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname_test.go +++ b/pkg/providers/property/resource_akamai_edge_hostname_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" ) func TestResourceEdgeHostname(t *testing.T) { @@ -103,8 +103,8 @@ func TestResourceEdgeHostname(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV6_COMPLIANCE"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test2.edgesuite.net"), resource.TestCheckOutput("edge_hostname", "test2.edgesuite.net"), ), @@ -188,8 +188,8 @@ func TestResourceEdgeHostname(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV6_PERFORMANCE"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.edgekey.net"), resource.TestCheckOutput("edge_hostname", "test.edgekey.net"), ), @@ -271,8 +271,8 @@ func TestResourceEdgeHostname(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV6_COMPLIANCE"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), ), }, @@ -367,8 +367,8 @@ func TestResourceEdgeHostname(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV4"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.aka.edgesuite.net"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "use_cases", loadFixtureString(fmt.Sprintf("%s/use_cases/use_cases_new.json", testDir))), resource.TestCheckOutput("edge_hostname", "test.aka.edgesuite.net"), @@ -407,8 +407,8 @@ func TestResourceEdgeHostname(t *testing.T) { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_net.tf")), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), ), }, @@ -514,8 +514,8 @@ func TestResourceEdgeHostname(t *testing.T) { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_ipv4.tf")), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV4"), ), @@ -524,8 +524,8 @@ func TestResourceEdgeHostname(t *testing.T) { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_update_ip_behavior.tf")), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV6_COMPLIANCE"), ), @@ -605,8 +605,8 @@ func TestResourceEdgeHostname(t *testing.T) { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_ipv4.tf")), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV4"), ), @@ -676,8 +676,8 @@ func TestResourceEdgeHostname(t *testing.T) { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_ipv4.tf")), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV4"), ), @@ -747,8 +747,8 @@ func TestResourceEdgeHostname(t *testing.T) { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_ipv4.tf")), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract_id", "ctr_2"), + resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group_id", "grp_2"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV4"), ), @@ -877,159 +877,12 @@ func TestResourceEdgeHostname(t *testing.T) { }, }, }, - "create edge hostname - whether edgehostnames are the same, created with usage product and product_id configs": { - init: func(mp *papi.Mock, mh *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: "eh_123", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test2", - DomainSuffix: "akamaized.net", - }, - { - ID: "eh_2", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test3", - DomainSuffix: "akamaized.net", - }, - }}, - }, 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: "eh_123", - }, 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: "eh_123", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test2", - DomainSuffix: "akamaized.net", - }, - { - ID: "eh_2", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test3", - DomainSuffix: "akamaized.net", - }, - { - ID: "eh_123", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test", - DomainSuffix: "akamaized.net", - }, - }}, - }, nil) - // second step - 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: "eh_123", - }, 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: "eh_123", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test2", - DomainSuffix: "akamaized.net", - }, - { - ID: "eh_2", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test3", - DomainSuffix: "akamaized.net", - }, - { - ID: "eh_123", - Domain: "test.akamaized.net", - ProductID: "prd_2", - DomainPrefix: "test", - DomainSuffix: "akamaized.net", - }, - }}, - }, nil) - }, - steps: []resource.TestStep{ - { - Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_net.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "product", "prd_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV6_COMPLIANCE"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), - ), - }, - { - Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_net_with_product_id.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "id", "eh_123"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "product_id", "prd_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "ip_behavior", "IPV6_COMPLIANCE"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "contract", "ctr_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "group", "grp_2"), - resource.TestCheckResourceAttr("akamai_edge_hostname.edgehostname", "edge_hostname", "test.akamaized.net"), - ), - }, - }, - }, "error on empty product id for creation": { init: func(mp *papi.Mock, mh *hapi.Mock) {}, steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_net_without_product_id.tf")), - ExpectError: regexp.MustCompile("one of `product_id, product` must be specified for creation"), - }, - }, - }, - "error both product id and product defined in config": { - init: func(mp *papi.Mock, mh *hapi.Mock) {}, - steps: []resource.TestStep{ - { - Config: loadFixtureString(fmt.Sprintf("%s/%s", testDir, "new_akamaized_net_with_both_product_and_product_id.tf")), - ExpectError: regexp.MustCompile("\"product\": conflicts with product_id"), + ExpectError: regexp.MustCompile("`product_id` must be specified for creation"), }, }, }, @@ -1042,8 +895,8 @@ func TestResourceEdgeHostname(t *testing.T) { test.init(client, clientHapi) useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: test.steps, + ProtoV5ProviderFactories: testAccProviders, + Steps: test.steps, }) }) client.AssertExpectations(t) @@ -1124,7 +977,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { expectGetEdgeHostnames(client, "ctr_1", "grp_2") useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { // please note that import does not support product id, that why we only define it in config for creation @@ -1144,7 +997,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { ImportStateId: id, ResourceName: "akamai_edge_hostname.importedgehostname", ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"ip_behavior", "product", "product_id"}, + ImportStateVerifyIgnore: []string{"ip_behavior", "product_id"}, }, }, }) diff --git a/pkg/providers/property/resource_akamai_property.go b/pkg/providers/property/resource_akamai_property.go index a46df4d40..25725b933 100644 --- a/pkg/providers/property/resource_akamai_property.go +++ b/pkg/providers/property/resource_akamai_property.go @@ -16,11 +16,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) func resourceProperty() *schema.Resource { @@ -96,54 +96,24 @@ func resourceProperty() *schema.Resource { ValidateDiagFunc: validatePropertyName, Description: "Name to give to the Property (must be unique)", }, - "group_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"group_id", "group"}, - StateFunc: addPrefixToState("grp_"), - Description: "Group ID to be assigned to the Property", - }, - "group": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("group"), - StateFunc: addPrefixToState("grp_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("grp_"), + Description: "Group ID to be assigned to the Property", }, - "contract_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"contract_id", "contract"}, - StateFunc: addPrefixToState("ctr_"), - Description: "Contract ID to be assigned to the Property", - }, - "contract": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("contract"), - StateFunc: addPrefixToState("ctr_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("ctr_"), + Description: "Contract ID to be assigned to the Property", }, - "product_id": { Type: schema.TypeString, - Optional: true, - Computed: true, + Required: true, Description: "Product ID to be assigned to the Property", StateFunc: addPrefixToState("prd_"), }, - "product": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ExactlyOneOf: []string{"product_id"}, - Deprecated: akamai.NoticeDeprecatedUseAlias("product"), - StateFunc: addPrefixToState("prd_"), - }, // Optional "rule_format": { @@ -249,51 +219,6 @@ func resourceProperty() *schema.Resource { Computed: true, Elem: papiError(), }, - "rule_warnings": { - Type: schema.TypeList, - Optional: true, - Computed: true, - Elem: papiError(), - Deprecated: "Rule warnings will not be set in state anymore", - }, - - // Hard-deprecated attributes: These are effectively removed, but we wanted to refer users to the upgrade guide - "cp_code": { - Type: schema.TypeString, - Optional: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("cp_code"), - }, - "contact": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Deprecated: akamai.NoticeDeprecatedUseAlias("contact"), - }, - "origin": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "hostname": {Type: schema.TypeString, Optional: true}, - "port": {Type: schema.TypeInt, Optional: true}, - "forward_hostname": {Type: schema.TypeString, Optional: true}, - "cache_key_hostname": {Type: schema.TypeString, Optional: true}, - "compress": {Type: schema.TypeBool, Optional: true}, - "enable_true_client_ip": {Type: schema.TypeBool, Optional: true}, - }, - }, - Deprecated: akamai.NoticeDeprecatedUseAlias("origin"), - }, - "is_secure": { - Type: schema.TypeBool, - Optional: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("is_secure"), - }, - "variables": { - Type: schema.TypeString, - Optional: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("variables"), - }, }, } } @@ -390,7 +315,7 @@ func compareFields(old, new *papi.RulesUpdate) (string, error) { } func hostNamesCustomDiff(_ context.Context, d *schema.ResourceDiff, m interface{}) error { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "hostNamesCustomDiff") o, n := d.GetChange("hostnames") @@ -442,36 +367,29 @@ func setPropertyVersionsComputedOnRulesChange(_ context.Context, rd *schema.Reso } func resourcePropertyCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyCreate") - client := inst.Client(meta) + client := Client(meta) ctx = log.NewContext(ctx, logger) - // Block creation if user has set any hard-deprecated attributes - for _, attr := range resPropForbiddenAttrs() { - if _, ok := d.GetOk(attr); ok { - return diag.Errorf("unsupported attribute: %q See the Akamai Terraform Upgrade Guide", attr) - } - } - // Schema guarantees these types propertyName := d.Get("name").(string) - groupID, err := tf.ResolveKeyStringState(d, "group_id", "group") + groupID, err := tf.GetStringValue("group_id", d) if err != nil { return diag.FromErr(err) } groupID = tools.AddPrefix(groupID, "grp_") - contractID := d.Get("contract_id").(string) - if contractID == "" { - contractID = d.Get("contract").(string) + contractID, err := tf.GetStringValue("contract_id", d) + if err != nil { + return diag.FromErr(err) } contractID = tools.AddPrefix(contractID, "ctr_") - productID := d.Get("product_id").(string) - if productID == "" { - productID = d.Get("product").(string) + productID, err := tf.GetStringValue("product_id", d) + if err != nil { + return diag.FromErr(err) } productID = tools.AddPrefix(productID, "prd_") @@ -512,7 +430,6 @@ func resourcePropertyCreate(ctx context.Context, d *schema.ResourceData, m inter "group_id": groupID, "contract_id": contractID, "product_id": productID, - "product": productID, } if err := rdSetAttrs(ctx, d, attrs); err != nil { return diag.FromErr(err) @@ -564,9 +481,9 @@ func resourcePropertyCreate(ctx context.Context, d *schema.ResourceData, m inter } func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - ctx = log.NewContext(ctx, akamai.Meta(m).Log("PAPI", "resourcePropertyRead")) + ctx = log.NewContext(ctx, meta.Must(m).Log("PAPI", "resourcePropertyRead")) logger := log.FromContext(ctx) - client := inst.Client(akamai.Meta(m)) + client := Client(meta.Must(m)) // Schema guarantees group_id, and contract_id are strings propertyID := d.Id() @@ -643,9 +560,7 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa attrs := map[string]interface{}{ "name": property.PropertyName, "group_id": property.GroupID, - "group": property.GroupID, "contract_id": property.ContractID, - "contract": property.ContractID, "latest_version": property.LatestVersion, "staging_version": stagingVersion, "production_version": productionVersion, @@ -657,7 +572,6 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa } if property.ProductID != "" { attrs["product_id"] = property.ProductID - attrs["product"] = property.ProductID } if err := rdSetAttrs(ctx, d, attrs); err != nil { return diag.FromErr(err) @@ -667,27 +581,16 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa } func resourcePropertyUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - ctx = log.NewContext(ctx, akamai.Meta(m).Log("PAPI", "resourcePropertyUpdate")) + ctx = log.NewContext(ctx, meta.Must(m).Log("PAPI", "resourcePropertyUpdate")) logger := log.FromContext(ctx) - client := inst.Client(akamai.Meta(m)) - - // Block changes to hard-deprecated attributes - for _, attr := range resPropForbiddenAttrs() { - if _, ok := d.GetOk(attr); ok && d.HasChange(attr) { - d.Partial(true) - return diag.Errorf("unsupported attribute: %q See the Akamai Terraform Upgrade Guide", attr) - } - } + client := Client(meta.Must(m)) diags := diag.Diagnostics{} immutable := []string{ "group_id", - "group", "contract_id", - "contract", "product_id", - "product", } for _, attr := range immutable { if d.HasChange(attr) { @@ -748,11 +651,6 @@ func resourcePropertyUpdate(ctx context.Context, d *schema.ResourceData, m inter return diag.FromErr(err) } - hostnames, err := validateHostnames(ctx, d, client, contractID, groupID) - if err != nil { - return diag.FromErr(err) - } - // if read_version is not the latest version or not editable then create a new version from it before proceeding if (propertyVersion != property.LatestVersion) || (resp.Version.ProductionStatus != papi.VersionStatusInactive || resp.Version.StagingStatus != papi.VersionStatusInactive) { // The latest version has been activated on either production or staging, so we need to create a new version to apply changes on @@ -769,7 +667,9 @@ func resourcePropertyUpdate(ctx context.Context, d *schema.ResourceData, m inter // hostnames if d.HasChange("hostnames") { + hostnamesVal, err := tf.GetSetValue("hostnames", d) if err == nil { + hostnames := mapToHostnames(hostnamesVal.List()) if len(hostnames) > 0 { if err := updatePropertyHostnames(ctx, client, property, hostnames); err != nil { d.Partial(true) @@ -794,8 +694,8 @@ func resourcePropertyUpdate(ctx context.Context, d *schema.ResourceData, m inter } func resourcePropertyDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - ctx = log.NewContext(ctx, akamai.Meta(m).Log("PAPI", "resourcePropertyDelete")) - client := inst.Client(akamai.Meta(m)) + ctx = log.NewContext(ctx, meta.Must(m).Log("PAPI", "resourcePropertyDelete")) + client := Client(meta.Must(m)) propertyID := d.Id() contractID := tools.AddPrefix(d.Get("contract_id").(string), "ctr_") @@ -809,7 +709,7 @@ func resourcePropertyDelete(ctx context.Context, d *schema.ResourceData, m inter } func resourcePropertyImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - ctx = log.NewContext(ctx, akamai.Meta(m).Log("PAPI", "resourcePropertyImport")) + ctx = log.NewContext(ctx, meta.Must(m).Log("PAPI", "resourcePropertyImport")) // User-supplied import ID is a comma-separated list of propertyID[,groupID[,contractID]] // contractID and groupID are optional as long as the propertyID is sufficient to fetch the property @@ -849,7 +749,7 @@ func resourcePropertyImport(ctx context.Context, d *schema.ResourceData, m inter return nil, ErrPropertyVersionNotFound } // if we ran validation and we actually have a network name, we still need to fetch the desired version number - _, attrs["read_version"], err = fetchProperty(ctx, inst.Client(akamai.Meta(m)), propertyID, groupID, contractID, version) + _, attrs["read_version"], err = fetchProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID, version) if err != nil { return nil, err } @@ -870,9 +770,9 @@ func resourcePropertyImport(ctx context.Context, d *schema.ResourceData, m inter var property *papi.Property var v int if !isDefaultVersion(version) { - property, v, err = fetchProperty(ctx, inst.Client(akamai.Meta(m)), propertyID, groupID, contractID, version) + property, v, err = fetchProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID, version) } else { - property, err = fetchLatestProperty(ctx, inst.Client(akamai.Meta(m)), propertyID, groupID, contractID) + property, err = fetchLatestProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID) } if err != nil { return nil, err @@ -909,16 +809,6 @@ func parseVersionNumber(version string) (int, error) { return versionNumber, err } -func resPropForbiddenAttrs() []string { - return []string{ - "cp_code", - "contact", - "origin", - "is_secure", - "variables", - } -} - func createProperty(ctx context.Context, client papi.PAPI, propertyName, groupID, contractID, productID, ruleFormat string) (propertyID string, err error) { req := papi.CreatePropertyRequest{ ContractID: contractID, @@ -1329,51 +1219,6 @@ func rdSetAttrs(ctx context.Context, d *schema.ResourceData, AttributeValues map return nil } -func contains(edgeHostnames *papi.GetEdgeHostnamesResponse, hostname papi.Hostname) bool { - for _, v := range edgeHostnames.EdgeHostnames.Items { - if hostname.CnameFrom == v.DomainPrefix { - return true - } - } - return false -} - -func checkHostnames(hostnames []papi.Hostname, edgeHostnames *papi.GetEdgeHostnamesResponse) error { - invalidHostnames := make([]string, 0) - for _, v := range hostnames { - if !contains(edgeHostnames, v) { - invalidHostnames = append(invalidHostnames, v.CnameFrom) - } - } - if len(invalidHostnames) > 0 { - return fmt.Errorf("hostnames with 'cname_from' containing %s do not exist under this account, you need to remove or replace invalid hostnames entries in your configuration to proceed with property version update", invalidHostnames) - } - return nil -} - -func validateHostnames(ctx context.Context, d *schema.ResourceData, client papi.PAPI, contractID, groupID string) ([]papi.Hostname, error) { - hostnames := make([]papi.Hostname, 0) - if d.HasChange("hostnames") { - hostnameVal, err := tf.GetSetValue("hostnames", d) - if err != nil { - return nil, err - } - edgeHostnames, err := client.GetEdgeHostnames(ctx, papi.GetEdgeHostnamesRequest{ - ContractID: contractID, - GroupID: groupID, - }) - if err != nil { - return nil, err - } - - hostnames = mapToHostnames(hostnameVal.List()) - if err := checkHostnames(hostnames, edgeHostnames); err != nil { - return nil, err - } - } - return hostnames, nil -} - func needsUpdate(ctx context.Context, d *schema.ResourceData, formatNeedsUpdate, rulesNeedUpdate bool, rulesJSON []byte, ruleFormat string, client papi.PAPI, property papi.Property) error { if formatNeedsUpdate || rulesNeedUpdate { var Rules papi.RulesUpdate diff --git a/pkg/providers/property/resource_akamai_property_activation.go b/pkg/providers/property/resource_akamai_property_activation.go index 1961757f4..41bfa075e 100644 --- a/pkg/providers/property/resource_akamai_property_activation.go +++ b/pkg/providers/property/resource_akamai_property_activation.go @@ -9,11 +9,11 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -26,7 +26,10 @@ func resourcePropertyActivation() *schema.Resource { ReadContext: resourcePropertyActivationRead, UpdateContext: resourcePropertyActivationUpdate, DeleteContext: resourcePropertyActivationDelete, - Schema: akamaiPropertyActivationSchema, + Importer: &schema.ResourceImporter{ + StateContext: resourcePropertyActivationImport, + }, + Schema: akamaiPropertyActivationSchema, Timeouts: &schema.ResourceTimeout{ Default: &PropertyResourceTimeout, }, @@ -47,19 +50,10 @@ var ( ) var akamaiPropertyActivationSchema = map[string]*schema.Schema{ - "property": { - Type: schema.TypeString, - Optional: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("property"), - Computed: true, - StateFunc: addPrefixToState("prp_"), - }, "property_id": { - Type: schema.TypeString, - Optional: true, - ExactlyOneOf: []string{"property_id", "property"}, - Computed: true, - StateFunc: addPrefixToState("prp_"), + Type: schema.TypeString, + Required: true, + StateFunc: addPrefixToState("prp_"), }, "activation_id": { Type: schema.TypeString, @@ -80,18 +74,11 @@ var akamaiPropertyActivationSchema = map[string]*schema.Schema{ Computed: true, Elem: papiError(), }, - "rule_warnings": { - Type: schema.TypeList, - Optional: true, - Computed: true, - Elem: papiError(), - Deprecated: "Rule warnings will not be set in state anymore", - }, "auto_acknowledge_rule_warnings": { Type: schema.TypeBool, Optional: true, - Default: true, - Description: "automatically acknowledge all rule warnings for activation to continue. default is true", + Default: false, + Description: "Automatically acknowledge all rule warnings for activation to continue. Default is false", }, "version": { Type: schema.TypeInt, @@ -139,9 +126,9 @@ func papiError() *schema.Resource { } func resourcePropertyActivationCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyActivationCreate") - client := inst.Client(meta) + client := Client(meta) logger.Debug("resourcePropertyActivationCreate call") @@ -280,9 +267,9 @@ func resourcePropertyActivationCreate(ctx context.Context, d *schema.ResourceDat } func resourcePropertyActivationDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyActivationDelete") - client := inst.Client(meta) + client := Client(meta) logger.Debug("resourcePropertyActivationDelete call") @@ -428,9 +415,9 @@ func flattenErrorArray(errors []*papi.Error) string { } func resourcePropertyActivationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyActivationRead") - client := inst.Client(meta) + client := Client(meta) logger.Debug("resourcePropertyActivationRead call") // create a context with logging for api calls @@ -479,6 +466,8 @@ func resourcePropertyActivationRead(ctx context.Context, d *schema.ResourceData, "version": activation.PropertyVersion, "network": network, "activation_id": activation.ActivationID, + "note": activation.Note, + "contact": activation.NotifyEmails, } if err = tf.SetAttrs(d, attrs); err != nil { return diag.FromErr(err) @@ -535,9 +524,9 @@ func resolveVersion(ctx context.Context, d *schema.ResourceData, client papi.PAP } func resourcePropertyActivationUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyActivationUpdate") - client := inst.Client(meta) + client := Client(meta) logger.Debug("resourcePropertyActivationUpdate call") // create a context with logging for api calls @@ -685,6 +674,29 @@ func resourcePropertyActivationUpdate(ctx context.Context, d *schema.ResourceDat return nil } +func resourcePropertyActivationImport(_ context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + meta := meta.Must(m) + logger := meta.Log("PAPI", "resourcePropertyActivationImport") + + logger.Debug("Importing property activation") + + parts := strings.Split(d.Id(), ":") + if len(parts) != 2 { + return nil, fmt.Errorf("invalid property activation identifier: %s", d.Id()) + } + + attrs := make(map[string]interface{}, 3) + attrs["property_id"] = parts[0] + attrs["network"] = parts[1] + attrs["auto_acknowledge_rule_warnings"] = false + + if err := tf.SetAttrs(d, attrs); err != nil { + return nil, err + } + + return []*schema.ResourceData{d}, nil +} + func addPropertyComplianceRecord(complianceRecord []interface{}, activatePAPIRequest papi.CreateActivationRequest) papi.CreateActivationRequest { if len(complianceRecord) == 0 { return activatePAPIRequest @@ -788,10 +800,6 @@ func setErrorsAndWarnings(d *schema.ResourceData, errors, warnings string) error func resolvePropertyID(d *schema.ResourceData) (string, error) { propertyID, err := tf.GetStringValue("property_id", d) - if errors.Is(err, tf.ErrNotFound) { - // use legacy property as fallback option - propertyID, err = tf.GetStringValue("property", d) - } return tools.AddPrefix(propertyID, "prp_"), err } diff --git a/pkg/providers/property/resource_akamai_property_activation_test.go b/pkg/providers/property/resource_akamai_property_activation_test.go index b4f866e35..df5c8ba5f 100644 --- a/pkg/providers/property/resource_akamai_property_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/mock" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) @@ -23,28 +23,28 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", papi.GetActivationsResponse{}, nil).Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", - []string{"user@example.com"}, "property activation note for creating", "atv_activation1", nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, nil).Once() + []string{"user@example.com"}, "property activation note for creating", "atv_activation1", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for creating", []string{"user@example.com"}, nil).Once() // read - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // second step // read - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // update expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).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", nil).Once() - expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, nil).Once() + []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() // read expectGetActivations(m, "prp_test", activationsResponseSecondVersionIsActive, nil).Once() // delete expectGetActivations(m, "prp_test", activationsResponseSecondVersionIsActive, nil).Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 2, "STAGING", - []string{"user@example.com"}, "property activation note for updating", "atv_update", nil).Once() - expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, nil).Once() + []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.ActivationTypeDeactivate, "property activation note for updating", []string{"user@example.com"}, nil).Once() }, steps: []resource.TestStep{ { @@ -52,13 +52,15 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_property_activation.test", "id", "prp_test:STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "property_id", "prp_test"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.#", "1"), + resource.TestCheckResourceAttrSet("akamai_property_activation.test", "contact.0"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.0", "user@example.com"), resource.TestCheckResourceAttr("akamai_property_activation.test", "network", "STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), resource.TestCheckResourceAttr("akamai_property_activation.test", "warnings", ""), resource.TestCheckResourceAttr("akamai_property_activation.test", "errors", ""), resource.TestCheckNoResourceAttr("akamai_property_activation.test", "rule_errors"), resource.TestCheckResourceAttr("akamai_property_activation.test", "auto_acknowledge_rule_warnings", "true"), - resource.TestCheckNoResourceAttr("akamai_property_activation.test", "rule_warnings"), resource.TestCheckResourceAttr("akamai_property_activation.test", "activation_id", "atv_activation1"), resource.TestCheckResourceAttr("akamai_property_activation.test", "status", "ACTIVE"), resource.TestCheckResourceAttr("akamai_property_activation.test", "note", "property activation note for creating"), @@ -68,6 +70,9 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { Config: loadFixtureString("./testdata/TestPropertyActivation/ok/resource_property_activation_update.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_property_activation.test", "id", "prp_test:STAGING"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.#", "1"), + resource.TestCheckResourceAttrSet("akamai_property_activation.test", "contact.0"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.0", "user@example.com"), resource.TestCheckResourceAttr("akamai_property_activation.test", "property_id", "prp_test"), resource.TestCheckResourceAttr("akamai_property_activation.test", "network", "STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "2"), @@ -106,11 +111,11 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { ).Return(&papi.CreateActivationResponse{ ActivationID: "atv_activation1", }, nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for creating", []string{"user@example.com"}, nil).Once() // read - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // delete - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() m.On( "CreateActivation", mock.Anything, @@ -133,7 +138,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { ).Return(&papi.CreateActivationResponse{ ActivationID: "atv_activation1", }, nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "property activation note for creating", []string{"user@example.com"}, nil).Once() }, steps: []resource.TestStep{ { @@ -141,6 +146,9 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_property_activation.test", "id", "prp_test:STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "property_id", "prp_test"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.#", "1"), + resource.TestCheckResourceAttrSet("akamai_property_activation.test", "contact.0"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.0", "user@example.com"), resource.TestCheckResourceAttr("akamai_property_activation.test", "network", "STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), resource.TestCheckResourceAttr("akamai_property_activation.test", "auto_acknowledge_rule_warnings", "true"), @@ -160,15 +168,15 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", papi.GetActivationsResponse{}, nil).Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", - []string{"user@example.com"}, "property activation note for creating", "atv_activation1", nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, nil).Once() + []string{"user@example.com"}, "property activation note for creating", "atv_activation1", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for creating", []string{"user@example.com"}, nil).Once() // read - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // delete - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 1, "STAGING", - []string{"user@example.com"}, "property activation note for creating", "atv_update", nil).Once() - expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, nil).Once() + []string{"user@example.com"}, "property activation note for creating", "atv_update", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "property activation note for creating", []string{"user@example.com"}, nil).Once() }, steps: []resource.TestStep{ @@ -177,11 +185,13 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_property_activation.test", "id", "prp_test:STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "property_id", "prp_test"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.#", "1"), + resource.TestCheckResourceAttrSet("akamai_property_activation.test", "contact.0"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.0", "user@example.com"), resource.TestCheckResourceAttr("akamai_property_activation.test", "network", "STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), resource.TestCheckResourceAttr("akamai_property_activation.test", "auto_acknowledge_rule_warnings", "true"), resource.TestCheckResourceAttr("akamai_property_activation.test", "warnings", ""), - resource.TestCheckNoResourceAttr("akamai_property_activation.test", "rule_warnings"), resource.TestCheckResourceAttr("akamai_property_activation.test", "errors", ""), resource.TestCheckResourceAttr("akamai_property_activation.test", "activation_id", "atv_activation1"), resource.TestCheckResourceAttr("akamai_property_activation.test", "status", "ACTIVE"), @@ -190,29 +200,31 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { }, }, }, - "schema with `property` instead of `property_id` - OK": { + "schema with minimum attributes - OK": { init: func(m *papi.Mock) { // create expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", papi.GetActivationsResponse{}, nil).Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", - []string{"user@example.com"}, "", "atv_activation1", nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, nil).Once() + []string{"user@example.com"}, "", "atv_activation1", false, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "", []string{"user@example.com"}, nil).Once() // read - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // delete - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 1, "STAGING", - []string{"user@example.com"}, "", "atv_update", nil).Once() - expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, nil).Once() + []string{"user@example.com"}, "", "atv_update", false, nil).Once() + expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "", []string{"user@example.com"}, nil).Once() }, steps: []resource.TestStep{ { - Config: loadFixtureString("testdata/TestPropertyActivation/ok/resource_property_activation_deprecated_arg.tf"), + Config: loadFixtureString("testdata/TestPropertyActivation/ok/resource_property_activation_minimum_args.tf"), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_property_activation.test", "id", "prp_test:STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "property_id", "prp_test"), - resource.TestCheckResourceAttr("akamai_property_activation.test", "property", "prp_test"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.#", "1"), + resource.TestCheckResourceAttrSet("akamai_property_activation.test", "contact.0"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.0", "user@example.com"), resource.TestCheckResourceAttr("akamai_property_activation.test", "network", "STAGING"), resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), resource.TestCheckResourceAttr("akamai_property_activation.test", "warnings", ""), @@ -229,10 +241,10 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // create expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", papi.GetActivationsResponse{}, nil).Once() - expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_activation1", nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, 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 - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // second step // no changes in configuration, but it was deactivated in other source, for example on UI -> terraform cleans state and activate this version again @@ -241,14 +253,14 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // create expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", activationsResponseDeactivated, nil).Once() - expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_activation1", nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, 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 - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // delete - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() - expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_update", nil).Once() - expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), 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{ { @@ -293,7 +305,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { steps: []resource.TestStep{ { Config: loadFixtureString("./testdata/TestPropertyActivation/no_propertyId/resource_property_activation.tf"), - ExpectError: regexp.MustCompile("one of `property,property_id` must be specified"), + ExpectError: regexp.MustCompile("Missing required argument"), }, }, }, @@ -320,12 +332,12 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { init: func(m *papi.Mock) { // create expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // read twice - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Twice() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Twice() // update expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() ExpectGetPropertyVersion(m, "prp_test", "", "", 1, papi.VersionStatusActive, "").Once() // delete expectGetActivations(m, "prp_test", activationsResponseDeactivated, nil).Once() @@ -344,12 +356,12 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { init: func(m *papi.Mock) { // create expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // read twice - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Twice() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Twice() // update expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() ExpectGetPropertyVersion(m, "prp_test", "", "", 1, papi.VersionStatusActive, "").Once() // delete expectGetActivations(m, "prp_test", activationsResponseDeactivated, nil).Once() @@ -370,17 +382,17 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // create expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", papi.GetActivationsResponse{}, nil).Once() - expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_activation1", nil).Once() - expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, 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 - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // second step // read - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() // update expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() // error on update m.On("CreateActivation", AnyCTX, papi.CreateActivationRequest{ @@ -394,9 +406,9 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { }, }).Return(nil, fmt.Errorf("some 500 error")).Once() // delete - terraform clean up after error is occurred - expectGetActivations(m, "prp_test", activationsResponseActivated, nil).Once() - expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 2, "STAGING", []string{"user@example.com"}, "", "atv_update", nil).Once() - expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, nil).Once() + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 2, "STAGING", []string{"user@example.com"}, "", "atv_update", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "", []string{"user@example.com"}, nil).Once() }, steps: []resource.TestStep{ @@ -411,6 +423,52 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { }, }, }, + "property activation import": { + init: func(m *papi.Mock) { + // create + expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() + expectGetActivations(m, "prp_test", papi.GetActivationsResponse{}, nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", + []string{"user@example.com"}, "property activation note for importing", "atv_activation1", false, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for importing", []string{"user@example.com"}, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for importing", []string{"user@example.com"}, nil).Once() + // read + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for importing", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() + // 2nd read for import + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for importing", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() + // delete + expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for importing", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z"), nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 1, "STAGING", + []string{"user@example.com"}, "property activation note for importing", "atv_activation1", false, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: loadFixtureString("./testdata/TestPropertyActivation/import/resource_property_activation_creation_for_import.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_activation.test", "id", "prp_test:STAGING"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "property_id", "prp_test"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.#", "1"), + resource.TestCheckResourceAttrSet("akamai_property_activation.test", "contact.0"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "contact.0", "user@example.com"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "network", "STAGING"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "auto_acknowledge_rule_warnings", "false"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "warnings", ""), + resource.TestCheckNoResourceAttr("akamai_property_activation.test", "rule_warnings"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "errors", ""), + resource.TestCheckResourceAttr("akamai_property_activation.test", "activation_id", "atv_activation1"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "status", "ACTIVE"), + resource.TestCheckResourceAttr("akamai_property_activation.test", "note", "property activation note for importing"), + ), + }, + { + ImportState: true, + ImportStateId: "prp_test:STAGING", + ResourceName: "akamai_property_activation.test", + ImportStateVerify: true, + }, + }, + }, } for name, test := range tests { @@ -421,9 +479,9 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { } useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: test.steps, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, + Steps: test.steps, }) }) client.AssertExpectations(t) @@ -431,8 +489,38 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { } } +func generateActivationResponseMock(activationID string, note string, version int, activationType papi.ActivationType, date string) papi.GetActivationsResponse { + return papi.GetActivationsResponse{ + Activations: papi.ActivationsItems{Items: append([]*papi.Activation{}, generateActivationItemMock(activationID, note, version, activationType, date))}, + } +} + +func generateActivationItemMock(activationID string, note string, version int, activationType papi.ActivationType, date string) *papi.Activation { + return &papi.Activation{ + AccountID: "act_1-6JHGX", + ActivationID: activationID, + ActivationType: activationType, + GroupID: "grp_91533", + PropertyName: "test", + PropertyID: "prp_test", + PropertyVersion: version, + Network: "STAGING", + Status: "ACTIVE", + SubmitDate: date, + UpdateDate: date, + NotifyEmails: []string{"user@example.com"}, + Note: note, + } +} + var ( - ruleTreeResponseValid = papi.GetRuleTreeResponse{ + mockActivationsListForDeactivation = append([]*papi.Activation{}, mockDeactivation, mockActivationCreation) + mockActivationsListForLifecycle = append([]*papi.Activation{}, mockDeactivationForLifecycle, mockActivationUpdate) + mockDeactivation = generateActivationItemMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeDeactivate, "2020-10-28T15:04:05Z") + mockDeactivationForLifecycle = generateActivationItemMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeDeactivate, "2020-10-28T14:04:05Z") + mockActivationCreation = generateActivationItemMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z") + mockActivationUpdate = generateActivationItemMock("atv_update", "property activation note for updating", 2, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z") + ruleTreeResponseValid = papi.GetRuleTreeResponse{ Response: papi.Response{ Errors: make([]*papi.Error, 0), Warnings: []*papi.Error{{Title: "some warning"}}, @@ -462,80 +550,11 @@ var ( ).Return(&response, nil) } - activationsResponseActivated = papi.GetActivationsResponse{ - Activations: papi.ActivationsItems{Items: []*papi.Activation{{ - AccountID: "act_1-6JHGX", - ActivationID: "atv_activation1", - ActivationType: "ACTIVATE", - GroupID: "grp_91533", - PropertyName: "test", - PropertyID: "prp_test", - PropertyVersion: 1, - Network: "STAGING", - Status: "ACTIVE", - SubmitDate: "2020-10-28T15:04:05Z", - UpdateDate: "2020-10-28T15:04:05Z", - }}}, - } activationsResponseDeactivated = papi.GetActivationsResponse{ - Activations: papi.ActivationsItems{Items: []*papi.Activation{ - { - AccountID: "act_1-6JHGX", - ActivationID: "atv_activation1", - ActivationType: "DEACTIVATE", - GroupID: "grp_91533", - PropertyName: "test", - PropertyID: "prp_test", - PropertyVersion: 1, - Network: "STAGING", - Status: "ACTIVE", - SubmitDate: "2020-10-28T15:04:05Z", - UpdateDate: "2020-10-28T15:04:05Z", - }, - { - AccountID: "act_1-6JHGX", - ActivationID: "atv_activation1", - ActivationType: "ACTIVATE", - GroupID: "grp_91533", - PropertyName: "test", - PropertyID: "prp_test", - PropertyVersion: 1, - Network: "STAGING", - Status: "ACTIVE", - SubmitDate: "2020-10-28T14:04:05Z", - UpdateDate: "2020-10-28T14:04:05Z", - }, - }}, + Activations: papi.ActivationsItems{Items: mockActivationsListForDeactivation}, } activationsResponseSecondVersionIsActive = papi.GetActivationsResponse{ - Activations: papi.ActivationsItems{Items: []*papi.Activation{ - { - AccountID: "act_1-6JHGX", - ActivationID: "atv_activation1", - ActivationType: "DEACTIVATE", - GroupID: "grp_91533", - PropertyName: "test", - PropertyID: "prp_test", - PropertyVersion: 1, - Network: "STAGING", - Status: "ACTIVE", - SubmitDate: "2020-10-28T14:04:05Z", - UpdateDate: "2020-10-28T14:04:05Z", - }, - { - AccountID: "act_1-6JHGX", - ActivationID: "atv_update", - ActivationType: "ACTIVATE", - GroupID: "grp_91533", - PropertyName: "test", - PropertyID: "prp_test", - PropertyVersion: 2, - Network: "STAGING", - Status: "ACTIVE", - SubmitDate: "2020-10-28T15:04:05Z", - UpdateDate: "2020-10-28T15:04:05Z", - }, - }}, + Activations: papi.ActivationsItems{Items: mockActivationsListForLifecycle}, } expectGetActivations = func(m *papi.Mock, propertyID string, response papi.GetActivationsResponse, err error) *mock.Call { if err != nil { @@ -553,7 +572,7 @@ var ( } expectCreateActivation = func(m *papi.Mock, propertyID string, activationType papi.ActivationType, version int, - network papi.ActivationNetwork, notify []string, note string, activationID string, err error) *mock.Call { + network papi.ActivationNetwork, notify []string, note string, activationID string, acknowledgeAllWarnings bool, err error) *mock.Call { if err != nil { return m.On( "CreateActivation", @@ -562,7 +581,7 @@ var ( PropertyID: propertyID, Activation: papi.Activation{ ActivationType: activationType, - AcknowledgeAllWarnings: true, + AcknowledgeAllWarnings: acknowledgeAllWarnings, PropertyVersion: version, Network: network, NotifyEmails: notify, @@ -578,7 +597,7 @@ var ( PropertyID: propertyID, Activation: papi.Activation{ ActivationType: activationType, - AcknowledgeAllWarnings: true, + AcknowledgeAllWarnings: acknowledgeAllWarnings, PropertyVersion: version, Network: network, NotifyEmails: notify, @@ -591,7 +610,7 @@ var ( } expectGetActivation = func(m *papi.Mock, propertyID string, activationID string, version int, - network papi.ActivationNetwork, status papi.ActivationStatus, actType papi.ActivationType, err error) *mock.Call { + network papi.ActivationNetwork, status papi.ActivationStatus, actType papi.ActivationType, note string, contact []string, err error) *mock.Call { if err != nil { return m.On( "GetActivation", @@ -618,6 +637,8 @@ var ( Network: network, Status: status, ActivationType: actType, + Note: note, + NotifyEmails: contact, }, }, 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 6062a53ea..eec524473 100644 --- a/pkg/providers/property/resource_akamai_property_activation_unit_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_unit_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/resource_akamai_property_common.go b/pkg/providers/property/resource_akamai_property_common.go index 919eb1c68..ddf9806fd 100644 --- a/pkg/providers/property/resource_akamai_property_common.go +++ b/pkg/providers/property/resource_akamai_property_common.go @@ -7,14 +7,14 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" ) -func getGroup(ctx context.Context, meta akamai.OperationMeta, groupID string) (*papi.Group, error) { +func getGroup(ctx context.Context, meta meta.Meta, groupID string) (*papi.Group, error) { logger := meta.Log("PAPI", "getGroup") - client := inst.Client(meta) + client := Client(meta) logger.Debugf("Fetching groups") res, err := client.GetGroups(ctx) if err != nil { @@ -38,9 +38,9 @@ func getGroup(ctx context.Context, meta akamai.OperationMeta, groupID string) (* return group, nil } -func getContract(ctx context.Context, meta akamai.OperationMeta, contractID string) (*papi.Contract, error) { +func getContract(ctx context.Context, meta meta.Meta, contractID string) (*papi.Contract, error) { logger := meta.Log("PAPI", "getContract") - client := inst.Client(meta) + client := Client(meta) logger.Debugf("Fetching contract") res, err := client.GetContracts(ctx) if err != nil { @@ -63,9 +63,9 @@ func getContract(ctx context.Context, meta akamai.OperationMeta, contractID stri return contract, nil } -func getProduct(ctx context.Context, meta akamai.OperationMeta, productID, contractID string) (*papi.ProductItem, error) { +func getProduct(ctx context.Context, meta meta.Meta, productID, contractID string) (*papi.ProductItem, error) { logger := meta.Log("PAPI", "getProduct") - client := inst.Client(meta) + client := Client(meta) if contractID == "" { return nil, ErrNoContractProvided } @@ -106,8 +106,8 @@ func convertString(v string) interface{} { return v } -func findProperty(ctx context.Context, name string, meta akamai.OperationMeta) (*papi.Property, error) { - client := inst.Client(meta) +func findProperty(ctx context.Context, name string, meta meta.Meta) (*papi.Property, error) { + client := Client(meta) results, err := client.SearchProperties(ctx, papi.SearchRequest{Key: papi.SearchKeyPropertyName, Value: name}) if err != nil { return nil, err diff --git a/pkg/providers/property/resource_akamai_property_helpers_test.go b/pkg/providers/property/resource_akamai_property_helpers_test.go index 6e213e1f1..6f3a59969 100644 --- a/pkg/providers/property/resource_akamai_property_helpers_test.go +++ b/pkg/providers/property/resource_akamai_property_helpers_test.go @@ -3,8 +3,8 @@ package property import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/tools" "github.com/stretchr/testify/mock" ) @@ -123,22 +123,6 @@ func ExpectUpdatePropertyVersionHostnames(client *papi.Mock, PropertyID, GroupID return call.Return(&res, nil) } -func ExpectGetEdgeHostnames(client *papi.Mock, contractID, groupID string, edgehostnames papi.EdgeHostnameItems) *mock.Call { - req := papi.GetEdgeHostnamesRequest{ - ContractID: contractID, - GroupID: groupID, - } - call := client.On("GetEdgeHostnames", AnyCTX, req) - - res := papi.GetEdgeHostnamesResponse{ - ContractID: contractID, - GroupID: groupID, - EdgeHostnames: edgehostnames, - } - - return call.Return(&res, nil) -} - // 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{ diff --git a/pkg/providers/property/resource_akamai_property_include.go b/pkg/providers/property/resource_akamai_property_include.go index 06bbf0878..156dd987a 100644 --- a/pkg/providers/property/resource_akamai_property_include.go +++ b/pkg/providers/property/resource_akamai_property_include.go @@ -10,10 +10,11 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -108,10 +109,10 @@ func resourcePropertyInclude() *schema.Resource { } func resourcePropertyIncludeCreate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Creating property include") @@ -171,10 +172,10 @@ func resourcePropertyIncludeCreate(ctx context.Context, rd *schema.ResourceData, } func resourcePropertyIncludeRead(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Reading property include") @@ -272,10 +273,10 @@ func resourcePropertyIncludeRead(ctx context.Context, rd *schema.ResourceData, m } func resourcePropertyIncludeUpdate(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Updating property include") @@ -328,10 +329,10 @@ func resourcePropertyIncludeUpdate(ctx context.Context, rd *schema.ResourceData, } func resourcePropertyIncludeDelete(ctx context.Context, rd *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeDelete") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Deleting property include") @@ -373,7 +374,7 @@ func resourcePropertyIncludeDelete(ctx context.Context, rd *schema.ResourceData, } func resourcePropertyIncludeImport(_ context.Context, rd *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeImport") logger.Debug("Importing property include") @@ -474,7 +475,7 @@ func buildRuleFormatHeader(ruleFormat string) http.Header { } func suppressDefaultRules(_, oldValue, newValue string, _ *schema.ResourceData) bool { - logger := akamai.Log("PAPI", "suppressDefaultRules") + logger := logger.Get("PAPI", "suppressDefaultRules") if len(newValue) > 0 || len(oldValue) == 0 { return false } diff --git a/pkg/providers/property/resource_akamai_property_include_activation.go b/pkg/providers/property/resource_akamai_property_include_activation.go index 32fa5730f..efd1da41e 100644 --- a/pkg/providers/property/resource_akamai_property_include_activation.go +++ b/pkg/providers/property/resource_akamai_property_include_activation.go @@ -11,11 +11,12 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/session" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/session" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/logger" + "github.com/akamai/terraform-provider-akamai/v5/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -107,7 +108,7 @@ func resourcePropertyIncludeActivation() *schema.Resource { } func readTimeoutFromEnvOrDefault(name string, timeout time.Duration) *time.Duration { - logger := akamai.Log("readTimeoutFromEnvOrDefault") + logger := logger.Get("readTimeoutFromEnvOrDefault") value := os.Getenv(name) if value != "" { @@ -129,10 +130,10 @@ var ( ) func resourcePropertyIncludeActivationCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeActivationCreate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Create property include activation") @@ -145,10 +146,10 @@ func resourcePropertyIncludeActivationCreate(ctx context.Context, d *schema.Reso } func resourcePropertyIncludeActivationRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeActivationRead") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Reading property include activation") rd, err := parsePropertyIncludeActivationResourceID(d.Id()) @@ -197,10 +198,10 @@ func resourcePropertyIncludeActivationRead(ctx context.Context, d *schema.Resour } func resourcePropertyIncludeActivationUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeActivationUpdate") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Updating property include activation") mutableAttrsHaveChanges := d.HasChanges("note", "notify_emails", "auto_acknowledge_rule_warnings", "compliance_record") @@ -217,10 +218,10 @@ func resourcePropertyIncludeActivationUpdate(ctx context.Context, d *schema.Reso } func resourcePropertyIncludeActivationDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeActivationDelete") ctx = session.ContextWithOptions(ctx, session.WithContextLog(logger)) - client := inst.Client(meta) + client := Client(meta) logger.Debug("Deactivating property include") activationResourceData := propertyIncludeActivationData{} @@ -258,7 +259,7 @@ func resourcePropertyIncludeActivationDelete(ctx context.Context, d *schema.Reso } func resourcePropertyIncludeActivationImport(_ context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { - meta := akamai.Meta(m) + meta := meta.Must(m) logger := meta.Log("PAPI", "resourcePropertyIncludeActivationImport") logger.Debug("Importing property include activation") @@ -284,7 +285,7 @@ func resourcePropertyIncludeActivationImport(_ context.Context, d *schema.Resour } func resourcePropertyIncludeActivationUpsert(ctx context.Context, d *schema.ResourceData, client papi.PAPI) error { - logger := akamai.Log("resourcePropertyIncludeActivationUpsert") + logger := logger.Get("resourcePropertyIncludeActivationUpsert") activationResourceData := propertyIncludeActivationData{} if err := activationResourceData.populateFromResource(d); err != nil { @@ -461,7 +462,7 @@ func isLatestActiveExpectedActivated(ctx context.Context, client papi.PAPI, acti } func createNewActivation(ctx context.Context, client papi.PAPI, activationResourceData propertyIncludeActivationData) error { - logger := akamai.Log("createNewActivation") + logger := logger.Get("createNewActivation") logger.Debug("preparing activation request") activateIncludeRequest := papi.ActivateIncludeRequest{ @@ -490,7 +491,7 @@ func createNewActivation(ctx context.Context, client papi.PAPI, activationResour } func createNewDeactivation(ctx context.Context, client papi.PAPI, activationResourceData propertyIncludeActivationData) error { - logger := akamai.Log("createNewDeactivation") + logger := logger.Get("createNewDeactivation") deactivateIncludeRequest := papi.DeactivateIncludeRequest{ IncludeID: activationResourceData.includeID, 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 2b086d086..dd82d0ac5 100644 --- a/pkg/providers/property/resource_akamai_property_include_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_include_activation_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -293,7 +293,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/property_include_activation.tf", testDir)), @@ -354,7 +354,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/property_include_activation.tf", testDir)), @@ -412,7 +412,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/property_include_activation.tf", testDir)), @@ -460,7 +460,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/property_include_activation.tf", testDir)), @@ -510,7 +510,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/no_compliance_record_on_production.tf", testDir)), @@ -550,7 +550,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/property_include_activation.tf", testDir)), @@ -606,7 +606,7 @@ func TestResourcePropertyIncludeActivation(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString(fmt.Sprintf("%s/property_include_activation.tf", testDir)), diff --git a/pkg/providers/property/resource_akamai_property_include_test.go b/pkg/providers/property/resource_akamai_property_include_test.go index 4037f7d0c..c6c027d69 100644 --- a/pkg/providers/property/resource_akamai_property_include_test.go +++ b/pkg/providers/property/resource_akamai_property_include_test.go @@ -7,9 +7,9 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/test" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/test" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -821,9 +821,9 @@ func TestResourcePropertyInclude(t *testing.T) { useClient(client, &hapi.Mock{}, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: testCase.steps, + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, + Steps: testCase.steps, }) }) client.AssertExpectations(t) diff --git a/pkg/providers/property/resource_akamai_property_schema_v0.go b/pkg/providers/property/resource_akamai_property_schema_v0.go index 566e962d2..83adc71cf 100644 --- a/pkg/providers/property/resource_akamai_property_schema_v0.go +++ b/pkg/providers/property/resource_akamai_property_schema_v0.go @@ -3,7 +3,7 @@ package property import ( "context" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/resource_akamai_property_test.go b/pkg/providers/property/resource_akamai_property_test.go index 508c8e0f2..73310c9e5 100644 --- a/pkg/providers/property/resource_akamai_property_test.go +++ b/pkg/providers/property/resource_akamai_property_test.go @@ -1,14 +1,15 @@ package property import ( + "errors" "fmt" "net/http" "regexp" "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/stretchr/testify/assert" @@ -137,12 +138,6 @@ func TestResProperty(t *testing.T) { } } - getEdgeHostnames := func(contractID, groupID string, edgehostnames papi.EdgeHostnameItems) BehaviorFunc { - return func(state *TestState) { - ExpectGetEdgeHostnames(state.Client, contractID, groupID, edgehostnames).Once() - } - } - getPropertyVersions := func(propertyID, propertyName, contractID, groupID string, items ...papi.PropertyVersionItems) BehaviorFunc { return func(state *TestState) { versionItems := &state.VersionItems @@ -248,10 +243,7 @@ func TestResProperty(t *testing.T) { 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", "contract", "ctr_0"), resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_0"), - resource.TestCheckResourceAttr("akamai_property.test", "group", "grp_0"), - resource.TestCheckResourceAttr("akamai_property.test", "product", "prd_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), @@ -278,7 +270,6 @@ func TestResProperty(t *testing.T) { advanceVersion("prp_0", 1, 2), getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusDeactivated, papi.VersionStatusInactive), setHostnames("prp_0", 2, "to2.test.domain"), - getEdgeHostnames("ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{{DomainPrefix: "from.test.domain"}}}), ), Steps: func(State *TestState, FixturePath string) []resource.TestStep { return []resource.TestStep{ @@ -320,7 +311,6 @@ func TestResProperty(t *testing.T) { advanceVersion("prp_0", 1, 2), getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusDeactivated), setHostnames("prp_0", 2, "to2.test.domain"), - getEdgeHostnames("ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{{DomainPrefix: "from.test.domain"}}}), ), Steps: func(State *TestState, FixturePath string) []resource.TestStep { return []resource.TestStep{ @@ -362,7 +352,6 @@ func TestResProperty(t *testing.T) { advanceVersion("prp_0", 1, 2), getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusActive), setHostnames("prp_0", 2, "to2.test.domain"), - getEdgeHostnames("ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{{DomainPrefix: "from.test.domain"}}}), ), Steps: func(State *TestState, FixturePath string) []resource.TestStep { return []resource.TestStep{ @@ -404,7 +393,6 @@ func TestResProperty(t *testing.T) { advanceVersion("prp_0", 1, 2), getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusActive), setHostnames("prp_0", 2, "to2.test.domain"), - getEdgeHostnames("ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{{DomainPrefix: "from.test.domain"}}}), ), Steps: func(State *TestState, FixturePath string) []resource.TestStep { return []resource.TestStep{ @@ -444,7 +432,6 @@ func TestResProperty(t *testing.T) { 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"), - getEdgeHostnames("ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{{DomainPrefix: "from.test.domain"}}}), ), Steps: func(State *TestState, FixturePath string) []resource.TestStep { return []resource.TestStep{ @@ -476,7 +463,6 @@ func TestResProperty(t *testing.T) { 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"), - getEdgeHostnames("ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{{DomainPrefix: "from.test.domain"}}}), ), Steps: func(State *TestState, FixturePath string) []resource.TestStep { return []resource.TestStep{ @@ -644,7 +630,7 @@ func TestResProperty(t *testing.T) { return func(t *testing.T) { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestResProperty/ConfigError/%s.tf", fixtureName), ExpectError: regexp.MustCompile(rx), @@ -653,42 +639,6 @@ func TestResProperty(t *testing.T) { } } - // Test Deprecated Schema Option - - // Run a test case to verify schema attribute deprecation - assertDeprecated := func(t *testing.T, attribute string) func(t *testing.T) { - return func(t *testing.T) { - if resourceProperty().Schema[attribute].Deprecated == "" { - t.Fatalf(`%q attribute is not marked deprecated`, attribute) - } - } - } - - // Test Forbidden Schema Option - - // Run a test case to confirm that the user is prompted to read the upgrade guide - assertForbiddenAttr := func(t *testing.T, fixtureName string) func(t *testing.T) { - - fixtureName = strings.ReplaceAll(fixtureName, " ", "_") - - return func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestResProperty/ForbiddenAttr/%s.tf", fixtureName), - ExpectError: regexp.MustCompile("See the Akamai Terraform Upgrade Guide"), - }}, - }) - }) - - client.AssertExpectations(t) - } - } - // Test Lifecycle // Run a happy-path test case that goes through a complete create-update-destroy cycle @@ -704,9 +654,9 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - IsUnitTest: true, - Steps: tc.Steps(State, fixturePrefix), + ProtoV5ProviderFactories: testAccProviders, + IsUnitTest: true, + Steps: tc.Steps(State, fixturePrefix), }) }) @@ -789,8 +739,8 @@ func TestResProperty(t *testing.T) { tc.ClientSetup(State) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: tc.Steps(State, ""), + ProtoV5ProviderFactories: testAccProviders, + Steps: tc.Steps(State, ""), }) }) @@ -807,35 +757,13 @@ func TestResProperty(t *testing.T) { // Test Schema Configuration t.Run("Schema Configuration Error: name not given", assertConfigError(t, "name not given", `"name" is required`)) - t.Run("Schema Configuration Error: neither contract nor contract_id given", assertConfigError(t, "neither contract nor contract_id given", `one of .contract,contract_id. must be specified`)) - t.Run("Schema Configuration Error: both contract and contract_id given", assertConfigError(t, "both contract and contract_id given", `only one of .contract,contract_id. can be specified`)) - t.Run("Schema Configuration Error: neither group nor group_id given", assertConfigError(t, "neither group nor group_id given", `one of .group,group_id. must be specified`)) - t.Run("Schema Configuration Error: both group and group_id given", assertConfigError(t, "both group and group_id given", `only one of .group,group_id. can be specified`)) - t.Run("Schema Configuration Error: neither product nor product_id given", assertConfigError(t, "neither product nor product_id given", `one of .product,product_id. must be specified`)) - t.Run("Schema Configuration Error: both product and product_id given", assertConfigError(t, "both product and product_id given", `only one of .product,product_id. can be specified`)) + 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 shorter than 86 characters`)) - // Test Deprecated Schema Option - - t.Run("Schema deprecation: contract", assertDeprecated(t, "contract")) - t.Run("Schema deprecation: group", assertDeprecated(t, "group")) - t.Run("Schema deprecation: product", assertDeprecated(t, "product")) - t.Run("Schema deprecation: cp_code", assertDeprecated(t, "cp_code")) - t.Run("Schema deprecation: contact", assertDeprecated(t, "contact")) - t.Run("Schema deprecation: origin", assertDeprecated(t, "origin")) - t.Run("Schema deprecation: is_secure", assertDeprecated(t, "is_secure")) - t.Run("Schema deprecation: variables", assertDeprecated(t, "variables")) - - // Test Forbidden Schema Option - - t.Run("Schema forbidden attribute: cp_code", assertForbiddenAttr(t, "cp_code")) - t.Run("Schema forbidden attribute: contact", assertForbiddenAttr(t, "contact")) - t.Run("Schema forbidden attribute: origin", assertForbiddenAttr(t, "origin")) - t.Run("Schema forbidden attribute: is_secure", assertForbiddenAttr(t, "is_secure")) - t.Run("Schema forbidden attribute: variables", assertForbiddenAttr(t, "variables")) - // Test Lifecycle t.Run("Lifecycle: latest version is not active (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionNotActive)) @@ -846,24 +774,13 @@ func TestResProperty(t *testing.T) { 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 (contract without prefix)", assertLifecycle(t, t.Name(), "contract without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (contract without prefix)", assertLifecycle(t, t.Name(), "contract without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (contract without prefix)", assertLifecycle(t, t.Name(), "contract 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 (group without prefix)", assertLifecycle(t, t.Name(), "group without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (group without prefix)", assertLifecycle(t, t.Name(), "group without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (group without prefix)", assertLifecycle(t, t.Name(), "group 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: latest version is not active (product without prefix)", assertLifecycle(t, t.Name(), "product without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (product without prefix)", assertLifecycle(t, t.Name(), "product without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (product without prefix)", assertLifecycle(t, t.Name(), "product without prefix", latestVersionActiveInProd)) t.Run("Lifecycle: no diff", assertLifecycle(t, t.Name(), "no diff", noDiff)) - t.Run("Lifecycle: no diff (product to product_id)", assertLifecycle(t, t.Name(), "product to product_id", noDiff)) - t.Run("Lifecycle: no diff (product_id to product)", assertLifecycle(t, t.Name(), "product_id to product", noDiff)) 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)) t.Run("Lifecycle: new version changed on server", assertLifecycle(t, t.Name(), "new version changed on server", changesMadeOutsideOfTerraform)) @@ -926,7 +843,7 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/%s-step0.tf", t.Name()), @@ -975,7 +892,7 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/%s/step0.tf", t.Name()), @@ -1026,7 +943,7 @@ func TestResProperty(t *testing.T) { ExpectRemoveProperty(client, "prp_1", "", "") useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResProperty/property_update_with_validation_error_for_rules.tf"), @@ -1107,7 +1024,7 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), @@ -1163,7 +1080,7 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), @@ -1211,7 +1128,7 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), @@ -1254,7 +1171,7 @@ func TestResProperty(t *testing.T) { useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{{ Config: loadFixtureString("testdata/TestResProperty/Creation/property.tf"), ExpectError: regexp.MustCompile("group not found: grp_0"), @@ -1281,7 +1198,7 @@ func TestResProperty(t *testing.T) { client.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf("given property name is not unique")) useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/%s.tf", t.Name()), @@ -1374,13 +1291,14 @@ func TestResProperty(t *testing.T) { Status: papi.ActivationStatusActive, ActivationType: papi.ActivationTypeActivate, SubmitDate: "2020-10-28T15:04:05Z", + NotifyEmails: []string{"dummy-user@akamai.com"}, }, }, }, }, nil).Once() } - t.Run("error update property version with incorrect edgehostname and update in rule tree", func(t *testing.T) { + t.Run("400 from UpdatePropertyVersionHostnames - incorrect/invalid edge hostname", func(t *testing.T) { client := &papi.Mock{} client.Test(T{t}) ruleFormat := "" @@ -1444,7 +1362,7 @@ func TestResProperty(t *testing.T) { 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, 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) @@ -1461,8 +1379,30 @@ func TestResProperty(t *testing.T) { // 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() - ExpectGetEdgeHostnames(client, "ctr_0", "grp_0", papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ - {DomainPrefix: "dxe-2406-issue-example-second.com"}, {DomainPrefix: "dxe-2406-issue.com"}}}).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", + }, + { + 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 @@ -1470,14 +1410,14 @@ func TestResProperty(t *testing.T) { 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, 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{ - ProviderFactories: testAccProviders, + ProtoV5ProviderFactories: testAccProviders, Steps: []resource.TestStep{ { Config: loadFixtureString("testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf"), @@ -1492,7 +1432,7 @@ func TestResProperty(t *testing.T) { resource.TestCheckResourceAttr("akamai_property.akaproperty", "id", "prp_0"), resource.TestCheckResourceAttr("akamai_property.akaproperty", "hostnames.#", "3"), ), - ExpectError: regexp.MustCompile("hostnames with 'cname_from' containing \\[does-not-exist.com] do not exist under this account, you need to remove or replace invalid hostnames entries in your configuration to proceed with property version update"), + ExpectError: regexp.MustCompile("Error: updating hostnames: request failed:"), }, }, }) @@ -1500,7 +1440,6 @@ func TestResProperty(t *testing.T) { client.AssertExpectations(t) }) - }) } diff --git a/pkg/providers/property/resource_akamai_property_variables.go b/pkg/providers/property/resource_akamai_property_variables.go deleted file mode 100644 index 670984b18..000000000 --- a/pkg/providers/property/resource_akamai_property_variables.go +++ /dev/null @@ -1,55 +0,0 @@ -package property - -import ( - "context" - - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func resourcePropertyVariables() *schema.Resource { - return &schema.Resource{ - CreateContext: resPropVarsOperation, - ReadContext: resPropVarsOperation, - DeleteContext: resPropVarsOperation, - UpdateContext: resPropVarsOperation, - Schema: map[string]*schema.Schema{ - "json": {Type: schema.TypeString, Computed: true, Description: "JSON variables representation"}, - "variables": { - Type: schema.TypeSet, - Optional: true, - Deprecated: akamai.NoticeDeprecatedUseAlias("akamai_property_variables"), - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "variable": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": {Type: schema.TypeString, Required: true, ValidateDiagFunc: tf.IsNotBlank}, - "hidden": {Type: schema.TypeBool, Required: true}, - "sensitive": {Type: schema.TypeBool, Required: true}, - "description": {Type: schema.TypeString, Optional: true}, - "value": {Type: schema.TypeString, Optional: true}, - }, - }, - }, - }, - }, - }, - }, - } -} - -func resPropVarsOperation(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics { - // Always fail for new resources and changed values - if d.IsNewResource() || d.HasChange("variables") { - return diag.Errorf(`resource "akamai_property_variables" is no longer supported - See Akamai Terraform Upgrade Guide`) - } - - // No changes and resource already exists, must be from previous version of plugin - return nil -} diff --git a/pkg/providers/property/resource_akamai_property_variables_test.go b/pkg/providers/property/resource_akamai_property_variables_test.go deleted file mode 100644 index d8bda3aa9..000000000 --- a/pkg/providers/property/resource_akamai_property_variables_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package property - -import ( - "regexp" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestResPropertyVariables(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - ProviderFactories: testAccProviders, - Steps: []resource.TestStep{{ - Config: loadFixtureString("testdata/TestResPropertyVariables/schema_version1_always_fails.tf"), - ExpectError: regexp.MustCompile(`resource "akamai_property_variables" is no longer supported`), - }}, - }) -} diff --git a/pkg/providers/property/ruleformats/builder.go b/pkg/providers/property/ruleformats/builder.go index d49eae09a..f17c544f1 100644 --- a/pkg/providers/property/ruleformats/builder.go +++ b/pkg/providers/property/ruleformats/builder.go @@ -6,9 +6,9 @@ import ( "fmt" "reflect" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" - "github.com/akamai/terraform-provider-akamai/v4/pkg/tools" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/tools" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/iancoleman/strcase" ) diff --git a/pkg/providers/property/ruleformats/rule_format_v2023_01_05.gen.go b/pkg/providers/property/ruleformats/rule_format_v2023_01_05.gen.go index 4c17f9e78..54e08e6fd 100644 --- a/pkg/providers/property/ruleformats/rule_format_v2023_01_05.gen.go +++ b/pkg/providers/property/ruleformats/rule_format_v2023_01_05.gen.go @@ -1533,7 +1533,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "breadcrumbs": { Optional: true, Type: schema.TypeList, - Description: "Provides per-HTTP transaction visibility into a request for content, regardless of how deep the request goes into the Akamai platform. The `X-Breadcrumbs` response header includes various data, such as network health and the location in the Akamai network used to serve content, which simplifies log review for troubleshooting. This behavior can be used in includes.", + Description: "Provides per-HTTP transaction visibility into a request for content, regardless of how deep the request goes into the Akamai platform. The `Akamai-Request-BC` response header includes various data, such as network health and the location in the Akamai network used to serve content, which simplifies log review for troubleshooting. This behavior can be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -3337,7 +3337,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "stream_type": { ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BEACON", "LOG", "BEACON_AND_LOG"}, false)), Optional: true, - Description: "Specify the DataStream type. `LOG` is the only value currently available, corresponding to DataStream 2.", + Description: "Specify the DataStream type.", Type: schema.TypeString, }, "beacon_stream_title": { @@ -5508,7 +5508,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "fast_invalidate": { Optional: true, Type: schema.TypeList, - Description: "Applies Akamai's `Fast Purge` feature to selected edge content, invalidating it within approximately five seconds. This behavior sends an `If-Modified-Since` request to the origin for subsequent requests, replacing it with origin content if its timestamp is more recent. Otherwise if the origin lacks a `Last-Modified` header, it sends a simple GET request. Note that this behavior does not simply delete content if more recent origin content is unavailable. See the `Fast Purge API` for an independent way to invalidate selected sets of content, and for more information on the feature. This behavior can be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -5726,7 +5726,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "front_end_optimization": { Optional: true, Type: schema.TypeList, - Description: "This behavior enables `Front End Optimization`, a suite of performance enhancements that accelerate page rendering and reduce download times, for example by `minifying` JavaScript and CSS. This behavior cannot be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior cannot be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -6993,7 +6993,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "input_validation": { Optional: true, Type: schema.TypeList, - Description: "The Input Validation Cloudlet detects anomalous edge requests and helps mitigate repeated invalid requests. You can configure it using either the Cloudlets Policy Manager application, available within `Control Center` under `Your services` > `Edge logic Cloudlets`, or the `Cloudlets API`. This behavior cannot be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior cannot be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -7792,7 +7792,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "media_client": { Optional: true, Type: schema.TypeList, - Description: "Enables client-side reporting through analytics beacon requests. This behavior cannot be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior cannot be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -8210,7 +8210,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "mobile_sdk_performance": { Optional: true, Type: schema.TypeList, - Description: "The Mobile Application Performance software development kit allows you to optimize native iOS and Android apps, effectively extending Akamai's intelligent edge platform's advantages to mobile devices operation in poor network conditions. This behavior enables the SDK's features for this set of requests. This behavior can be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -10553,7 +10553,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "resource_optimizer": { Optional: true, Type: schema.TypeList, - Description: "Use this along with `adaptiveAcceleration` to compress and cache resources such as JavaScript, CSS, and font files. This behavior can be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -11862,7 +11862,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "shutr": { Optional: true, Type: schema.TypeList, - Description: "The SHUTR protocol extends HTTP to reduce the amount of header data necessary for web transactions with mobile devices. This behavior can be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -11987,7 +11987,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "standard_tls_migration": { Optional: true, Type: schema.TypeList, - Description: "Migrates traffic to Standard TLS. Apply this behavior within the default rule or any `hostname` match. In some cases you may need to apply this along with the `standardTLSMigrationOverride` behavior. This behavior cannot be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior cannot be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -12074,7 +12074,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "standard_tls_migration_override": { Optional: true, Type: schema.TypeList, - Description: "When applying `standardTLSMigration`, add this behavior if your new certificate is SNI-only, if your property includes any `advanced features`, any Edge IP Binding enabled hosts, or if any foreground downloads are configured. This behavior is for internal usage only. This behavior cannot be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior is for internal usage only. This behavior cannot be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -12353,7 +12353,7 @@ func getBehaviorsSchemaV20230105() map[string]*schema.Schema { "tcp_optimization": { Optional: true, Type: schema.TypeList, - Description: "Enables a suite of optimizations targeting buffers, time-outs, and packet loss that improve transmission performance. This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/pkg/providers/property/ruleformats/rule_format_v2023_05_30.gen.go b/pkg/providers/property/ruleformats/rule_format_v2023_05_30.gen.go new file mode 100644 index 000000000..b5cd1e6f3 --- /dev/null +++ b/pkg/providers/property/ruleformats/rule_format_v2023_05_30.gen.go @@ -0,0 +1,15708 @@ +package ruleformats + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func init() { + schemasRegistry.register(RuleFormat{ + version: "rules_v2023_05_30", + behaviorsSchemas: getBehaviorsSchemaV20230530(), + criteriaSchemas: getCriteriaSchemaV20230530(), + typeMappings: map[string]interface{}{"adScalerCircuitBreaker.returnErrorResponseCodeBased.408": 408, "adScalerCircuitBreaker.returnErrorResponseCodeBased.500": 500, "adScalerCircuitBreaker.returnErrorResponseCodeBased.502": 502, "adScalerCircuitBreaker.returnErrorResponseCodeBased.504": 504}, + nameMappings: map[string]string{"allowFcmParentOverride": "allowFCMParentOverride", "allowHttpsCacheKeySharing": "allowHTTPSCacheKeySharing", "allowHttpsDowngrade": "allowHTTPSDowngrade", "allowHttpsUpgrade": "allowHTTPSUpgrade", "conditionalHttpStatus": "conditionalHTTPStatus", "contentCharacteristicsAmd": "contentCharacteristicsAMD", "contentCharacteristicsDd": "contentCharacteristicsDD", "dcpAuthHmacTransformation": "dcpAuthHMACTransformation", "detectSmartDnsProxy": "detectSmartDNSProxy", "detectSmartDnsProxyAction": "detectSmartDNSProxyAction", "detectSmartDnsProxyRedirecturl": "detectSmartDNSProxyRedirecturl", "enableCmcdSegmentPrefetch": "enableCMCDSegmentPrefetch", "enableEs256": "enableES256", "enableIpAvoidance": "enableIPAvoidance", "enableIpProtection": "enableIPProtection", "enableIpRedirectOnDeny": "enableIPRedirectOnDeny", "enableRs256": "enableRS256", "enableTokenInUri": "enableTokenInURI", "g2OToken": "g2oToken", "g2Oheader": "g2oheader", "i18NCharset": "i18nCharset", "i18NStatus": "i18nStatus", "isCertificateSniOnly": "isCertificateSNIOnly", "logEdgeIp": "logEdgeIP", "originSettings": "origin_settings", "overrideIpAddresses": "overrideIPAddresses", "segmentDurationDash": "segmentDurationDASH", "segmentDurationDashCustom": "segmentDurationDASHCustom", "segmentDurationHds": "segmentDurationHDS", "segmentDurationHdsCustom": "segmentDurationHDSCustom", "segmentDurationHls": "segmentDurationHLS", "segmentDurationHlsCustom": "segmentDurationHLSCustom", "segmentSizeDash": "segmentSizeDASH", "segmentSizeHds": "segmentSizeHDS", "segmentSizeHls": "segmentSizeHLS", "sf3COriginHost": "sf3cOriginHost", "sf3COriginHostHeader": "sf3cOriginHostHeader", "smartDnsProxy": "smartDNSProxy", "standardTlsMigration": "standardTLSMigration", "standardTlsMigrationOverride": "standardTLSMigrationOverride", "titleAicMobile": "title_aic_mobile", "titleAicNonmobile": "title_aic_nonmobile", "tokenAuthHlsTitle": "tokenAuthHLSTitle"}, + shouldFlatten: []string{"apiPrioritization.cloudletPolicy", "apiPrioritization.throttledCpCode", "apiPrioritization.throttledCpCode.cpCodeLimits", "apiPrioritization.netStorage", "applicationLoadBalancer.cloudletPolicy", "applicationLoadBalancer.allDownNetStorage", "audienceSegmentation.cloudletPolicy", "cpCode.value", "cpCode.value.cpCodeLimits", "edgeRedirector.cloudletPolicy", "failAction.netStorageHostname", "failAction.cpCode", "failAction.cpCode.cpCodeLimits", "firstPartyMarketing.cloudletPolicy", "firstPartyMarketingPlus.cloudletPolicy", "forwardRewrite.cloudletPolicy", "imageAndVideoManager.cpCodeOriginal", "imageAndVideoManager.cpCodeOriginal.cpCodeLimits", "imageAndVideoManager.cpCodeTransformed", "imageAndVideoManager.cpCodeTransformed.cpCodeLimits", "imageManager.cpCodeOriginal", "imageManager.cpCodeOriginal.cpCodeLimits", "imageManager.cpCodeTransformed", "imageManager.cpCodeTransformed.cpCodeLimits", "imageManagerVideo.cpCodeOriginal", "imageManagerVideo.cpCodeOriginal.cpCodeLimits", "imageManagerVideo.cpCodeTransformed", "imageManagerVideo.cpCodeTransformed.cpCodeLimits", "origin.netStorage", "phasedRelease.cloudletPolicy", "requestControl.cloudletPolicy", "requestControl.netStorage", "siteShield.ssmap", "visitorPrioritization.cloudletPolicy", "visitorPrioritization.waitingRoomCpCode", "visitorPrioritization.waitingRoomCpCode.cpCodeLimits", "visitorPrioritization.waitingRoomNetStorage", "webApplicationFirewall.firewallConfiguration", "matchCpCode.value", "matchCpCode.value.cpCodeLimits"}, + }) +} + +func getBehaviorsSchemaV20230530() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "ad_scaler_circuit_breaker": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior works with `manifestRerouting` to provide the scale and reliability of Akamai network while simultaneously allowing third party partners to modify the requested media content with value-added features. The `adScalerCircuitBreaker` behavior specifies the fallback action in case the technology partner encounters errors and can't modify the requested media object. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "response_delay_based": { + Optional: true, + Description: "Triggers a fallback action based on the delayed response from the technology partner's server.", + Type: schema.TypeBool, + }, + "response_delay_threshold": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"500ms"}, false)), + Optional: true, + Description: "Specifies the maximum response delay that, if exceeded, triggers the fallback action.", + Type: schema.TypeString, + }, + "response_code_based": { + Optional: true, + Description: "Triggers a fallback action based on the response code from the technology partner's server.", + Type: schema.TypeBool, + }, + "response_codes": { + ValidateDiagFunc: validateRegex("^(([0-9]{3})(,?))+$"), + Optional: true, + Description: "Specifies the codes in the partner's response that trigger the fallback action, either `408`, `500`, `502`, `504`, `SAME_AS_RECEIEVED`, or `SPECIFY_YOUR_OWN` for a custom code.", + Type: schema.TypeString, + }, + "fallback_action_response_code_based": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RETURN_AKAMAI_COPY", "RETURN_ERROR"}, false)), + Optional: true, + Description: "Specifies the fallback action.", + Type: schema.TypeString, + }, + "return_error_response_code_based": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SAME_AS_RECEIVED", "408", "500", "502", "504", "SPECIFY_YOUR_OWN"}, false)), + Optional: true, + Description: "Specifies the error to include in the response to the client.", + Type: schema.TypeString, + }, + "specify_your_own_response_code_based": { + ValidateDiagFunc: validateRegex("^\\d{3}$"), + Optional: true, + Description: "Defines a custom error response.", + Type: schema.TypeString, + }, + }, + }, + }, + "adaptive_acceleration": { + Optional: true, + Type: schema.TypeList, + Description: "Adaptive Acceleration uses HTTP/2 server push functionality with Ion properties to pre-position content and improve the performance of HTML page loading based on real user monitoring (RUM) timing data. It also helps browsers to preconnect to content that’s likely needed for upcoming requests. To use this behavior, make sure you enable the `http2` behavior. Use the `Adaptive Acceleration API` to report on the set of assets this feature optimizes. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "source": { + Optional: true, + Description: "The source Adaptive Acceleration uses to gather the real user monitoring timing data, either `mPulse` or `realUserMonitoring`. The recommended `mPulse` option supports all optimizations and requires the `mPulse` behavior added by default to new Ion properties. The classic `realUserMonitoring` method has been deprecated. If you set it as the data source, make sure you use it with the `realUserMonitoring` behavior.", + Type: schema.TypeString, + }, + "title_http2_server_push": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_push": { + Optional: true, + Description: "Recognizes resources like JavaScript, CSS, and images based on gathered timing data and sends these resources to a browser as it's waiting for a response to the initial request for your website or app. See `Automatic Server Push` for more information.", + Type: schema.TypeBool, + }, + "title_preconnect": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_preconnect": { + Optional: true, + Description: "Allows browsers to anticipate what connections your site needs, and establishes those connections ahead of time. See `Automatic Preconnect` for more information.", + Type: schema.TypeBool, + }, + "title_preload": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "preload_enable": { + Optional: true, + Description: "Allows browsers to preload necessary fonts before they fetch and process other resources. See `Automatic Font Preload` for more information.", + Type: schema.TypeBool, + }, + "ab_testing": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "ab_logic": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DISABLED", "CLOUDLETS", "MANUAL"}, false)), + Optional: true, + Description: "Specifies whether to use Adaptive Acceleration in an A/B testing environment. To include Adaptive Acceleration data in your A/B testing, specify the mode you want to apply. Otherwise, `DISABLED` by default. See `Add A/B testing to A2` for details.", + Type: schema.TypeString, + }, + "cookie_name": { + Optional: true, + Description: "This specifies the name of the cookie file used for redirecting the requests in the A/B testing environment.", + Type: schema.TypeString, + }, + "compression": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "title_ro": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_ro": { + Optional: true, + Description: "Enables the Resource Optimizer, which automates the compression and delivery of your `.css`, `.js`, and `.svg` content using a combination of Brotli and Zopfli compressions. The compression is performed offline, during a time to live that the feature automatically sets. See the `resourceOptimizer` and `resourceOptimizerExtendedCompatibility` behaviors for more details.", + Type: schema.TypeBool, + }, + "title_brotli": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_brotli_compression": { + Optional: true, + Description: "Applies Brotli compression, converting your origin content to cache on edge servers.", + Type: schema.TypeBool, + }, + "enable_for_noncacheable": { + Optional: true, + Description: "Applies Brotli compression to non-cacheable content.", + Type: schema.TypeBool, + }, + }, + }, + }, + "adaptive_image_compression": { + Optional: true, + Type: schema.TypeList, + Description: "The Adaptive Image Compression feature compresses JPEG images depending on the requesting network's performance, thus improving response time. The behavior specifies three performance tiers based on round-trip tests: 1 for excellent, 2 for good, and 3 for poor. It assigns separate performance criteria for mobile (cellular) and non-mobile networks, which the `compressMobile` and `compressStandard` options enable independently. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "title_aic_mobile": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "compress_mobile": { + Optional: true, + Description: "Adapts images served over cellular mobile networks.", + Type: schema.TypeBool, + }, + "tier1_mobile_compression_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMPRESS", "BYPASS", "STRIP"}, false)), + Optional: true, + Description: "Specifies tier-1 behavior.", + Type: schema.TypeString, + }, + "tier1_mobile_compression_value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the compression percentage.", + Type: schema.TypeInt, + }, + "tier2_mobile_compression_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMPRESS", "BYPASS", "STRIP"}, false)), + Optional: true, + Description: "Specifies tier-2 cellular-network behavior.", + Type: schema.TypeString, + }, + "tier2_mobile_compression_value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the compression percentage.", + Type: schema.TypeInt, + }, + "tier3_mobile_compression_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMPRESS", "BYPASS", "STRIP"}, false)), + Optional: true, + Description: "Specifies tier-3 cellular-network behavior.", + Type: schema.TypeString, + }, + "tier3_mobile_compression_value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the compression percentage.", + Type: schema.TypeInt, + }, + "title_aic_nonmobile": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "compress_standard": { + Optional: true, + Description: "Adapts images served over non-cellular networks.", + Type: schema.TypeBool, + }, + "tier1_standard_compression_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMPRESS", "BYPASS", "STRIP"}, false)), + Optional: true, + Description: "Specifies tier-1 non-cellular network behavior.", + Type: schema.TypeString, + }, + "tier1_standard_compression_value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the compression percentage.", + Type: schema.TypeInt, + }, + "tier2_standard_compression_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMPRESS", "BYPASS", "STRIP"}, false)), + Optional: true, + Description: "Specifies tier-2 non-cellular network behavior.", + Type: schema.TypeString, + }, + "tier2_standard_compression_value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the compression percentage.", + Type: schema.TypeInt, + }, + "tier3_standard_compression_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMPRESS", "BYPASS", "STRIP"}, false)), + Optional: true, + Description: "Specifies tier-3 non-cellular network behavior.", + Type: schema.TypeString, + }, + "tier3_standard_compression_value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the compression percentage.", + Type: schema.TypeInt, + }, + }, + }, + }, + "advanced": { + Optional: true, + Type: schema.TypeList, + Description: "This specifies Akamai XML metadata. It can only be configured on your behalf by Akamai Professional Services. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "description": { + Optional: true, + Description: "Human-readable description of what the XML block does.", + Type: schema.TypeString, + }, + "xml": { + Optional: true, + Description: "Akamai XML metadata.", + Type: schema.TypeString, + }, + }, + }, + }, + "aggregated_reporting": { + Optional: true, + Type: schema.TypeList, + Description: "Configure a custom report that collects traffic data. The data is based on one to four variables, such as `sum`, `average`, `min`, and `max`. These aggregation attributes help compile traffic data summaries. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables aggregated reporting.", + Type: schema.TypeBool, + }, + "report_name": { + Optional: true, + Description: "The unique name of the aggregated report within the property. If you reconfigure any attributes or variables in the aggregated reporting behavior, update this field to a unique value to enable logging data in a new instance of the report.", + Type: schema.TypeString, + }, + "attributes_count": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 4)), + Optional: true, + Description: "The number of attributes to include in the report, ranging from 1 to 4.", + Type: schema.TypeInt, + }, + "attribute1": { + Optional: true, + Description: "Specify a previously user-defined variable name as a report attribute. The values extracted for all attributes range from 0 to 20 characters.", + Type: schema.TypeString, + }, + "attribute2": { + Optional: true, + Description: "Specify a previously user-defined variable name as a report attribute. The values extracted for all attributes range from 0 to 20 characters.", + Type: schema.TypeString, + }, + "attribute3": { + Optional: true, + Description: "Specify a previously user-defined variable name as a report attribute. The values extracted for all attributes range from 0 to 20 characters.", + Type: schema.TypeString, + }, + "attribute4": { + Optional: true, + Description: "Specify a previously user-defined variable name as a report attribute. The values extracted for all attributes range from 0 to 20 characters.", + Type: schema.TypeString, + }, + }, + }, + }, + "akamaizer": { + Optional: true, + Type: schema.TypeList, + Description: "This allows you to run regular expression substitutions over web pages. To apply this behavior, you need to match on a `contentType`. Contact Akamai Professional Services for help configuring the Akamaizer. See also the `akamaizerTag` behavior. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Akamaizer behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "akamaizer_tag": { + Optional: true, + Type: schema.TypeList, + Description: "This specifies HTML tags and replacement rules for hostnames used in conjunction with the `akamaizer` behavior. Contact Akamai Professional Services for help configuring the Akamaizer. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_hostname": { + Optional: true, + Description: "Specifies the hostname to match on as a Perl-compatible regular expression.", + Type: schema.TypeString, + }, + "replacement_hostname": { + Optional: true, + Description: "Specifies the replacement hostname for the tag to use.", + Type: schema.TypeString, + }, + "scope": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ATTRIBUTE", "URL_ATTRIBUTE", "BLOCK", "PAGE"}, false)), + Optional: true, + Description: "Specifies the part of HTML content the `tagsAttribute` refers to.", + Type: schema.TypeString, + }, + "tags_attribute": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"A", "A_HREF", "IMG", "IMG_SRC", "SCRIPT", "SCRIPT_SRC", "LINK", "LINK_HREF", "TD", "TD_BACKGROUND", "TABLE", "TABLE_BACKGROUND", "IFRAME", "IFRAME_SRC", "AREA", "AREA_HREF", "BASE", "BASE_HREF", "FORM", "FORM_ACTION"}, false)), + Optional: true, + Description: "Specifies the tag or tag/attribute combination to operate on.", + Type: schema.TypeString, + }, + "replace_all": { + Optional: true, + Description: "Replaces all matches when enabled, otherwise replaces only the first match.", + Type: schema.TypeBool, + }, + "include_tags_attribute": { + Optional: true, + Description: "Whether to include the `tagsAttribute` value.", + Type: schema.TypeBool, + }, + }, + }, + }, + "all_http_in_cache_hierarchy": { + Optional: true, + Type: schema.TypeList, + Description: "Allow all HTTP request methods to be used for the edge's parent servers, useful to implement features such as `Site Shield`, `SureRoute`, and Tiered Distribution. (See the `siteShield`, `sureRoute`, and `tieredDistribution` behaviors.) This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables all HTTP requests for parent servers in the cache hierarchy.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_cloudlets_origins": { + Optional: true, + Type: schema.TypeList, + Description: "Allows Cloudlets Origins to determine the criteria, separately from the Property Manager, under which alternate `origin` definitions are assigned. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows you to assign custom origin definitions referenced in sub-rules by `cloudletsOrigin` labels. If disabled, all sub-rules are ignored.", + Type: schema.TypeBool, + }, + "honor_base_directory": { + Optional: true, + Description: "Prefixes any Cloudlet-generated origin path with a path defined by an Origin Base Path behavior. If no path is defined, it has no effect. If another Cloudlet policy already prepends the same Origin Base Path, the path is not duplicated.", + Type: schema.TypeBool, + }, + "purge_origin_query_parameter": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "When purging content from a Cloudlets Origin, this specifies a query parameter name whose value is the specific named origin to purge. Note that this only applies to content purge requests, for example when using the `Content Control Utility API`.", + Type: schema.TypeString, + }, + }, + }, + }, + "allow_delete": { + Optional: true, + Type: schema.TypeList, + Description: "Allow HTTP requests using the DELETE method. By default, GET, HEAD, and OPTIONS requests are allowed, and all other methods result in a 501 error. Such content does not cache, and any DELETE requests pass to the origin. See also the `allowOptions`, `allowPatch`, `allowPost`, and `allowPut` behaviors. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows DELETE requests. Content does `not` cache.", + Type: schema.TypeBool, + }, + "allow_body": { + Optional: true, + Description: "Allows data in the body of the DELETE request.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_https_cache_key_sharing": { + Optional: true, + Type: schema.TypeList, + Description: "HTTPS cache key sharing allows HTTP requests to be served from an HTTPS cache. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables HTTPS cache key sharing.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_https_downgrade": { + Optional: true, + Type: schema.TypeList, + Description: "Passes HTTPS requests to origin as HTTP. This is useful when incorporating Standard TLS or Akamai's shared certificate delivery security with an origin that serves HTTP traffic. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Downgrades to HTTP protocol for the origin server.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_options": { + Optional: true, + Type: schema.TypeList, + Description: "GET, HEAD, and OPTIONS requests are allowed by default. All other HTTP methods result in a 501 error. For full support of Cross-Origin Resource Sharing (CORS), you need to allow requests that use the OPTIONS method. If you're using the `corsSupport` behavior, do not disable OPTIONS requests. The response to an OPTIONS request is not cached, so the request always goes through the Akamai network to your origin, unless you use the `constructResponse` behavior to send responses directly from the Akamai network. See also the `allowDelete`, `allowPatch`, `allowPost`, and `allowPut` behaviors. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Set this to `true` to reflect the default policy where edge servers allow the OPTIONS method, without caching the response. Set this to `false` to deny OPTIONS requests and respond with a 501 error.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_patch": { + Optional: true, + Type: schema.TypeList, + Description: "Allow HTTP requests using the PATCH method. By default, GET, HEAD, and OPTIONS requests are allowed, and all other methods result in a 501 error. Such content does not cache, and any PATCH requests pass to the origin. See also the `allowDelete`, `allowOptions`, `allowPost`, and `allowPut` behaviors. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows PATCH requests. Content does `not` cache.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_post": { + Optional: true, + Type: schema.TypeList, + Description: "Allow HTTP requests using the POST method. By default, GET, HEAD, and OPTIONS requests are allowed, and POST requests are denied with 403 error. All other methods result in a 501 error. See also the `allowDelete`, `allowOptions`, `allowPatch`, and `allowPut` behaviors. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows POST requests.", + Type: schema.TypeBool, + }, + "allow_without_content_length": { + Optional: true, + Description: "By default, POST requests also require a `Content-Length` header, or they result in a 411 error. With this option enabled with no specified `Content-Length`, the edge server relies on a `Transfer-Encoding` header to chunk the data. If neither header is present, it assumes the request has no body, and it adds a header with a `0` value to the forward request.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_put": { + Optional: true, + Type: schema.TypeList, + Description: "Allow HTTP requests using the PUT method. By default, GET, HEAD, and OPTIONS requests are allowed, and all other methods result in a 501 error. Such content does not cache, and any PUT requests pass to the origin. See also the `allowDelete`, `allowOptions`, `allowPatch`, and `allowPost` behaviors. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows PUT requests. Content does `not` cache.", + Type: schema.TypeBool, + }, + }, + }, + }, + "allow_transfer_encoding": { + Optional: true, + Type: schema.TypeList, + Description: "Controls whether to allow or deny Chunked Transfer Encoding (CTE) requests to pass to your origin. If your origin supports CTE, you should enable this behavior. This behavior also protects against a known issue when pairing `http2` and `webdav` behaviors within the same rule tree, in which case it's required. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows Chunked Transfer Encoding requests.", + Type: schema.TypeBool, + }, + }, + }, + }, + "alt_svc_header": { + Optional: true, + Type: schema.TypeList, + Description: "Sets the maximum age value for the Alternative Services (`Alt-Svc`) header. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "max_age": { + Optional: true, + Description: "Specifies the `max-age` value in seconds for the `Alt-Svc` header. The default `max-age` for an `Alt-Svc` header is 93600 seconds (26 hours).", + Type: schema.TypeInt, + }, + }, + }, + }, + "api_prioritization": { + Optional: true, + Type: schema.TypeList, + Description: "Enables the API Prioritization Cloudlet, which maintains continuity in user experience by serving an alternate static response when load is too high. You can configure rules using either the Cloudlets Policy Manager application or the `Cloudlets API`. Use this feature serve static API content, such as fallback JSON data. To serve non-API HTML content, use the `visitorPrioritization` behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Activates the API Prioritization feature.", + Type: schema.TypeBool, + }, + "is_shared_policy": { + Optional: true, + Description: "Whether you want to apply the Cloudlet shared policy to an unlimited number of properties within your account. Learn more about shared policies and how to create them in `Cloudlets Policy Manager`.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "Identifies the Cloudlet shared policy to use with this behavior. Use the `Cloudlets API` to list available shared policies.", + Type: schema.TypeInt, + }, + "label": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "A label to distinguish this API Prioritization policy from any others in the same property.", + Type: schema.TypeString, + }, + "use_throttled_cp_code": { + Optional: true, + Description: "Specifies whether to apply an alternative CP code for requests served the alternate response.", + Type: schema.TypeBool, + }, + "throttled_cp_code": { + Optional: true, + Description: "Specifies the CP code as an object.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "use_throttled_status_code": { + Optional: true, + Description: "Allows you to assign a specific HTTP response code to a throttled request.", + Type: schema.TypeBool, + }, + "throttled_status_code": { + ValidateDiagFunc: validateRegex("^\\d{3}$"), + Optional: true, + Description: "Specifies the HTTP response code for requests that receive the alternate response.", + Type: schema.TypeInt, + }, + "net_storage": { + Optional: true, + Description: "Specify the NetStorage domain that contains the alternate response.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cp_code": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "download_domain_name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "g2o_token": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "net_storage_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specify the full NetStorage path for the alternate response, including trailing file name.", + Type: schema.TypeString, + }, + "alternate_response_cache_ttl": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(5, 30)), + Optional: true, + Description: "Specifies the alternate response's time to live in the cache, `5` minutes by default.", + Type: schema.TypeInt, + }, + }, + }, + }, + "application_load_balancer": { + Optional: true, + Type: schema.TypeList, + Description: "Enables the Application Load Balancer Cloudlet, which automates load balancing based on configurable criteria. To configure this behavior, use either the Cloudlets Policy Manager or the `Cloudlets API` to set up a policy. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Activates the Application Load Balancer Cloudlet.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "label": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "A label to distinguish this Application Load Balancer policy from any others within the same property.", + Type: schema.TypeString, + }, + "stickiness_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "stickiness_cookie_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "NEVER", "ON_BROWSER_CLOSE", "FIXED_DATE", "DURATION", "ORIGIN_SESSION"}, false)), + Optional: true, + Description: "Determines how a cookie persistently associates the client with a load-balanced origin.", + Type: schema.TypeString, + }, + "stickiness_expiration_date": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies when the cookie expires.", + Type: schema.TypeString, + }, + "stickiness_duration": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Sets how long it is before the cookie expires.", + Type: schema.TypeString, + }, + "stickiness_refresh": { + Optional: true, + Description: "Extends the duration of the cookie with each new request. When enabled, the `DURATION` thus specifies the latency between requests that would cause the cookie to expire.", + Type: schema.TypeBool, + }, + "origin_cookie_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the name for your session cookie.", + Type: schema.TypeString, + }, + "specify_stickiness_cookie_domain": { + Optional: true, + Description: "Specifies whether to use a cookie domain with the stickiness cookie, to tell the browser to which domain to send the cookie.", + Type: schema.TypeBool, + }, + "stickiness_cookie_domain": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies the domain to track the stickiness cookie.", + Type: schema.TypeString, + }, + "stickiness_cookie_automatic_salt": { + Optional: true, + Description: "Sets whether to assign a `salt` value automatically to the cookie to prevent manipulation by the user. You should not enable this if sharing the population cookie across more than one property.", + Type: schema.TypeBool, + }, + "stickiness_cookie_salt": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the stickiness cookie's salt value. Use this option to share the cookie across many properties.", + Type: schema.TypeString, + }, + "stickiness_cookie_set_http_only_flag": { + Optional: true, + Description: "Ensures the cookie is transmitted only over HTTP.", + Type: schema.TypeBool, + }, + "all_down_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "all_down_net_storage": { + Optional: true, + Description: "Specifies a NetStorage account for a static maintenance page as a fallback when no origins are available.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cp_code": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "download_domain_name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "g2o_token": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "all_down_net_storage_file": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the fallback maintenance page's filename, expressed as a full path from the root of the NetStorage server.", + Type: schema.TypeString, + }, + "all_down_status_code": { + ValidateDiagFunc: validateRegex("^\\d{3}$"), + Optional: true, + Description: "Specifies the HTTP response code when all load-balancing origins are unavailable.", + Type: schema.TypeString, + }, + "failover_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "failover_status_codes": { + Optional: true, + Description: "Specifies a set of HTTP status codes that signal a failure on the origin, in which case the cookie that binds the client to that origin is invalidated and the client is rerouted to another available origin.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "failover_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"AUTOMATIC", "MANUAL", "DISABLED"}, false)), + Optional: true, + Description: "Determines what to do if an origin fails.", + Type: schema.TypeString, + }, + "failover_origin_map": { + Optional: true, + Description: "Specifies a fixed set of failover mapping rules.", + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from_origin_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-\\.]+$"), + Optional: true, + Description: "Specifies the origin whose failure triggers the mapping rule.", + Type: schema.TypeString, + }, + "to_origin_ids": { + Optional: true, + Description: "Requests stuck to the `fromOriginId` origin retry for each alternate origin `toOriginIds`, until one succeeds.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "failover_attempts_threshold": { + Optional: true, + Description: "Sets the number of failed requests that would trigger the failover process.", + Type: schema.TypeInt, + }, + "cached_content_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "allow_cache_prefresh": { + Optional: true, + Description: "Allows the cache to prefresh. Only appropriate if all origins serve the same content for the same URL.", + Type: schema.TypeBool, + }, + }, + }, + }, + "audience_segmentation": { + Optional: true, + Type: schema.TypeList, + Description: "Allows you to divide your users into different segments based on a persistent cookie. You can configure rules using either the Cloudlets Policy Manager application or the `Cloudlets API`. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Audience Segmentation cloudlet feature.", + Type: schema.TypeBool, + }, + "is_shared_policy": { + Optional: true, + Description: "Whether you want to use a shared policy for a Cloudlet. Learn more about shared policies and how to create them in `Cloudlets Policy Manager`.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "This identifies the Cloudlet shared policy to use with this behavior. You can list available shared policies with the `Cloudlets API`.", + Type: schema.TypeInt, + }, + "label": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies a suffix to append to the cookie name. This helps distinguish this audience segmentation policy from any others within the same property.", + Type: schema.TypeString, + }, + "segment_tracking_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "segment_tracking_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IN_QUERY_PARAM", "IN_COOKIE_HEADER", "IN_CUSTOM_HEADER", "NONE"}, false)), + Optional: true, + Description: "Specifies the method to pass segment information to the origin. The Cloudlet passes the rule applied to a given request location.", + Type: schema.TypeString, + }, + "segment_tracking_query_param": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This query parameter specifies the name of the segmentation rule.", + Type: schema.TypeString, + }, + "segment_tracking_cookie_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This cookie name specifies the name of the segmentation rule.", + Type: schema.TypeString, + }, + "segment_tracking_custom_header": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This custom HTTP header specifies the name of the segmentation rule.", + Type: schema.TypeString, + }, + "population_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "population_cookie_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NEVER", "ON_BROWSER_CLOSE", "DURATION"}, false)), + Optional: true, + Description: "Specifies when the segmentation cookie expires.", + Type: schema.TypeString, + }, + "population_duration": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the lifetime of the segmentation cookie.", + Type: schema.TypeString, + }, + "population_refresh": { + Optional: true, + Description: "If disabled, sets the expiration time only if the cookie is not yet present in the request.", + Type: schema.TypeBool, + }, + "specify_population_cookie_domain": { + Optional: true, + Description: "Whether to specify a cookie domain with the population cookie. It tells the browser to which domain to send the cookie.", + Type: schema.TypeBool, + }, + "population_cookie_domain": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies the domain to track the population cookie.", + Type: schema.TypeString, + }, + "population_cookie_automatic_salt": { + Optional: true, + Description: "Whether to assign a `salt` value automatically to the cookie to prevent manipulation by the user. You should not enable if sharing the population cookie across more than one property.", + Type: schema.TypeBool, + }, + "population_cookie_salt": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the cookie's salt value. Use this option to share the cookie across many properties.", + Type: schema.TypeString, + }, + "population_cookie_include_rule_name": { + Optional: true, + Description: "When enabled, includes in the session cookie the name of the rule in which this behavior appears.", + Type: schema.TypeBool, + }, + }, + }, + }, + "auto_domain_validation": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows standard TLS domain validated certificates to renew automatically. Apply it after using the `Certificate Provisioning System` to request a certificate for a hostname. To provision certificates programmatically, see the `Certificate Provisioning System API`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "autodv": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "base_directory": { + Optional: true, + Type: schema.TypeList, + Description: "Prefix URLs sent to the origin with a base path. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^/([^:#\\[\\]@/?]+/)*$"), + Optional: true, + Description: "Specifies the base path of content on your origin server. The value needs to begin and end with a slash (`/`) character, for example `/parent/child/`.", + Type: schema.TypeString, + }, + }, + }, + }, + "boss_beaconing": { + Optional: true, + Type: schema.TypeList, + Description: "Triggers diagnostic data beacons for use with BOSS, Akamai's monitoring and diagnostics system. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enable diagnostic data beacons.", + Type: schema.TypeBool, + }, + "cpcodes": { + ValidateDiagFunc: validateRegex("^[0-9 ]*$"), + Optional: true, + Description: "The space-separated list of CP codes that trigger the beacons. You need to specify the same set of CP codes within BOSS.", + Type: schema.TypeString, + }, + "request_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"EDGE", "EDGE_MIDGRESS"}, false)), + Optional: true, + Description: "Specify when to trigger a beacon.", + Type: schema.TypeString, + }, + "forward_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"MIDGRESS", "ORIGIN", "MIDGRESS_ORIGIN"}, false)), + Optional: true, + Description: "Specify when to trigger a beacon.", + Type: schema.TypeString, + }, + "sampling_frequency": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SAMPLING_FREQ_0_0", "SAMPLING_FREQ_0_1"}, false)), + Optional: true, + Description: "Specifies a sampling frequency or disables beacons.", + Type: schema.TypeString, + }, + "conditional_sampling_frequency": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CONDITIONAL_SAMPLING_FREQ_0_0", "CONDITIONAL_SAMPLING_FREQ_0_1", "CONDITIONAL_SAMPLING_FREQ_0_2", "CONDITIONAL_SAMPLING_FREQ_0_3"}, false)), + Optional: true, + Description: "Specifies a conditional sampling frequency or disables beacons.", + Type: schema.TypeString, + }, + "conditional_http_status": { + Optional: true, + Description: "Specifies the set of response status codes or ranges that trigger the beacon.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "conditional_error_pattern": { + Optional: true, + Description: "A space-separated set of error patterns that trigger beacons to conditional feeds. Each pattern can include wildcards, such as `*CONNECT* *DENIED*`.", + Type: schema.TypeString, + }, + }, + }, + }, + "breadcrumbs": { + Optional: true, + Type: schema.TypeList, + Description: "Provides per-HTTP transaction visibility into a request for content, regardless of how deep the request goes into the Akamai platform. The `Akamai-Request-BC` response header includes various data, such as network health and the location in the Akamai network used to serve content, which simplifies log review for troubleshooting. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Breadcrumbs feature.", + Type: schema.TypeBool, + }, + "opt_mode": { + Optional: true, + Description: "Specifies whether to include Breadcrumbs data in the response header. To bypass the current `optMode`, append the opposite `ak-bc` query string to each request from your player.", + Type: schema.TypeBool, + }, + "logging_enabled": { + Optional: true, + Description: "Whether to collect all Breadcrumbs data in logs, including the response headers sent a requesting client. This can also be helpful if you're using `DataStream 2` to retrieve log data. This way, all Breadcrumbs data is carried in the logs it uses.", + Type: schema.TypeBool, + }, + }, + }, + }, + "break_connection": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior simulates an origin connection problem, typically to test an accompanying `failAction` policy. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the break connection behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "brotli": { + Optional: true, + Type: schema.TypeList, + Description: "Accesses Brotli-compressed assets from your origin and caches them on edge servers. This doesn't compress resources within the content delivery network in real time. You need to set up Brotli compression separately on your origin. If a requesting client doesn't support Brotli, edge servers deliver non-Brotli resources. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Fetches Brotli-compressed assets from your origin and caches them on edge servers.", + Type: schema.TypeBool, + }, + }, + }, + }, + "cache_error": { + Optional: true, + Type: schema.TypeList, + Description: "Caches the origin's error responses to decrease server load. Applies for 10 seconds by default to the following HTTP codes: `204`, `305`, `400`, `404`, `405`, `501`, `502`, `503`, `504`, and `505`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Activates the error-caching behavior.", + Type: schema.TypeBool, + }, + "ttl": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Overrides the default caching duration of `10s`. Note that if set to `0`, it is equivalent to `no-cache`, which forces revalidation and may cause a traffic spike. This can be counterproductive when, for example, the origin is producing an error code of `500`.", + Type: schema.TypeString, + }, + "preserve_stale": { + Optional: true, + Description: "When enabled, the edge server preserves stale cached objects when the origin returns `400`, `500`, `502`, `503`, and `504` error codes. This avoids re-fetching and re-caching content after transient errors.", + Type: schema.TypeBool, + }, + }, + }, + }, + "cache_id": { + Optional: true, + Type: schema.TypeList, + Description: "Controls which query parameters, headers, and cookies are included in or excluded from the cache key identifier. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "rule": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"INCLUDE_QUERY_PARAMS", "INCLUDE_COOKIES", "INCLUDE_HEADERS", "EXCLUDE_QUERY_PARAMS", "INCLUDE_ALL_QUERY_PARAMS", "INCLUDE_VARIABLE", "INCLUDE_URL"}, false)), + Optional: true, + Description: "Specifies how to modify the cache ID.", + Type: schema.TypeString, + }, + "include_value": { + Optional: true, + Description: "Includes the value of the specified elements in the cache ID. Otherwise only their names are included.", + Type: schema.TypeBool, + }, + "optional": { + Optional: true, + Description: "Requires the behavior's specified elements to be present for content to cache. When disabled, requests that lack the specified elements are still cached.", + Type: schema.TypeBool, + }, + "elements": { + Optional: true, + Description: "Specifies the names of the query parameters, cookies, or headers to include or exclude from the cache ID.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "variable_name": { + Optional: true, + Description: "Specifies the name of the variable you want to include in the cache key.", + Type: schema.TypeString, + }, + }, + }, + }, + "cache_key_ignore_case": { + Optional: true, + Type: schema.TypeList, + Description: "By default, cache keys are generated under the assumption that path and filename components are case-sensitive, so that `File.html` and `file.html` use separate cache keys. Enabling this behavior forces URL components whose case varies to resolve to the same cache key. Enable this behavior if your origin server is already case-insensitive, such as those based on Microsoft IIS. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Ignores case when forming cache keys.", + Type: schema.TypeBool, + }, + }, + }, + }, + "cache_key_query_params": { + Optional: true, + Type: schema.TypeList, + Description: "By default, cache keys are formed as URLs with full query strings. This behavior allows you to consolidate cached objects based on specified sets of query parameters. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"INCLUDE_ALL_PRESERVE_ORDER", "INCLUDE_ALL_ALPHABETIZE_ORDER", "IGNORE_ALL", "INCLUDE", "IGNORE"}, false)), + Optional: true, + Description: "Configures how sets of query string parameters translate to cache keys. Be careful not to ignore any parameters that result in substantially different content, as it is `not` reflected in the cached object.", + Type: schema.TypeString, + }, + "parameters": { + Optional: true, + Description: "Specifies the set of parameter field names to include in or exclude from the cache key. By default, these match the field names as string prefixes.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "exact_match": { + Optional: true, + Description: "When enabled, `parameters` needs to match exactly. Keep disabled to match string prefixes.", + Type: schema.TypeBool, + }, + }, + }, + }, + "cache_key_rewrite": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior rewrites a default cache key's path. Contact Akamai Professional Services for help configuring it. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "purge_key": { + ValidateDiagFunc: validateRegex("^[\\w-]+$"), + Optional: true, + Description: "Specifies the new cache key path as an alphanumeric value.", + Type: schema.TypeString, + }, + }, + }, + }, + "cache_post": { + Optional: true, + Type: schema.TypeList, + Description: "By default, POST requests are passed to the origin. This behavior overrides the default, and allows you to cache POST responses. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables caching of POST responses.", + Type: schema.TypeBool, + }, + "use_body": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IGNORE", "MD5", "QUERY"}, false)), + Optional: true, + Description: "Define how and whether to use the POST message body as a cache key.", + Type: schema.TypeString, + }, + }, + }, + }, + "cache_redirect": { + Optional: true, + Type: schema.TypeList, + Description: "Controls the caching of HTTP 302 and 307 temporary redirects. By default, Akamai edge servers don't cache them. Enabling this behavior instructs edge servers to allow these redirects to be cached the same as HTTP 200 responses. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the redirect caching behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "cache_tag": { + Optional: true, + Type: schema.TypeList, + Description: "This adds a cache tag to the requested object. With cache tags, you can flexibly fast purge tagged segments of your cached content. You can either define these tags with an `Edge-Cache-Tag` header at the origin server level, or use this behavior to directly add a cache tag to the object as the edge server caches it. The `cacheTag` behavior can only take a single value, including a variable. If you want to specify more tags for an object, add a few instances of this behavior to your configuration. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "tag": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9\\&\\'\\^\\-\\$\\!\\`\\#\\%\\.\\+\\~\\_\\|\\/]+$"), + Optional: true, + Description: "Specifies the cache tag you want to add to your cached content. A cache tag is only added when the object is first added to cache. A single cache tag can't exceed 128 characters and can only include alphanumeric characters, plus this class of characters: ```[!#$%'+./^_`|~-]```", + Type: schema.TypeString, + }, + }, + }, + }, + "cache_tag_visible": { + Optional: true, + Type: schema.TypeList, + Description: "Cache tags are comma-separated string values you define within an `Edge-Cache-Tag` header. You can use them to flexibly fast purge tagged segments of your cached content. You can either define these headers at the origin server level, or use the `modifyOutgoingResponseHeader` behavior to configure them at the edge. Apply this behavior to confirm you're deploying the intended set of cache tags to your content. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NEVER", "PRAGMA_HEADER", "ALWAYS"}, false)), + Optional: true, + Description: "Specifies when to include the `Edge-Cache-Tag` in responses.", + Type: schema.TypeString, + }, + }, + }, + }, + "caching": { + Optional: true, + Type: schema.TypeList, + Description: "Control content caching on edge servers: whether or not to cache, whether to honor the origin's caching headers, and for how long to cache. Note that any `NO_STORE` or `BYPASS_CACHE` HTTP headers set on the origin's content override this behavior. For more details on how caching works in Property Manager, see the `Learn about caching` section in the guide. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"MAX_AGE", "NO_STORE", "BYPASS_CACHE", "CACHE_CONTROL_AND_EXPIRES", "CACHE_CONTROL", "EXPIRES"}, false)), + Optional: true, + Description: "Specify the caching option.", + Type: schema.TypeString, + }, + "must_revalidate": { + Optional: true, + Description: "Determines what to do once the cached content has expired, by which time the Akamai platform should have re-fetched and validated content from the origin. If enabled, only allows the re-fetched content to be served. If disabled, may serve stale content if the origin is unavailable.", + Type: schema.TypeBool, + }, + "ttl": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "The maximum time content may remain cached. Setting the value to `0` is the same as setting a `no-cache` header, which forces content to revalidate.", + Type: schema.TypeString, + }, + "default_ttl": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Set the `MAX_AGE` header for the cached content.", + Type: schema.TypeString, + }, + "cache_control_directives": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enhanced_rfc_support": { + Optional: true, + Description: "This enables honoring particular `Cache-Control` header directives from the origin. Supports all official `RFC 7234` directives except for `no-transform`.", + Type: schema.TypeBool, + }, + "cacheability_settings": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "honor_no_store": { + Optional: true, + Description: "Instructs edge servers not to cache the response when the origin response includes the `no-store` directive.", + Type: schema.TypeBool, + }, + "honor_private": { + Optional: true, + Description: "Instructs edge servers not to cache the response when the origin response includes the `private` directive.", + Type: schema.TypeBool, + }, + "honor_no_cache": { + Optional: true, + Description: "With the `no-cache` directive present in the response, this instructs edge servers to validate or refetch the response for each request. Effectively, set the time to live `ttl` to zero seconds.", + Type: schema.TypeBool, + }, + "expiration_settings": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "honor_max_age": { + Optional: true, + Description: "This instructs edge servers to cache the object for a length of time set by the `max-age` directive in the response. When present in the origin response, this directive takes precedence over the `max-age` directive and the `defaultTtl` setting.", + Type: schema.TypeBool, + }, + "honor_s_maxage": { + Optional: true, + Description: "Instructs edge servers to cache the object for a length of time set by the `s-maxage` directive in the response. When present in the origin response, this directive takes precedence over the `max-age` directive and the `defaultTtl` setting.", + Type: schema.TypeBool, + }, + "revalidation_settings": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "honor_must_revalidate": { + Optional: true, + Description: "This instructs edge servers to successfully revalidate with the origin server before using stale objects in the cache to satisfy new requests.", + Type: schema.TypeBool, + }, + "honor_proxy_revalidate": { + Optional: true, + Description: "With the `proxy-revalidate` directive present in the response, this instructs edge servers to successfully revalidate with the origin server before using stale objects in the cache to satisfy new requests.", + Type: schema.TypeBool, + }, + }, + }, + }, + "central_authorization": { + Optional: true, + Type: schema.TypeList, + Description: "Forward client requests to the origin server for authorization, along with optional `Set-Cookie` headers, useful when you need to maintain tight access control. The edge server forwards an `If-Modified-Since` header, to which the origin needs to respond with a `304` (Not-Modified) HTTP status when authorization succeeds. If so, the edge server responds to the client with the cached object, since it does not need to be re-acquired from the origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the centralized authorization behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "chase_redirects": { + Optional: true, + Type: schema.TypeList, + Description: "Controls whether the edge server chases any redirects served from the origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows edge servers to chase redirects.", + Type: schema.TypeBool, + }, + "limit": { + Optional: true, + Description: "Specifies, as a string, the maximum number of redirects to follow.", + Type: schema.TypeString, + }, + "serve404": { + Optional: true, + Description: "Once the redirect `limit` is reached, enabling this option serves an HTTP `404` (Not Found) error instead of the last redirect.", + Type: schema.TypeBool, + }, + }, + }, + }, + "client_characteristics": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the client ecosystem. Akamai uses this information to optimize your metadata configuration, which may result in better end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "country": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"GLOBAL", "GLOBAL_US_CENTRIC", "GLOBAL_EU_CENTRIC", "GLOBAL_ASIA_CENTRIC", "EUROPE", "NORTH_AMERICA", "SOUTH_AMERICA", "NORDICS", "ASIA_PACIFIC", "AUSTRALIA", "GERMANY", "INDIA", "ITALY", "JAPAN", "TAIWAN", "UNITED_KINGDOM", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Specifies the client request's geographic region.", + Type: schema.TypeString, + }, + }, + }, + }, + "cloud_interconnects": { + Optional: true, + Type: schema.TypeList, + Description: "Cloud Interconnects forwards traffic from edge servers to your cloud origin through Private Network Interconnects (PNIs), helping to reduce the egress costs at the origin. Supports origins hosted by Google Cloud Provider (GCP). This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Channels the traffic to maximize the egress discount at the origin.", + Type: schema.TypeBool, + }, + "cloud_locations": { + Optional: true, + Description: "Specifies the geographical locations of your cloud origin. You should enable Cloud Interconnects only if your origin is in one of these locations, since GCP doesn't provide a discount for egress traffic for any other regions.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "cloud_wrapper": { + Optional: true, + Type: schema.TypeList, + Description: "`Cloud Wrapper` maximizes origin offload for large libraries of video, game, and software downloads by optimizing data caches in regions nearest to your origin. You can't use this behavior in conjunction with `sureRoute` or `tieredDistribution`. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables Cloud Wrapper behavior.", + Type: schema.TypeBool, + }, + "location": { + Optional: true, + Description: "The location you want to distribute your Cloud Wrapper cache space to. This behavior allows all locations configured in your Cloud Wrapper configuration.", + Type: schema.TypeString, + }, + }, + }, + }, + "cloud_wrapper_advanced": { + Optional: true, + Type: schema.TypeList, + Description: "Your account representative uses this behavior to implement a customized failover configuration on your behalf. Use Cloud Wrapper Advanced with an enabled `cloudWrapper` behavior in the same rule. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables failover for Cloud Wrapper.", + Type: schema.TypeBool, + }, + "failover_map": { + Optional: true, + Description: "Specifies the failover map to handle Cloud Wrapper failures. Contact your account representative for more information.", + Type: schema.TypeString, + }, + "custom_failover_map": { + ValidateDiagFunc: validateRegex("^[a-zA-Z][a-zA-Z0-9-]*$"), + Optional: true, + Description: "Specifies the custom failover map to handle Cloud Wrapper failures. Contact your account representative for more information.", + Type: schema.TypeString, + }, + }, + }, + }, + "common_media_client_data": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enable_cmcd_segment_prefetch": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + }, + }, + }, + "conditional_origin": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "origin_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-\\.]+$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "construct_response": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior constructs an HTTP response, complete with HTTP status code and body, to serve from the edge independently of your origin. It supports all request methods except for `POST`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Serves the custom response.", + Type: schema.TypeBool, + }, + "body": { + Optional: true, + Description: "HTML response of up to 2000 characters to send to the end-user client.", + Type: schema.TypeString, + }, + "response_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{200, 404, 401, 403, 405, 417, 500, 501, 502, 503, 504})), + Optional: true, + Description: "The HTTP response code to send to the end-user client.", + Type: schema.TypeInt, + }, + "force_eviction": { + Optional: true, + Description: "Removes the underlying object from the cache, since it is not being served.", + Type: schema.TypeBool, + }, + "ignore_purge": { + Optional: true, + Description: "Whether to ignore the custom response when purging.", + Type: schema.TypeBool, + }, + }, + }, + }, + "content_characteristics": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the delivered content. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "object_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the size of the object retrieved from the origin.", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LONG_TAIL", "ALL_POPULAR", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the content's expected popularity.", + Type: schema.TypeString, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the total size of the content library delivered.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"USER_GENERATED", "WEB_OBJECTS", "SOFTWARE", "IMAGES", "OTHER_OBJECTS", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the type of content.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_characteristics_amd": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the delivered content. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the total size of the content library delivered.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SD", "HD", "ULTRA_HD", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the quality of media content.", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LONG_TAIL", "ALL_POPULAR", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the content's expected popularity.", + Type: schema.TypeString, + }, + "hls": { + Optional: true, + Description: "Enable delivery of HLS media.", + Type: schema.TypeBool, + }, + "segment_duration_hls": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S", "OTHER"}, false)), + Optional: true, + Description: "Specifies the duration of individual segments.", + Type: schema.TypeString, + }, + "segment_duration_hls_custom": { + Optional: true, + Description: "Customizes the number of seconds for the segment.", + Type: schema.TypeFloat, + }, + "segment_size_hls": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "hds": { + Optional: true, + Description: "Enable delivery of HDS media.", + Type: schema.TypeBool, + }, + "segment_duration_hds": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S", "OTHER"}, false)), + Optional: true, + Description: "Specifies the duration of individual fragments.", + Type: schema.TypeString, + }, + "segment_duration_hds_custom": { + Optional: true, + Description: "Customizes the number of seconds for the fragment.", + Type: schema.TypeInt, + }, + "segment_size_hds": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "dash": { + Optional: true, + Description: "Enable delivery of DASH media.", + Type: schema.TypeBool, + }, + "segment_duration_dash": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S", "OTHER"}, false)), + Optional: true, + Description: "Specifies the duration of individual segments.", + Type: schema.TypeString, + }, + "segment_duration_dash_custom": { + Optional: true, + Description: "Customizes the number of seconds for the segment.", + Type: schema.TypeInt, + }, + "segment_size_dash": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "smooth": { + Optional: true, + Description: "Enable delivery of Smooth media.", + Type: schema.TypeBool, + }, + "segment_duration_smooth": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S", "OTHER"}, false)), + Optional: true, + Description: "Specifies the duration of individual fragments.", + Type: schema.TypeString, + }, + "segment_duration_smooth_custom": { + Optional: true, + Description: "Customizes the number of seconds for the fragment.", + Type: schema.TypeFloat, + }, + "segment_size_smooth": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_characteristics_dd": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the delivered content. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "object_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the size of the object retrieved from the origin.", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LONG_TAIL", "ALL_POPULAR", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the content's expected popularity.", + Type: schema.TypeString, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the total size of the content library delivered.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"VIDEO", "SOFTWARE", "SOFTWARE_PATCH", "GAME", "GAME_PATCH", "OTHER_DOWNLOADS", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the type of content.", + Type: schema.TypeString, + }, + "optimize_option": { + Optional: true, + Description: "Optimizes the delivery throughput and download times for large files.", + Type: schema.TypeBool, + }, + }, + }, + }, + "content_characteristics_wsd_large_file": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the delivered content, specifically targeted to delivering large files. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "object_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the size of the object retrieved from the origin.", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LONG_TAIL", "ALL_POPULAR", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the content's expected popularity.", + Type: schema.TypeString, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the total size of the content library delivered.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"VIDEO", "SOFTWARE", "SOFTWARE_PATCH", "GAME", "GAME_PATCH", "OTHER_DOWNLOADS", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the type of content.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_characteristics_wsd_live": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the delivered content, specifically targeted to delivering live video. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the total size of the content library delivered.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SD", "HD", "ULTRA_HD", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the quality of media content.", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LONG_TAIL", "ALL_POPULAR", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the content's expected popularity.", + Type: schema.TypeString, + }, + "hls": { + Optional: true, + Description: "Enable delivery of HLS media.", + Type: schema.TypeBool, + }, + "segment_duration_hls": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual segments.", + Type: schema.TypeString, + }, + "segment_size_hls": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "hds": { + Optional: true, + Description: "Enable delivery of HDS media.", + Type: schema.TypeBool, + }, + "segment_duration_hds": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual fragments.", + Type: schema.TypeString, + }, + "segment_size_hds": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "dash": { + Optional: true, + Description: "Enable delivery of DASH media.", + Type: schema.TypeBool, + }, + "segment_duration_dash": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual segments.", + Type: schema.TypeString, + }, + "segment_size_dash": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "smooth": { + Optional: true, + Description: "Enable delivery of Smooth media.", + Type: schema.TypeBool, + }, + "segment_duration_smooth": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual fragments.", + Type: schema.TypeString, + }, + "segment_size_smooth": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_characteristics_wsd_vod": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the delivered content, specifically targeted to delivering on-demand video. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the total size of the content library delivered.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SD", "HD", "ULTRA_HD", "OTHER", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the quality of media content.", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LONG_TAIL", "ALL_POPULAR", "UNKNOWN"}, false)), + Optional: true, + Description: "Optimize based on the content's expected popularity.", + Type: schema.TypeString, + }, + "hls": { + Optional: true, + Description: "Enable delivery of HLS media.", + Type: schema.TypeBool, + }, + "segment_duration_hls": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual segments.", + Type: schema.TypeString, + }, + "segment_size_hls": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "hds": { + Optional: true, + Description: "Enable delivery of HDS media.", + Type: schema.TypeBool, + }, + "segment_duration_hds": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual fragments.", + Type: schema.TypeString, + }, + "segment_size_hds": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "dash": { + Optional: true, + Description: "Enable delivery of DASH media.", + Type: schema.TypeBool, + }, + "segment_duration_dash": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual segments.", + Type: schema.TypeString, + }, + "segment_size_dash": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + "smooth": { + Optional: true, + Description: "Enable delivery of Smooth media.", + Type: schema.TypeBool, + }, + "segment_duration_smooth": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SEGMENT_DURATION_2S", "SEGMENT_DURATION_4S", "SEGMENT_DURATION_6S", "SEGMENT_DURATION_8S", "SEGMENT_DURATION_10S"}, false)), + Optional: true, + Description: "Specifies the duration of individual fragments.", + Type: schema.TypeString, + }, + "segment_size_smooth": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "ONE_MB_TO_TEN_MB", "TEN_MB_TO_100_MB", "GREATER_THAN_100MB", "UNKNOWN", "OTHER"}, false)), + Optional: true, + Description: "Specifies the size of the media object retrieved from the origin.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_pre_position": { + Optional: true, + Type: schema.TypeList, + Description: "Content Preposition. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Content PrePosition behavior.", + Type: schema.TypeBool, + }, + "source_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ORIGIN"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "targets": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLOUDWRAPPER"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "first_location": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "second_location": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "content_targeting_protection": { + Optional: true, + Type: schema.TypeList, + Description: "Content Targeting is based on `EdgeScape`, Akamai's location-based access control system. You can use it to allow or deny access to a set of geographic regions or IP addresses. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Content Targeting feature.", + Type: schema.TypeBool, + }, + "geo_protection_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_geo_protection": { + Optional: true, + Description: "When enabled, verifies IP addresses are unique to specific geographic regions.", + Type: schema.TypeBool, + }, + "geo_protection_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY"}, false)), + Optional: true, + Description: "Specifies how to handle requests.", + Type: schema.TypeString, + }, + "countries": { + Optional: true, + Description: "Specifies a set of two-character ISO 3166 country codes from which to allow or deny traffic. See `EdgeScape Data Codes` for a list.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "regions": { + Optional: true, + Description: "Specifies a set of ISO 3166-2 regional codes from which to allow or deny traffic. See `EdgeScape Data Codes` for a list.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "dmas": { + Optional: true, + Description: "Specifies the set of Designated Market Area codes from which to allow or deny traffic. See `EdgeScape Data Codes` for a list.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "override_ip_addresses": { + Optional: true, + Description: "Specify a set of IP addresses or CIDR blocks that exceptions to the set of included or excluded areas.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "enable_geo_redirect_on_deny": { + Optional: true, + Description: "When enabled, redirects denied requests rather than responding with an error code.", + Type: schema.TypeBool, + }, + "geo_redirect_url": { + Optional: true, + Description: "This specifies the full URL to the redirect page for denied requests.", + Type: schema.TypeString, + }, + "ip_protection_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_ip_protection": { + Optional: true, + Description: "Allows you to control access to your content from specific sets of IP addresses and CIDR blocks.", + Type: schema.TypeBool, + }, + "ip_protection_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY"}, false)), + Optional: true, + Description: "Specifies how to handle requests.", + Type: schema.TypeString, + }, + "ip_addresses": { + Optional: true, + Description: "Specify a set of IP addresses or CIDR blocks to allow or deny.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "enable_ip_redirect_on_deny": { + Optional: true, + Description: "When enabled, redirects denied requests rather than responding with an error code.", + Type: schema.TypeBool, + }, + "ip_redirect_url": { + Optional: true, + Description: "This specifies the full URL to the redirect page for denied requests.", + Type: schema.TypeString, + }, + "referrer_protection_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_referrer_protection": { + Optional: true, + Description: "Allows you allow traffic from certain referring websites, and disallow traffic from unauthorized sites that hijack those links.", + Type: schema.TypeBool, + }, + "referrer_protection_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY"}, false)), + Optional: true, + Description: "Specify the action to take.", + Type: schema.TypeString, + }, + "referrer_domains": { + Optional: true, + Description: "Specifies the set of domains from which to allow or deny traffic.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "enable_referrer_redirect_on_deny": { + Optional: true, + Description: "When enabled, redirects denied requests rather than responding with an error code.", + Type: schema.TypeBool, + }, + "referrer_redirect_url": { + Optional: true, + Description: "This specifies the full URL to the redirect page for denied requests.", + Type: schema.TypeString, + }, + }, + }, + }, + "cors_support": { + Optional: true, + Type: schema.TypeList, + Description: "Cross-origin resource sharing (CORS) allows web pages in one domain to access restricted resources from your domain. Specify external origin hostnames, methods, and headers that you want to accept via HTTP response headers. Full support of CORS requires allowing requests that use the OPTIONS method. See `allowOptions`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables CORS feature.", + Type: schema.TypeBool, + }, + "allow_origins": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ANY", "SPECIFIED"}, false)), + Optional: true, + Description: "In responses to preflight requests, sets which origin hostnames to accept requests from.", + Type: schema.TypeString, + }, + "origins": { + Optional: true, + Description: "Defines the origin hostnames to accept requests from. The hostnames that you enter need to start with `http` or `https`. For detailed hostname syntax requirements, refer to RFC-952 and RFC-1123 specifications.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "allow_credentials": { + Optional: true, + Description: "Accepts requests made using credentials, like cookies or TLS client certificates.", + Type: schema.TypeBool, + }, + "allow_headers": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ANY", "SPECIFIED"}, false)), + Optional: true, + Description: "In responses to preflight requests, defines which headers to allow when making the actual request.", + Type: schema.TypeString, + }, + "headers": { + Optional: true, + Description: "Defines the supported request headers.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "methods": { + Optional: true, + Description: "Specifies any combination of the following methods: `DELETE`, `GET`, `PATCH`, `POST`, and `PUT` that are allowed when accessing the resource from an external domain.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "expose_headers": { + Optional: true, + Description: "In responses to preflight requests, lists names of headers that clients can access. By default, clients can access the following simple response headers: `Cache-Control`, `Content-Language`, `Content-Type`, `Expires`, `Last-Modified`, and `Pragma`. You can add other header names to make them accessible to clients.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "preflight_max_age": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Defines the number of seconds that the browser should cache the response to a preflight request.", + Type: schema.TypeString, + }, + }, + }, + }, + "cp_code": { + Optional: true, + Type: schema.TypeList, + Description: "Content Provider Codes (CP codes) allow you to distinguish various reporting and billing segments. You receive a CP code when purchasing Akamai service, and you need it to access properties. This behavior allows you to apply any valid CP code, including additional ones you may request from Akamai Professional Services. For a CP code to be valid, it needs to belong to the same contract and be associated with the same product as the property, and the group needs access to it. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + Optional: true, + Description: "Specifies a `value` object, which includes an `id` key and a descriptive `name`.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "custom_behavior": { + Optional: true, + Type: schema.TypeList, + Description: "Allows you to insert a customized XML metadata behavior into any property's rule tree. Talk to your Akamai representative to implement the customized behavior. Once it's ready, run PAPI's `List custom behaviors` operation, then apply the relevant `behaviorId` value from the response within the current `customBehavior`. See `Custom behaviors and overrides` for guidance on custom metadata behaviors. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior_id": { + Optional: true, + Description: "The unique identifier for the predefined custom behavior you want to insert into the current rule.", + Type: schema.TypeString, + }, + }, + }, + }, + "datastream": { + Optional: true, + Type: schema.TypeList, + Description: "The `DataStream` reporting service provides real-time logs on application activity, including aggregated metrics on complete request and response cycles and origin response times. Apply this behavior to report on this set of traffic. Use the `DataStream API` to aggregate the data. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "stream_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BEACON", "LOG", "BEACON_AND_LOG"}, false)), + Optional: true, + Description: "Specify the DataStream type.", + Type: schema.TypeString, + }, + "beacon_stream_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables DataStream reporting.", + Type: schema.TypeBool, + }, + "datastream_ids": { + ValidateDiagFunc: validateRegex("^[0-9]+(-[0-9]+)*$"), + Optional: true, + Description: "A set of dash-separated DataStream ID values to limit the scope of reported data. By default, all active streams report. Use the DataStream application to gather stream ID values that apply to this property configuration. Specifying IDs for any streams that don't apply to this property has no effect, and results in no data reported.", + Type: schema.TypeString, + }, + "log_stream_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "log_enabled": { + Optional: true, + Description: "Enables log collection for the property by associating it with DataStream configurations.", + Type: schema.TypeBool, + }, + "log_stream_name": { + Optional: true, + Description: "Specifies the unique IDs of streams configured for the property. For properties created with the previous version of the rule format, this option contains a string instead of an array of strings. You can use the `List streams` operation to get stream IDs.", + Type: schema.TypeString, + }, + "sampling_percentage": { + Optional: true, + Description: "Specifies the percentage of log data you want to collect for this property.", + Type: schema.TypeInt, + }, + "collect_midgress_traffic": { + Optional: true, + Description: "If enabled, gathers midgress traffic data within the Akamai platform, such as between two edge servers, for all streams configured.", + Type: schema.TypeBool, + }, + }, + }, + }, + "dcp": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. (The `IoT Edge Connect API` allows programmatic access.) This behavior allows you to select previously reserved namespaces and set the protocols for users to publish and receive messages within these namespaces. Use the `verifyJsonWebTokenForDcp` behavior to control access. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables IoT Edge Connect.", + Type: schema.TypeBool, + }, + "namespace_id": { + Optional: true, + Description: "Specifies the globally reserved name for a specific configuration. It includes authorization rules over publishing and subscribing to logical categories known as `topics`. This provides a root path for all topics defined within a namespace configuration. You can use the `IoT Edge Connect API` to configure access control lists for your namespace configuration.", + Type: schema.TypeString, + }, + "tlsenabled": { + Optional: true, + Description: "When enabled, you can publish and receive messages over a secured MQTT connection on port 8883.", + Type: schema.TypeBool, + }, + "wsenabled": { + Optional: true, + Description: "When enabled, you can publish and receive messages through a secured MQTT connection over WebSockets on port 443.", + Type: schema.TypeBool, + }, + "gwenabled": { + Optional: true, + Description: "When enabled, you can publish and receive messages over a secured HTTP connection on port 443.", + Type: schema.TypeBool, + }, + "anonymous": { + Optional: true, + Description: "When enabled, you don't need to pass the JWT token with the mqtt request, and JWT validation is skipped.", + Type: schema.TypeBool, + }, + }, + }, + }, + "dcp_auth_hmac_transformation": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. In conjunction with `dcpAuthVariableExtractor`, this behavior affects how clients can authenticate themselves to edge servers, and which groups within namespaces are authorized to access topics. It transforms a source string value extracted from the client certificate and stored as a variable, then generates a hash value based on the selected algorithm, for use in authenticating the client request. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "hash_conversion_algorithm": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SHA256", "MD5", "SHA384"}, false)), + Optional: true, + Description: "Specifies the hash algorithm.", + Type: schema.TypeString, + }, + "hash_conversion_key": { + Optional: true, + Description: "Specifies the key to generate the hash, ideally a long random string to ensure adequate security.", + Type: schema.TypeString, + }, + }, + }, + }, + "dcp_auth_regex_transformation": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. In conjunction with `dcpAuthVariableExtractor`, this behavior affects how clients can authenticate themselves to edge servers, and which groups within namespaces are authorized to access topics. It transforms a source string value extracted from the client certificate and stored as a variable, then transforms the string based on a regular expression search pattern, for use in authenticating the client request. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "regex_pattern": { + ValidateDiagFunc: validateRegex("^[^\\(\\)]*\\([^\\(\\)]+\\)[^\\(\\)]*$"), + Optional: true, + Description: "Specifies a Perl-compatible regular expression with a single grouping to capture the text. For example, a value of `^.(.{0,10})` omits the first character, but then captures up to 10 characters after that. If the regular expression does not capture a substring, authentication may fail.", + Type: schema.TypeString, + }, + }, + }, + }, + "dcp_auth_substring_transformation": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. In conjunction with `dcpAuthVariableExtractor`, this behavior affects how clients can authenticate themselves to edge servers, and which groups within namespaces are authorized to access topics. It transforms a source string value extracted from the client certificate and stored as a variable, then extracts a substring, for use in authenticating the client request. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "substring_start": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "The zero-based index offset of the first character to extract. If the index is out of bound from the string's length, authentication may fail.", + Type: schema.TypeString, + }, + "substring_end": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "The zero-based index offset of the last character to extract, where `-1` selects the remainder of the string. If the index is out of bound from the string's length, authentication may fail.", + Type: schema.TypeString, + }, + }, + }, + }, + "dcp_auth_variable_extractor": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. This behavior affects how clients can authenticate themselves to edge servers, and which groups within namespaces are authorized to access topics. When enabled, this behavior allows end users to authenticate their requests with valid x509 client certificates. Either a client identifier or access authorization groups are required to make the request valid. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "certificate_field": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SUBJECT_DN", "V3_SUBJECT_ALT_NAME", "SERIAL", "FINGERPRINT_DYN", "FINGERPRINT_MD5", "FINGERPRINT_SHA1", "V3_NETSCAPE_COMMENT"}, false)), + Optional: true, + Description: "Specifies the field in the client certificate to extract the variable from.", + Type: schema.TypeString, + }, + "dcp_mutual_auth_processing_variable_id": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"VAR_DCP_CLIENT_ID", "VAR_DCP_AUTH_GROUP"}, false)), + Optional: true, + Description: "Where to store the value.", + Type: schema.TypeString, + }, + }, + }, + }, + "dcp_default_authz_groups": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. This behavior defines a set of default authorization groups to add to each request the property configuration controls. These groups have access regardless of the authentication method you use, either JWT using the `verifyJsonWebTokenForDcp` behavior, or mutual authentication using the `dcpAuthVariableExtractor` behavior to control where authorization groups are extracted from within certificates. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "group_names": { + Optional: true, + Description: "Specifies the set of authorization groups to assign to all connecting devices.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "dcp_dev_relations": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. This behavior allows Akamai-external clients to use developer test accounts in a shared environment. In conjunction with `verifyJsonWebTokenForDcp`, this behavior allows you to use your own JWTs in your requests, or those generated by Akamai. It lets you either enable the default JWT server for your test configuration by setting the authentication endpoint to a default path, or specify custom settings for your JWT server and the authentication endpoint. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the default JWT server and sets the authentication endpoint to a default path.", + Type: schema.TypeBool, + }, + "custom_values": { + Optional: true, + Description: "Allows you to specify custom JWT server connection values.", + Type: schema.TypeBool, + }, + "hostname": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9]([a-zA-Z0-9_\\-]*[a-zA-Z0-9])?)\\.)+([a-zA-Z]+|xn--[a-zA-Z0-9]+)$"), + Optional: true, + Description: "Specifies the JWT server's hostname.", + Type: schema.TypeString, + }, + "path": { + Optional: true, + Description: "Specifies the path to your JWT server's authentication endpoint. This lets you generate JWTs to sign your requests.", + Type: schema.TypeString, + }, + }, + }, + }, + "dcp_real_time_auth": { + Optional: true, + Type: schema.TypeList, + Description: "INTERNAL ONLY: The `Internet of Things: Edge Connect` product allows connected users and devices to communicate on a publish-subscribe basis within reserved namespaces. This behavior lets you configure the real time authentication to edge servers. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "extract_namespace": { + Optional: true, + Description: "Extracts a namespace from JSON web tokens (JWT).", + Type: schema.TypeBool, + }, + "namespace_claim": { + Optional: true, + Description: "Specifies the claim in JWT to extract the namespace from.", + Type: schema.TypeString, + }, + "extract_jurisdiction": { + Optional: true, + Description: "Extracts a jurisdiction that defines a geographically distributed set of servers from JWT.", + Type: schema.TypeBool, + }, + "jurisdiction_claim": { + Optional: true, + Description: "Specifies the claim in JWT to extract the jurisdiction from.", + Type: schema.TypeString, + }, + "extract_hostname": { + Optional: true, + Description: "Extracts a hostname from JWT.", + Type: schema.TypeBool, + }, + "hostname_claim": { + Optional: true, + Description: "Specifies the claim in JWT to extract the hostname from.", + Type: schema.TypeString, + }, + }, + }, + }, + "delivery_receipt": { + Optional: true, + Type: schema.TypeList, + Description: "A static behavior that's required when specifying the Cloud Monitor module's (`edgeConnect` behavior. You can only apply this behavior if the property is marked as secure. See `Secure property requirements` for guidance. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "deny_access": { + Optional: true, + Type: schema.TypeList, + Description: "Assuming a condition in the rule matches, this denies access to the requested content. For example, a `userLocation` match paired with this behavior would deny requests from a specified part of the world. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "reason": { + ValidateDiagFunc: validateRegex("^[\\w-]+$"), + Optional: true, + Description: "Text message that keys why access is denied. Any subsequent `denyAccess` behaviors within the rule tree may refer to the same `reason` key to override the current behavior.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Denies access when enabled.", + Type: schema.TypeBool, + }, + }, + }, + }, + "deny_direct_failover_access": { + Optional: true, + Type: schema.TypeList, + Description: "A static behavior required for all properties that implement a failover under the Cloud Security Failover product. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "device_characteristic_cache_id": { + Optional: true, + Type: schema.TypeList, + Description: "By default, source URLs serve as cache IDs on edge servers. Electronic Data Capture allows you to specify an additional set of device characteristics to generate separate cache keys. Use this in conjunction with the `deviceCharacteristicHeader` behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "elements": { + Optional: true, + Description: "Specifies a set of information about the device with which to generate a separate cache key.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "device_characteristic_header": { + Optional: true, + Type: schema.TypeList, + Description: "Sends selected information about requesting devices to the origin server, in the form of an `X-Akamai-Device-Characteristics` HTTP header. Use in conjunction with the `deviceCharacteristicCacheId` behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "elements": { + Optional: true, + Description: "Specifies the set of information about the requesting device to send to the origin server.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "dns_async_refresh": { + Optional: true, + Type: schema.TypeList, + Description: "Allow an edge server to use an expired DNS record when forwarding a request to your origin. The `type A` DNS record refreshes `after` content is served to the end user, so there is no wait for the DNS resolution. Avoid this behavior if you want to be able to disable a server immediately after its DNS record expires. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows edge servers to refresh an expired DNS record after serving content.", + Type: schema.TypeBool, + }, + "timeout": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Set the maximum allowed time an expired DNS record may be active.", + Type: schema.TypeString, + }, + }, + }, + }, + "dns_prefresh": { + Optional: true, + Type: schema.TypeList, + Description: "Allows edge servers to refresh your origin's DNS record independently from end-user requests. The `type A` DNS record refreshes before the origin's DNS record expires. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows edge servers to refresh DNS records before they expire.", + Type: schema.TypeBool, + }, + "delay": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the amount of time following a DNS record's expiration to asynchronously prefresh it.", + Type: schema.TypeString, + }, + "timeout": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the amount of time to prefresh a DNS entry if there have been no requests to the domain name.", + Type: schema.TypeString, + }, + }, + }, + }, + "downgrade_protocol": { + Optional: true, + Type: schema.TypeList, + Description: "Serve static objects to the end-user client over HTTPS, but fetch them from the origin via HTTP. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the protocol downgrading behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "download_complete_marker": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: OTA Updates` product allows customers to securely distribute firmware to devices over cellular networks. Based on match criteria that executes a rule, this behavior logs requests to the OTA servers as completed in aggregated and individual reports. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "download_notification": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: OTA Updates` product allows customers to securely distribute firmware to devices over cellular networks. Based on match criteria that executes a rule, this behavior allows requests to the `OTA Updates API` for a list of completed downloads to individual vehicles. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "downstream_cache": { + Optional: true, + Type: schema.TypeList, + Description: "Specify the caching instructions the edge server sends to the end user's client or client proxies. By default, the cache's duration is whichever is less: the remaining lifetime of the edge cache, or what the origin's header specifies. If the origin is set to `no-store` or `bypass-cache`, edge servers send `cache-busting` headers downstream to prevent downstream caching. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "MUST_REVALIDATE", "BUST", "TUNNEL_ORIGIN", "NONE"}, false)), + Optional: true, + Description: "Specify the caching instructions the edge server sends to the end user's client.", + Type: schema.TypeString, + }, + "allow_behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESSER", "GREATER", "REMAINING_LIFETIME", "FROM_MAX_AGE", "FROM_VALUE", "PASS_ORIGIN"}, false)), + Optional: true, + Description: "Specify how the edge server calculates the downstream cache by setting the value of the `Expires` header.", + Type: schema.TypeString, + }, + "ttl": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Sets the duration of the cache. Setting the value to `0` equates to a `no-cache` header that forces revalidation.", + Type: schema.TypeString, + }, + "send_headers": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL_AND_EXPIRES", "CACHE_CONTROL", "EXPIRES", "PASS_ORIGIN"}, false)), + Optional: true, + Description: "Specifies the HTTP headers to include in the response to the client.", + Type: schema.TypeString, + }, + "send_private": { + Optional: true, + Description: "Adds a `Cache-Control: private` header to prevent objects from being cached in a shared caching proxy.", + Type: schema.TypeBool, + }, + }, + }, + }, + "dynamic_throughtput_optimization": { + Optional: true, + Type: schema.TypeList, + Description: "Enables `quick retry`, which detects slow forward throughput while fetching an object, and attempts a different forward connection path to avoid congestion. By default, connections under 5 mbps trigger this behavior. When the transfer rate drops below this rate during a connection attempt, quick retry is enabled and a different forward connection path is used. Contact Akamai Professional Services to override this threshold. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the quick retry feature.", + Type: schema.TypeBool, + }, + }, + }, + }, + "dynamic_throughtput_optimization_override": { + Optional: true, + Type: schema.TypeList, + Description: "This overrides the default threshold of 5 Mbps that triggers the `dynamicThroughtputOptimization` behavior, which enables the quick retry feature. Quick retry detects slow forward throughput while fetching an object, and attempts a different forward connection path to avoid congestion. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "throughput": { + Optional: true, + Description: "Specifies the default target forward throughput in Mbps, ranging from 2 to 50 Mbps. If this time is exceeded during a connection attempt, quick retry is enabled and a different forward connection path is used.", + Type: schema.TypeString, + }, + }, + }, + }, + "dynamic_web_content": { + Optional: true, + Type: schema.TypeList, + Description: "In conjunction with the `subCustomer` behavior, this optional behavior allows you to control how dynamic web content behaves for your subcustomers using `Akamai Cloud Embed`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "sure_route": { + Optional: true, + Description: "Optimizes how subcustomer traffic routes from origin to edge servers. See the `sureRoute` behavior for more information.", + Type: schema.TypeBool, + }, + "prefetch": { + Optional: true, + Description: "Allows subcustomer content to prefetch over HTTP/2.", + Type: schema.TypeBool, + }, + "real_user_monitoring": { + Optional: true, + Description: "Allows Real User Monitoring (RUM) to collect performance data for subcustomer content. See the `realUserMonitoring` behavior for more information.", + Type: schema.TypeBool, + }, + "image_compression": { + Optional: true, + Description: "Enables image compression for subcustomer content.", + Type: schema.TypeBool, + }, + }, + }, + }, + "ecms_bulk_upload": { + Optional: true, + Type: schema.TypeList, + Description: "Uploads a ZIP archive with objects to an existing data set. The target data set stores objects as key-value pairs. The path to an object in the ZIP archive is a key, and the content of an object is a value. For an overview, see `ecmsDatabase`. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables sending a compressed archive file with objects. Sends the archive file to the default path of the target data set: `/bulk//`.", + Type: schema.TypeBool, + }, + }, + }, + }, + "ecms_database": { + Optional: true, + Type: schema.TypeList, + Description: "Edge Connect Message Store is available for `Internet of Things: Edge Connect` users. It lets you create databases and data sets within these databases. You can use this object store to save files smaller than 2 GB. `ecmsDatabase` specifies a default database for requests to this property, unless indicated otherwise in the URL. To access objects in the default database, you can skip its name in the URLs. To access objects in a different database, pass its name in the header, query parameter, or a regular expression matching a URL segment. You can also configure the `ecmsDataset` behavior to specify a default data set for requests. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "database": { + Optional: true, + Description: "Specifies a default database for this property. If you don't configure a default data set in the `ecmsDataset` behavior, requests to objects in this database follow the pattern: `/datastore//`.", + Type: schema.TypeString, + }, + "extract_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQUEST_HEADER", "QUERY_STRING", "REGEX"}, false)), + Optional: true, + Description: "Specifies where to pass a database name in requests. If the specified location doesn't include the database name or the name doesn't match the regular expression, the default database is used.", + Type: schema.TypeString, + }, + "header_name": { + Optional: true, + Description: "Specifies the request header that passed the database name. By default, it points to `X-KV-Database`.", + Type: schema.TypeString, + }, + "query_parameter_name": { + Optional: true, + Description: "Specifies the query string parameter that passed the database name. By default, it points to `database`.", + Type: schema.TypeString, + }, + "regex_pattern": { + ValidateDiagFunc: validateRegex("^[^\\(\\)]*\\([^\\(\\)]+\\)[^\\(\\)]*$"), + Optional: true, + Description: "Specifies the regular expression that matches the database name in the URL.", + Type: schema.TypeString, + }, + }, + }, + }, + "ecms_dataset": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies a default data set for requests to this property unless indicated otherwise in the URL. To access objects in this data set, you can skip the data set name in the URLs. To access objects in a different data set within a database, pass the data set name in the header, query parameter, or a regular expression pattern matching a URL segment. You can also configure the `ecmsDatabase` behavior to specify a default database for requests. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "dataset": { + Optional: true, + Description: "Specifies a default data set for this property. If you don't configure a default database in the `ecmsDatabase` behavior, requests to objects in this data set follow the pattern: `/datastore//`.", + Type: schema.TypeString, + }, + "extract_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQUEST_HEADER", "QUERY_STRING", "REGEX"}, false)), + Optional: true, + Description: "Specifies where to pass a data set name in requests. If the specified location doesn't include the data set name or the name doesn't match the regular expression pattern, the default data set is used.", + Type: schema.TypeString, + }, + "header_name": { + Optional: true, + Description: "Specifies the request header that passed the data set name. By default, it points to `X-KV-Dataset`.", + Type: schema.TypeString, + }, + "query_parameter_name": { + Optional: true, + Description: "Specifies the query string parameter that passed the data set name. By default, it points to `dataset`.", + Type: schema.TypeString, + }, + "regex_pattern": { + ValidateDiagFunc: validateRegex("^[^\\(\\)]*\\([^\\(\\)]+\\)[^\\(\\)]*$"), + Optional: true, + Description: "Specifies the regular expression that matches the data set name in the URL.", + Type: schema.TypeString, + }, + }, + }, + }, + "ecms_object_key": { + Optional: true, + Type: schema.TypeList, + Description: "Defines a regular expression to match object keys in custom URLs and to access objects in a data set. You can point custom URLs to access proper values in the target data set. For an overview, see `ecmsDatabase`. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "regex": { + ValidateDiagFunc: validateRegex("^[^\\(\\)]*\\([^\\(\\)]+\\)[^\\(\\)]*$"), + Optional: true, + Description: "Enables sending a compressed archive file with objects to the default path of the target data set: `/bulk//`.", + Type: schema.TypeString, + }, + }, + }, + }, + "edge_connect": { + Optional: true, + Type: schema.TypeList, + Description: "Configures traffic logs for the Cloud Monitor push API. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables Cloud Monitor's log-publishing behavior.", + Type: schema.TypeBool, + }, + "api_connector": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DEFAULT", "SIEM_JSON", "BMC_APM"}, false)), + Optional: true, + Description: "Describes the API connector type.", + Type: schema.TypeString, + }, + "api_data_elements": { + Optional: true, + Description: "Specifies the data set to log.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "destination_hostname": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies the target hostname accepting push API requests.", + Type: schema.TypeString, + }, + "destination_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the push API's endpoint.", + Type: schema.TypeString, + }, + "override_aggregate_settings": { + Optional: true, + Description: "When enabled, overrides default log settings.", + Type: schema.TypeBool, + }, + "aggregate_time": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies how often logs are generated.", + Type: schema.TypeString, + }, + "aggregate_lines": { + ValidateDiagFunc: validateRegex("^[1-9]\\d*$"), + Optional: true, + Description: "Specifies the maximum number of lines to include in each log.", + Type: schema.TypeString, + }, + "aggregate_size": { + ValidateDiagFunc: validateRegex("^\\d+[K,M,G,T]B$"), + Optional: true, + Description: "Specifies the log's maximum size.", + Type: schema.TypeString, + }, + }, + }, + }, + "edge_load_balancing_advanced": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior implements customized Edge Load Balancing features. Contact Akamai Professional Services for help configuring it. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "description": { + Optional: true, + Description: "A description of what the `xml` block does.", + Type: schema.TypeString, + }, + "xml": { + Optional: true, + Description: "A block of Akamai XML metadata.", + Type: schema.TypeString, + }, + }, + }, + }, + "edge_load_balancing_data_center": { + Optional: true, + Type: schema.TypeList, + Description: "The Edge Load Balancing module allows you to specify groups of data centers that implement load balancing, session persistence, and real-time dynamic failover. Enabling ELB routes requests contextually based on location, device, or network, along with optional rules you specify. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "origin_id": { + Optional: true, + Description: "Corresponds to the `id` specified by the `edgeLoadBalancingOrigin` behavior associated with this data center.", + Type: schema.TypeString, + }, + "description": { + Optional: true, + Description: "Provides a description for the ELB data center, for your own reference.", + Type: schema.TypeString, + }, + "hostname": { + ValidateDiagFunc: validateAny(validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), validateRegex("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")), + Optional: true, + Description: "Specifies the data center's hostname.", + Type: schema.TypeString, + }, + "cookie_name": { + ValidateDiagFunc: validateRegex("^[^\\s;]+$"), + Optional: true, + Description: "If using session persistence, this specifies the value of the cookie named in the corresponding `edgeLoadBalancingOrigin` behavior's `cookie_name` option.", + Type: schema.TypeString, + }, + "failover_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_failover": { + Optional: true, + Description: "Allows you to specify failover rules.", + Type: schema.TypeBool, + }, + "ip": { + ValidateDiagFunc: validateRegex("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"), + Optional: true, + Description: "Specifies this data center's IP address.", + Type: schema.TypeString, + }, + "failover_rules": { + Optional: true, + Description: "Provides up to four failover rules to apply in the specified order.", + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "failover_hostname": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "The hostname of the data center to fail over to.", + Type: schema.TypeString, + }, + "modify_request": { + Optional: true, + Description: "Allows you to modify the request's hostname or path.", + Type: schema.TypeBool, + }, + "override_hostname": { + Optional: true, + Description: "Overrides the request's hostname with the `failover_hostname`.", + Type: schema.TypeBool, + }, + "context_root": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the path to use in the forwarding request, typically the root (`/`) when failing over to a different data center, or a full path such as `/static/error.html` when failing over to an error page.", + Type: schema.TypeString, + }, + "absolute_path": { + Optional: true, + Description: "When enabled, interprets the path specified by `context_root` as an absolute server path, for example to reference a site-down page. Otherwise when disabled, the path is appended to the request.", + Type: schema.TypeBool, + }, + }, + }, + }, + }, + }, + }, + "edge_load_balancing_origin": { + Optional: true, + Type: schema.TypeList, + Description: "The Edge Load Balancing module allows you to implement groups of data centers featuring load balancing, session persistence, and real-time dynamic failover. Enabling ELB routes requests contextually based on location, device, or network, along with optional rules you specify. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "id": { + Optional: true, + Description: "Specifies a unique descriptive string for this ELB origin. The value needs to match the `origin_id` specified by the `edgeLoadBalancingDataCenter` behavior associated with this origin.", + Type: schema.TypeString, + }, + "description": { + Optional: true, + Description: "Provides a description for the ELB origin, for your own reference.", + Type: schema.TypeString, + }, + "hostname": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies the hostname associated with the ELB rule.", + Type: schema.TypeString, + }, + "session_persistence_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_session_persistence": { + Optional: true, + Description: "Allows you to specify a cookie to pin the user's browser session to one data center. When disabled, ELB's default load balancing may send users to various data centers within the same session.", + Type: schema.TypeBool, + }, + "cookie_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This specifies the name of the cookie that marks users' persistent sessions. The accompanying `edgeLoadBalancingDataCenter` behavior's `description` option specifies the cookie's value.", + Type: schema.TypeString, + }, + }, + }, + }, + "edge_origin_authorization": { + Optional: true, + Type: schema.TypeList, + Description: "Allows the origin server to use a cookie to ensure requests from Akamai servers are genuine. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the cookie-authorization behavior.", + Type: schema.TypeBool, + }, + "cookie_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the name of the cookie to use for authorization.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[^\\s;]+$"), + Optional: true, + Description: "Specifies the value of the authorization cookie.", + Type: schema.TypeString, + }, + "domain": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specify the cookie's domain, which needs to match the top-level domain of the `Host` header the origin server receives.", + Type: schema.TypeString, + }, + }, + }, + }, + "edge_redirector": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior enables the `Edge Redirector Cloudlet` application, which helps you manage large numbers of redirects. With Cloudlets available on your contract, choose `Your services` > `Edge logic Cloudlets` to control the Edge Redirector within `Control Center`. Otherwise use the `Cloudlets API` to configure it programmatically. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Edge Redirector Cloudlet.", + Type: schema.TypeBool, + }, + "is_shared_policy": { + Optional: true, + Description: "Whether you want to apply the Cloudlet shared policy to an unlimited number of properties within your account. Learn more about shared policies and how to create them in `Cloudlets Policy Manager`.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Specifies the Cloudlet policy as an object.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "Identifies the Cloudlet shared policy to use with this behavior. Use the `Cloudlets API` to list available shared policies.", + Type: schema.TypeInt, + }, + }, + }, + }, + "edge_scape": { + Optional: true, + Type: schema.TypeList, + Description: "`EdgeScape` allows you to customize content based on the end user's geographic location or connection speed. When enabled, the edge server sends a special `X-Akamai-Edgescape` header to the origin server encoding relevant details about the end-user client as key-value pairs. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, sends the `X-Akamai-Edgescape` request header to the origin.", + Type: schema.TypeBool, + }, + }, + }, + }, + "edge_side_includes": { + Optional: true, + Type: schema.TypeList, + Description: "Allows edge servers to process edge side include (ESI) code to generate dynamic content. To apply this behavior, you need to match on a `contentType`, `path`, or `filename`. Since this behavior requires more parsing time, you should not apply it to pages that lack ESI code, or to any non-HTML content. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables ESI processing.", + Type: schema.TypeBool, + }, + "enable_via_http": { + Optional: true, + Description: "Enable ESI only for content featuring the `Edge-control: dca=esi` HTTP response header.", + Type: schema.TypeBool, + }, + "pass_set_cookie": { + Optional: true, + Description: "Allows edge servers to pass your origin server's cookies to the ESI processor.", + Type: schema.TypeBool, + }, + "pass_client_ip": { + Optional: true, + Description: "Allows edge servers to pass the client IP header to the ESI processor.", + Type: schema.TypeBool, + }, + "i18n_status": { + Optional: true, + Description: "Provides internationalization support for ESI.", + Type: schema.TypeBool, + }, + "i18n_charset": { + Optional: true, + Description: "Specifies the character sets to use when transcoding the ESI language, `UTF-8` and `ISO-8859-1` for example.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "detect_injection": { + Optional: true, + Description: "Denies attempts to inject ESI code.", + Type: schema.TypeBool, + }, + }, + }, + }, + "edge_worker": { + Optional: true, + Type: schema.TypeList, + Description: "`EdgeWorkers` are JavaScript applications that allow you to manipulate your web traffic on edge servers outside of Property Manager behaviors, and deployed independently from your configuration's logic. This behavior applies an EdgeWorker to a set of edge requests. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, applies specified EdgeWorker functionality to this rule's web traffic.", + Type: schema.TypeBool, + }, + "create_edge_worker": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "edge_worker_id": { + Optional: true, + Description: "Identifies the EdgeWorker application to apply to this rule's web traffic. You can use the `EdgeWorkers API` to get this value.", + Type: schema.TypeString, + }, + "resource_tier": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "enhanced_akamai_protocol": { + Optional: true, + Type: schema.TypeList, + Description: "Enables the Enhanced Akamai Protocol, a suite of advanced routing and transport optimizations that increase your website's performance and reliability. It is only available to specific applications, and requires a special routing from edge to origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "display": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "enhanced_proxy_detection": { + Optional: true, + Type: schema.TypeList, + Description: "Enhanced Proxy Detection (EPD) leverages the GeoGuard service provided by GeoComply to add proxy detection and location spoofing protection. It identifies requests for your content that have been redirected from an unwanted source through a proxy. You can then allow, deny, or redirect these requests. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Applies GeoGuard proxy detection.", + Type: schema.TypeBool, + }, + "forward_header_enrichment": { + Optional: true, + Description: "Whether the Enhanced Proxy Detection (Akamai-EPD) header is included in the forward request to mark a connecting IP address as an anonymous proxy, with a two-letter designation. See the `epdForwardHeaderEnrichment` behavior for details.", + Type: schema.TypeBool, + }, + "enable_configuration_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BEST_PRACTICE", "ADVANCED"}, false)), + Optional: true, + Description: "Specifies how to field the proxy request.", + Type: schema.TypeString, + }, + "best_practice_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "Specifies how to field the proxy request.", + Type: schema.TypeString, + }, + "best_practice_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect requests.", + Type: schema.TypeString, + }, + "anonymous_vpn": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_anonymous_vpn": { + Optional: true, + Description: "This enables detection of requests from anonymous VPNs.", + Type: schema.TypeBool, + }, + "detect_anonymous_vpn_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "Specifies how to field anonymous VPN requests.", + Type: schema.TypeString, + }, + "detect_anonymous_vpn_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect anonymous VPN requests.", + Type: schema.TypeString, + }, + "public_proxy": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_public_proxy": { + Optional: true, + Description: "This enables detection of requests from public proxies.", + Type: schema.TypeBool, + }, + "detect_public_proxy_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "Specifies how to field public proxy requests.", + Type: schema.TypeString, + }, + "detect_public_proxy_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect public proxy requests.", + Type: schema.TypeString, + }, + "tor_exit_node": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_tor_exit_node": { + Optional: true, + Description: "This enables detection of requests from Tor exit nodes.", + Type: schema.TypeBool, + }, + "detect_tor_exit_node_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "This specifies whether to `DENY`, `ALLOW`, or `REDIRECT` requests from Tor exit nodes.", + Type: schema.TypeString, + }, + "detect_tor_exit_node_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect requests from Tor exit nodes.", + Type: schema.TypeString, + }, + "smart_dns_proxy": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_smart_dns_proxy": { + Optional: true, + Description: "This enables detection of requests from smart DNS proxies.", + Type: schema.TypeBool, + }, + "detect_smart_dns_proxy_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "Specifies whether to `DENY`, `ALLOW`, or `REDIRECT` smart DNS proxy requests.", + Type: schema.TypeString, + }, + "detect_smart_dns_proxy_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect DNS proxy requests.", + Type: schema.TypeString, + }, + "hosting_provider": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_hosting_provider": { + Optional: true, + Description: "This detects requests from a hosting provider.", + Type: schema.TypeBool, + }, + "detect_hosting_provider_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "This specifies whether to `DENY`, `ALLOW`, or `REDIRECT` requests from hosting providers.", + Type: schema.TypeString, + }, + "detect_hosting_provider_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the absolute URL to which to redirect requests from hosting providers.", + Type: schema.TypeString, + }, + "vpn_data_center": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_vpn_data_center": { + Optional: true, + Description: "This enables detection of requests from VPN data centers.", + Type: schema.TypeBool, + }, + "detect_vpn_data_center_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "This specifies whether to `DENY`, `ALLOW`, or `REDIRECT` requests from VPN data centers.", + Type: schema.TypeString, + }, + "detect_vpn_data_center_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect requests from VPN data centers.", + Type: schema.TypeString, + }, + "residential_proxy": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_residential_proxy": { + Optional: true, + Description: "This enables detection of requests from a residential proxy. See `Enhanced Proxy Detection with GeoGuard` and learn more about this GeoGuard category before enabling it.", + Type: schema.TypeBool, + }, + "detect_residential_proxy_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALLOW", "DENY", "REDIRECT"}, false)), + Optional: true, + Description: "This specifies whether to `DENY`, `ALLOW`, or `REDIRECT` requests from residential proxies.", + Type: schema.TypeString, + }, + "detect_residential_proxy_redirecturl": { + ValidateDiagFunc: validateRegex("(http|https)://(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?"), + Optional: true, + Description: "This specifies the URL to which to redirect requests.", + Type: schema.TypeString, + }, + }, + }, + }, + "epd_forward_header_enrichment": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior identifies unwanted requests from an anonymous proxy. This and the `enhancedProxyDetection` behavior work together and need to be included either in the same rule, or in the default one. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Sends the Enhanced Proxy Detection (`Akamai-EPD`) header in the forward request to determine whether the connecting IP address is an anonymous proxy. The header can contain one or more two-letter codes that indicate the IP address type detected by edge servers:", + Type: schema.TypeBool, + }, + }, + }, + }, + "fail_action": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies how to respond when the origin is not available: by serving stale content, by serving an error page, or by redirecting. To apply this behavior, you should match on an `originTimeout` or `matchResponseCode`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled in case of a failure to contact the origin, the current behavior applies.", + Type: schema.TypeBool, + }, + "action_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SERVE_STALE", "REDIRECT", "RECREATED_CO", "RECREATED_CEX", "RECREATED_NS", "DYNAMIC"}, false)), + Optional: true, + Description: "Specifies the basic action to take when there is a failure to contact the origin.", + Type: schema.TypeString, + }, + "saas_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HOSTNAME", "PATH", "QUERY_STRING", "COOKIE"}, false)), + Optional: true, + Description: "Identifies the component of the request that identifies the SaaS dynamic fail action.", + Type: schema.TypeString, + }, + "saas_cname_enabled": { + Optional: true, + Description: "Specifies whether to use a CNAME chain to determine the hostname for the SaaS dynamic failaction.", + Type: schema.TypeBool, + }, + "saas_cname_level": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the number of elements in the CNAME chain backwards from the edge hostname that determines the hostname for the SaaS dynamic failaction.", + Type: schema.TypeInt, + }, + "saas_cookie": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the name of the cookie that identifies this SaaS dynamic failaction.", + Type: schema.TypeString, + }, + "saas_query_string": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "Specifies the name of the query parameter that identifies this SaaS dynamic failaction.", + Type: schema.TypeString, + }, + "saas_regex": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9\\:\\[\\]\\{\\}\\(\\)\\.\\?_\\-\\*\\+\\^\\$\\\\\\/\\|&=!]{1,250})$"), + Optional: true, + Description: "Specifies the substitution pattern (a Perl-compatible regular expression) that defines the SaaS dynamic failaction.", + Type: schema.TypeString, + }, + "saas_replace": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9]|\\$[1-9])(([a-zA-Z0-9\\._\\-]|\\$[1-9]){0,250}([a-zA-Z0-9]|\\$[1-9]))?){1,10}$"), + Optional: true, + Description: "Specifies the replacement pattern that defines the SaaS dynamic failaction.", + Type: schema.TypeString, + }, + "saas_suffix": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})\\.(com|net|org|info|biz|us|co\\.uk|ac\\.uk|org\\.uk|me\\.uk|ca|eu|com\\.au|co|co\\.za|ru|es|me|tv|pro|in|ie|de|it|nl|fr|co\\.il|ch|se|co\\.nz|pl|jp|name|mobi|cc|ws|be|com\\.mx|at|nu|asia|co\\.nz|net\\.nz|org\\.nz|com\\.au|net\\.au|org\\.au|tools)$"), + Optional: true, + Description: "Specifies the static portion of the SaaS dynamic failaction.", + Type: schema.TypeString, + }, + "dynamic_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SERVE_301", "SERVE_302", "SERVE_ALTERNATE"}, false)), + Optional: true, + Description: "Specifies the redirect method.", + Type: schema.TypeString, + }, + "dynamic_custom_path": { + Optional: true, + Description: "Allows you to modify the original requested path.", + Type: schema.TypeBool, + }, + "dynamic_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the new path.", + Type: schema.TypeString, + }, + "redirect_hostname_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ORIGINAL", "ALTERNATE"}, false)), + Optional: true, + Description: "Whether to preserve or customize the hostname.", + Type: schema.TypeString, + }, + "redirect_hostname": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "When the `actionType` is `REDIRECT` and the `redirectHostnameType` is `ALTERNATE`, this specifies the hostname for the redirect.", + Type: schema.TypeString, + }, + "redirect_custom_path": { + Optional: true, + Description: "Uses the `redirectPath` to customize a new path.", + Type: schema.TypeBool, + }, + "redirect_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies a new path.", + Type: schema.TypeString, + }, + "redirect_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{302, 301})), + Optional: true, + Description: "Specifies the HTTP response code.", + Type: schema.TypeInt, + }, + "content_hostname": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies the static hostname for the alternate redirect.", + Type: schema.TypeString, + }, + "content_custom_path": { + Optional: true, + Description: "Specifies a custom redirect path.", + Type: schema.TypeBool, + }, + "content_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies a custom redirect path.", + Type: schema.TypeString, + }, + "net_storage_hostname": { + Optional: true, + Description: "When the `actionType` is `RECREATED_NS`, specifies the `NetStorage` origin to serve the alternate content. Contact Akamai Professional Services for your NetStorage origin's `id`.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cp_code": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "download_domain_name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "g2o_token": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "net_storage_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "When the `actionType` is `RECREATED_NS`, specifies the path for the `NetStorage` request.", + Type: schema.TypeString, + }, + "cex_hostname": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies a hostname.", + Type: schema.TypeString, + }, + "cex_custom_path": { + Optional: true, + Description: "Specifies a custom path.", + Type: schema.TypeBool, + }, + "cex_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies a custom path.", + Type: schema.TypeString, + }, + "cp_code": { + Optional: true, + Description: "Specifies a CP code for which to log errors for the NetStorage location.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "status_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{200, 404, 500, 100, 101, 102, 103, 122, 201, 202, 203, 204, 205, 206, 207, 226, 400, 401, 402, 403, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 422, 423, 424, 425, 426, 428, 429, 431, 444, 449, 450, 499, 501, 502, 503, 504, 505, 506, 507, 509, 510, 511, 598, 599})), + Optional: true, + Description: "Assigns a new HTTP status code to the failure response.", + Type: schema.TypeInt, + }, + "preserve_query_string": { + Optional: true, + Description: "When using either `contentCustomPath`, `cexCustomPath`, `dynamicCustomPath`, or `redirectCustomPath` to specify a custom path, enabling this passes in the original request's query string as part of the path.", + Type: schema.TypeBool, + }, + "modify_protocol": { + Optional: true, + Description: "Modifies the redirect's protocol using the value of the `protocol` field.", + Type: schema.TypeBool, + }, + "protocol": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HTTP", "HTTPS"}, false)), + Optional: true, + Description: "When the `actionType` is `REDIRECT` and `modifyProtocol` is enabled, this specifies the redirect's protocol.", + Type: schema.TypeString, + }, + "allow_fcm_parent_override": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + }, + }, + }, + "failover_bot_manager_feature_compatibility": { + Optional: true, + Type: schema.TypeList, + Description: "Ensures that functionality such as challenge authentication and reset protocol work with a failover product property you use to create an alternate hostname. Apply it to any properties that implement a failover under the Cloud Security Failover product. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "compatibility": { + Optional: true, + Description: "This behavior does not include any options. Specifying the behavior itself enables it.", + Type: schema.TypeBool, + }, + }, + }, + }, + "fast_invalidate": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, forces a validation test for all edge content to which the behavior applies.", + Type: schema.TypeBool, + }, + }, + }, + }, + "first_party_marketing": { + Optional: true, + Type: schema.TypeList, + Description: "Enables the Cloud Marketing Cloudlet, which helps MediaMath customers collect usage data and place corresponding tags for use in online advertising. You can configure tags using either the Cloudlets Policy Manager application or the `Cloudlets API`. See also the `firstPartyMarketingPlus` behavior, which integrates better with both MediaMath and its partners. Both behaviors support the same set of options. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Cloud Marketing Cloudlet.", + Type: schema.TypeBool, + }, + "java_script_insertion_rule": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NEVER", "POLICY", "ALWAYS"}, false)), + Optional: true, + Description: "Select how to insert the MediaMath JavaScript reference script.", + Type: schema.TypeString, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "media_math_prefix": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specify the URL path prefix that distinguishes Cloud Marketing requests from your other web traffic. Include the leading slash character, but no trailing slash. For example, if the path prefix is `/mmath`, and the request is for `www.example.com/dir`, the new URL is `www.example.com/mmath/dir`.", + Type: schema.TypeString, + }, + }, + }, + }, + "first_party_marketing_plus": { + Optional: true, + Type: schema.TypeList, + Description: "Enables the Cloud Marketing Plus Cloudlet, which helps MediaMath customers collect usage data and place corresponding tags for use in online advertising. You can configure tags using either the Cloudlets Policy Manager application or the `Cloudlets API`. See also the `firstPartyMarketing` behavior, which integrates with MediaMath but not its partners. Both behaviors support the same set of options. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Cloud Marketing Plus Cloudlet.", + Type: schema.TypeBool, + }, + "java_script_insertion_rule": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NEVER", "POLICY", "ALWAYS"}, false)), + Optional: true, + Description: "Select how to insert the MediaMath JavaScript reference script.", + Type: schema.TypeString, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "media_math_prefix": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specify the URL path prefix that distinguishes Cloud Marketing requests from your other web traffic. Include the leading slash character, but no trailing slash. For example, if the path prefix is `/mmath`, and the request is for `www.example.com/dir`, the new URL is `www.example.com/mmath/dir`.", + Type: schema.TypeString, + }, + }, + }, + }, + "forward_rewrite": { + Optional: true, + Type: schema.TypeList, + Description: "The Forward Rewrite Cloudlet allows you to conditionally modify the forward path in edge content without affecting the URL that displays in the user's address bar. If Cloudlets are available on your contract, choose `Your services` > `Edge logic Cloudlets` to control how this feature works within `Control Center`, or use the `Cloudlets API` to configure it programmatically. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Forward Rewrite Cloudlet behavior.", + Type: schema.TypeBool, + }, + "is_shared_policy": { + Optional: true, + Description: "Whether you want to use a shared policy for a Cloudlet. Learn more about shared policies and how to create them in `Cloudlets Policy Manager`.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "This identifies the Cloudlet shared policy to use with this behavior. You can list available shared policies with the `Cloudlets API`.", + Type: schema.TypeInt, + }, + }, + }, + }, + "g2oheader": { + Optional: true, + Type: schema.TypeList, + Description: "The `signature header authentication` (g2o) security feature provides header-based verification of outgoing origin requests. Edge servers encrypt request data in a pre-defined header, which the origin uses to verify that the edge server processed the request. This behavior configures the request data, header names, encryption algorithm, and shared secret to use for verification. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the g2o verification behavior.", + Type: schema.TypeBool, + }, + "data_header": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies the name of the header that contains the request data that needs to be encrypted.", + Type: schema.TypeString, + }, + "signed_header": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies the name of the header containing encrypted request data.", + Type: schema.TypeString, + }, + "encoding_version": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{1, 2, 3, 4, 5})), + Optional: true, + Description: "Specifies the version of the encryption algorithm as an integer from `1` through `5`.", + Type: schema.TypeInt, + }, + "use_custom_sign_string": { + Optional: true, + Description: "When disabled, the encrypted string is based on the forwarded URL. If enabled, you can use `customSignString` to customize the set of data to encrypt.", + Type: schema.TypeBool, + }, + "custom_sign_string": { + Optional: true, + Description: "Specifies the set of data to be encrypted as a combination of concatenated strings.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "secret_key": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]{24}$"), + Optional: true, + Description: "Specifies the shared secret key.", + Type: schema.TypeString, + }, + "nonce": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]{1,8}$"), + Optional: true, + Description: "Specifies the cryptographic `nonce` string.", + Type: schema.TypeString, + }, + }, + }, + }, + "global_request_number": { + Optional: true, + Type: schema.TypeList, + Description: "Generates a unique identifier for each request on the Akamai edge network, for use in logging and debugging. GRN identifiers follow the same format as Akamai's error reference strings, for example: `0.05313217.1567801841.1457a3`. You can use the Edge Diagnostics API's `Translate error string` operation to get low-level details about any request. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "output_option": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RESPONSE_HEADER", "REQUEST_HEADER", "BOTH_HEADERS", "ASSIGN_VARIABLE"}, false)), + Optional: true, + Description: "Specifies how to report the GRN value.", + Type: schema.TypeString, + }, + "header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "With `outputOption` set to specify any set of headers, this specifies the name of the header to report the GRN value.", + Type: schema.TypeString, + }, + "variable_name": { + Optional: true, + Description: "This specifies the name of the variable to assign the GRN value to. You need to pre-declare any `variable` you specify within the rule tree.", + Type: schema.TypeString, + }, + }, + }, + }, + "graphql_caching": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior configures how to cache GraphQL-based API traffic. Enable `caching` for your GraphQL API traffic, along with `allowPost` to cache POST responses. To configure REST API traffic, use the `rapid` behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables GraphQL caching.", + Type: schema.TypeBool, + }, + "cache_responses_with_errors": { + Optional: true, + Description: "When enabled, caches responses that include an `error` field at the top of the response body object. Disable this if your GraphQL server yields temporary errors with success codes in the 2xx range.", + Type: schema.TypeBool, + }, + "advanced": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "post_request_processing_error_handling": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"APPLY_CACHING_BEHAVIOR", "NO_STORE"}, false)), + Optional: true, + Description: "Specify what happens if GraphQL query processing fails on POST requests.", + Type: schema.TypeString, + }, + "operations_url_query_parameter_name": { + Optional: true, + Description: "Specifies the name of a query parameter that identifies requests as GraphQL queries.", + Type: schema.TypeString, + }, + "operations_json_body_parameter_name": { + Optional: true, + Description: "The name of the JSON body parameter that identifies GraphQL POST requests.", + Type: schema.TypeString, + }, + }, + }, + }, + "gzip_response": { + Optional: true, + Type: schema.TypeList, + Description: "Apply `gzip` compression to speed transfer time. This behavior applies best to text-based content such as HTML, CSS, and JavaScript, especially once files exceed about 10KB. Do not apply it to already compressed image formats, or to small files that would add more time to uncompress. To apply this behavior, you should match on `contentType` or the content's `cacheability`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ORIGIN_RESPONSE", "ALWAYS", "NEVER"}, false)), + Optional: true, + Description: "Specify when to compress responses.", + Type: schema.TypeString, + }, + }, + }, + }, + "hd_data_advanced": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior specifies Akamai XML metadata that can only be configured on your behalf by Akamai Professional Services. Unlike the `advanced` behavior, this may apply a different set of overriding metadata that executes in a post-processing phase. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "description": { + Optional: true, + Description: "Human-readable description of what the XML block does.", + Type: schema.TypeString, + }, + "xml": { + Optional: true, + Description: "A block of Akamai XML metadata.", + Type: schema.TypeString, + }, + }, + }, + }, + "health_detection": { + Optional: true, + Type: schema.TypeList, + Description: "Monitors the health of your origin server by tracking unsuccessful attempts to contact it. Use this behavior to keep end users from having to wait several seconds before a forwarded request times out, or to reduce requests on the origin server when it is unavailable. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "retry_count": { + Optional: true, + Description: "The number of consecutive connection failures that mark an IP address as faulty.", + Type: schema.TypeInt, + }, + "retry_interval": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the amount of time the edge server will wait before trying to reconnect to an IP address it has already identified as faulty.", + Type: schema.TypeString, + }, + "maximum_reconnects": { + Optional: true, + Description: "Specifies the maximum number of times the edge server will contact your origin server. If your origin is associated with several IP addresses, `maximumReconnects` effectively overrides the value of `retryCount`.", + Type: schema.TypeInt, + }, + }, + }, + }, + "hsaf_eip_binding": { + Optional: true, + Type: schema.TypeList, + Description: "Edge IP Binding works with a limited set of static IP addresses to distribute your content, which can be limiting in large footprint environments. This behavior sets Hash Serial and Forward (HSAF) for Edge IP Binding to deal with larger footprints. It can only be configured on your behalf by Akamai Professional Services. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables HSAF for Edge IP Binding customers with a large footprint.", + Type: schema.TypeBool, + }, + "custom_extracted_serial": { + Optional: true, + Description: "Whether to pull the serial number from the variable value set in the `advanced` behavior. Work with your Akamai Services team to add the `advanced` behavior earlier in your property to extract and apply the `AKA_PM_EIP_HSAF_SERIAL` variable.", + Type: schema.TypeBool, + }, + "hash_min_value": { + Optional: true, + Description: "Specifies the minimum value for the HSAF hash range, from 2 through 2045. This needs to be lower than `hashMaxValue`.", + Type: schema.TypeInt, + }, + "hash_max_value": { + Optional: true, + Description: "Specifies the maximum value for the hash range, from 3 through 2046. This needs to be higher than `hashMinValue`.", + Type: schema.TypeInt, + }, + "tier": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"EDGE", "PARENT", "BOTH"}, false)), + Optional: true, + Description: "Specifies where the behavior is applied.", + Type: schema.TypeString, + }, + }, + }, + }, + "http2": { + Optional: true, + Type: schema.TypeList, + Description: "Enables the HTTP/2 protocol, which reduces latency and improves efficiency. You can only apply this behavior if the property is marked as secure. See `Secure property requirements` for guidance. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "http3": { + Optional: true, + Type: schema.TypeList, + Description: "This enables the HTTP/3 protocol that uses QUIC. The behavior allows for improved performance and faster connection setup. You can only apply this behavior if the property is marked as secure. See `Secure property requirements` and the `Property Manager documentation` for guidance. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enable": { + Optional: true, + Description: "This enables HTTP/3 connections between requesting clients and Akamai edge servers. You also need to enable QUIC and TLS 1.3 in your certificate deployment settings. See the `Property Manager documentation` for more details.", + Type: schema.TypeBool, + }, + }, + }, + }, + "http_strict_transport_security": { + Optional: true, + Type: schema.TypeList, + Description: "Applies HTTP Strict Transport Security (HSTS), disallowing insecure HTTP traffic. Apply this to hostnames managed with Standard TLS or Enhanced TLS certificates. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enable": { + Optional: true, + Description: "Applies HSTS to this set of requests.", + Type: schema.TypeBool, + }, + "max_age": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ZERO_MINS", "TEN_MINS", "ONE_DAY", "ONE_MONTH", "THREE_MONTHS", "SIX_MONTHS", "ONE_YEAR"}, false)), + Optional: true, + Description: "Specifies the duration for which to apply HSTS for new browser connections.", + Type: schema.TypeString, + }, + "include_sub_domains": { + Optional: true, + Description: "When enabled, applies HSTS to all subdomains.", + Type: schema.TypeBool, + }, + "preload": { + Optional: true, + Description: "When enabled, adds this domain to the browser's preload list. You still need to declare the domain at `hstspreload.org`.", + Type: schema.TypeBool, + }, + "redirect": { + Optional: true, + Description: "When enabled, redirects all HTTP requests to HTTPS.", + Type: schema.TypeBool, + }, + "redirect_status_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{301, 302})), + Optional: true, + Description: "Specifies a response code.", + Type: schema.TypeInt, + }, + }, + }, + }, + "http_to_https_upgrade": { + Optional: true, + Type: schema.TypeList, + Description: "Upgrades an HTTP edge request to HTTPS for the remainder of the request flow. Enable this behavior only if your origin supports HTTPS, and if your `origin` behavior is configured with `originCertsToHonor` to verify SSL certificates. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "upgrade": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "im_override": { + Optional: true, + Type: schema.TypeList, + Description: "This specifies common query parameters that affect how `imageManager` transforms images, potentially overriding policy, width, format, or density request parameters. This also allows you to assign the value of one of the property's `rule tree variables` to one of Image and Video Manager's own policy variables. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "override": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"POLICY", "POLICY_VARIABLE", "WIDTH", "FORMAT", "DPR", "EXCLUDE_QUERY"}, false)), + Optional: true, + Description: "Selects the type of query parameter you want to set.", + Type: schema.TypeString, + }, + "typesel": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"VALUE", "VARIABLE"}, false)), + Optional: true, + Description: "Specifies how to set a query parameter.", + Type: schema.TypeString, + }, + "formatvar": { + Optional: true, + Description: "This selects the variable with the name of the browser you want to optimize images for. The variable specifies the same type of data as the `format` option below.", + Type: schema.TypeString, + }, + "format": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CHROME", "IE", "SAFARI", "GENERIC", "AVIF_WEBP_JPEG_PNG_GIF", "JP2_WEBP_JPEG_PNG_GIF", "WEBP_JPEG_PNG_GIF", "JPEG_PNG_GIF"}, false)), + Optional: true, + Description: "Specifies the type of the browser, or the encodings passed in the `Accept` header, that you want to optimize images for.", + Type: schema.TypeString, + }, + "dprvar": { + Optional: true, + Description: "This selects the variable with the desired pixel density. The variable specifies the same type of data as the `dpr` option below.", + Type: schema.TypeString, + }, + "dpr": { + Optional: true, + Description: "Directly specifies the pixel density. The numeric value is a scaling factor of 1, representing normal density.", + Type: schema.TypeFloat, + }, + "widthvar": { + Optional: true, + Description: "Selects the variable with the desired width. If the Image and Video Manager policy doesn't define that width, it serves the next largest width.", + Type: schema.TypeString, + }, + "width": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Sets the image's desired pixel width directly. If the Image Manager policy doesn't define that width, it serves the next largest width.", + Type: schema.TypeFloat, + }, + "policyvar": { + Optional: true, + Description: "This selects the variable with the desired Image and Video Manager policy name to apply to image requests. If there is no policy by that name, Image and Video Manager serves the image unmodified.", + Type: schema.TypeString, + }, + "policy": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,32}$"), + Optional: true, + Description: "This selects the desired Image and Video Manager policy name directly. If there is no policy by that name, Image and Video Manager serves the image unmodified.", + Type: schema.TypeString, + }, + "policyvar_name": { + Optional: true, + Description: "This selects the name of one of the variables defined in an Image and Video Manager policy that you want to replace with the property's rule tree variable.", + Type: schema.TypeString, + }, + "policyvar_i_mvar": { + Optional: true, + Description: "This selects one of the property's rule tree variables to assign to the `policyvarName` variable within Image and Video Manager.", + Type: schema.TypeString, + }, + "exclude_all_query_parameters": { + Optional: true, + Description: "Whether to exclude all query parameters from the Image and Video Manager cache key.", + Type: schema.TypeBool, + }, + "excluded_query_parameters": { + Optional: true, + Description: "Specifies individual query parameters to exclude from the Image and Video Manager cache key.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "image_and_video_manager": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "policy_set_type": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + "resize": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + "apply_best_file_type": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + "cp_code_original": { + Optional: true, + Description: "", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "cp_code_transformed": { + Optional: true, + Description: "", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "image_set": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]+([^-].|[^v])$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "video_set": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]+-v$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "image_manager": { + Optional: true, + Type: schema.TypeList, + Description: "Optimizes images' size or file type for the requesting device. You can also use this behavior to generate API tokens to apply your own policies to matching images using the `Image and Video Manager API`. To apply this behavior, you need to match on a `fileExtension`. Once you apply Image and Video Manager to traffic, you can add the `advancedImMatch` to ensure the behavior applies to the requests from the Image and Video Manager backend. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "settings_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enable image management capabilities and generate a corresponding API token.", + Type: schema.TypeBool, + }, + "resize": { + Optional: true, + Description: "Specify whether to scale down images to the maximum screen resolution, as determined by the rendering device's user agent. Note that enabling this may affect screen layout in unexpected ways.", + Type: schema.TypeBool, + }, + "apply_best_file_type": { + Optional: true, + Description: "Specify whether to convert images to the best file type for the requesting device, based on its user agent and the initial image file. This produces the smallest file size possible that retains image quality.", + Type: schema.TypeBool, + }, + "super_cache_region": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"US", "ASIA", "AUSTRALIA", "EMEA", "JAPAN", "CHINA"}, false)), + Optional: true, + Description: "Specifies a location for your site's heaviest traffic, for use in caching derivatives on edge servers.", + Type: schema.TypeString, + }, + "traffic_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "cp_code_original": { + Optional: true, + Description: "Assigns a CP code to track traffic and billing for original images that the Image and Video Manager has not modified.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "cp_code_transformed": { + Optional: true, + Description: "Assigns a separate CP code to track traffic and billing for derived images.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "api_reference_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "use_existing_policy_set": { + Optional: true, + Description: "Whether to use a previously created policy set that may be referenced in other properties, or create a new policy set to use with this property. A policy set can be shared across multiple properties belonging to the same contract. The behavior populates any changes to the policy set across all properties that reference that set.", + Type: schema.TypeBool, + }, + "policy_set": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]+([^-].|[^v])$"), + Optional: true, + Description: "Identifies the existing policy set configured with `Image and Video Manager API`.", + Type: schema.TypeString, + }, + "advanced": { + Optional: true, + Description: "Generates a custom `Image and Video Manager API` token to apply a corresponding policy to this set of images. The token consists of a descriptive label (the `policyToken`) concatenated with a property-specific identifier that's generated when you save the property. The API registers the token when you activate the property.", + Type: schema.TypeBool, + }, + "policy_token": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,64}$"), + Optional: true, + Description: "Assign a prefix label to help match the policy token to this set of images, limited to 32 alphanumeric or underscore characters. If you don't specify a label, `default` becomes the prefix.", + Type: schema.TypeString, + }, + "policy_token_default": { + Optional: true, + Description: "Specify the default policy identifier, which is registered with the `Image and Video Manager API` once you activate this property. The `advanced` option needs to be inactive.", + Type: schema.TypeString, + }, + }, + }, + }, + "image_manager_video": { + Optional: true, + Type: schema.TypeList, + Description: "Optimizes videos managed by Image and Video Manager for the requesting device. You can also use this behavior to generate API tokens to apply your own policies to matching videos using the `Image and Video Manager API`. To apply this behavior, you need to match on a `fileExtension`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "settings_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Applies Image and Video Manager's video optimization to the current content.", + Type: schema.TypeBool, + }, + "resize": { + Optional: true, + Description: "When enabled, scales down video for smaller mobile screens, based on the device's `User-Agent` header.", + Type: schema.TypeBool, + }, + "apply_best_file_type": { + Optional: true, + Description: "When enabled, automatically converts videos to the best file type for the requesting device. This produces the smallest file size that retains image quality, based on the user agent and the initial image file.", + Type: schema.TypeBool, + }, + "super_cache_region": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"US", "ASIA", "AUSTRALIA", "EMEA", "JAPAN", "CHINA"}, false)), + Optional: true, + Description: "To optimize caching, assign a region close to your site's heaviest traffic.", + Type: schema.TypeString, + }, + "traffic_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "cp_code_original": { + Optional: true, + Description: "Select the CP code for which to track Image and Video Manager video traffic. Use this along with `cpCodeTransformed` to track traffic to derivative video content.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "cp_code_transformed": { + Optional: true, + Description: "Select the CP code to identify derivative transformed video content.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "api_reference_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "use_existing_policy_set": { + Optional: true, + Description: "Whether to use a previously created policy set that may be referenced in other properties, or create a new policy set to use with this property. A policy set can be shared across multiple properties belonging to the same contract. The behavior populates any changes to the policy set across all properties that reference that set.", + Type: schema.TypeBool, + }, + "policy_set": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]+-v$"), + Optional: true, + Description: "Identifies the existing policy set configured with `Image and Video Manager API`.", + Type: schema.TypeString, + }, + "advanced": { + Optional: true, + Description: "When disabled, applies a single standard policy based on your property name. Allows you to reference a rule-specific `policyToken` for videos with different match criteria.", + Type: schema.TypeBool, + }, + "policy_token": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,64}$"), + Optional: true, + Description: "Specifies a custom policy defined in the Image and Video Manager Policy Manager or the `Image and Video Manager API`. The policy name can include up to 64 alphanumeric, dash, or underscore characters.", + Type: schema.TypeString, + }, + "policy_token_default": { + Optional: true, + Description: "Specify the default policy identifier, which is registered with the `Image and Video Manager API` once you activate this property.", + Type: schema.TypeString, + }, + }, + }, + }, + "include": { + Optional: true, + Type: schema.TypeList, + Description: "Includes let you reuse chunks of a property configuration that you can manage separately from the rest of the property rule tree. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "id": { + Optional: true, + Description: "Identifies the include you want to add to your rule tree. You can get the include ID using `PAPI`. This option only accepts digits, without the `inc_` ID prefix.", + Type: schema.TypeString, + }, + }, + }, + }, + "instant": { + Optional: true, + Type: schema.TypeList, + Description: "The Instant feature allows you to prefetch content to the edge cache by adding link relation attributes to markup. For example: This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "prefetch_cacheable": { + Optional: true, + Description: "When enabled, applies prefetching only to objects already set to be cacheable, for example using the `caching` behavior. Only applies to content with the `tieredDistribution` behavior enabled.", + Type: schema.TypeBool, + }, + "prefetch_no_store": { + Optional: true, + Description: "Allows otherwise non-cacheable `no-store` content to prefetch if the URL path ends with `/` to indicate a request for a default file, or if the extension matches the value of the `prefetchNoStoreExtensions` option. Only applies to content with the `sureRoute` behavior enabled.", + Type: schema.TypeBool, + }, + "prefetch_no_store_extensions": { + Optional: true, + Description: "Specifies a set of file extensions for which the `prefetchNoStore` option is allowed.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "prefetch_html": { + Optional: true, + Description: "Allows edge servers to prefetch additional HTML pages while pages that link to them are being delivered. This only applies to links from `` or `` tags with the appropriate link relation attribute.", + Type: schema.TypeBool, + }, + "custom_link_relations": { + Optional: true, + Description: "Specify link relation values that activate the prefetching behavior. For example, specifying `fetch` allows you to use shorter `rel=\"fetch\"` markup.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "instant_config": { + Optional: true, + Type: schema.TypeList, + Description: "Multi-Domain Configuration, also known as `InstantConfig`, allows you to apply property settings to all incoming hostnames based on a DNS lookup, without explicitly listing them among the property's hostnames. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the InstantConfig behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "large_file_optimization": { + Optional: true, + Type: schema.TypeList, + Description: "The `Large File Optimization` feature improves performance and reliability when delivering large files. You need this behavior for objects larger than 1.8GB, and it's recommended for anything over 100MB. You should apply it only to the specific content to be optimized, such as a download directory's `.gz` files, and enable the `useVersioning` option while enforcing your own filename versioning policy. Note that it is best to use `NetStorage` for objects larger than 1.8GB. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the file optimization behavior.", + Type: schema.TypeBool, + }, + "enable_partial_object_caching": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"PARTIAL_OBJECT_CACHING", "NON_PARTIAL_OBJECT_CACHING"}, false)), + Optional: true, + Description: "Specifies whether to cache partial objects.", + Type: schema.TypeString, + }, + "minimum_size": { + ValidateDiagFunc: validateRegex("^\\d+[K,M,G,T]B$"), + Optional: true, + Description: "Optimization only applies to files larger than this, expressed as a number suffixed with a unit string such as `MB` or `GB`.", + Type: schema.TypeString, + }, + "maximum_size": { + ValidateDiagFunc: validateRegex("^\\d+[K,M,G,T]B$"), + Optional: true, + Description: "Optimization does not apply to files larger than this, expressed as a number suffixed with a unit string such as `MB` or `GB`. The size of a file can't be greater than 323 GB. If you need to optimize a larger file, contact Akamai Professional Services for help. This option is for internal usage only.", + Type: schema.TypeString, + }, + "use_versioning": { + Optional: true, + Description: "When `enablePartialObjectCaching` is set to `PARTIAL_OBJECT_CACHING`, enabling this option signals your intention to vary filenames by version, strongly recommended to avoid serving corrupt content when chunks come from different versions of the same file.", + Type: schema.TypeBool, + }, + }, + }, + }, + "large_file_optimization_advanced": { + Optional: true, + Type: schema.TypeList, + Description: "The `Large File Optimization` feature improves performance and reliability when delivering large files. You need this behavior for objects larger than 1.8GB, and it's recommended for anything over 100MB. You should apply it only to the specific content to be optimized, such as a download directory's `.gz` files. Note that it is best to use `NetStorage` for objects larger than 1.8GB. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the file optimization behavior.", + Type: schema.TypeBool, + }, + "object_size": { + ValidateDiagFunc: validateRegex("^\\d+[K,M,G,T]B$"), + Optional: true, + Description: "Specifies the size of the file at which point to apply partial object (POC) caching. Append a numeric value with a `MB` or `GB` suffix.", + Type: schema.TypeString, + }, + "fragment_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HALF_MB", "ONE_MB", "TWO_MB", "FOUR_MB"}, false)), + Optional: true, + Description: "Specifies the size of each fragment used for partial object caching.", + Type: schema.TypeString, + }, + "prefetch_during_request": { + Optional: true, + Description: "The number of POC fragments to prefetch during the request.", + Type: schema.TypeInt, + }, + "prefetch_after_request": { + Optional: true, + Description: "The number of POC fragments to prefetch after the request.", + Type: schema.TypeInt, + }, + }, + }, + }, + "limit_bit_rate": { + Optional: true, + Type: schema.TypeList, + Description: "Control the rate at which content serves out to end users, optionally varying the speed depending on the file size or elapsed download time. Each bit rate specified in the `bitrateTable` array corresponds to a `thresholdTable` entry that activates it. You can use this behavior to prevent media downloads from progressing faster than they are viewed, for example, or to differentiate various tiers of end-user experience. To apply this behavior, you should match on a `contentType`, `path`, or `filename`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, activates the bit rate limiting behavior.", + Type: schema.TypeBool, + }, + "bitrate_table": { + Optional: true, + Description: "Specifies a download rate that corresponds to a `thresholdTable` entry. The bit rate appears as a two-member object consisting of a numeric `bitrateValue` and a `bitrateUnit` string, with allowed values of `Kbps`, `Mbps`, and `Gbps`.", + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bitrate_value": { + Optional: true, + Description: "The numeric indicator of the download rate.", + Type: schema.TypeFloat, + }, + "bitrate_unit": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"KBPS", "MBPS", "GBPS"}, false)), + Optional: true, + Description: "The unit of measurement, either `KBPS`, `MBPS`, or `GBPS`.", + Type: schema.TypeString, + }, + }, + }, + }, + "threshold_table": { + Optional: true, + Description: "Specifies the minimum size of the file or the amount of elapsed download time before applying the bit rate limit from the corresponding `bitrateTable` entry. The threshold appears as a two-member object consisting of a numeric `thresholdValue` and `thresholdUnit` string, with allowed values of `SECONDS` or `BYTES`.", + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "threshold_value": { + Optional: true, + Description: "The numeric indicator of the minimum file size or elapsed download time.", + Type: schema.TypeInt, + }, + "threshold_unit": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BYTES", "SECONDS"}, false)), + Optional: true, + Description: "The unit of measurement, either `SECONDS` of the elapsed download time, or `BYTES` of the file size.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "log_custom": { + Optional: true, + Type: schema.TypeList, + Description: "Logs custom details from the origin response in the `Log Delivery Service` report. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "log_custom_log_field": { + Optional: true, + Description: "Whether to append additional custom data to each log line.", + Type: schema.TypeBool, + }, + "custom_log_field": { + Optional: true, + Description: "Specifies an additional data field to append to each log line, maximum 40 bytes, typically based on a dynamically generated built-in system variable. For example, `round-trip: {{builtin.AK_CLIENT_TURNAROUND_TIME}}ms` logs the total time to complete the response. See `Support for variables` for more information. Since this option can specify both a request and response, it overrides any `customLogField` settings in the `report` behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "m_pulse": { + Optional: true, + Type: schema.TypeList, + Description: "`mPulse` provides high-level performance analytics and predictive recommendations based on real end user data. See the `mPulse Quick Start` to set up mPulse on your website. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Applies performance monitoring to this behavior's set of content.", + Type: schema.TypeBool, + }, + "require_pci": { + Optional: true, + Description: "Suppresses gathering metrics for potentially sensitive end-user interactions. Enabling this omits data from some older browsers.", + Type: schema.TypeBool, + }, + "loader_version": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"V10", "V12", "LATEST", "BETA"}, false)), + Optional: true, + Description: "Specifies the version of the Boomerang JavaScript loader snippet. See `mPulse Loader Snippets` for more information.", + Type: schema.TypeString, + }, + "title_optional": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "api_key": { + ValidateDiagFunc: validateRegex("^$|^[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}$"), + Optional: true, + Description: "This generated value uniquely identifies sections of your website for you to analyze independently. To access this value, see `Enable mPulse in Property Manager`.", + Type: schema.TypeString, + }, + "buffer_size": { + ValidateDiagFunc: validateRegex("^(1[5-9][0-9]|1[0-9]{3}|[2-9][0-9]{2,3})$"), + Optional: true, + Description: "Allows you to override the browser's default (150) maximum number of reported performance timeline entries.", + Type: schema.TypeString, + }, + "config_override": { + Optional: true, + Description: "A JSON string representing a configuration object passed to the JavaScript library under which mPulse runs. It corresponds at run-time to the `window.BOOMR_config` object. For example, this turns on monitoring of Single Page App frameworks: `\"{\\\"history\\\": {\\\"enabled\\\": true, \\\"auto\\\": true}}\"`. See `Configuration Overrides` for more information.", + Type: schema.TypeString, + }, + }, + }, + }, + "manifest_personalization": { + Optional: true, + Type: schema.TypeList, + Description: "Allows customers who use the Adaptive Media Delivery product to enhance content based on the capabilities of each end user's device. This behavior configures a `manifest` for both HLS Live and on-demand streaming. For more information, see `Adaptive Media Delivery`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Manifest Personalization feature.", + Type: schema.TypeBool, + }, + "hls_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "hls_enabled": { + Optional: true, + Description: "Allows you to customize the HLS master manifest that's sent to the requesting client.", + Type: schema.TypeBool, + }, + "hls_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BEST_PRACTICE", "CUSTOM"}, false)), + Optional: true, + Description: "Applies with `hlsEnabled` on.", + Type: schema.TypeString, + }, + "hls_preferred_bitrate": { + ValidateDiagFunc: validateRegex("^\\d+$"), + Optional: true, + Description: "Sets the preferred bit rate in Kbps. This causes the media playlist specified in the `#EXT-X-STREAM-INF` tag that most closely matches the value to list first. All other playlists maintain their current position in the manifest.", + Type: schema.TypeString, + }, + "hls_filter_in_bitrates": { + ValidateDiagFunc: validateRegex("^\\d+(,\\d+)*$"), + Optional: true, + Description: "Specifies a comma-delimited set of preferred bit rates, such as `100,200,400`. Playlists specified in the `#EXT-X-STREAM-INF` tag with bit rates outside of any of those values by up to 100 Kbps are excluded from the manifest.", + Type: schema.TypeString, + }, + "hls_filter_in_bitrate_ranges": { + Optional: true, + Description: "Specifies a comma-delimited set of bit rate ranges, such as `100-400,1000-4000`. Playlists specified in the `#EXT-X-STREAM-INF` tag with bit rates outside of any of those ranges are excluded from the manifest.", + Type: schema.TypeString, + }, + "hls_query_param_enabled": { + Optional: true, + Description: "Specifies query parameters for the HLS master manifest to customize the manifest's content. Any settings specified in the query string override those already configured in Property Manager.", + Type: schema.TypeBool, + }, + "hls_query_param_secret_key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]{32}$"), + Optional: true, + Description: "Specifies a primary key as a token to accompany the request.", + Type: schema.TypeString, + }, + "hls_query_param_transition_key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]{32}$"), + Optional: true, + Description: "Specifies a transition key as a token to accompany the request.", + Type: schema.TypeString, + }, + "hls_show_advanced": { + Optional: true, + Description: "Allows you to configure advanced settings.", + Type: schema.TypeBool, + }, + "hls_enable_debug_headers": { + Optional: true, + Description: "Includes additional `Akamai-Manifest-Personalization` and `Akamai-Manifest-Personalization-Config-Source` debugging headers.", + Type: schema.TypeBool, + }, + }, + }, + }, + "manifest_rerouting": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior works with `adScalerCircuitBreaker`. It delegates parts of the media delivery workflow, like ad insertion, to other technology partners. Akamai reroutes manifest file requests to partner platforms for processing prior to being delivered. Rerouting simplifies the workflow and improves the media streaming experience. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "partner": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"adobe_primetime"}, false)), + Optional: true, + Description: "Set this value to `adobe_primetime`, which is an external technology partner that provides value added offerings, like advertisement integration, to the requested media objects.", + Type: schema.TypeString, + }, + "username": { + ValidateDiagFunc: validateRegex("^[0-9A-Za-z!@.,;:'\"?-]{1,50}$"), + Optional: true, + Description: "The user name for your Adobe Primetime account.", + Type: schema.TypeString, + }, + }, + }, + }, + "manual_server_push": { + Optional: true, + Type: schema.TypeList, + Description: "With the `http2` behavior enabled, this loads a specified set of objects into the client browser's cache. To apply this behavior, you should match on a `path` or `filename`. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "serverpushlist": { + Optional: true, + Description: "Specifies the set of objects to load into the client browser's cache over HTTP2. Each value in the array represents a hostname and full path to the object, such as `www.example.com/js/site.js`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "media_acceleration": { + Optional: true, + Type: schema.TypeList, + Description: "Enables Accelerated Media Delivery for this set of requests. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables Media Acceleration.", + Type: schema.TypeBool, + }, + }, + }, + }, + "media_acceleration_quic_optout": { + Optional: true, + Type: schema.TypeList, + Description: "When enabled, disables use of QUIC protocol for this set of accelerated media content. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "optout": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "media_client": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables client-side download analytics.", + Type: schema.TypeBool, + }, + "beacon_id": { + Optional: true, + Description: "Specifies the ID of data source's beacon.", + Type: schema.TypeString, + }, + "use_hybrid_http_udp": { + Optional: true, + Description: "Enables the hybrid HTTP/UDP protocol.", + Type: schema.TypeBool, + }, + }, + }, + }, + "media_file_retrieval_optimization": { + Optional: true, + Type: schema.TypeList, + Description: "Media File Retrieval Optimization (MFRO) speeds the delivery of large media files by relying on caches of partial objects. You should use it for files larger than 100 MB. It's required for files larger than 1.8 GB, and works best with `NetStorage`. To apply this behavior, you should match on a `fileExtension`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the partial-object caching behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "media_origin_failover": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies how edge servers respond when the origin is unresponsive, or suffers from server or content errors. You can specify how many times to retry, switch to a backup origin hostname, or configure a redirect. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "detect_origin_unresponsive_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_origin_unresponsive": { + Optional: true, + Description: "Allows you to configure what happens when the origin is unresponsive.", + Type: schema.TypeBool, + }, + "origin_unresponsive_detection_level": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"AGGRESSIVE", "CONSERVATIVE", "MODERATE"}, false)), + Optional: true, + Description: "Specify the level of response to slow origin connections.", + Type: schema.TypeString, + }, + "origin_unresponsive_blacklist_origin_ip": { + Optional: true, + Description: "Enabling this blacklists the origin's IP address.", + Type: schema.TypeBool, + }, + "origin_unresponsive_blacklist_window": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"TEN_S", "THIRTY_S"}, false)), + Optional: true, + Description: "This sets the delay before blacklisting an IP address.", + Type: schema.TypeString, + }, + "origin_unresponsive_recovery": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RETRY_X_TIMES", "SWITCH_TO_BACKUP_ORIGIN", "REDIRECT_TO_DIFFERENT_ORIGIN_LOCATION"}, false)), + Optional: true, + Description: "This sets the recovery option.", + Type: schema.TypeString, + }, + "origin_unresponsive_retry_limit": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ONE", "TWO", "THREE"}, false)), + Optional: true, + Description: "Sets how many times to retry.", + Type: schema.TypeString, + }, + "origin_unresponsive_backup_host": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies the origin hostname.", + Type: schema.TypeString, + }, + "origin_unresponsive_alternate_host": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies the redirect's destination hostname.", + Type: schema.TypeString, + }, + "origin_unresponsive_modify_request_path": { + Optional: true, + Description: "Modifies the request path.", + Type: schema.TypeBool, + }, + "origin_unresponsive_modified_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "This specifies the path to form the new URL.", + Type: schema.TypeString, + }, + "origin_unresponsive_include_query_string": { + Optional: true, + Description: "Enabling this includes the original set of query parameters.", + Type: schema.TypeBool, + }, + "origin_unresponsive_redirect_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{301, 302})), + Optional: true, + Description: "Specifies the redirect response code.", + Type: schema.TypeInt, + }, + "origin_unresponsive_change_protocol": { + Optional: true, + Description: "This allows you to change the request protocol.", + Type: schema.TypeBool, + }, + "origin_unresponsive_protocol": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HTTP", "HTTPS"}, false)), + Optional: true, + Description: "Specifies which protocol to use.", + Type: schema.TypeString, + }, + "detect_origin_unavailable_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_origin_unavailable": { + Optional: true, + Description: "Allows you to configure failover settings when the origin server responds with errors.", + Type: schema.TypeBool, + }, + "origin_unavailable_detection_level": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RESPONSE_CODES"}, false)), + Optional: true, + Description: "Specify `RESPONSE_CODES`, the only available option.", + Type: schema.TypeString, + }, + "origin_unavailable_response_codes": { + Optional: true, + Description: "Specifies the set of response codes identifying when the origin responds with errors.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "origin_unavailable_blacklist_origin_ip": { + Optional: true, + Description: "Enabling this blacklists the origin's IP address.", + Type: schema.TypeBool, + }, + "origin_unavailable_blacklist_window": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"TEN_S", "THIRTY_S"}, false)), + Optional: true, + Description: "This sets the delay before blacklisting an IP address.", + Type: schema.TypeString, + }, + "origin_unavailable_recovery": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RETRY_X_TIMES", "SWITCH_TO_BACKUP_ORIGIN", "REDIRECT_TO_DIFFERENT_ORIGIN_LOCATION"}, false)), + Optional: true, + Description: "This sets the recovery option.", + Type: schema.TypeString, + }, + "origin_unavailable_retry_limit": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ONE", "TWO", "THREE"}, false)), + Optional: true, + Description: "Sets how many times to retry.", + Type: schema.TypeString, + }, + "origin_unavailable_backup_host": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies the origin hostname.", + Type: schema.TypeString, + }, + "origin_unavailable_alternate_host": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies the redirect's destination hostname.", + Type: schema.TypeString, + }, + "origin_unavailable_modify_request_path": { + Optional: true, + Description: "Modifies the request path.", + Type: schema.TypeBool, + }, + "origin_unavailable_modified_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "This specifies the path to form the new URL.", + Type: schema.TypeString, + }, + "origin_unavailable_include_query_string": { + Optional: true, + Description: "Enabling this includes the original set of query parameters.", + Type: schema.TypeBool, + }, + "origin_unavailable_redirect_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{301, 302})), + Optional: true, + Description: "Specifies either a redirect response code.", + Type: schema.TypeInt, + }, + "origin_unavailable_change_protocol": { + Optional: true, + Description: "Modifies the request protocol.", + Type: schema.TypeBool, + }, + "origin_unavailable_protocol": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HTTP", "HTTPS"}, false)), + Optional: true, + Description: "Specifies either the `HTTP` or `HTTPS` protocol.", + Type: schema.TypeString, + }, + "detect_object_unavailable_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "detect_object_unavailable": { + Optional: true, + Description: "Allows you to configure failover settings when the origin has content errors.", + Type: schema.TypeBool, + }, + "object_unavailable_detection_level": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RESPONSE_CODES"}, false)), + Optional: true, + Description: "Specify `RESPONSE_CODES`, the only available option.", + Type: schema.TypeString, + }, + "object_unavailable_response_codes": { + Optional: true, + Description: "Specifies the set of response codes identifying when there are content errors.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "object_unavailable_blacklist_origin_ip": { + Optional: true, + Description: "Enabling this blacklists the origin's IP address.", + Type: schema.TypeBool, + }, + "object_unavailable_blacklist_window": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"TEN_S", "THIRTY_S"}, false)), + Optional: true, + Description: "This sets the delay before blacklisting an IP address.", + Type: schema.TypeString, + }, + "object_unavailable_recovery": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RETRY_X_TIMES", "SWITCH_TO_BACKUP_ORIGIN", "REDIRECT_TO_DIFFERENT_ORIGIN_LOCATION"}, false)), + Optional: true, + Description: "This sets the recovery option.", + Type: schema.TypeString, + }, + "object_unavailable_retry_limit": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ONE", "TWO", "THREE"}, false)), + Optional: true, + Description: "Sets how many times to retry.", + Type: schema.TypeString, + }, + "object_unavailable_backup_host": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies the origin hostname.", + Type: schema.TypeString, + }, + "object_unavailable_alternate_host": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies the redirect's destination hostname.", + Type: schema.TypeString, + }, + "object_unavailable_modify_request_path": { + Optional: true, + Description: "Enabling this allows you to modify the request path.", + Type: schema.TypeBool, + }, + "object_unavailable_modified_path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "This specifies the path to form the new URL.", + Type: schema.TypeString, + }, + "object_unavailable_include_query_string": { + Optional: true, + Description: "Enabling this includes the original set of query parameters.", + Type: schema.TypeBool, + }, + "object_unavailable_redirect_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{301, 302})), + Optional: true, + Description: "Specifies a redirect response code.", + Type: schema.TypeInt, + }, + "object_unavailable_change_protocol": { + Optional: true, + Description: "Changes the request protocol.", + Type: schema.TypeBool, + }, + "object_unavailable_protocol": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HTTP", "HTTPS"}, false)), + Optional: true, + Description: "Specifies either the `HTTP` or `HTTPS` protocol.", + Type: schema.TypeString, + }, + "other_options": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "client_response_code": { + Optional: true, + Description: "Specifies the response code served to the client.", + Type: schema.TypeString, + }, + "cache_error_response": { + Optional: true, + Description: "When enabled, caches the error response.", + Type: schema.TypeBool, + }, + "cache_window": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ONE_S", "TEN_S", "THIRTY_S"}, false)), + Optional: true, + Description: "This sets error response's TTL.", + Type: schema.TypeString, + }, + }, + }, + }, + "metadata_caching": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior reduces time spent waiting for the initial response, also known as time to first byte, during peak traffic events. Contact Akamai Professional Services for help configuring it. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables metadata caching.", + Type: schema.TypeBool, + }, + }, + }, + }, + "mobile_sdk_performance": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Mobile App Performance SDK.", + Type: schema.TypeBool, + }, + "secondary_multipath_to_origin": { + Optional: true, + Description: "When enabled, sends secondary multi-path requests to the origin server.", + Type: schema.TypeBool, + }, + }, + }, + }, + "modify_incoming_request_header": { + Optional: true, + Type: schema.TypeList, + Description: "Modify, add, remove, or pass along specific request headers coming upstream from the client. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ADD", "DELETE", "MODIFY", "PASS"}, false)), + Optional: true, + Description: "Either `ADD`, `DELETE`, `MODIFY`, or `PASS` incoming HTTP request headers.", + Type: schema.TypeString, + }, + "standard_add_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ACCEPT_ENCODING", "ACCEPT_LANGUAGE", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `ADD`, this specifies the name of the field to add.", + Type: schema.TypeString, + }, + "standard_delete_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IF_MODIFIED_SINCE", "VIA", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `DELETE`, this specifies the name of the field to remove.", + Type: schema.TypeString, + }, + "standard_modify_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ACCEPT_ENCODING", "ACCEPT_LANGUAGE", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `MODIFY`, this specifies the name of the field to modify.", + Type: schema.TypeString, + }, + "standard_pass_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ACCEPT_ENCODING", "ACCEPT_LANGUAGE", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `PASS`, this specifies the name of the field to pass through.", + Type: schema.TypeString, + }, + "custom_header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies a custom field name that applies when the relevant `standard` header name is set to `OTHER`.", + Type: schema.TypeString, + }, + "header_value": { + Optional: true, + Description: "Specifies the new header value.", + Type: schema.TypeString, + }, + "new_header_value": { + Optional: true, + Description: "Supplies an HTTP header replacement value.", + Type: schema.TypeString, + }, + "avoid_duplicate_headers": { + Optional: true, + Description: "When enabled with the `action` set to `MODIFY`, prevents creation of more than one instance of a header.", + Type: schema.TypeBool, + }, + }, + }, + }, + "modify_incoming_response_header": { + Optional: true, + Type: schema.TypeList, + Description: "Modify, add, remove, or pass along specific response headers coming downstream from the origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ADD", "DELETE", "MODIFY", "PASS"}, false)), + Optional: true, + Description: "Either `ADD`, `DELETE`, `MODIFY`, or `PASS` incoming HTTP response headers.", + Type: schema.TypeString, + }, + "standard_add_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "CONTENT_TYPE", "EDGE_CONTROL", "EXPIRES", "LAST_MODIFIED", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `ADD`, this specifies the name of the field to add.", + Type: schema.TypeString, + }, + "standard_delete_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "CONTENT_TYPE", "VARY", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `DELETE`, this specifies the name of the field to remove.", + Type: schema.TypeString, + }, + "standard_modify_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "CONTENT_TYPE", "EDGE_CONTROL", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `MODIFY`, this specifies the name of the field to modify.", + Type: schema.TypeString, + }, + "standard_pass_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "EXPIRES", "PRAGMA", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `PASS`, this specifies the name of the field to pass through.", + Type: schema.TypeString, + }, + "custom_header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies a custom field name that applies when the relevant `standard` header name is set to `OTHER`.", + Type: schema.TypeString, + }, + "header_value": { + Optional: true, + Description: "Specifies the header's new value.", + Type: schema.TypeString, + }, + "new_header_value": { + Optional: true, + Description: "Specifies an HTTP header replacement value.", + Type: schema.TypeString, + }, + "avoid_duplicate_headers": { + Optional: true, + Description: "When enabled with the `action` set to `MODIFY`, prevents creation of more than one instance of a header.", + Type: schema.TypeBool, + }, + }, + }, + }, + "modify_outgoing_request_header": { + Optional: true, + Type: schema.TypeList, + Description: "Modify, add, remove, or pass along specific request headers going upstream towards the origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ADD", "DELETE", "MODIFY", "REGEX"}, false)), + Optional: true, + Description: "Either `ADD` or `DELETE` outgoing HTTP request headers, `MODIFY` their fixed values, or specify a `REGEX` pattern to transform them.", + Type: schema.TypeString, + }, + "standard_add_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"USER_AGENT", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `ADD`, this specifies the name of the field to add.", + Type: schema.TypeString, + }, + "standard_delete_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"PRAGMA", "USER_AGENT", "VIA", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `DELETE`, this specifies the name of the field to remove.", + Type: schema.TypeString, + }, + "standard_modify_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"USER_AGENT", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `MODIFY` or `REGEX`, this specifies the name of the field to modify.", + Type: schema.TypeString, + }, + "custom_header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies a custom field name that applies when the relevant `standard` header name is set to `OTHER`.", + Type: schema.TypeString, + }, + "header_value": { + Optional: true, + Description: "Specifies the new header value.", + Type: schema.TypeString, + }, + "new_header_value": { + Optional: true, + Description: "Specifies an HTTP header replacement value.", + Type: schema.TypeString, + }, + "regex_header_match": { + Optional: true, + Description: "Specifies a Perl-compatible regular expression to match within the header value.", + Type: schema.TypeString, + }, + "regex_header_replace": { + Optional: true, + Description: "Specifies text that replaces the `regexHeaderMatch` pattern within the header value.", + Type: schema.TypeString, + }, + "match_multiple": { + Optional: true, + Description: "When enabled with the `action` set to `REGEX`, replaces all occurrences of the matched regular expression, otherwise only the first match if disabled.", + Type: schema.TypeBool, + }, + "avoid_duplicate_headers": { + Optional: true, + Description: "When enabled with the `action` set to `MODIFY`, prevents creation of more than one instance of a header.", + Type: schema.TypeBool, + }, + }, + }, + }, + "modify_outgoing_response_header": { + Optional: true, + Type: schema.TypeList, + Description: "Modify, add, remove, or pass along specific response headers going downstream towards the client. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ADD", "DELETE", "MODIFY", "REGEX"}, false)), + Optional: true, + Description: "Either `ADD` or `DELETE` outgoing HTTP response headers, `MODIFY` their fixed values, or specify a `REGEX` pattern to transform them.", + Type: schema.TypeString, + }, + "standard_add_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "CONTENT_DISPOSITION", "CONTENT_TYPE", "EDGE_CONTROL", "P3P", "PRAGMA", "ACCESS_CONTROL_ALLOW_ORIGIN", "ACCESS_CONTROL_ALLOW_METHODS", "ACCESS_CONTROL_ALLOW_HEADERS", "ACCESS_CONTROL_EXPOSE_HEADERS", "ACCESS_CONTROL_ALLOW_CREDENTIALS", "ACCESS_CONTROL_MAX_AGE", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `ADD`, this specifies the name of the field to add.", + Type: schema.TypeString, + }, + "standard_delete_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "CONTENT_DISPOSITION", "CONTENT_TYPE", "EXPIRES", "P3P", "PRAGMA", "ACCESS_CONTROL_ALLOW_ORIGIN", "ACCESS_CONTROL_ALLOW_METHODS", "ACCESS_CONTROL_ALLOW_HEADERS", "ACCESS_CONTROL_EXPOSE_HEADERS", "ACCESS_CONTROL_ALLOW_CREDENTIALS", "ACCESS_CONTROL_MAX_AGE", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `DELETE`, this specifies the name of the field to remove.", + Type: schema.TypeString, + }, + "standard_modify_header_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CACHE_CONTROL", "CONTENT_DISPOSITION", "CONTENT_TYPE", "P3P", "PRAGMA", "ACCESS_CONTROL_ALLOW_ORIGIN", "ACCESS_CONTROL_ALLOW_METHODS", "ACCESS_CONTROL_ALLOW_HEADERS", "ACCESS_CONTROL_EXPOSE_HEADERS", "ACCESS_CONTROL_ALLOW_CREDENTIALS", "ACCESS_CONTROL_MAX_AGE", "OTHER"}, false)), + Optional: true, + Description: "If the value of `action` is `MODIFY` or `REGEX`, this specifies the name of the field to modify.", + Type: schema.TypeString, + }, + "custom_header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies a custom field name that applies when the relevant `standard` header name is set to `OTHER`.", + Type: schema.TypeString, + }, + "header_value": { + Optional: true, + Description: "Specifies the existing value of the header to match.", + Type: schema.TypeString, + }, + "new_header_value": { + Optional: true, + Description: "Specifies the new HTTP header replacement value.", + Type: schema.TypeString, + }, + "regex_header_match": { + Optional: true, + Description: "Specifies a Perl-compatible regular expression to match within the header value.", + Type: schema.TypeString, + }, + "regex_header_replace": { + Optional: true, + Description: "Specifies text that replaces the `regexHeaderMatch` pattern within the header value.", + Type: schema.TypeString, + }, + "match_multiple": { + Optional: true, + Description: "When enabled with the `action` set to `REGEX`, replaces all occurrences of the matched regular expression, otherwise only the first match if disabled.", + Type: schema.TypeBool, + }, + "avoid_duplicate_headers": { + Optional: true, + Description: "When enabled with the `action` set to `MODIFY`, prevents creation of more than one instance of a header. The last header clobbers others with the same name. This option affects the entire set of outgoing headers, and is not confined to the subset of regular expression matches.", + Type: schema.TypeBool, + }, + }, + }, + }, + "modify_via_header": { + Optional: true, + Type: schema.TypeList, + Description: "Removes or renames the HTTP `Via` headers used to inform the server of proxies through which the request was sent to the origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables `Via` header modifications.", + Type: schema.TypeBool, + }, + "modification_option": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"REMOVE_HEADER", "RENAME_HEADER"}, false)), + Optional: true, + Description: "Specify how you want to handle the header.", + Type: schema.TypeString, + }, + "rename_header_to": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies a new name to replace the existing `Via` header.", + Type: schema.TypeString, + }, + }, + }, + }, + "origin": { + Optional: true, + Type: schema.TypeList, + Description: "Specify the hostname and settings used to contact the origin once service begins. You can use your own origin, `NetStorage`, an Edge Load Balancing origin, or a SaaS dynamic origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "origin_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CUSTOMER", "NET_STORAGE", "MEDIA_SERVICE_LIVE", "EDGE_LOAD_BALANCING_ORIGIN_GROUP", "SAAS_DYNAMIC_ORIGIN"}, false)), + Optional: true, + Description: "Choose where your content is retrieved from.", + Type: schema.TypeString, + }, + "net_storage": { + Optional: true, + Description: "Specifies the details of the NetStorage server.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cp_code": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "download_domain_name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "g2o_token": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "origin_id": { + Optional: true, + Description: "Identifies the Edge Load Balancing origin. This needs to correspond to an `edgeLoadBalancingOrigin` behavior's `id` attribute within the same property.", + Type: schema.TypeString, + }, + "hostname": { + Optional: true, + Description: "Specifies the hostname or IPv4 address of your origin server, from which edge servers can retrieve your content.", + Type: schema.TypeString, + }, + "second_hostname_enabled": { + Optional: true, + Description: "Available only for certain products. This specifies whether you want to use an additional origin server address.", + Type: schema.TypeBool, + }, + "second_hostname": { + Optional: true, + Description: "Specifies the origin server's hostname, IPv4 address, or IPv6 address. Edge servers retrieve your content from this origin server.", + Type: schema.TypeString, + }, + "mslorigin": { + Optional: true, + Description: "This specifies the media's origin server.", + Type: schema.TypeString, + }, + "saas_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HOSTNAME", "PATH", "QUERY_STRING", "COOKIE"}, false)), + Optional: true, + Description: "Specifies the part of the request that identifies this SaaS dynamic origin.", + Type: schema.TypeString, + }, + "saas_cname_enabled": { + Optional: true, + Description: "Enabling this allows you to use a `CNAME chain` to determine the hostname for this SaaS dynamic origin.", + Type: schema.TypeBool, + }, + "saas_cname_level": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the desired number of hostnames to use in the `CNAME chain`, starting backwards from the edge server.", + Type: schema.TypeInt, + }, + "saas_cookie": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the name of the cookie that identifies this SaaS dynamic origin.", + Type: schema.TypeString, + }, + "saas_query_string": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "Specifies the name of the query parameter that identifies this SaaS dynamic origin.", + Type: schema.TypeString, + }, + "saas_regex": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9\\:\\[\\]\\{\\}\\(\\)\\.\\?_\\-\\*\\+\\^\\$\\\\\\/\\|&=!]{1,250})$"), + Optional: true, + Description: "Specifies the Perl-compatible regular expression match that identifies this SaaS dynamic origin.", + Type: schema.TypeString, + }, + "saas_replace": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9]|\\$[1-9])(([a-zA-Z0-9\\._\\-]|\\$[1-9]){0,250}([a-zA-Z0-9]|\\$[1-9]))?){1,10}$"), + Optional: true, + Description: "Specifies replacement text for what `saasRegex` matches.", + Type: schema.TypeString, + }, + "saas_suffix": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})\\.(com|net|org|info|biz|us|co\\.uk|ac\\.uk|org\\.uk|me\\.uk|ca|eu|com\\.au|co|co\\.za|ru|es|me|tv|pro|in|ie|de|it|nl|fr|co\\.il|ch|se|co\\.nz|pl|jp|name|mobi|cc|ws|be|com\\.mx|at|nu|asia|co\\.nz|net\\.nz|org\\.nz|com\\.au|net\\.au|org\\.au|tools)$"), + Optional: true, + Description: "Specifies the static part of the SaaS dynamic origin.", + Type: schema.TypeString, + }, + "forward_host_header": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"REQUEST_HOST_HEADER", "ORIGIN_HOSTNAME", "CUSTOM"}, false)), + Optional: true, + Description: "When the `originType` is set to either `CUSTOMER` or `SAAS_DYNAMIC_ORIGIN`, this specifies which `Host` header to pass to the origin.", + Type: schema.TypeString, + }, + "custom_forward_host_header": { + Optional: true, + Description: "This specifies the name of the custom host header the edge server should pass to the origin.", + Type: schema.TypeString, + }, + "cache_key_hostname": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"REQUEST_HOST_HEADER", "ORIGIN_HOSTNAME"}, false)), + Optional: true, + Description: "Specifies the hostname to use when forming a cache key.", + Type: schema.TypeString, + }, + "ip_version": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IPV4", "DUALSTACK", "IPV6"}, false)), + Optional: true, + Description: "Specifies which IP version to use when getting content from the origin.", + Type: schema.TypeString, + }, + "use_unique_cache_key": { + Optional: true, + Description: "With a shared `hostname` such as provided by Amazon AWS, sets a unique cache key for your content.", + Type: schema.TypeBool, + }, + "compress": { + Optional: true, + Description: "Enables `gzip` compression for non-NetStorage origins.", + Type: schema.TypeBool, + }, + "enable_true_client_ip": { + Optional: true, + Description: "When enabled on non-NetStorage origins, allows you to send a custom header (the `trueClientIpHeader`) identifying the IP address of the immediate client connecting to the edge server. This may provide more useful information than the standard `X-Forward-For` header, which proxies may modify.", + Type: schema.TypeBool, + }, + "true_client_ip_header": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "This specifies the name of the field that identifies the end client's IP address, for example `True-Client-IP`.", + Type: schema.TypeString, + }, + "true_client_ip_client_setting": { + Optional: true, + Description: "If a client sets the `True-Client-IP` header, the edge server allows it and passes the value to the origin. Otherwise the edge server removes it and sets the value itself.", + Type: schema.TypeBool, + }, + "origin_certificate": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "verification_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"PLATFORM_SETTINGS", "CUSTOM", "THIRD_PARTY"}, false)), + Optional: true, + Description: "For non-NetStorage origins, maximize security by controlling which certificates edge servers should trust.", + Type: schema.TypeString, + }, + "origin_sni": { + Optional: true, + Description: "For non-NetStorage origins, enabling this adds a Server Name Indication (SNI) header in the SSL request sent to the origin, with the origin hostname as the value. See the `verification settings in the Origin Server behavior` or contact your Akamai representative for more information.", + Type: schema.TypeBool, + }, + "custom_valid_cn_values": { + Optional: true, + Description: "Specifies values to look for in the origin certificate's `Subject Alternate Name` or `Common Name` fields. Specify `{{Origin Hostname}}` and `{{Forward Host Header}}` within the text in the order you want them to be evaluated. (Note that these two template items are not the same as in-line `variables`, which use the same curly-brace syntax.)", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "origin_certs_to_honor": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COMBO", "STANDARD_CERTIFICATE_AUTHORITIES", "CUSTOM_CERTIFICATE_AUTHORITIES", "CUSTOM_CERTIFICATES"}, false)), + Optional: true, + Description: "Specifies which certificate to trust.", + Type: schema.TypeString, + }, + "standard_certificate_authorities": { + Optional: true, + Description: "", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "custom_certificate_authorities": { + Optional: true, + Description: "Specifies an array of certification objects. See the `verification settings in the Origin Server behavior` or contact your Akamai representative for details on this object's requirements.", + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pem_encoded_cert": { + ValidateDiagFunc: validateRegex("^-----BEGIN CERTIFICATE-----(.|\\s)*-----END CERTIFICATE-----\\s*$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "sha1_fingerprint": { + ValidateDiagFunc: validateRegex("^[a-f0-9]{40}$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "custom_certificates": { + Optional: true, + Description: "Specifies an array of certification objects. See the `verification settings in the Origin Server behavior` or contact your Akamai representative for details on this object's requirements.", + Type: schema.TypeList, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pem_encoded_cert": { + ValidateDiagFunc: validateRegex("^-----BEGIN CERTIFICATE-----(.|\\s)*-----END CERTIFICATE-----\\s*$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "sha1_fingerprint": { + ValidateDiagFunc: validateRegex("^[a-f0-9]{40}$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "ports": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "http_port": { + Optional: true, + Description: "Specifies the port on your origin server to which edge servers should connect for HTTP requests, customarily `80`.", + Type: schema.TypeInt, + }, + "https_port": { + Optional: true, + Description: "Specifies the port on your origin server to which edge servers should connect for secure HTTPS requests, customarily `443`. This option only applies if the property is marked as secure. See `Secure property requirements` for guidance.", + Type: schema.TypeInt, + }, + }, + }, + }, + "origin_characteristics": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the origin. Akamai uses this information to optimize your metadata configuration, which may result in better origin offload and end-user performance. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "authentication_method_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "authentication_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"AUTOMATIC", "SIGNATURE_HEADER_AUTHENTICATION", "MSL_AUTHENTICATION", "AWS", "GCS_HMAC_AUTHENTICATION", "AWS_STS"}, false)), + Optional: true, + Description: "Specifies the authentication method.", + Type: schema.TypeString, + }, + "encoding_version": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{1, 2, 3, 4, 5})), + Optional: true, + Description: "Specifies the version of the encryption algorithm, an integer from `1` to `5`.", + Type: schema.TypeInt, + }, + "use_custom_sign_string": { + Optional: true, + Description: "Specifies whether to customize your signed string.", + Type: schema.TypeBool, + }, + "custom_sign_string": { + Optional: true, + Description: "Specifies the data to be encrypted as a series of enumerated variable names. See `Built-in system variables` for guidance on each.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "secret_key": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]{24}$"), + Optional: true, + Description: "Specifies the shared secret key.", + Type: schema.TypeString, + }, + "nonce": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]{1,8}$"), + Optional: true, + Description: "Specifies the nonce.", + Type: schema.TypeString, + }, + "mslkey": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]{10,}$"), + Optional: true, + Description: "Specifies the access key provided by the hosting service.", + Type: schema.TypeString, + }, + "mslname": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]{1,8}$"), + Optional: true, + Description: "Specifies the origin name provided by the hosting service.", + Type: schema.TypeString, + }, + "access_key_encrypted_storage": { + Optional: true, + Description: "Enables secure use of access keys defined in Cloud Access Manager. Access keys store encrypted authentication details required to sign requests to cloud origins. If you disable this option, you'll need to store the authentication details unencrypted.", + Type: schema.TypeBool, + }, + "gcs_access_key_version_guid": { + Optional: true, + Description: "Identifies the unique `gcsAccessKeyVersionGuid` access key `created` in Cloud Access Manager to sign your requests to Google Cloud Storage in interoperability mode.", + Type: schema.TypeString, + }, + "gcs_hmac_key_access_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9]{1,128}$"), + Optional: true, + Description: "Specifies the active access ID linked to your Google account.", + Type: schema.TypeString, + }, + "gcs_hmac_key_secret": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9+/=_-]{1,40}$"), + Optional: true, + Description: "Specifies the secret linked to the access ID that you want to use to sign requests to Google Cloud Storage.", + Type: schema.TypeString, + }, + "aws_access_key_version_guid": { + Optional: true, + Description: "Identifies the unique `awsAccessKeyVersionGuid` access key `created` in Cloud Access Manager to sign your requests to AWS S3.", + Type: schema.TypeString, + }, + "aws_access_key_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9]{1,128}$"), + Optional: true, + Description: "Specifies active access key ID linked to your AWS account.", + Type: schema.TypeString, + }, + "aws_secret_access_key": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9+/=_-]{1,1024}$"), + Optional: true, + Description: "Specifies the secret linked to the access key identifier that you want to use to sign requests to AWS.", + Type: schema.TypeString, + }, + "aws_region": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9-]+$"), + Optional: true, + Description: "This specifies the AWS region code of the location where your bucket resides.", + Type: schema.TypeString, + }, + "aws_host": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9]([a-zA-Z0-9_\\-]*[a-zA-Z0-9])?)\\.)+([a-zA-Z]+|xn--[a-zA-Z0-9]+)$"), + Optional: true, + Description: "This specifies the AWS hostname, without `http://` or `https://` prefixes. If you leave this option empty, it inherits the hostname from the `origin` behavior.", + Type: schema.TypeString, + }, + "aws_service": { + Optional: true, + Description: "This specifies the subdomain of your AWS service. It precedes `amazonaws.com` or the region code in the AWS hostname. For example, `s3.amazonaws.com`.", + Type: schema.TypeString, + }, + "property_id_tag": { + Optional: true, + Description: "Whether to include the property identifier for this delivery configuration as an additional identifier tag in the Assume Role verification call to AWS. You'll need to include the property identifier (`AK_ARLID`) in a condition in your `AWS IAM policy` for validation.", + Type: schema.TypeBool, + }, + "hostname_tag": { + Optional: true, + Description: "Whether to include the hostname used to access this delivery configuration as an additional identifier tag in the Assume Role verification call to AWS. You'll need to include this hostname (`AK_HOST`) in a condition in your `AWS IAM policy` for validation.", + Type: schema.TypeBool, + }, + "role_arn": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9][a-zA-Z0-9_\\+=,.@\\-:/]{0,2047}$"), + Optional: true, + Description: "The Amazon Resource Name (ARN) of the `AWS IAM role` you want to use. This role needs to be configured with the proper permissions for your target resources. The `AWS IAM policy` needs to contain the trust relationships defining other users that can assume this role.", + Type: schema.TypeString, + }, + "aws_ar_region": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9][a-zA-Z0-9\\-]{0,63}$"), + Optional: true, + Description: "Specifies the AWS region code that represents the location of your AWS bucket.", + Type: schema.TypeString, + }, + "end_point_service": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9][a-zA-Z0-9\\-]{0,63}$"), + Optional: true, + Description: "Specifies the code of your AWS service. It precedes `.amazonaws.com` or the region code in your AWS hostname.", + Type: schema.TypeString, + }, + "origin_location_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "country": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"EUROPE", "NORTH_AMERICA", "LATIN_AMERICA", "SOUTH_AMERICA", "NORDICS", "ASIA_PACIFIC", "OTHER_AMERICAS", "OTHER_APJ", "OTHER_EMEA", "AUSTRALIA", "GERMANY", "INDIA", "ITALY", "JAPAN", "MEXICO", "TAIWAN", "UNITED_KINGDOM", "US_EAST", "US_CENTRAL", "US_WEST", "GLOBAL_MULTI_GEO", "OTHER", "UNKNOWN", "ADC"}, false)), + Optional: true, + Description: "Specifies the origin's geographic region.", + Type: schema.TypeString, + }, + "adc_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "direct_connect_geo": { + Optional: true, + Description: "Provides a region used by Akamai Direct Connection.", + Type: schema.TypeString, + }, + }, + }, + }, + "origin_characteristics_wsd": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies characteristics of the origin, for use in Akamai's Wholesale Delivery product. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "origintype": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"AZURE", "UNKNOWN"}, false)), + Optional: true, + Description: "Specifies an origin type.", + Type: schema.TypeString, + }, + }, + }, + }, + "origin_failure_recovery_method": { + Optional: true, + Type: schema.TypeList, + Description: "Origin Failover requires that you set up a separate rule containing origin failure recovery methods. You also need to set up the Origin Failure Recovery Policy behavior in a separate rule with a desired match criteria, and select the desired failover method. You can do this using Property Manager. Learn more about this process in `Adaptive Media Delivery Implementation Guide`. You can use the `originFailureRecoveryPolicy` member to edit existing instances of the Origin Failure Recover Policy behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "recovery_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"RETRY_ALTERNATE_ORIGIN", "RESPOND_CUSTOM_STATUS"}, false)), + Optional: true, + Description: "Specifies the recovery method.", + Type: schema.TypeString, + }, + "custom_status_code": { + Optional: true, + Description: "Specifies the custom status code to be sent to the client.", + Type: schema.TypeString, + }, + }, + }, + }, + "origin_failure_recovery_policy": { + Optional: true, + Type: schema.TypeList, + Description: "Configures how to detect an origin failure, in which case the `originFailureRecoveryMethod` behavior applies. You can also define up to three sets of criteria to detect origin failure based on specific response codes. Use it to apply specific retry or recovery actions. You can do this using Property Manager. Learn more about this process in `Adaptive Media Delivery Implementation Guide`. You can use the `originFailureRecoveryMethod` member to edit existing instances of the Origin Failure Recover Method behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Activates and configures a recovery policy.", + Type: schema.TypeBool, + }, + "tuning_parameters": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_ip_avoidance": { + Optional: true, + Description: "Temporarily blocks an origin IP address that experienced a certain number of failures. When an IP address is blocked, the `configName` established for `originResponsivenessRecoveryConfigName` is applied.", + Type: schema.TypeBool, + }, + "ip_avoidance_error_threshold": { + Optional: true, + Description: "Defines the number of failures that need to occur to an origin address before it's blocked.", + Type: schema.TypeInt, + }, + "ip_avoidance_retry_interval": { + Optional: true, + Description: "Defines the number of seconds after which the IP address is removed from the blocklist.", + Type: schema.TypeInt, + }, + "binary_equivalent_content": { + Optional: true, + Description: "Synchronizes content between the primary and backup origins, byte for byte.", + Type: schema.TypeBool, + }, + "origin_responsiveness_monitoring": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "monitor_origin_responsiveness": { + Optional: true, + Description: "Enables continuous monitoring of connectivity to the origin. If necessary, applies retry or recovery actions.", + Type: schema.TypeBool, + }, + "origin_responsiveness_timeout": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"AGGRESSIVE", "MODERATE", "CONSERVATIVE", "USER_SPECIFIED"}, false)), + Optional: true, + Description: "The timeout threshold that triggers a retry or recovery action.", + Type: schema.TypeString, + }, + "origin_responsiveness_custom_timeout": { + Optional: true, + Description: "Specify a custom timeout, from 1 to 10 seconds.", + Type: schema.TypeInt, + }, + "origin_responsiveness_enable_retry": { + Optional: true, + Description: "If a specific failure condition applies, attempts a retry on the same origin before executing the recovery method.", + Type: schema.TypeBool, + }, + "origin_responsiveness_enable_recovery": { + Optional: true, + Description: "Enables a recovery action for a specific failure condition.", + Type: schema.TypeBool, + }, + "origin_responsiveness_recovery_config_name": { + Optional: true, + Description: "Specifies a recovery configuration using the `configName` you defined in the `recoveryConfig` match criteria. Specify 3 to 20 alphanumeric characters or dashes. Ensure that you use the `recoveryConfig` match criteria to apply this option.", + Type: schema.TypeString, + }, + "status_code_monitoring1": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "monitor_status_codes1": { + Optional: true, + Description: "Enables continuous monitoring for the specific origin status codes that trigger retry or recovery actions.", + Type: schema.TypeBool, + }, + "monitor_response_codes1": { + Optional: true, + Description: "Defines the origin response codes that trigger a subsequent retry or recovery action. Specify a single code entry (`501`) or a range (`501:504`). If you configure other `monitorStatusCodes*` and `monitorResponseCodes*` options, you can't use the same codes here.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "monitor_status_codes1_enable_retry": { + Optional: true, + Description: "When the defined response codes apply, attempts a retry on the same origin before executing the recovery method.", + Type: schema.TypeBool, + }, + "monitor_status_codes1_enable_recovery": { + Optional: true, + Description: "Enables the recovery action for the response codes you define.", + Type: schema.TypeBool, + }, + "monitor_status_codes1_recovery_config_name": { + Optional: true, + Description: "Specifies a recovery configuration using the `configName` you defined in the `recoveryConfig` match criteria. Specify 3 to 20 alphanumeric characters or dashes. Ensure that you use the `recoveryConfig` match criteria to apply this option.", + Type: schema.TypeString, + }, + "status_code_monitoring2": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "monitor_status_codes2": { + Optional: true, + Description: "Enables continuous monitoring for the specific origin status codes that trigger retry or recovery actions.", + Type: schema.TypeBool, + }, + "monitor_response_codes2": { + Optional: true, + Description: "Defines the origin response codes that trigger a subsequent retry or recovery action. Specify a single code entry (`501`) or a range (`501:504`). If you configure other `monitorStatusCodes*` and `monitorResponseCodes*` options, you can't use the same codes here.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "monitor_status_codes2_enable_retry": { + Optional: true, + Description: "When the defined response codes apply, attempts a retry on the same origin before executing the recovery method.", + Type: schema.TypeBool, + }, + "monitor_status_codes2_enable_recovery": { + Optional: true, + Description: "Enables the recovery action for the response codes you define.", + Type: schema.TypeBool, + }, + "monitor_status_codes2_recovery_config_name": { + Optional: true, + Description: "Specifies a recovery configuration using the `configName` you defined in the `recoveryConfig` match criteria. Specify 3 to 20 alphanumeric characters or dashes. Ensure that you use the `recoveryConfig` match criteria to apply this option.", + Type: schema.TypeString, + }, + "status_code_monitoring3": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "monitor_status_codes3": { + Optional: true, + Description: "Enables continuous monitoring for the specific origin status codes that trigger retry or recovery actions.", + Type: schema.TypeBool, + }, + "monitor_response_codes3": { + Optional: true, + Description: "Defines the origin response codes that trigger a subsequent retry or recovery action. Specify a single code entry (`501`) or a range (`501:504`). If you configure other `monitorStatusCodes*` and `monitorResponseCodes*` options, you can't use the same codes here..", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "monitor_status_codes3_enable_retry": { + Optional: true, + Description: "When the defined response codes apply, attempts a retry on the same origin before executing the recovery method.", + Type: schema.TypeBool, + }, + "monitor_status_codes3_enable_recovery": { + Optional: true, + Description: "Enables the recovery action for the response codes you define.", + Type: schema.TypeBool, + }, + "monitor_status_codes3_recovery_config_name": { + Optional: true, + Description: "Specifies a recovery configuration using the `configName` you defined in the `recoveryConfig` match criteria. Specify 3 to 20 alphanumeric characters or dashes. Ensure that you use the `recoveryConfig` match criteria to apply this option.", + Type: schema.TypeString, + }, + }, + }, + }, + "origin_ip_acl": { + Optional: true, + Type: schema.TypeList, + Description: "Origin IP Access Control List limits the traffic to your origin. It only allows requests from specific edge servers that are configured as part of a supernet defined by CIDR blocks. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enable": { + Optional: true, + Description: "Enables the Origin IP Access Control List behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "persistent_client_connection": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior activates `persistent connections` between edge servers and clients, which allow for better performance and more efficient use of resources. Compare with the `persistentConnection` behavior, which configures persistent connections for the entire journey from origin to edge to client. Contact Akamai Professional Services for help configuring either. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the persistent connections behavior.", + Type: schema.TypeBool, + }, + "timeout": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the timeout period after which edge server closes the persistent connection with the client, 500 seconds by default.", + Type: schema.TypeString, + }, + }, + }, + }, + "persistent_connection": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior enables more efficient `persistent connections` from origin to edge server to client. Compare with the `persistentClientConnection` behavior, which customizes persistent connections from edge to client. Contact Akamai Professional Services for help configuring either. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables persistent connections.", + Type: schema.TypeBool, + }, + "timeout": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the timeout period after which edge server closes a persistent connection.", + Type: schema.TypeString, + }, + }, + }, + }, + "personally_identifiable_information": { + Optional: true, + Type: schema.TypeList, + Description: "Marks content covered by the current rule as sensitive `personally identifiable information` that needs to be treated as secure and private. That includes anything involving personal information: name, social security number, date and place of birth, mother's maiden name, biometric data, or any other data linked to an individual. If you attempt to save a property with such a rule that also caches or logs sensitive content, the added behavior results in a validation error. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, marks content as personally identifiable information (PII).", + Type: schema.TypeBool, + }, + }, + }, + }, + "phased_release": { + Optional: true, + Type: schema.TypeList, + Description: "The Phased Release Cloudlet provides gradual and granular traffic management to an alternate origin in near real time. Use the `Cloudlets API` or the Cloudlets Policy Manager application within `Control Center` to set up your Cloudlets policies. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Phased Release Cloudlet.", + Type: schema.TypeBool, + }, + "is_shared_policy": { + Optional: true, + Description: "Whether you want to apply the Cloudlet shared policy to an unlimited number of properties within your account. Learn more about shared policies and how to create them in `Cloudlets Policy Manager`.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Specifies the Cloudlet policy as an object.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "Identifies the Cloudlet shared policy to use with this behavior. Use the `Cloudlets API` to list available shared policies.", + Type: schema.TypeInt, + }, + "label": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "A label to distinguish this Phased Release policy from any others within the same property.", + Type: schema.TypeString, + }, + "population_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "population_cookie_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "NEVER", "ON_BROWSER_CLOSE", "FIXED_DATE", "DURATION"}, false)), + Optional: true, + Description: "Select when to assign a cookie to the population of users the Cloudlet defines. If you select the Cloudlet's `random` membership option, it overrides this option's value so that it is effectively `NONE`.", + Type: schema.TypeString, + }, + "population_expiration_date": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the date and time when membership expires, and the browser no longer sends the cookie. Subsequent requests re-evaluate based on current membership settings.", + Type: schema.TypeString, + }, + "population_duration": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Sets the lifetime of the cookie from the initial request. Subsequent requests re-evaluate based on current membership settings.", + Type: schema.TypeString, + }, + "population_refresh": { + Optional: true, + Description: "Enabling this option resets the original duration of the cookie if the browser refreshes before the cookie expires.", + Type: schema.TypeBool, + }, + "failover_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "failover_enabled": { + Optional: true, + Description: "Allows failure responses at the origin defined by the Cloudlet to fail over to the prevailing origin defined by the property.", + Type: schema.TypeBool, + }, + "failover_response_code": { + Optional: true, + Description: "Defines the set of failure codes that initiate the failover response.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "failover_duration": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 300)), + Optional: true, + Description: "Specifies the number of seconds to wait until the client tries to access the failover origin after the initial failure is detected. Set the value to `0` to immediately request the alternate origin upon failure.", + Type: schema.TypeInt, + }, + }, + }, + }, + "preconnect": { + Optional: true, + Type: schema.TypeList, + Description: "With the `http2` behavior enabled, this requests a specified set of domains that relate to your property hostname, and keeps the connection open for faster loading of content from those domains. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "preconnectlist": { + Optional: true, + Description: "Specifies the set of hostnames to which to preconnect over HTTP2.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "predictive_content_delivery": { + Optional: true, + Type: schema.TypeList, + Description: "Improves user experience and reduces the cost of downloads by enabling mobile devices to predictively fetch and cache content from catalogs managed by Akamai servers. You can't use this feature if in the `segmentedMediaOptimization` behavior, the value for `behavior` is set to `LIVE`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the predictive content delivery behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "predictive_prefetching": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior potentially reduces the client's page load time by pre-caching objects based on historical data for the page, not just its current set of referenced objects. It also detects second-level dependencies, such as objects retrieved by JavaScript. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the predictive prefetching behavior.", + Type: schema.TypeBool, + }, + "accuracy_target": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LOW", "MEDIUM", "HIGH"}, false)), + Optional: true, + Description: "The level of prefetching. A higher level results in better client performance, but potentially greater load on the origin.", + Type: schema.TypeString, + }, + }, + }, + }, + "prefetch": { + Optional: true, + Type: schema.TypeList, + Description: "Instructs edge servers to retrieve content linked from requested pages as they load, rather than waiting for separate requests for the linked content. This behavior applies depending on the rule's set of matching conditions. Use in conjunction with the `prefetchable` behavior, which specifies the set of objects to prefetch. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Applies prefetching behavior when enabled.", + Type: schema.TypeBool, + }, + }, + }, + }, + "prefetchable": { + Optional: true, + Type: schema.TypeList, + Description: "Allow matching objects to prefetch into the edge cache as the parent page that links to them loads, rather than waiting for a direct request. This behavior applies depending on the rule's set of matching conditions. Use `prefetch` to enable the overall behavior for parent pages that contain links to the object. To apply this behavior, you need to match on a `filename` or `fileExtension`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows matching content to prefetch when referenced on a requested parent page.", + Type: schema.TypeBool, + }, + }, + }, + }, + "prefresh_cache": { + Optional: true, + Type: schema.TypeList, + Description: "Refresh cached content before its time-to-live (TTL) expires, to keep end users from having to wait for the origin to provide fresh content. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the cache prefreshing behavior.", + Type: schema.TypeBool, + }, + "prefreshval": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 99)), + Optional: true, + Description: "Specifies when the prefresh occurs as a percentage of the TTL. For example, for an object whose cache has 10 minutes left to live, and an origin response that is routinely less than 30 seconds, a percentage of `95` prefreshes the content without unnecessarily increasing load on the origin.", + Type: schema.TypeInt, + }, + }, + }, + }, + "quality": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "origin_settings": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "country": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"EUROPE", "NORTH_AMERICA", "LATIN_AMERICA", "SOUTH_AMERICA", "NORDICS", "ASIA_PACIFIC", "OTHER_AMERICAS", "OTHER_APJ", "OTHER_EMEA", "AUSTRALIA", "GERMANY", "INDIA", "ITALY", "JAPAN", "MEXICO", "TAIWAN", "UNITED_KINGDOM", "US_EAST", "US_CENTRAL", "US_WEST"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "audience_settings": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "end_user_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"GLOBAL", "GLOBAL_US_CENTRIC", "GLOBAL_EU_CENTRIC", "GLOBAL_ASIA_CENTRIC", "EUROPE", "NORTH_AMERICA", "SOUTH_AMERICA", "NORDICS", "ASIA_PACIFIC", "AUSTRALIA", "GERMANY", "INDIA", "ITALY", "JAPAN", "TAIWAN", "UNITED_KINGDOM"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "maximum_concurrent_users": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "LESS_THAN_10K", "10K_TO_50K", "50K_TO_100K", "GREATER_THAN_100K"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "content_settings": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "content_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "SITE", "IMAGES", "CONFIG", "OTHERS", "AUDIO", "SD_VIDEO", "HD_VIDEO", "SUPER_HD_VIDEO", "LARGE_OBJECTS"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "object_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"LESS_THAN_1MB", "1_TO_10MB", "10_TO_100MB", "GREATER_THAN_100MB"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "download_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"FOREGROUND", "BACKGROUND"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "popularity_distribution": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"TYPICAL", "LONG_TAIL", "ALL_POPULAR", "ALL_UNPOPULAR"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "delivery_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ON_DEMAND", "LIVE"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "delivery_format": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DASH", "HDS", "HLS", "SILVER_LIGHT", "OTHER"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "segment_duration": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{2, 4, 6, 8, 10})), + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "catalog_size": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "refresh_rate": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "HOURLY", "DAILY", "MONTHLY", "YEARLY"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "optimize_for": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "ORIGIN", "STARTUP"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "quic_beta": { + Optional: true, + Type: schema.TypeList, + Description: "For a share of responses, includes an `Alt-Svc` header for compatible clients to initiate subsequent sessions using the QUIC protocol. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables QUIC support.", + Type: schema.TypeBool, + }, + "quic_offer_percentage": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 50)), + Optional: true, + Description: "The percentage of responses for which to allow QUIC sessions.", + Type: schema.TypeInt, + }, + }, + }, + }, + "random_seek": { + Optional: true, + Type: schema.TypeList, + Description: "Optimizes `.flv` and `.mp4` files to allow random jump-point navigation. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "flv": { + Optional: true, + Description: "Enables random seek optimization in FLV files.", + Type: schema.TypeBool, + }, + "mp4": { + Optional: true, + Description: "Enables random seek optimization in MP4 files.", + Type: schema.TypeBool, + }, + "maximum_size": { + ValidateDiagFunc: validateRegex("^\\d+[K,M,G,T]B$"), + Optional: true, + Description: "Sets the maximum size of the MP4 file to optimize, expressed as a number suffixed with a unit string such as `MB` or `GB`.", + Type: schema.TypeString, + }, + }, + }, + }, + "rapid": { + Optional: true, + Type: schema.TypeList, + Description: "The `Akamai API Gateway` allows you to configure API traffic delivered over the Akamai network. Apply this behavior to a set of API assets, then use Akamai's `API Endpoints API` to configure how the traffic responds. Use the `API Keys and Traffic Management API` to control access to your APIs. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables API Gateway for the current set of content.", + Type: schema.TypeBool, + }, + }, + }, + }, + "read_timeout": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior specifies how long the edge server should wait for a response from the requesting forward server after a connection has already been established. Any failure to read aborts the request and sends a `504` Gateway Timeout error to the client. Contact Akamai Professional Services for help configuring this behavior. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the read timeout necessary before failing with a `504` error. This value should never be zero.", + Type: schema.TypeString, + }, + }, + }, + }, + "real_time_reporting": { + Optional: true, + Type: schema.TypeList, + Description: "This enables `Real-Time Reporting` for Akamai Cloud Embed customers. The behavior can only be configured on your behalf by Akamai Professional Services. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables reports on delivery of cloud hosted content at near real-time latencies.", + Type: schema.TypeBool, + }, + "advanced": { + Optional: true, + Description: "Enables advanced options.", + Type: schema.TypeBool, + }, + "beacon_sampling_percentage": { + Optional: true, + Description: "Specifies the percentage for sampling.", + Type: schema.TypeFloat, + }, + }, + }, + }, + "real_user_monitoring": { + Optional: true, + Type: schema.TypeList, + Description: "Real User Monitoring (RUM) injects JavaScript into HTML pages served to end-user clients that monitors page-load performance and reports on various data, such as browser type and geographic location. The `report` behavior allows you to configure logs. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, activates real-use monitoring.", + Type: schema.TypeBool, + }, + }, + }, + }, + "redirect": { + Optional: true, + Type: schema.TypeList, + Description: "Respond to the client request with a redirect without contacting the origin. Specify the redirect as a path expression starting with a `/` character relative to the current root, or as a fully qualified URL. This behavior relies primarily on `destinationHostname` and `destinationPath` to manipulate the hostname and path independently. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "mobile_default_choice": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DEFAULT", "MOBILE"}, false)), + Optional: true, + Description: "Either specify a default response for mobile browsers, or customize your own.", + Type: schema.TypeString, + }, + "destination_protocol": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SAME_AS_REQUEST", "HTTP", "HTTPS"}, false)), + Optional: true, + Description: "Choose the protocol for the redirect URL.", + Type: schema.TypeString, + }, + "destination_hostname": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SAME_AS_REQUEST", "SUBDOMAIN", "SIBLING", "OTHER"}, false)), + Optional: true, + Description: "Specify how to change the requested hostname, independently from the pathname.", + Type: schema.TypeString, + }, + "destination_hostname_subdomain": { + Optional: true, + Description: "Specifies a subdomain to prepend to the current hostname. For example, a value of `m` changes `www.example.com` to `m.www.example.com`.", + Type: schema.TypeString, + }, + "destination_hostname_sibling": { + Optional: true, + Description: "Specifies the subdomain with which to replace to the current hostname's leftmost subdomain. For example, a value of `m` changes `www.example.com` to `m.example.com`.", + Type: schema.TypeString, + }, + "destination_hostname_other": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "Specifies the full hostname with which to replace the current hostname.", + Type: schema.TypeString, + }, + "destination_path": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SAME_AS_REQUEST", "PREFIX_REQUEST", "OTHER"}, false)), + Optional: true, + Description: "Specify how to change the requested pathname, independently from the hostname.", + Type: schema.TypeString, + }, + "destination_path_prefix": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "When `destinationPath` is set to `PREFIX_REQUEST`, this prepends the current path. For example, a value of `/prefix/path` changes `/example/index.html` to `/prefix/path/example/index.html`.", + Type: schema.TypeString, + }, + "destination_path_suffix_status": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NO_SUFFIX", "SUFFIX"}, false)), + Optional: true, + Description: "When `destinationPath` is set to `PREFIX_REQUEST`, this gives you the option of adding a suffix.", + Type: schema.TypeString, + }, + "destination_path_suffix": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9\\[\\]/?#!=&_\\-\\.]+$"), + Optional: true, + Description: "When `destinationPath` is set to `PREFIX_REQUEST` and `destinationPathSuffixStatus` is set to `SUFFIX`, this specifies the suffix to append to the path.", + Type: schema.TypeString, + }, + "destination_path_other": { + ValidateDiagFunc: validateRegex("^/"), + Optional: true, + Description: "When `destinationPath` is set to `PREFIX_REQUEST`, this replaces the current path.", + Type: schema.TypeString, + }, + "query_string": { + Optional: true, + Description: "When set to `APPEND`, passes incoming query string parameters as part of the redirect URL. Otherwise set this to `IGNORE`.", + Type: schema.TypeString, + }, + "response_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{301, 302, 303, 307})), + Optional: true, + Description: "Specify the redirect's response code.", + Type: schema.TypeInt, + }, + }, + }, + }, + "redirectplus": { + Optional: true, + Type: schema.TypeList, + Description: "Respond to the client request with a redirect without contacting the origin. This behavior fills the same need as `redirect`, but allows you to use `variables` to express the redirect `destination`'s component values more concisely. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the redirect feature.", + Type: schema.TypeBool, + }, + "destination": { + Optional: true, + Description: "Specifies the redirect as a path expression starting with a `/` character relative to the current root, or as a fully qualified URL. Optionally inject variables, as in this example that refers to the original request's filename: `/path/to/{{builtin.AK_FILENAME}}`.", + Type: schema.TypeString, + }, + "response_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{301, 302, 303, 307})), + Optional: true, + Description: "Assigns the status code for the redirect response.", + Type: schema.TypeInt, + }, + }, + }, + }, + "referer_checking": { + Optional: true, + Type: schema.TypeList, + Description: "Limits allowed requests to a set of domains you specify. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the referer-checking behavior.", + Type: schema.TypeBool, + }, + "strict": { + Optional: true, + Description: "When enabled, excludes requests whose `Referer` header include a relative path, or that are missing a `Referer`. When disabled, only excludes requests whose `Referer` hostname is not part of the `domains` set.", + Type: schema.TypeBool, + }, + "domains": { + Optional: true, + Description: "Specifies the set of allowed domains. With `allowChildren` disabled, prefixing values with `*.` specifies domains for which subdomains are allowed.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "allow_children": { + Optional: true, + Description: "Allows all subdomains for the `domains` set, just like adding a `*.` prefix to each.", + Type: schema.TypeBool, + }, + }, + }, + }, + "remove_query_parameter": { + Optional: true, + Type: schema.TypeList, + Description: "Remove named query parameters before forwarding the request to the origin. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "parameters": { + Optional: true, + Description: "Specifies parameters to remove from the request.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "remove_vary": { + Optional: true, + Type: schema.TypeList, + Description: "By default, responses that feature a `Vary` header value of anything other than `Accept-Encoding` and a corresponding `Content-Encoding: gzip` header aren't cached on edge servers. `Vary` headers indicate when a URL's content varies depending on some variable, such as which `User-Agent` requests it. This behavior simply removes the `Vary` header to make responses cacheable. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, removes the `Vary` header to ensure objects can be cached.", + Type: schema.TypeBool, + }, + }, + }, + }, + "report": { + Optional: true, + Type: schema.TypeList, + Description: "Specify the HTTP request headers or cookie names to log in your Log Delivery Service reports. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "log_host": { + Optional: true, + Description: "Log the `Host` header.", + Type: schema.TypeBool, + }, + "log_referer": { + Optional: true, + Description: "Log the `Referer` header.", + Type: schema.TypeBool, + }, + "log_user_agent": { + Optional: true, + Description: "Log the `User-Agent` header.", + Type: schema.TypeBool, + }, + "log_accept_language": { + Optional: true, + Description: "Log the `Accept-Language` header.", + Type: schema.TypeBool, + }, + "log_cookies": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"OFF", "ALL", "SOME"}, false)), + Optional: true, + Description: "Specifies the set of cookies to log.", + Type: schema.TypeString, + }, + "cookies": { + Optional: true, + Description: "This specifies the set of cookies names whose values you want to log.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "log_custom_log_field": { + Optional: true, + Description: "Whether to append additional custom data to each log line.", + Type: schema.TypeBool, + }, + "custom_log_field": { + Optional: true, + Description: "Specifies an additional data field to append to each log line, maximum 40 bytes, typically based on a dynamically generated built-in system variable. For example, `round-trip: {{builtin.AK_CLIENT_TURNAROUND_TIME}}ms` logs the total time to complete the response. See `Support for variables` for more information. If you enable the `logCustom` behavior, it overrides the `customLogField` option.", + Type: schema.TypeString, + }, + "log_edge_ip": { + Optional: true, + Description: "Whether to log the IP address of the Akamai edge server that served the response to the client.", + Type: schema.TypeBool, + }, + "log_x_forwarded_for": { + Optional: true, + Description: "Log any `X-Forwarded-For` request header.", + Type: schema.TypeBool, + }, + }, + }, + }, + "request_control": { + Optional: true, + Type: schema.TypeList, + Description: "The Request Control Cloudlet allows you to control access to your web content based on the incoming request's IP or geographic location. With Cloudlets available on your contract, choose `Your services` > `Edge logic Cloudlets` to control how the feature works within `Control Center`, or use the `Cloudlets API` to configure it programmatically. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Request Control Cloudlet.", + Type: schema.TypeBool, + }, + "is_shared_policy": { + Optional: true, + Description: "Whether you want to apply the Cloudlet shared policy to an unlimited number of properties within your account. Learn more about shared policies and how to create them in `Cloudlets Policy Manager`.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "Identifies the Cloudlet shared policy to use with this behavior. Use the `Cloudlets API` to list available shared policies.", + Type: schema.TypeInt, + }, + "enable_branded403": { + Optional: true, + Description: "If enabled, serves a branded 403 page for this Cloudlet instance.", + Type: schema.TypeBool, + }, + "branded403_status_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{200, 302, 403, 503})), + Optional: true, + Description: "Specifies the response status code for the branded deny action.", + Type: schema.TypeInt, + }, + "net_storage": { + Optional: true, + Description: "Specifies the NetStorage domain that contains the branded 403 page.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cp_code": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "download_domain_name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "g2o_token": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "branded403_file": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the full path of the branded 403 page, including the filename, but excluding the NetStorage CP code path component.", + Type: schema.TypeString, + }, + "branded403_url": { + ValidateDiagFunc: validateRegex("^[^\\s]+$"), + Optional: true, + Description: "Specifies the redirect URL for the branded deny action.", + Type: schema.TypeString, + }, + "branded_deny_cache_ttl": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(5, 30)), + Optional: true, + Description: "Specifies the branded response page's time to live in the cache, `5` minutes by default.", + Type: schema.TypeInt, + }, + }, + }, + }, + "request_type_marker": { + Optional: true, + Type: schema.TypeList, + Description: "The `Internet of Things: OTA Updates` product allows customers to securely distribute firmware to devices over cellular networks. When using the `downloadCompleteMarker` behavior to log successful downloads, this related behavior identifies download or campaign server types in aggregated and individual reports. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "request_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DOWNLOAD", "CAMPAIGN_SERVER"}, false)), + Optional: true, + Description: "Specifies the type of request.", + Type: schema.TypeString, + }, + }, + }, + }, + "resource_optimizer": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Resource Optimizer feature.", + Type: schema.TypeBool, + }, + }, + }, + }, + "resource_optimizer_extended_compatibility": { + Optional: true, + Type: schema.TypeList, + Description: "This enhances the standard version of the `resourceOptimizer` behavior to support the compression of additional file formats and address some compatibility issues. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Resource Optimizer feature.", + Type: schema.TypeBool, + }, + "enable_all_features": { + Optional: true, + Description: "Enables `additional support` and error handling.", + Type: schema.TypeBool, + }, + }, + }, + }, + "response_code": { + Optional: true, + Type: schema.TypeList, + Description: "Change the existing response code. For example, if your origin sends a `301` permanent redirect, this behavior can change it on the edge to a temporary `302` redirect. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "status_code": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntInSlice([]int{200, 301, 302, 303, 404, 500, 100, 101, 102, 103, 122, 201, 202, 203, 204, 205, 206, 207, 226, 300, 304, 305, 306, 307, 308, 400, 401, 402, 403, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 422, 423, 424, 425, 426, 428, 429, 431, 444, 449, 450, 499, 501, 502, 503, 504, 505, 506, 507, 509, 510, 511, 598, 599})), + Optional: true, + Description: "The HTTP status code to replace the existing one.", + Type: schema.TypeInt, + }, + "override206": { + Optional: true, + Description: "Allows any specified `200` success code to override a `206` partial-content code, in which case the response's content length matches the requested range length.", + Type: schema.TypeBool, + }, + }, + }, + }, + "response_cookie": { + Optional: true, + Type: schema.TypeList, + Description: "Set a cookie to send downstream to the client with either a fixed value or a unique stamp. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "cookie_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the name of the cookie, which serves as a key to determine if the cookie is set.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows you to set a response cookie.", + Type: schema.TypeBool, + }, + "type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"FIXED", "UNIQUE"}, false)), + Optional: true, + Description: "What type of value to assign.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[^\\s;]+$"), + Optional: true, + Description: "If the cookie `type` is `FIXED`, this specifies the cookie value.", + Type: schema.TypeString, + }, + "format": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"AKAMAI", "APACHE"}, false)), + Optional: true, + Description: "When the `type` of cookie is set to `UNIQUE`, this sets the date format.", + Type: schema.TypeString, + }, + "default_domain": { + Optional: true, + Description: "When enabled, uses the default domain value, otherwise the set specified in the `domain` field.", + Type: schema.TypeBool, + }, + "default_path": { + Optional: true, + Description: "When enabled, uses the default path value, otherwise the set specified in the `path` field.", + Type: schema.TypeBool, + }, + "domain": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "If the `defaultDomain` is disabled, this sets the domain for which the cookie is valid. For example, `example.com` makes the cookie valid for that hostname and all subdomains.", + Type: schema.TypeString, + }, + "path": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "If the `defaultPath` is disabled, sets the path component for which the cookie is valid.", + Type: schema.TypeString, + }, + "expires": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ON_BROWSER_CLOSE", "FIXED_DATE", "DURATION", "NEVER"}, false)), + Optional: true, + Description: "Sets various ways to specify when the cookie expires.", + Type: schema.TypeString, + }, + "expiration_date": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "If `expires` is set to `FIXED_DATE`, this sets when the cookie expires as a UTC date and time.", + Type: schema.TypeString, + }, + "duration": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "If `expires` is set to `DURATION`, this sets the cookie's lifetime.", + Type: schema.TypeString, + }, + "same_site": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DEFAULT", "NONE", "LAX", "STRICT"}, false)), + Optional: true, + Description: "This option controls the `SameSite` cookie attribute that reduces the risk of cross-site request forgery attacks.", + Type: schema.TypeString, + }, + "secure": { + Optional: true, + Description: "When enabled, sets the cookie's `Secure` flag to transmit it with `HTTPS`.", + Type: schema.TypeBool, + }, + "http_only": { + Optional: true, + Description: "When enabled, includes the `HttpOnly` attribute in the `Set-Cookie` response header to mitigate the risk of client-side scripts accessing the protected cookie, if the browser supports it.", + Type: schema.TypeBool, + }, + }, + }, + }, + "restrict_object_caching": { + Optional: true, + Type: schema.TypeList, + Description: "You need this behavior to deploy the Object Caching product. It disables serving HTML content and limits the maximum object size to 100MB. Contact Akamai Professional Services for help configuring it. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "maximum_size": { + Optional: true, + Description: "Specifies a fixed maximum size of non-HTML content to cache.", + Type: schema.TypeString, + }, + }, + }, + }, + "return_cache_status": { + Optional: true, + Type: schema.TypeList, + Description: "Generates a response header with information about cache status. Among other things, this can tell you whether the response came from the Akamai cache, or from the origin. Status values report with either of these forms of syntax, depending for example on whether you're deploying traffic using `sureRoute` or `tieredDistribution`: This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "response_header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "Specifies the name of the HTTP header in which to report the cache status value.", + Type: schema.TypeString, + }, + }, + }, + }, + "rewrite_url": { + Optional: true, + Type: schema.TypeList, + Description: "Modifies the path of incoming requests to forward to the origin. This helps you offload URL-rewriting tasks to the edge to increase the origin server's performance, allows you to redirect links to different targets without changing markup, and hides your original directory structure. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"REPLACE", "REMOVE", "REWRITE", "PREPEND", "REGEX_REPLACE"}, false)), + Optional: true, + Description: "The action to perform on the path.", + Type: schema.TypeString, + }, + "match": { + ValidateDiagFunc: validateRegex("^/([^:#\\[\\]@/?]+/)*$"), + Optional: true, + Description: "When `behavior` is `REMOVE` or `REPLACE`, specifies the part of the incoming path you'd like to remove or modify.", + Type: schema.TypeString, + }, + "match_regex": { + Optional: true, + Description: "When `behavior` is set to `REGEX_REPLACE`, specifies the Perl-compatible regular expression to replace with `targetRegex`.", + Type: schema.TypeString, + }, + "target_regex": { + Optional: true, + Description: "When `behavior` is set to `REGEX_REPLACE`, this replaces whatever the `matchRegex` field matches, along with any captured sequences from `\\$1` through `\\$9`.", + Type: schema.TypeString, + }, + "target_path": { + ValidateDiagFunc: validateRegex("^/([^:#\\[\\]@/?]+/)*$"), + Optional: true, + Description: "When `behavior` is set to `REPLACE`, this path replaces whatever the `match` field matches in the incoming request's path.", + Type: schema.TypeString, + }, + "target_path_prepend": { + ValidateDiagFunc: validateRegex("^/([^:#\\[\\]@/?]+/)*$"), + Optional: true, + Description: "When `behavior` is set to `PREPEND`, specifies a path to prepend to the incoming request's URL.", + Type: schema.TypeString, + }, + "target_url": { + ValidateDiagFunc: validateRegex("(/\\S*)?$"), + Optional: true, + Description: "When `behavior` is set to `REWRITE`, specifies the full path to request from the origin.", + Type: schema.TypeString, + }, + "match_multiple": { + Optional: true, + Description: "When enabled, replaces all potential matches rather than only the first.", + Type: schema.TypeBool, + }, + "keep_query_string": { + Optional: true, + Description: "When enabled, retains the original path's query parameters.", + Type: schema.TypeBool, + }, + }, + }, + }, + "rum_custom": { + Optional: true, + Type: schema.TypeList, + Description: "With `realUserMonitoring` enabled, this configures the sample of data to include in your RUM report. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "rum_sample_rate": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the percentage of web traffic to include in your RUM report.", + Type: schema.TypeInt, + }, + "rum_group_name": { + ValidateDiagFunc: validateRegex("^[0-9a-zA-Z]*$"), + Optional: true, + Description: "A deprecated option to specify an alternate name under which to batch this set of web traffic in your report. Do not use it.", + Type: schema.TypeString, + }, + }, + }, + }, + "saas_definitions": { + Optional: true, + Type: schema.TypeList, + Description: "Configures how the Software as a Service feature identifies `customers`, `applications`, and `users`. A different set of options is available for each type of targeted request, each enabled with the `action`-suffixed option. In each case, you can use `PATH`, `COOKIE`, `QUERY_STRING`, or `HOSTNAME` components as identifiers, or `disable` the SaaS behavior for certain targets. If you rely on a `HOSTNAME`, you also have the option of specifying a `CNAME chain` rather than an individual hostname. The various options suffixed `regex` and `replace` subsequently remove the identifier from the request. This behavior requires a sibling `origin` behavior whose `originType` option is set to `SAAS_DYNAMIC_ORIGIN`. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "customer_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "customer_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DISABLED", "HOSTNAME", "PATH", "QUERY_STRING", "COOKIE"}, false)), + Optional: true, + Description: "Specifies the request component that identifies a SaaS customer.", + Type: schema.TypeString, + }, + "customer_cname_enabled": { + Optional: true, + Description: "Enabling this allows you to identify customers using a `CNAME chain` rather than a single hostname.", + Type: schema.TypeBool, + }, + "customer_cname_level": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the number of CNAMEs to use in the chain.", + Type: schema.TypeInt, + }, + "customer_cookie": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This specifies the name of the cookie that identifies the customer.", + Type: schema.TypeString, + }, + "customer_query_string": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "This names the query parameter that identifies the customer.", + Type: schema.TypeString, + }, + "customer_regex": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9\\:\\[\\]\\{\\}\\(\\)\\.\\?_\\-\\*\\+\\^\\$\\\\\\/\\|&=!]{1,250})$"), + Optional: true, + Description: "Specifies a Perl-compatible regular expression with which to substitute the request's customer ID.", + Type: schema.TypeString, + }, + "customer_replace": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9_\\-]|\\$[1-9]){1,250})$"), + Optional: true, + Description: "Specifies a string to replace the request's customer ID matched by `customerRegex`.", + Type: schema.TypeString, + }, + "application_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "application_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DISABLED", "HOSTNAME", "PATH", "QUERY_STRING", "COOKIE"}, false)), + Optional: true, + Description: "Specifies the request component that identifies a SaaS application.", + Type: schema.TypeString, + }, + "application_cname_enabled": { + Optional: true, + Description: "Enabling this allows you to identify applications using a `CNAME chain` rather than a single hostname.", + Type: schema.TypeBool, + }, + "application_cname_level": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the number of CNAMEs to use in the chain.", + Type: schema.TypeInt, + }, + "application_cookie": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This specifies the name of the cookie that identifies the application.", + Type: schema.TypeString, + }, + "application_query_string": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "This names the query parameter that identifies the application.", + Type: schema.TypeString, + }, + "application_regex": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9\\:\\[\\]\\{\\}\\(\\)\\.\\?_\\-\\*\\+\\^\\$\\\\\\/\\|&=!]{1,250})$"), + Optional: true, + Description: "Specifies a Perl-compatible regular expression with which to substitute the request's application ID.", + Type: schema.TypeString, + }, + "application_replace": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9_\\-]|\\$[1-9]){1,250})$"), + Optional: true, + Description: "Specifies a string to replace the request's application ID matched by `applicationRegex`.", + Type: schema.TypeString, + }, + "users_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "users_action": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DISABLED", "HOSTNAME", "PATH", "QUERY_STRING", "COOKIE"}, false)), + Optional: true, + Description: "Specifies the request component that identifies a SaaS user.", + Type: schema.TypeString, + }, + "users_cname_enabled": { + Optional: true, + Description: "Enabling this allows you to identify users using a `CNAME chain` rather than a single hostname.", + Type: schema.TypeBool, + }, + "users_cname_level": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the number of CNAMEs to use in the chain.", + Type: schema.TypeInt, + }, + "users_cookie": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "This specifies the name of the cookie that identifies the user.", + Type: schema.TypeString, + }, + "users_query_string": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "This names the query parameter that identifies the user.", + Type: schema.TypeString, + }, + "users_regex": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9\\:\\[\\]\\{\\}\\(\\)\\.\\?_\\-\\*\\+\\^\\$\\\\\\/\\|&=!]{1,250})$"), + Optional: true, + Description: "Specifies a Perl-compatible regular expression with which to substitute the request's user ID.", + Type: schema.TypeString, + }, + "users_replace": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z0-9_\\-]|\\$[1-9]){1,250})$"), + Optional: true, + Description: "Specifies a string to replace the request's user ID matched by `usersRegex`.", + Type: schema.TypeString, + }, + }, + }, + }, + "sales_force_commerce_cloud_client": { + Optional: true, + Type: schema.TypeList, + Description: "If you use the Salesforce Commerce Cloud platform for your origin content, this behavior allows your edge content managed by Akamai to contact directly to origin. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Akamai Connector for Salesforce Commerce Cloud.", + Type: schema.TypeBool, + }, + "connector_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\.]+\\-[a-zA-Z0-9_\\.]+\\-[a-zA-Z0-9\\-_\\.]+$|^door2.dw.com$"), + Optional: true, + Description: "An ID value that helps distinguish different types of traffic sent from Akamai to the Salesforce Commerce Cloud. Form the value as `instance-realm-customer`, where `instance` is either `production` or `development`, `realm` is your Salesforce Commerce Cloud service `$REALM` value, and `customer` is the name for your organization in Salesforce Commerce Cloud. You can use alphanumeric characters, underscores, or dot characters within dash-delimited segment values.", + Type: schema.TypeString, + }, + "origin_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DEFAULT", "CUSTOMER"}, false)), + Optional: true, + Description: "Specifies where the origin is.", + Type: schema.TypeString, + }, + "sf3c_origin_host": { + Optional: true, + Description: "This specifies the hostname or IP address of the custom Salesforce origin.", + Type: schema.TypeString, + }, + "origin_host_header": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DEFAULT", "CUSTOMER"}, false)), + Optional: true, + Description: "Specifies where the `Host` header is defined.", + Type: schema.TypeString, + }, + "sf3c_origin_host_header": { + Optional: true, + Description: "This specifies the hostname or IP address of the custom Salesforce host header.", + Type: schema.TypeString, + }, + "allow_override_origin_cache_key": { + Optional: true, + Description: "When enabled, overrides the forwarding origin's cache key.", + Type: schema.TypeBool, + }, + }, + }, + }, + "sales_force_commerce_cloud_provider": { + Optional: true, + Type: schema.TypeList, + Description: "This manages traffic between mutual customers and the Salesforce Commerce Cloud platform. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables Akamai Provider for Salesforce Commerce Cloud.", + Type: schema.TypeBool, + }, + }, + }, + }, + "sales_force_commerce_cloud_provider_host_header": { + Optional: true, + Type: schema.TypeList, + Description: "Manages host header values sent to the Salesforce Commerce Cloud platform. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "host_header_source": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"PROPERTY", "CUSTOMER"}, false)), + Optional: true, + Description: "Specify where the host header derives from.", + Type: schema.TypeString, + }, + }, + }, + }, + "save_post_dca_processing": { + Optional: true, + Type: schema.TypeList, + Description: "Used in conjunction with the `cachePost` behavior, this behavior allows the body of POST requests to be processed through Dynamic Content Assembly. Contact Akamai Professional Services for help configuring it. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables processing of POST requests.", + Type: schema.TypeBool, + }, + }, + }, + }, + "schedule_invalidation": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies when cached content that satisfies a rule's criteria expires, optionally at repeating intervals. In addition to periodic cache flushes, you can use this behavior to minimize potential conflicts when related objects expire at different times. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "start": { + Optional: true, + Description: "The UTC date and time when matching cached content is to expire.", + Type: schema.TypeString, + }, + "repeat": { + Optional: true, + Description: "When enabled, invalidation recurs periodically from the `start` time based on the `repeatInterval` time.", + Type: schema.TypeBool, + }, + "repeat_interval": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies how often to invalidate content from the `start` time, expressed in seconds. For example, an expiration set to midnight and an interval of `86400` seconds invalidates content once a day. Repeating intervals of less than 5 minutes are not allowed for `NetStorage` origins.", + Type: schema.TypeString, + }, + "refresh_method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"INVALIDATE", "PURGE"}, false)), + Optional: true, + Description: "Specifies how to invalidate the content.", + Type: schema.TypeString, + }, + }, + }, + }, + "script_management": { + Optional: true, + Type: schema.TypeList, + Description: "Ensures unresponsive linked JavaScript files do not prevent HTML pages from loading. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Script Management feature.", + Type: schema.TypeBool, + }, + "serviceworker": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"YES_SERVICE_WORKER", "NO_SERVICE_WORKER"}, false)), + Optional: true, + Description: "Script Management uses a JavaScript service worker called `akam-sw.js`. It applies a policy that helps you manage scripts.", + Type: schema.TypeString, + }, + "timestamp": { + Optional: true, + Description: "A read-only epoch timestamp that represents the last time a Script Management policy was synchronized with its Ion property.", + Type: schema.TypeInt, + }, + }, + }, + }, + "segmented_content_protection": { + Optional: true, + Type: schema.TypeList, + Description: "Validates authorization tokens at the edge server to prevent unauthorized link sharing. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "token_authentication_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the segmented content protection behavior.", + Type: schema.TypeBool, + }, + "key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]{32}$"), + Optional: true, + Description: "Specifies the encryption key to use as a shared secret to validate tokens.", + Type: schema.TypeString, + }, + "use_advanced": { + Optional: true, + Description: "Allows you to specify advanced `transitionKey` and `salt` options.", + Type: schema.TypeBool, + }, + "transition_key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]{32}$"), + Optional: true, + Description: "An alternate encryption key to match along with the `key` field, allowing you to rotate keys with no down time.", + Type: schema.TypeString, + }, + "salt": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(16, 16)), + Optional: true, + Description: "Specifies a salt as input into the token for added security. This value needs to match the salt used in the token generation code.", + Type: schema.TypeString, + }, + "header_for_salt": { + Optional: true, + Description: "This allows you to include additional salt properties specific to each end user to strengthen the relationship between the session token and playback session. This specifies the set of request headers whose values generate the salt value, typically `User-Agent`, `X-Playback-Session-Id`, and `Origin`. Any specified header needs to appear in the player's request.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "field_carry_over": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "session_id": { + Optional: true, + Description: "Enabling this option carries the `session_id` value from the access token over to the session token, for use in tracking and counting unique playback sessions.", + Type: schema.TypeBool, + }, + "data_payload": { + Optional: true, + Description: "Enabling this option carries the `data/payload` field from the access token over to the session token, allowing access to opaque data for log analysis for a URL protected by a session token.", + Type: schema.TypeBool, + }, + "ip": { + Optional: true, + Description: "Enabling this restricts content access to a specific IP address, only appropriate if it does not change during the playback session.", + Type: schema.TypeBool, + }, + "acl": { + Optional: true, + Description: "Enabling this option carries the `ACL` field from the access token over to the session token, to limit the requesting client's access to the specific URL or path set in the `ACL` field. Playback may fail if the base path of the master playlist (and variant playlist, plus segments) varies from that of the `ACL` field.", + Type: schema.TypeBool, + }, + "token_auth_hls_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enable_token_in_uri": { + Optional: true, + Description: "When enabled, passes tokens in HLS variant manifest URLs and HLS segment URLs, as an alternative to cookies.", + Type: schema.TypeBool, + }, + "hls_master_manifest_files": { + Optional: true, + Description: "Specifies the set of filenames that form HLS master manifest URLs. You can use `*` wildcard characters, but make sure to specify master manifest filenames uniquely, to distinguish them from variant manifest files.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "token_revocation_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "token_revocation_enabled": { + Optional: true, + Description: "Enable this to deny requests from playback URLs that contain a `TokenAuth` token that uses specific token identifiers.", + Type: schema.TypeBool, + }, + "revoked_list_id": { + Optional: true, + Description: "Identifies the `TokenAuth` tokens to block from accessing your content.", + Type: schema.TypeInt, + }, + "media_encryption_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "hls_media_encryption": { + Optional: true, + Description: "Enables HLS Segment Encryption.", + Type: schema.TypeBool, + }, + "dash_media_encryption": { + Optional: true, + Description: "Whether to enable DASH Media Encryption.", + Type: schema.TypeBool, + }, + }, + }, + }, + "segmented_media_optimization": { + Optional: true, + Type: schema.TypeList, + Description: "Optimizes segmented media for live or streaming delivery contexts. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "behavior": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ON_DEMAND", "LIVE"}, false)), + Optional: true, + Description: "Sets the type of media content to optimize.", + Type: schema.TypeString, + }, + "enable_ull_streaming": { + Optional: true, + Description: "Enables ultra low latency (ULL) streaming. ULL reduces latency and decreases overall transfer time of live streams.", + Type: schema.TypeBool, + }, + "show_advanced": { + Optional: true, + Description: "Allows you to configure advanced media options.", + Type: schema.TypeBool, + }, + "live_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CONTINUOUS", "EVENT"}, false)), + Optional: true, + Description: "The type of live media.", + Type: schema.TypeString, + }, + "start_time": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "This specifies when the live media event begins.", + Type: schema.TypeString, + }, + "end_time": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "This specifies when the live media event ends.", + Type: schema.TypeString, + }, + "dvr_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CONFIGURABLE", "UNKNOWN"}, false)), + Optional: true, + Description: "The type of DVR.", + Type: schema.TypeString, + }, + "dvr_window": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Set the duration for your media, or `0m` if a DVR is not required.", + Type: schema.TypeString, + }, + }, + }, + }, + "segmented_media_streaming_prefetch": { + Optional: true, + Type: schema.TypeList, + Description: "Prefetches HLS and DASH media stream manifest and segment files, accelerating delivery to end users. For prefetching to work, your origin media's response needs to specify `CDN-Origin-Assist-Prefetch-Path` headers with each URL to prefetch, expressed as either a relative or absolute path. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables media stream prefetching.", + Type: schema.TypeBool, + }, + }, + }, + }, + "set_variable": { + Optional: true, + Type: schema.TypeList, + Description: "Modify a variable to insert into subsequent fields within the rule tree. Use this behavior to specify the predeclared `variableName` and determine from where to derive its new value. Based on this `valueSource`, you can either generate the value, extract it from some part of the incoming request, assign it from another variable (including a set of built-in system variables), or directly specify its text. Optionally choose a `transform` function to modify the value once. See `Support for variables` for more information. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "variable_name": { + Optional: true, + Description: "Specifies the predeclared root name of the variable to modify. When you declare a variable name such as `VAR`, its name is preprended with `PMUSER_` and accessible in a `user` namespace, so that you invoke it in subsequent text fields within the rule tree as `{{user.PMUSER_VAR}}`. In deployed `XML metadata`, it appears as `%(PMUSER_VAR)`.", + Type: schema.TypeString, + }, + "value_source": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"EXPRESSION", "EXTRACT", "GENERATE"}, false)), + Optional: true, + Description: "Determines how you want to set the value.", + Type: schema.TypeString, + }, + "variable_value": { + Optional: true, + Description: "This directly specifies the value to assign to the variable. The expression may include a mix of static text and other variables, such as `new_filename.{{builtin.AK_EXTENSION}}` to embed a system variable.", + Type: schema.TypeString, + }, + "extract_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_CERTIFICATE", "CLIENT_REQUEST_HEADER", "COOKIE", "EDGESCAPE", "PATH_COMPONENT_OFFSET", "QUERY_STRING", "DEVICE_PROFILE", "RESPONSE_HEADER", "SET_COOKIE"}, false)), + Optional: true, + Description: "This specifies from where to get the value.", + Type: schema.TypeString, + }, + "certificate_field_name": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"VERSION", "SERIAL", "FINGERPRINT_MD5", "FINGERPRINT_SHA1", "FINGERPRINT_DYN", "ISSUER_DN", "SUBJECT_DN", "NOT_BEFORE", "NOT_AFTER", "SIGNATURE_ALGORITHM", "SIGNATURE", "CONTENTS_DER", "CONTENTS_PEM", "CONTENTS_PEM_NO_LABELS", "COUNT", "STATUS_MSG", "KEY_LENGTH"}, false)), + Optional: true, + Description: "Specifies the certificate's content.", + Type: schema.TypeString, + }, + "header_name": { + Optional: true, + Description: "Specifies the case-insensitive name of the HTTP header to extract.", + Type: schema.TypeString, + }, + "response_header_name": { + Optional: true, + Description: "Specifies the case-insensitive name of the HTTP header to extract.", + Type: schema.TypeString, + }, + "set_cookie_name": { + Optional: true, + Description: "Specifies the name of the origin's `Set-Cookie` response header.", + Type: schema.TypeString, + }, + "cookie_name": { + Optional: true, + Description: "Specifies the name of the cookie to extract.", + Type: schema.TypeString, + }, + "location_id": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"GEOREGION", "COUNTRY_CODE", "REGION_CODE", "CITY", "DMA", "PMSA", "MSA", "AREACODE", "COUNTY", "FIPS", "LAT", "LONG", "TIMEZONE", "ZIP", "CONTINENT", "NETWORK", "NETWORK_TYPE", "ASNUM", "THROUGHPUT", "BW"}, false)), + Optional: true, + Description: "Specifies the `X-Akamai-Edgescape` header's field name. Possible values specify basic geolocation, various geographic standards, and information about the client's network. For details on EdgeScape header fields, see the `EdgeScape User Guide`.", + Type: schema.TypeString, + }, + "path_component_offset": { + Optional: true, + Description: "This specifies a portion of the path. The indexing starts from `1`, so a value of `/path/to/nested/filename.html` and an offset of `1` yields `path`, and `3` yields `nested`. Negative indexes offset from the right, so `-2` also yields `nested`.", + Type: schema.TypeString, + }, + "query_parameter_name": { + Optional: true, + Description: "Specifies the name of the query parameter from which to extract the value.", + Type: schema.TypeString, + }, + "generator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HEXRAND", "RAND"}, false)), + Optional: true, + Description: "This specifies the type of value to generate.", + Type: schema.TypeString, + }, + "number_of_bytes": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 16)), + Optional: true, + Description: "Specifies the number of random hex bytes to generate.", + Type: schema.TypeInt, + }, + "min_random_number": { + Optional: true, + Description: "Specifies the lower bound of the random number.", + Type: schema.TypeString, + }, + "max_random_number": { + Optional: true, + Description: "Specifies the upper bound of the random number.", + Type: schema.TypeString, + }, + "transform": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NONE", "ADD", "BASE_64_DECODE", "BASE_64_ENCODE", "BASE_32_DECODE", "BASE_32_ENCODE", "BITWISE_AND", "BITWISE_NOT", "BITWISE_OR", "BITWISE_XOR", "DECIMAL_TO_HEX", "DECRYPT", "DIVIDE", "ENCRYPT", "EPOCH_TO_STRING", "EXTRACT_PARAM", "HASH", "JSON_EXTRACT", "HEX_TO_DECIMAL", "HEX_DECODE", "HEX_ENCODE", "HMAC", "LOWER", "MD5", "MINUS", "MODULO", "MULTIPLY", "NORMALIZE_PATH_WIN", "REMOVE_WHITESPACE", "COMPRESS_WHITESPACE", "SHA_1", "SHA_256", "STRING_INDEX", "STRING_LENGTH", "STRING_TO_EPOCH", "SUBSTITUTE", "SUBSTRING", "SUBTRACT", "TRIM", "UPPER", "BASE_64_URL_DECODE", "BASE_64_URL_ENCODE", "URL_DECODE", "URL_ENCODE", "URL_DECODE_UNI", "UTC_SECONDS", "XML_DECODE", "XML_ENCODE"}, false)), + Optional: true, + Description: "Specifies a function to transform the value. For more details on each transform function, see `Set Variable: Operations`.", + Type: schema.TypeString, + }, + "operand_one": { + Optional: true, + Description: "Specifies an additional operand when the `transform` function is set to various arithmetic functions (`ADD`, `SUBTRACT`, `MULTIPLY`, `DIVIDE`, or `MODULO`) or bitwise functions (`BITWISE_AND`, `BITWISE_OR`, or `BITWISE_XOR`).", + Type: schema.TypeString, + }, + "algorithm": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ALG_3DES", "ALG_AES128", "ALG_AES256"}, false)), + Optional: true, + Description: "Specifies the algorithm to apply.", + Type: schema.TypeString, + }, + "encryption_key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]+$"), + Optional: true, + Description: "Specifies the encryption hex key. For `ALG_3DES` it needs to be 48 characters long, 32 characters for `ALG_AES128`, and 64 characters for `ALG_AES256`.", + Type: schema.TypeString, + }, + "initialization_vector": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]+$"), + Optional: true, + Description: "Specifies a one-time number as an initialization vector. It needs to be 15 characters long for `ALG_3DES`, and 32 characters for both `ALG_AES128` and `ALG_AES256`.", + Type: schema.TypeString, + }, + "encryption_mode": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CBC", "ECB"}, false)), + Optional: true, + Description: "Specifies the encryption mode.", + Type: schema.TypeString, + }, + "nonce": { + Optional: true, + Description: "Specifies the one-time number used for encryption.", + Type: schema.TypeString, + }, + "prepend_bytes": { + Optional: true, + Description: "Specifies a number of random bytes to prepend to the key.", + Type: schema.TypeBool, + }, + "format_string": { + Optional: true, + Description: "Specifies an optional format string for the conversion, using format codes such as `%m/%d/%y` as specified by `strftime`. A blank value defaults to RFC-2616 format.", + Type: schema.TypeString, + }, + "param_name": { + Optional: true, + Description: "Extracts the value for the specified parameter name from a string that contains key/value pairs. (Use `separator` below to parse them.)", + Type: schema.TypeString, + }, + "separator": { + Optional: true, + Description: "Specifies the character that separates pairs of values within the string.", + Type: schema.TypeString, + }, + "min": { + Optional: true, + Description: "Specifies a minimum value for the generated integer.", + Type: schema.TypeInt, + }, + "max": { + Optional: true, + Description: "Specifies a maximum value for the generated integer.", + Type: schema.TypeInt, + }, + "hmac_key": { + Optional: true, + Description: "Specifies the secret to use in generating the base64-encoded digest.", + Type: schema.TypeString, + }, + "hmac_algorithm": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SHA1", "SHA256", "MD5"}, false)), + Optional: true, + Description: "Specifies the algorithm to use to generate the base64-encoded digest.", + Type: schema.TypeString, + }, + "ip_version": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IPV4", "IPV6"}, false)), + Optional: true, + Description: "Specifies the IP version under which a subnet mask generates.", + Type: schema.TypeString, + }, + "ipv6_prefix": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 128)), + Optional: true, + Description: "Specifies the prefix of the IPV6 address, a value between 0 and 128.", + Type: schema.TypeInt, + }, + "ipv4_prefix": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 32)), + Optional: true, + Description: "Specifies the prefix of the IPV4 address, a value between 0 and 32.", + Type: schema.TypeInt, + }, + "sub_string": { + Optional: true, + Description: "Specifies a substring for which the returned value represents a zero-based offset of where it appears in the original string, or `-1` if there's no match.", + Type: schema.TypeString, + }, + "regex": { + Optional: true, + Description: "Specifies the regular expression pattern (PCRE) to match the value.", + Type: schema.TypeString, + }, + "replacement": { + Optional: true, + Description: "Specifies the replacement string. Reinsert grouped items from the match into the replacement using `$1`, `$2` ... `$n`.", + Type: schema.TypeString, + }, + "case_sensitive": { + Optional: true, + Description: "Enabling this makes all matches case sensitive.", + Type: schema.TypeBool, + }, + "global_substitution": { + Optional: true, + Description: "Replaces all matches in the string, not just the first.", + Type: schema.TypeBool, + }, + "start_index": { + Optional: true, + Description: "Specifies the zero-based character offset at the start of the substring. Negative indexes specify the offset from the end of the string.", + Type: schema.TypeString, + }, + "end_index": { + Optional: true, + Description: "Specifies the zero-based character offset at the end of the substring, without including the character at that index position. Negative indexes specify the offset from the end of the string.", + Type: schema.TypeString, + }, + "except_chars": { + Optional: true, + Description: "Specifies characters `not` to encode, possibly overriding the default set.", + Type: schema.TypeString, + }, + "force_chars": { + Optional: true, + Description: "Specifies characters to encode, possibly overriding the default set.", + Type: schema.TypeString, + }, + "device_profile": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_MOBILE", "IS_TABLET", "IS_WIRELESS_DEVICE", "PHYSICAL_SCREEN_HEIGHT", "PHYSICAL_SCREEN_WIDTH", "RESOLUTION_HEIGHT", "RESOLUTION_WIDTH", "VIEWPORT_WIDTH", "BRAND_NAME", "DEVICE_OS", "DEVICE_OS_VERSION", "DUAL_ORIENTATION", "MAX_IMAGE_HEIGHT", "MAX_IMAGE_WIDTH", "MOBILE_BROWSER", "MOBILE_BROWSER_VERSION", "PDF_SUPPORT", "COOKIE_SUPPORT"}, false)), + Optional: true, + Description: "Specifies the client device attribute. Possible values specify information about the client device, including device type, size and browser. For details on fields, see `Device Characterization`.", + Type: schema.TypeString, + }, + }, + }, + }, + "simulate_error_code": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior simulates various error response codes. Contact Akamai Professional Services for help configuring it. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "error_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ERR_DNS_TIMEOUT", "ERR_SUREROUTE_DNS_FAIL", "ERR_DNS_FAIL", "ERR_CONNECT_TIMEOUT", "ERR_NO_GOOD_FWD_IP", "ERR_DNS_IN_REGION", "ERR_CONNECT_FAIL", "ERR_READ_TIMEOUT", "ERR_READ_ERROR", "ERR_WRITE_ERROR"}, false)), + Optional: true, + Description: "Specifies the type of error.", + Type: schema.TypeString, + }, + "timeout": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "When the `errorType` is `ERR_CONNECT_TIMEOUT`, `ERR_DNS_TIMEOUT`, `ERR_SUREROUTE_DNS_FAIL`, or `ERR_READ_TIMEOUT`, generates an error after the specified amount of time from the initial request.", + Type: schema.TypeString, + }, + }, + }, + }, + "site_shield": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior implements the `Site Shield` feature, which helps prevent non-Akamai machines from contacting your origin. You get an email with a list of Akamai servers allowed to contact your origin, with which you establish an Access Control List on your firewall to prevent any other requests. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "ssmap": { + Optional: true, + Description: "Identifies the hostname for the Site Shield map. See `Create a Site Shield map` for more details. Form an object with a `value` key that references the hostname, for example: `\"ssmap\":{\"value\":\"ss.akamai.net\"}`.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "value": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "srmap": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "nossmap": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "standard_tls_migration": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows migration to Standard TLS.", + Type: schema.TypeBool, + }, + "migration_from": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SHARED_CERT", "NON_SECURE", "ENHANCED_SECURE"}, false)), + Optional: true, + Description: "What kind of traffic you're migrating from.", + Type: schema.TypeString, + }, + "allow_https_upgrade": { + Optional: true, + Description: "Allows temporary upgrade of HTTP traffic to HTTPS.", + Type: schema.TypeBool, + }, + "allow_https_downgrade": { + Optional: true, + Description: "Allow temporary downgrade of HTTPS traffic to HTTP. This removes various `Origin`, `Referer`, `Cookie`, `Cookie2`, `sec-*` and `proxy-*` headers from the request to origin.", + Type: schema.TypeBool, + }, + "migration_start_time": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies when to start migrating the cache.", + Type: schema.TypeString, + }, + "migration_duration": { + ValidateDiagFunc: validateRegex("^[1-9]$|^[1-2]\\d$|^30$"), + Optional: true, + Description: "Specifies the number of days to migrate the cache.", + Type: schema.TypeInt, + }, + "cache_sharing_start_time": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies when to start cache sharing.", + Type: schema.TypeString, + }, + "cache_sharing_duration": { + ValidateDiagFunc: validateRegex("^[1-9]$|^[1-2]\\d$|^30$"), + Optional: true, + Description: "Specifies the number cache sharing days.", + Type: schema.TypeInt, + }, + "is_certificate_sni_only": { + Optional: true, + Description: "Sets whether your new certificate is SNI-only.", + Type: schema.TypeBool, + }, + "is_tiered_distribution_used": { + Optional: true, + Description: "Allows you to align traffic to various `tieredDistribution` areas.", + Type: schema.TypeBool, + }, + "td_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"GLOBAL", "APAC", "EUROPE", "US_EAST", "US_CENTRAL", "US_WEST", "AUSTRALIA", "GLOBAL_LEGACY"}, false)), + Optional: true, + Description: "Specifies the `tieredDistribution` location.", + Type: schema.TypeString, + }, + }, + }, + }, + "standard_tls_migration_override": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior is for internal usage only. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "info": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "strict_header_parsing": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior specifies how the edge servers should handle requests containing improperly formatted or invalid headers that don’t comply with `RFC 9110`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "valid_mode": { + Optional: true, + Description: "Rejects requests made with non-RFC-compliant headers that contain invalid characters in the header name or value or which contain invalidly-folded header lines. When disabled, the edge servers allow such requests, passing the invalid headers to the origin server unchanged.", + Type: schema.TypeBool, + }, + "strict_mode": { + Optional: true, + Description: "Rejects requests made with non-RFC-compliant, improperly formatted headers, where the header line starts with a colon, misses a colon or doesn’t end with CR LF. When disabled, the edge servers allow such requests, but correct the violation by removing or rewriting the header line before passing the headers to the origin server.", + Type: schema.TypeBool, + }, + }, + }, + }, + "sub_customer": { + Optional: true, + Type: schema.TypeList, + Description: "When positioned in a property's top-level default rule, enables various `Cloud Embed` features that allow you to leverage Akamai's CDN architecture for your own subcustomers. This behavior's options allow you to use Cloud Embed to configure your subcustomers' content. Once enabled, you can use the `Akamai Cloud Embed API` (ACE) to assign subcustomers to this base configuration, and to customize policies for them. See also the `dynamicWebContent` behavior to configure subcustomers' dynamic web content. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows Cloud Embed to dynamically modify your subcustomers' content.", + Type: schema.TypeBool, + }, + "origin": { + Optional: true, + Description: "Allows you to assign origin hostnames for customers.", + Type: schema.TypeBool, + }, + "partner_domain_suffix": { + Optional: true, + Description: "This specifies the appropriate domain suffix, which you should typically match with your property hostname. It identifies the domain as trustworthy on the Akamai network, despite being defined within Cloud Embed, outside of your base property configuration. Include this domain suffix if you want to purge subcustomer URLs. For example, if you provide a value of `suffix.example.com`, then to purge `subcustomer.com/some/path`, specify `subcustomer.com.suffix.example.com/some/path` as the purge request's URL.", + Type: schema.TypeString, + }, + "caching": { + Optional: true, + Description: "Modifies content caching rules.", + Type: schema.TypeBool, + }, + "referrer": { + Optional: true, + Description: "Sets subcustomers' referrer whitelists or blacklist.", + Type: schema.TypeBool, + }, + "ip": { + Optional: true, + Description: "Sets subcustomers' IP whitelists or blacklists.", + Type: schema.TypeBool, + }, + "geo_location": { + Optional: true, + Description: "Sets subcustomers' location-based whitelists or blacklists.", + Type: schema.TypeBool, + }, + "refresh_content": { + Optional: true, + Description: "Allows you to reschedule when content validates for subcustomers.", + Type: schema.TypeBool, + }, + "modify_path": { + Optional: true, + Description: "Modifies a subcustomer's request path.", + Type: schema.TypeBool, + }, + "cache_key": { + Optional: true, + Description: "Allows you to set which query parameters are included in the cache key.", + Type: schema.TypeBool, + }, + "token_authorization": { + Optional: true, + Description: "When enabled, this allows you to configure edge servers to use tokens to control access to subcustomer content. Use Cloud Embed to configure the token to appear in a cookie, header, or query parameter.", + Type: schema.TypeBool, + }, + "site_failover": { + Optional: true, + Description: "Allows you to configure unique failover sites for each subcustomer's policy.", + Type: schema.TypeBool, + }, + "content_compressor": { + Optional: true, + Description: "Allows compression of subcustomer content.", + Type: schema.TypeBool, + }, + "access_control": { + Optional: true, + Description: "When enabled, this allows you to deny requests to a subcustomer's content based on specific match conditions, which you use Cloud Embed to configure in each subcustomer's policy.", + Type: schema.TypeBool, + }, + "dynamic_web_content": { + Optional: true, + Description: "Allows you to apply the `dynamicWebContent` behavior to further modify how dynamic content behaves for subcustomers.", + Type: schema.TypeBool, + }, + "on_demand_video_delivery": { + Optional: true, + Description: "Enables delivery of media assets to subcustomers.", + Type: schema.TypeBool, + }, + "large_file_delivery": { + Optional: true, + Description: "Enables large file delivery for subcustomers.", + Type: schema.TypeBool, + }, + "live_video_delivery": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + "web_application_firewall": { + Optional: true, + Description: "Web application firewall (WAF) filters, monitors, and blocks certain HTTP traffic. Use `Akamai Cloud Embed` to add a specific behavior to a subcustomer policy and configure how WAF protection is applied.", + Type: schema.TypeBool, + }, + }, + }, + }, + "sure_route": { + Optional: true, + Type: schema.TypeList, + Description: "The `SureRoute` feature continually tests different routes between origin and edge servers to identify the optimal path. By default, it conducts `races` to identify alternative paths to use in case of a transmission failure. These races increase origin traffic slightly. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the SureRoute behavior, to optimize delivery of non-cached content.", + Type: schema.TypeBool, + }, + "type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"PERFORMANCE", "CUSTOM_MAP"}, false)), + Optional: true, + Description: "Specifies the set of edge servers used to test routes.", + Type: schema.TypeString, + }, + "custom_map": { + Optional: true, + Description: "If `type` is `CUSTOM_MAP`, this specifies the map string provided to you by Akamai Professional Services, or included as part of the `Site Shield` product.", + Type: schema.TypeString, + }, + "test_object_url": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the path and filename for your origin's test object to use in races to test routes.", + Type: schema.TypeString, + }, + "sr_download_link_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "to_host_status": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"INCOMING_HH", "OTHER"}, false)), + Optional: true, + Description: "Specifies which hostname to use.", + Type: schema.TypeString, + }, + "to_host": { + Optional: true, + Description: "If `toHostStatus` is `OTHER`, this specifies the custom `Host` header to use when requesting the SureRoute test object.", + Type: schema.TypeString, + }, + "race_stat_ttl": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the time-to-live to preserve SureRoute race results, typically `30m`. If traffic exceeds a certain threshold after TTL expires, the overflow is routed directly to the origin, not necessarily optimally. If traffic remains under the threshold, the route is determined by the winner of the most recent race.", + Type: schema.TypeString, + }, + "force_ssl_forward": { + Optional: true, + Description: "Forces SureRoute to use SSL when requesting the origin's test object, appropriate if your origin does not respond to HTTP requests, or responds with a redirect to HTTPS.", + Type: schema.TypeBool, + }, + "allow_fcm_parent_override": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + "enable_custom_key": { + Optional: true, + Description: "When disabled, caches race results under the race destination's hostname. If enabled, use `customStatKey` to specify a custom hostname.", + Type: schema.TypeBool, + }, + "custom_stat_key": { + ValidateDiagFunc: validateRegex("^([a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,62})+$"), + Optional: true, + Description: "This specifies a hostname under which to cache race results. This may be useful when a property corresponds to many origin hostnames. By default, SureRoute would launch races for each origin, but consolidating under a single hostname runs only one race.", + Type: schema.TypeString, + }, + }, + }, + }, + "tcp_optimization": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior is deprecated, but you should not disable or remove it if present. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "display": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "tea_leaf": { + Optional: true, + Type: schema.TypeList, + Description: "Allows IBM Tealeaf Customer Experience on Cloud to record HTTPS requests and responses for Akamai-enabled properties. Recorded data becomes available in your IBM Tealeaf account. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, capture HTTPS requests and responses, and send the data to your IBM Tealeaf account.", + Type: schema.TypeBool, + }, + "limit_to_dynamic": { + Optional: true, + Description: "Limit traffic to dynamic, uncached (`No-Store`) content.", + Type: schema.TypeBool, + }, + "ibm_customer_id": { + Optional: true, + Description: "The integer identifier for the IBM Tealeaf Connector account.", + Type: schema.TypeInt, + }, + }, + }, + }, + "tiered_distribution": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows Akamai edge servers to retrieve cached content from other Akamai servers, rather than directly from the origin. These interim `parent` servers in the `cache hierarchy` (`CH`) are positioned close to the origin, and fall along the path from the origin to the edge server. Tiered Distribution typically reduces the origin server's load, and reduces the time it takes for edge servers to refresh content. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, activates tiered distribution.", + Type: schema.TypeBool, + }, + "tiered_distribution_map": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CH2", "CHAPAC", "CHEU2", "CHEUS2", "CHCUS2", "CHWUS2", "CHAUS", "CH"}, false)), + Optional: true, + Description: "Optionally map the tiered parent server's location close to your origin. A narrower local map minimizes the origin server's load, and increases the likelihood the requested object is cached. A wider global map reduces end-user latency, but decreases the likelihood the requested object is in any given parent server's cache. This option cannot apply if the property is marked as secure. See `Secure property requirements` for guidance.", + Type: schema.TypeString, + }, + }, + }, + }, + "tiered_distribution_advanced": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows Akamai edge servers to retrieve cached content from other Akamai servers, rather than directly from the origin. These interim `parent` servers in the `cache hierarchy` (`CH`) are positioned close to the origin, and fall along the path from the origin to the edge server. Tiered Distribution typically reduces the origin server's load, and reduces the time it takes for edge servers to refresh content. This advanced behavior provides a wider set of options than `tieredDistribution`. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "When enabled, activates tiered distribution.", + Type: schema.TypeBool, + }, + "method": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SERIAL_PREPEND", "DOMAIN_LOOKUP"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "policy": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"PERFORMANCE", "TIERED_DISTRIBUTION", "FAIL_OVER", "SITE_SHIELD", "SITE_SHIELD_PERFORMANCE"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "tiered_distribution_map": { + Optional: true, + Description: "Optionally map the tiered parent server's location close to your origin: `CHEU2` for Europe; `CHAUS` for Australia; `CHAPAC` for China and the Asian Pacific area; `CHWUS2`, `CHCUS2`, and `CHEUS2` for different parts of the United States. Choose `CH` or `CH2` for a more global map. A narrower local map minimizes the origin server's load, and increases the likelihood the requested object is cached. A wider global map reduces end-user latency, but decreases the likelihood the requested object is in any given parent server's cache. This option cannot apply if the property is marked as secure. See `Secure property requirements` for guidance.", + Type: schema.TypeString, + }, + "allowall": { + Optional: true, + Description: "", + Type: schema.TypeBool, + }, + }, + }, + }, + "tiered_distribution_customization": { + Optional: true, + Type: schema.TypeList, + Description: "With Tiered Distribution, Akamai edge servers retrieve cached content from other Akamai servers, rather than directly from the origin. This behavior sets custom Tiered Distribution maps (TD0) and migrates TD1 maps configured with `advanced features` to Cloud Wrapper. You need to enable `cloudWrapper` within the same rule. This behavior is for internal usage only. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "tier1_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "custom_map_enabled": { + Optional: true, + Description: "Enables custom maps.", + Type: schema.TypeBool, + }, + "custom_map_name": { + ValidateDiagFunc: validateRegex("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)+(akamai|akamaiedge)\\.net$"), + Optional: true, + Description: "Specifies the custom map name.", + Type: schema.TypeString, + }, + "serial_start": { + Optional: true, + Description: "Specifies a numeric serial start value.", + Type: schema.TypeString, + }, + "serial_end": { + Optional: true, + Description: "Specifies a numeric serial end value. Akamai uses serial numbers to group machines and share objects in their cache with other machines in the same region.", + Type: schema.TypeString, + }, + "hash_algorithm": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"GCC", "JENKINS"}, false)), + Optional: true, + Description: "Specifies the hash algorithm.", + Type: schema.TypeString, + }, + "cloudwrapper_map_migration_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "map_migration_enabled": { + Optional: true, + Description: "Enables migration of the custom map to Cloud Wrapper.", + Type: schema.TypeBool, + }, + "migration_within_cw_maps_enabled": { + Optional: true, + Description: "Enables migration within Cloud Wrapper maps.", + Type: schema.TypeBool, + }, + "location": { + Optional: true, + Description: "Location from which Cloud Wrapper migration is performed. User should choose the existing Cloud Wrapper location. The new Cloud Wrapper location (to which migration has to happen) is expected to be updated as part of the main \"Cloud Wrapper\" behavior.", + Type: schema.TypeString, + }, + "migration_start_date": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies when to start migrating the map.", + Type: schema.TypeString, + }, + "migration_end_date": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies when the map migration should end.", + Type: schema.TypeString, + }, + }, + }, + }, + "timeout": { + Optional: true, + Type: schema.TypeList, + Description: "Sets the HTTP connect timeout. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the timeout, for example `10s`.", + Type: schema.TypeString, + }, + }, + }, + }, + "uid_configuration": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows you to extract unique identifier (UID) values from live traffic, for use in OTA applications. Note that you are responsible for maintaining the security of any data that may identify individual users. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "legal_text": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Allows you to extract UIDs from client requests.", + Type: schema.TypeBool, + }, + "extract_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQUEST_HEADER", "QUERY_STRING", "VARIABLE"}, false)), + Optional: true, + Description: "Where to extract the UID value from.", + Type: schema.TypeString, + }, + "header_name": { + Optional: true, + Description: "This specifies the name of the HTTP header from which to extract the UID value.", + Type: schema.TypeString, + }, + "query_parameter_name": { + Optional: true, + Description: "This specifies the name of the query parameter from which to extract the UID value.", + Type: schema.TypeString, + }, + "variable_name": { + Optional: true, + Description: "This specifies the name of the rule tree variable from which to extract the UID value.", + Type: schema.TypeString, + }, + }, + }, + }, + "validate_entity_tag": { + Optional: true, + Type: schema.TypeList, + Description: "Instructs edge servers to compare the request's `ETag` header with that of the cached object. If they differ, the edge server sends a new copy of the object. This validation occurs in addition to the default validation of `Last-Modified` and `If-Modified-Since` headers. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the ETag validation behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + "verify_json_web_token": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows you to use JSON Web Tokens (JWT) to verify requests. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "extract_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQUEST_HEADER", "QUERY_STRING"}, false)), + Optional: true, + Description: "Specify from where to extract the JWT value.", + Type: schema.TypeString, + }, + "header_name": { + Optional: true, + Description: "This specifies the name of the header from which to extract the JWT value.", + Type: schema.TypeString, + }, + "query_parameter_name": { + Optional: true, + Description: "This specifies the name of the query parameter from which to extract the JWT value.", + Type: schema.TypeString, + }, + "jwt": { + Optional: true, + Description: "An identifier for the JWT keys collection.", + Type: schema.TypeString, + }, + "enable_rs256": { + Optional: true, + Description: "Verifies JWTs signed with the RS256 algorithm. This signature helps ensure that the token hasn't been tampered with.", + Type: schema.TypeBool, + }, + "enable_es256": { + Optional: true, + Description: "Verifies JWTs signed with the ES256 algorithm. This signature helps ensure that the token hasn't been tampered with.", + Type: schema.TypeBool, + }, + }, + }, + }, + "verify_json_web_token_for_dcp": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows you to use JSON web tokens (JWT) to verify requests for use in implementing `IoT Edge Connect`, which you use the `dcp` behavior to configure. You can specify the location in a request to pass a JSON web token (JWT), collections of public keys to verify the integrity of this token, and specific claims to extract from it. Use the `verifyJsonWebToken` behavior for other JWT validation. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "extract_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQUEST_HEADER", "QUERY_STRING", "CLIENT_REQUEST_HEADER_AND_QUERY_STRING"}, false)), + Optional: true, + Description: "Specifies where to get the JWT value from.", + Type: schema.TypeString, + }, + "primary_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQUEST_HEADER", "QUERY_STRING"}, false)), + Optional: true, + Description: "Specifies the primary location to extract the JWT value from. If the specified option doesn't include the JWTs, the system checks the secondary one.", + Type: schema.TypeString, + }, + "custom_header": { + Optional: true, + Description: "The JWT value comes from the `X-Akamai-DCP-Token` header by default. Enabling this option allows you to extract it from another header name that you specify.", + Type: schema.TypeBool, + }, + "header_name": { + Optional: true, + Description: "This specifies the name of the header to extract the JWT value from.", + Type: schema.TypeString, + }, + "query_parameter_name": { + Optional: true, + Description: "Specifies the name of the query parameter from which to extract the JWT value.", + Type: schema.TypeString, + }, + "jwt": { + Optional: true, + Description: "An identifier for the JWT keys collection.", + Type: schema.TypeString, + }, + "extract_client_id": { + Optional: true, + Description: "Allows you to extract the client ID claim name stored in JWT.", + Type: schema.TypeBool, + }, + "client_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,20}$"), + Optional: true, + Description: "This specifies the claim name.", + Type: schema.TypeString, + }, + "extract_authorizations": { + Optional: true, + Description: "Allows you to extract the authorization groups stored in the JWT.", + Type: schema.TypeBool, + }, + "authorizations": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,20}$"), + Optional: true, + Description: "This specifies the authorization group name.", + Type: schema.TypeString, + }, + "extract_user_name": { + Optional: true, + Description: "Allows you to extract the user name stored in the JWT.", + Type: schema.TypeBool, + }, + "user_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,20}$"), + Optional: true, + Description: "This specifies the user name.", + Type: schema.TypeString, + }, + "enable_rs256": { + Optional: true, + Description: "Verifies JWTs signed with the RS256 algorithm. This signature helps to ensure that the token hasn't been tampered with.", + Type: schema.TypeBool, + }, + "enable_es256": { + Optional: true, + Description: "Verifies JWTs signed with the ES256 algorithm. This signature helps to ensure that the token hasn't been tampered with.", + Type: schema.TypeBool, + }, + }, + }, + }, + "verify_token_authorization": { + Optional: true, + Type: schema.TypeList, + Description: "Verifies Auth 2.0 tokens. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "use_advanced": { + Optional: true, + Description: "If enabled, allows you to specify advanced options such as `algorithm`, `escapeHmacInputs`, `ignoreQueryString`, `transitionKey`, and `salt`.", + Type: schema.TypeBool, + }, + "location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COOKIE", "QUERY_STRING", "CLIENT_REQUEST_HEADER"}, false)), + Optional: true, + Description: "Specifies where to find the token in the incoming request.", + Type: schema.TypeString, + }, + "location_id": { + Optional: true, + Description: "When `location` is `CLIENT_REQUEST_HEADER`, specifies the name of the incoming request's header where to find the token.", + Type: schema.TypeString, + }, + "algorithm": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"SHA256", "SHA1", "MD5"}, false)), + Optional: true, + Description: "Specifies the algorithm that generates the token. It needs to match the method chosen in the token generation code.", + Type: schema.TypeString, + }, + "escape_hmac_inputs": { + Optional: true, + Description: "URL-escapes HMAC inputs passed in as query parameters.", + Type: schema.TypeBool, + }, + "ignore_query_string": { + Optional: true, + Description: "Enabling this removes the query string from the URL used to form an encryption key.", + Type: schema.TypeBool, + }, + "key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]{64}$"), + Optional: true, + Description: "The shared secret used to validate tokens, which needs to match the key used in the token generation code.", + Type: schema.TypeString, + }, + "transition_key": { + ValidateDiagFunc: validateRegex("^(0x)?[0-9a-fA-F]{64}$"), + Optional: true, + Description: "Specifies a transition key as a hex value.", + Type: schema.TypeString, + }, + "salt": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(16, 16)), + Optional: true, + Description: "Specifies a salt string for input when generating the token, which needs to match the salt value used in the token generation code.", + Type: schema.TypeString, + }, + "failure_response": { + Optional: true, + Description: "When enabled, sends an HTTP error when an authentication test fails.", + Type: schema.TypeBool, + }, + }, + }, + }, + "virtual_waiting_room": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior helps you maintain business continuity for dynamic applications in high-demand situations such as flash sales. It decreases abandonment by providing a user-friendly waiting room experience. FIFO (First-in First-out) is a request processing mechanism that prioritizes the first requests that enter the waiting room to send them first to the origin. Users can see both their estimated arrival time and position in the line. With Cloudlets available on your contract, choose `Your services` > `Edge logic Cloudlets` to control Virtual Waitig Room within `Control Center`. Otherwise use the `Cloudlets API` to configure it programmatically. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "This identifies the Visitor Waiting Room Cloudlet shared policy to use with this behavior. You can list available shared policies with the `Cloudlets API`.", + Type: schema.TypeInt, + }, + "domain_config": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HOST_HEADER", "CUSTOM"}, false)), + Optional: true, + Description: "This specifies the domain used to establish a session with the visitor.", + Type: schema.TypeString, + }, + "custom_cookie_domain": { + ValidateDiagFunc: validateRegex("^(\\.)?(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"), + Optional: true, + Description: "This specifies a domain for all session cookies. In case you configure many property hostnames, this may be their common domain. Make sure the user agent accepts the custom domain for any request matching the `virtualWaitingRoom` behavior. Don't use top level domains (TLDs).", + Type: schema.TypeString, + }, + "waiting_room_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "waiting_room_path": { + Optional: true, + Description: "This specifies the path to the waiting room main page on the origin server, for example `/vp/waiting-room.html`. When the request is marked as Waiting Room Main Page and blocked, the visitor enters the waiting room. The behavior sets the outgoing request path to the `waitingRoomPath` and modifies the cache key accordingly. See the `virtualWaitingRoomRequest` match criteria to further customize these requests.", + Type: schema.TypeString, + }, + "waiting_room_assets_paths": { + Optional: true, + Description: "This specifies the base paths to static resources such as JavaScript, CSS, or image files for the Waiting Room Main Page requests. The option supports the multiple-character `*` wildcard. Requests matching any of these paths aren't blocked, but marked as Waiting Room Assets and passed through to the origin. See the `virtualWaitingRoomRequest` match criteria to further customize these requests.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "access_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "session_duration": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 86400)), + Optional: true, + Description: "Specifies the number of seconds users remain in the waiting room queue.", + Type: schema.TypeInt, + }, + "session_auto_prolong": { + Optional: true, + Description: "Whether the queue session should prolong automatically when the `sessionDuration` expires and the visitor remains active.", + Type: schema.TypeBool, + }, + }, + }, + }, + "virtual_waiting_room_with_edge_workers": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior allows you to configure the `virtualWaitingRoom` behavior with EdgeWorkers for extended scalability and customization. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + }, + }, + }, + "visitor_prioritization": { + Optional: true, + Type: schema.TypeList, + Description: "The `Visitor Prioritization Cloudlet` decreases abandonment by providing a user-friendly waiting room experience. With Cloudlets available on your contract, choose `Your services` > `Edge logic Cloudlets` to control Visitor Prioritization within `Control Center`. Otherwise use the `Cloudlets API` to configure it programmatically. To serve non-HTML API content such as JSON blocks, see the `apiPrioritization` behavior. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the Visitor Prioritization behavior.", + Type: schema.TypeBool, + }, + "cloudlet_policy": { + Optional: true, + Description: "Identifies the Cloudlet policy.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "user_identification_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "user_identification_by_cookie": { + Optional: true, + Description: "When enabled, identifies users by the value of a cookie.", + Type: schema.TypeBool, + }, + "user_identification_key_cookie": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies the name of the cookie whose value identifies users. To match a user, the value of the cookie needs to remain constant across all requests.", + Type: schema.TypeString, + }, + "user_identification_by_headers": { + Optional: true, + Description: "When enabled, identifies users by the values of GET or POST request headers.", + Type: schema.TypeBool, + }, + "user_identification_key_headers": { + Optional: true, + Description: "Specifies names of request headers whose values identify users. To match a user, values for all the specified headers need to remain constant across all requests.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "user_identification_by_ip": { + Optional: true, + Description: "Allows IP addresses to identify users.", + Type: schema.TypeBool, + }, + "user_identification_by_params": { + Optional: true, + Description: "When enabled, identifies users by the values of GET or POST request parameters.", + Type: schema.TypeBool, + }, + "user_identification_key_params": { + Optional: true, + Description: "Specifies names of request parameters whose values identify users. To match a user, values for all the specified parameters need to remain constant across all requests. Parameters that are absent or blank may also identify users.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "allowed_user_cookie_management_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "allowed_user_cookie_enabled": { + Optional: true, + Description: "Sets a cookie for users who have been allowed through to the site.", + Type: schema.TypeBool, + }, + "allowed_user_cookie_label": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies a label to distinguish this cookie for an allowed user from others. The value appends to the cookie's name, and helps you to maintain the same user assignment across behaviors within a property, and across properties.", + Type: schema.TypeString, + }, + "allowed_user_cookie_duration": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 600)), + Optional: true, + Description: "Sets the number of seconds for the allowed user's session once allowed through to the site.", + Type: schema.TypeInt, + }, + "allowed_user_cookie_refresh": { + Optional: true, + Description: "Resets the duration of an allowed cookie with each request, so that it only expires if the user doesn't make any requests for the specified duration. Do not enable this option if you want to set a fixed time for all users.", + Type: schema.TypeBool, + }, + "allowed_user_cookie_advanced": { + Optional: true, + Description: "Sets advanced configuration options for the allowed user's cookie.", + Type: schema.TypeBool, + }, + "allowed_user_cookie_automatic_salt": { + Optional: true, + Description: "Sets an automatic `salt` value to verify the integrity of the cookie for an allowed user. Disable this if you want to share the cookie across properties.", + Type: schema.TypeBool, + }, + "allowed_user_cookie_salt": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies a fixed `salt` value, which is incorporated into the cookie's value to prevent users from manipulating it. You can use the same salt string across different behaviors or properties to apply a single cookie to all allowed users.", + Type: schema.TypeString, + }, + "allowed_user_cookie_domain_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DYNAMIC", "CUSTOMER"}, false)), + Optional: true, + Description: "Specify with `allowedUserCookieAdvanced` enabled.", + Type: schema.TypeString, + }, + "allowed_user_cookie_domain": { + ValidateDiagFunc: validateRegex("^(\\.)?(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"), + Optional: true, + Description: "Specifies a domain for an allowed user cookie.", + Type: schema.TypeString, + }, + "allowed_user_cookie_http_only": { + Optional: true, + Description: "Applies the `HttpOnly` flag to the allowed user's cookie to ensure it's accessed over HTTP and not manipulated by the client.", + Type: schema.TypeBool, + }, + "waiting_room_cookie_management_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "waiting_room_cookie_enabled": { + Optional: true, + Description: "Enables a cookie to track a waiting room assignment.", + Type: schema.TypeBool, + }, + "waiting_room_cookie_share_label": { + Optional: true, + Description: "Enabling this option shares the same `allowedUserCookieLabel` string. If disabled, specify a different `waitingRoomCookieLabel`.", + Type: schema.TypeBool, + }, + "waiting_room_cookie_label": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies a label to distinguish this waiting room cookie from others. The value appends to the cookie's name, and helps you to maintain the same waiting room assignment across behaviors within a property, and across properties.", + Type: schema.TypeString, + }, + "waiting_room_cookie_duration": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 120)), + Optional: true, + Description: "Sets the number of seconds for which users remain in the waiting room. During this time, users who refresh the waiting room page remain there.", + Type: schema.TypeInt, + }, + "waiting_room_cookie_advanced": { + Optional: true, + Description: "When enabled along with `waitingRoomCookieEnabled`, sets advanced configuration options for the waiting room cookie.", + Type: schema.TypeBool, + }, + "waiting_room_cookie_automatic_salt": { + Optional: true, + Description: "Sets an automatic `salt` value to verify the integrity of the waiting room cookie. Disable this if you want to share the cookie across properties.", + Type: schema.TypeBool, + }, + "waiting_room_cookie_salt": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "Specifies a fixed `salt` value, which is incorporated into the cookie's value to prevent users from manipulating it. You can use the same salt string across different behaviors or properties to apply a single cookie for the waiting room session.", + Type: schema.TypeString, + }, + "waiting_room_cookie_domain_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"DYNAMIC", "CUSTOMER"}, false)), + Optional: true, + Description: "Specify with `waitingRoomCookieAdvanced` enabled, selects whether to use the `DYNAMIC` incoming host header, or a `CUSTOMER`-defined cookie domain.", + Type: schema.TypeString, + }, + "waiting_room_cookie_domain": { + ValidateDiagFunc: validateRegex("^(\\.)?(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"), + Optional: true, + Description: "Specifies a domain for the waiting room cookie.", + Type: schema.TypeString, + }, + "waiting_room_cookie_http_only": { + Optional: true, + Description: "Applies the `HttpOnly` flag to the waiting room cookie to ensure it's accessed over HTTP and not manipulated by the client.", + Type: schema.TypeBool, + }, + "waiting_room_management_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "waiting_room_status_code": { + ValidateDiagFunc: validateRegex("[2|4|5][0-9][0-9]"), + Optional: true, + Description: "Specifies the response code for requests sent to the waiting room.", + Type: schema.TypeInt, + }, + "waiting_room_use_cp_code": { + Optional: true, + Description: "Allows you to assign a different CP code that tracks any requests that are sent to the waiting room.", + Type: schema.TypeBool, + }, + "waiting_room_cp_code": { + Optional: true, + Description: "Specifies a `cpcode` object for requests sent to the waiting room, including a numeric `id` key and a descriptive `name`.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "waiting_room_net_storage": { + Optional: true, + Description: "Specifies the NetStorage domain for the waiting room page.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cp_code": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "download_domain_name": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "g2o_token": { + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "waiting_room_directory": { + ValidateDiagFunc: validateRegex("^[^#\\[\\]@]+$"), + Optional: true, + Description: "Specifies the NetStorage directory that contains the static waiting room page, with no trailing slash character.", + Type: schema.TypeString, + }, + "waiting_room_cache_ttl": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(5, 30)), + Optional: true, + Description: "Specifies the waiting room page's time to live in the cache, `5` minutes by default.", + Type: schema.TypeInt, + }, + }, + }, + }, + "visitor_prioritization_fifo": { + Optional: true, + Type: schema.TypeList, + Description: "(**BETA**) The `Visitor Prioritization Cloudlet (FIFO)` decreases abandonment by providing a user-friendly waiting room experience. FIFO (First-in First-out) is a fair request processing mechanism, which prioritizes the first requests that enter the waiting room to send them first to the origin. Users can see both their estimated arrival time and position in the line. With Cloudlets available on your contract, choose `Your services` > `Edge logic Cloudlets` to control Visitor Prioritization (FIFO) within `Control Center`. Otherwise use the `Cloudlets API` to configure it programmatically. To serve non-HTML API content such as JSON blocks, see the `apiPrioritization` behavior. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "cloudlet_shared_policy": { + Optional: true, + Description: "This identifies the Visitor Prioritization FIFO shared policy to use with this behavior. You can list available shared policies with the `Cloudlets API`.", + Type: schema.TypeInt, + }, + "domain_config": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HOST_HEADER", "CUSTOM"}, false)), + Optional: true, + Description: "This specifies how to set the domain used to establish a session with the visitor.", + Type: schema.TypeString, + }, + "custom_cookie_domain": { + ValidateDiagFunc: validateRegex("^(\\.)?(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)+([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"), + Optional: true, + Description: "This specifies a domain for all session cookies. In case you configure many property hostnames, this may be their common domain. Make sure the user agent accepts the custom domain for any request matching the `visitorPrioritizationFifo` behavior. Don't use top level domains (TLDs).", + Type: schema.TypeString, + }, + "waiting_room_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "waiting_room_path": { + Optional: true, + Description: "This specifies the path to the waiting room main page on the origin server, for example `/vp/waiting-room.html`. When the request is marked as `Waiting Room Main Page` and blocked, the visitor enters the waiting room. The behavior sets the outgoing request path to the `waitingRoomPath` and modifies the cache key accordingly. See the `visitorPrioritizationRequest` match criteria to further customize these requests.", + Type: schema.TypeString, + }, + "waiting_room_assets_paths": { + Optional: true, + Description: "This specifies the base paths to static resources such as `JavaScript`, `CSS`, or image files for the `Waiting Room Main Page` requests. The option supports the multiple-character `*` wildcard. Requests matching any of these paths aren't blocked, but marked as `Waiting Room Assets` and passed through to the origin. See the `visitorPrioritizationRequest` match criteria to further customize these requests.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "access_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "session_duration": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 86400)), + Optional: true, + Description: "Specifies the number of seconds users remain in the waiting room queue.", + Type: schema.TypeInt, + }, + "session_auto_prolong": { + Optional: true, + Description: "Whether the queue session should prolong automatically when the `sessionDuration` expires and the visitor remains active.", + Type: schema.TypeBool, + }, + }, + }, + }, + "visitor_prioritization_fifo_standalone": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + }, + }, + }, + "watermarking": { + Optional: true, + Type: schema.TypeList, + Description: "Adds watermarking for each valid user's content. Content segments are delivered from different sources using a pattern unique to each user, based on a watermarking token included in each request. If your content is pirated or redistributed, you can forensically analyze the segments to extract the pattern, and identify the user who leaked the content. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enable": { + Optional: true, + Description: "Enables the watermarking behavior.", + Type: schema.TypeBool, + }, + "token_signing_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "signature_verification_enable": { + Optional: true, + Description: "When enabled, you can verify the signature in your watermarking token.", + Type: schema.TypeBool, + }, + "verification_key_id1": { + Optional: true, + Description: "Specifies a unique identifier for the first public key.", + Type: schema.TypeString, + }, + "verification_public_key1": { + Optional: true, + Description: "Specifies the first public key in its entirety.", + Type: schema.TypeString, + }, + "verification_key_id2": { + Optional: true, + Description: "Specifies a unique identifier for the optional second public key.", + Type: schema.TypeString, + }, + "verification_public_key2": { + Optional: true, + Description: "Specifies the optional second public key in its entirety. Specify a second key to enable rotation.", + Type: schema.TypeString, + }, + "pattern_encryption_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "pattern_decryption_enable": { + Optional: true, + Description: "If patterns in your watermarking tokens have been encrypted, enabling this allows you to provide values to decrypt them.", + Type: schema.TypeBool, + }, + "decryption_password_id1": { + Optional: true, + Description: "Specifies a label that corresponds to the primary password.", + Type: schema.TypeString, + }, + "decryption_password1": { + Optional: true, + Description: "Provides the primary password used to encrypt patterns in your watermarking tokens.", + Type: schema.TypeString, + }, + "decryption_password_id2": { + Optional: true, + Description: "Specifies a label for the secondary password, used in rotation scenarios to identify which password to use for decryption.", + Type: schema.TypeString, + }, + "decryption_password2": { + Optional: true, + Description: "Provides the secondary password you can use to rotate passwords.", + Type: schema.TypeString, + }, + "miscellaneous_settings_title": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "use_original_as_a": { + Optional: true, + Description: "When you work with your watermarking vendor, you can apply several preprocessing methods to your content. See the `AMD help` for more information. With the standard `filename-prefix AB naming` preprocessing method, the watermarking vendor creates two variants of the original segment content and labels them as an `A` and `B` segment in the filename. If you selected the `unlabeled A variant` preprocessing method, enabling this option tells your configuration to use the original filename segment content as your `A` variant.", + Type: schema.TypeBool, + }, + "ab_variant_location": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"FILENAME_PREFIX", "PARENT_DIRECTORY_PREFIX"}, false)), + Optional: true, + Description: "When you work with your watermarking vendor, you can apply several preprocessing methods to your content. See the `AMD help` for more information. Use this option to specify the location of the `A` and `B` variant segments.", + Type: schema.TypeString, + }, + }, + }, + }, + "web_application_firewall": { + Optional: true, + Type: schema.TypeList, + Description: "This behavior implements a suite of security features that blocks threatening HTTP and HTTPS requests. Use it as your primary firewall, or in addition to existing security measures. Only one referenced configuration is allowed per property, so this behavior typically belongs as part of its default rule. This behavior cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "firewall_configuration": { + Optional: true, + Description: "An object featuring details about your firewall configuration.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "config_id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "production_status": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior", + Type: schema.TypeString, + }, + "staging_status": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior", + Type: schema.TypeString, + }, + "production_version": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior", + Type: schema.TypeInt, + }, + "staging_version": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior", + Type: schema.TypeInt, + }, + "file_name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + "web_sockets": { + Optional: true, + Type: schema.TypeList, + Description: "The WebSocket protocol allows web applications real-time bidirectional communication between clients and servers. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables WebSocket traffic.", + Type: schema.TypeBool, + }, + }, + }, + }, + "webdav": { + Optional: true, + Type: schema.TypeList, + Description: "Web-based Distributed Authoring and Versioning (WebDAV) is a set of extensions to the HTTP protocol that allows users to collaboratively edit and manage files on remote web servers. This behavior enables WebDAV, and provides support for the following additional request methods: PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, and UNLOCK. To apply this behavior, you need to match on a `requestMethod`. This behavior can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "enabled": { + Optional: true, + Description: "Enables the WebDAV behavior.", + Type: schema.TypeBool, + }, + }, + }, + }, + } +} + +func getCriteriaSchemaV20230530() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "advanced_im_match": { + Optional: true, + Type: schema.TypeList, + Description: "Matches whether the `imageManager` behavior already applies to the current set of requests. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Specifies the match's logic.", + Type: schema.TypeString, + }, + "match_on": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ANY_IM", "PRISTINE"}, false)), + Optional: true, + Description: "Specifies the match's scope.", + Type: schema.TypeString, + }, + }, + }, + }, + "bucket": { + Optional: true, + Type: schema.TypeList, + Description: "This matches a specified percentage of requests when used with the accompanying behavior. Contact Akamai Professional Services for help configuring it. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "percentage": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specifies the percentage of requests to match.", + Type: schema.TypeInt, + }, + }, + }, + }, + "cacheability": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the current cache state. Note that any `NO_STORE` or `BYPASS_CACHE` HTTP headers set on the origin's content overrides properties' `caching` instructions, in which case this criteria does not apply. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Specifies the match's logic.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NO_STORE", "BYPASS_CACHE", "CACHEABLE"}, false)), + Optional: true, + Description: "Content's cache is enabled (`CACHEABLE`) or not (`NO_STORE`), or else is ignored (`BYPASS_CACHE`).", + Type: schema.TypeString, + }, + }, + }, + }, + "china_cdn_region": { + Optional: true, + Type: schema.TypeList, + Description: "Identifies traffic deployed over Akamai's regional ChinaCDN infrastructure. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Specify whether the request `IS` or `IS_NOT` deployed over ChinaCDN.", + Type: schema.TypeString, + }, + }, + }, + }, + "client_certificate": { + Optional: true, + Type: schema.TypeList, + Description: "Matches whether you have configured a client certificate to authenticate requests to edge servers. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "is_certificate_present": { + Optional: true, + Description: "Executes rule behaviors only if a client certificate authenticates requests.", + Type: schema.TypeBool, + }, + "is_certificate_valid": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"VALID", "INVALID", "IGNORE"}, false)), + Optional: true, + Description: "Matches whether the certificate is `VALID` or `INVALID`. You can also `IGNORE` the certificate's validity.", + Type: schema.TypeString, + }, + }, + }, + }, + "client_ip": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the IP number of the requesting client. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the contents of `values` if set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "IP or CIDR block, for example: `71.92.0.0/14`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "use_headers": { + Optional: true, + Description: "When connecting via a proxy server as determined by the `X-Forwarded-For` header, enabling this option matches the connecting client's IP address rather than the original end client specified in the header.", + Type: schema.TypeBool, + }, + }, + }, + }, + "client_ip_version": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the version of the IP protocol used by the requesting client. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IPV4", "IPV6"}, false)), + Optional: true, + Description: "The IP version of the client request, either `IPV4` or `IPV6`.", + Type: schema.TypeString, + }, + "use_x_forwarded_for": { + Optional: true, + Description: "When connecting via a proxy server as determined by the `X-Forwarded-For` header, enabling this option matches the connecting client's IP address rather than the original end client specified in the header.", + Type: schema.TypeBool, + }, + }, + }, + }, + "cloudlets_origin": { + Optional: true, + Type: schema.TypeList, + Description: "Allows Cloudlets Origins, referenced by label, to define their own criteria to assign custom origin definitions. The criteria may match, for example, for a specified percentage of requests defined by the cloudlet to use an alternative version of a website. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "origin_id": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-\\.]+$"), + Optional: true, + Description: "The Cloudlets Origins identifier, limited to alphanumeric and underscore characters.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_delivery_network": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies the type of Akamai network handling the request. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Matches the specified `network` if set to `IS`, otherwise `IS_NOT` reverses the match.", + Type: schema.TypeString, + }, + "network": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"STAGING", "PRODUCTION"}, false)), + Optional: true, + Description: "Match the network.", + Type: schema.TypeString, + }, + }, + }, + }, + "content_type": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the HTTP response header's `Content-Type`. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches any `Content-Type` among specified `values` when set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "`Content-Type` response header value, for example `text/html`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "match_wildcard": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches among the `values`, so that specifying `text/*` matches both `text/html` and `text/css`.", + Type: schema.TypeBool, + }, + "match_case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive match for all `values`.", + Type: schema.TypeBool, + }, + }, + }, + }, + "device_characteristic": { + Optional: true, + Type: schema.TypeList, + Description: "Match various aspects of the device or browser making the request. Based on the value of the `characteristic` option, the expected value is either a boolean, a number, or a string, possibly representing a version number. Each type of value requires a different field. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "characteristic": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BRAND_NAME", "MODEL_NAME", "MARKETING_NAME", "IS_WIRELESS_DEVICE", "IS_TABLET", "DEVICE_OS", "DEVICE_OS_VERSION", "MOBILE_BROWSER", "MOBILE_BROWSER_VERSION", "RESOLUTION_WIDTH", "RESOLUTION_HEIGHT", "PHYSICAL_SCREEN_HEIGHT", "PHYSICAL_SCREEN_WIDTH", "COOKIE_SUPPORT", "AJAX_SUPPORT_JAVASCRIPT", "FULL_FLASH_SUPPORT", "ACCEPT_THIRD_PARTY_COOKIE", "XHTML_SUPPORT_LEVEL", "IS_MOBILE"}, false)), + Optional: true, + Description: "Aspect of the device or browser to match.", + Type: schema.TypeString, + }, + "string_match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"MATCHES_ONE_OF", "DOES_NOT_MATCH_ONE_OF"}, false)), + Optional: true, + Description: "When the `characteristic` expects a string value, set this to `MATCHES_ONE_OF` to match against the `stringValue` set, otherwise set to `DOES_NOT_MATCH_ONE_OF` to exclude that set of values.", + Type: schema.TypeString, + }, + "numeric_match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT", "IS_LESS_THAN", "IS_LESS_THAN_OR_EQUAL", "IS_MORE_THAN", "IS_MORE_THAN_OR_EQUAL"}, false)), + Optional: true, + Description: "When the `characteristic` expects a numeric value, compares the specified `numericValue` against the matched client.", + Type: schema.TypeString, + }, + "version_match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT", "IS_LESS_THAN", "IS_LESS_THAN_OR_EQUAL", "IS_MORE_THAN", "IS_MORE_THAN_OR_EQUAL"}, false)), + Optional: true, + Description: "When the `characteristic` expects a version string value, compares the specified `versionValue` against the matched client, using the following operators: `IS`, `IS_MORE_THAN_OR_EQUAL`, `IS_MORE_THAN`, `IS_LESS_THAN_OR_EQUAL`, `IS_LESS_THAN`, `IS_NOT`.", + Type: schema.TypeString, + }, + "boolean_value": { + Optional: true, + Description: "When the `characteristic` expects a boolean value, this specifies the value.", + Type: schema.TypeBool, + }, + "string_value": { + Optional: true, + Description: "When the `characteristic` expects a string, this specifies the set of values.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "numeric_value": { + Optional: true, + Description: "When the `characteristic` expects a numeric value, this specifies the number.", + Type: schema.TypeInt, + }, + "version_value": { + Optional: true, + Description: "When the `characteristic` expects a version number, this specifies it as a string.", + Type: schema.TypeString, + }, + "match_case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive match for the `stringValue` field.", + Type: schema.TypeBool, + }, + "match_wildcard": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `stringValue` field.", + Type: schema.TypeBool, + }, + }, + }, + }, + "ecmd_auth_groups": { + Optional: true, + Type: schema.TypeList, + Description: "This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CONTAINS", "DOES_NOT_CONTAIN"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,255}$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "ecmd_auth_scheme": { + Optional: true, + Type: schema.TypeList, + Description: "This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "auth_scheme": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ANONYMOUS", "JWT", "MUTUAL"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "ecmd_is_authenticated": { + Optional: true, + Type: schema.TypeList, + Description: "This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_AUTHENTICATED", "IS_NOT_AUTHENTICATED"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "ecmd_username": { + Optional: true, + Type: schema.TypeList, + Description: "This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CONTAINS", "DOES_NOT_CONTAIN", "STARTS_WITH", "DOES_NOT_START_WITH", "ENDS_WITH", "DOES_NOT_END_WITH", "LENGTH_EQUALS", "LENGTH_GREATER_THAN", "LENGTH_SMALLER_THAN"}, false)), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_-]{1,255}$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + "length": { + ValidateDiagFunc: validateRegex("^[1-9]\\d*$"), + Optional: true, + Description: "", + Type: schema.TypeString, + }, + }, + }, + }, + "edge_workers_failure": { + Optional: true, + Type: schema.TypeList, + Description: "Checks the EdgeWorkers execution status and detects whether a customer's JavaScript failed on edge servers. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "exec_status": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"FAILURE", "SUCCESS"}, false)), + Optional: true, + Description: "Specify execution status.", + Type: schema.TypeString, + }, + }, + }, + }, + "file_extension": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the requested filename's extension, if present. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the contents of `values` if set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "An array of file extension strings, with no leading dot characters, for example `png`, `jpg`, `jpeg`, and `gif`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "match_case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive match.", + Type: schema.TypeBool, + }, + }, + }, + }, + "filename": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the requested filename, or test whether it is present. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF", "IS_EMPTY", "IS_NOT_EMPTY"}, false)), + Optional: true, + Description: "If set to `IS_ONE_OF` or `IS_NOT_ONE_OF`, matches whether the filename matches one of the `values`. If set to `IS_EMPTY` or `IS_NOT_EMPTY`, matches whether the specified filename is part of the path.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "Matches the filename component of the request URL. Wildcards are allowed, where `?` matches a single character and `*` matches more than one. For example, specify `filename.*` to accept any extension.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "match_case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive match for the `values` field.", + Type: schema.TypeBool, + }, + }, + }, + }, + "hostname": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the requested hostname. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the contents of `values` when set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "A list of hostnames. Wildcards match, so `*.example.com` matches both `m.example.com` and `www.example.com`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "match_advanced": { + Optional: true, + Type: schema.TypeList, + Description: "This specifies match criteria using Akamai XML metadata. It can only be configured on your behalf by Akamai Professional Services. This criterion is for internal usage only. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "description": { + Optional: true, + Description: "A human-readable description of what the XML block does.", + Type: schema.TypeString, + }, + "open_xml": { + Optional: true, + Description: "An XML string that opens the relevant block.", + Type: schema.TypeString, + }, + "close_xml": { + Optional: true, + Description: "An XML string that closes the relevant block.", + Type: schema.TypeString, + }, + }, + }, + }, + "match_cp_code": { + Optional: true, + Type: schema.TypeList, + Description: "Match the assigned content provider code. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + Optional: true, + Description: "Specifies an object that encodes the matching `value`, including an `id` key and a descriptive `name`.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Optional: true, + Description: "", + Type: schema.TypeInt, + }, + "name": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "created_date": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "description": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + "products": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "cp_code_limits": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeList, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "current_capacity": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeInt, + }, + "limit_type": { + Optional: true, + Description: "This field is only intended for export compatibility purposes, and modifying it will not impact your use of the behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "match_response_code": { + Optional: true, + Type: schema.TypeList, + Description: "Match a set or range of HTTP response codes. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF", "IS_BETWEEN", "IS_NOT_BETWEEN"}, false)), + Optional: true, + Description: "Matches numeric range or a specified set of `values`.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "A set of response codes to match, for example `[\"404\",\"500\"]`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "lower_bound": { + ValidateDiagFunc: validateRegex("^\\d{3}$"), + Optional: true, + Description: "Specifies the start of a range of responses. For example, `400` to match anything from `400` to `500`.", + Type: schema.TypeInt, + }, + "upper_bound": { + ValidateDiagFunc: validateRegex("^\\d{3}$"), + Optional: true, + Description: "Specifies the end of a range of responses. For example, `500` to match anything from `400` to `500`.", + Type: schema.TypeInt, + }, + }, + }, + }, + "match_variable": { + Optional: true, + Type: schema.TypeList, + Description: "Matches a built-in variable, or a custom variable pre-declared within the rule tree by the `setVariable` behavior. See `Support for variables` for more information on this feature. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "variable_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z_][a-zA-Z0-9_]{0,31}$"), + Optional: true, + Description: "The name of the variable to match.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT", "IS_ONE_OF", "IS_NOT_ONE_OF", "IS_EMPTY", "IS_NOT_EMPTY", "IS_BETWEEN", "IS_NOT_BETWEEN", "IS_GREATER_THAN", "IS_GREATER_THAN_OR_EQUAL_TO", "IS_LESS_THAN", "IS_LESS_THAN_OR_EQUAL_TO"}, false)), + Optional: true, + Description: "The type of match, based on which you use different options to specify the match criteria.", + Type: schema.TypeString, + }, + "variable_values": { + Optional: true, + Description: "Specifies an array of matching strings.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "variable_expression": { + Optional: true, + Description: "Specifies a single matching string.", + Type: schema.TypeString, + }, + "lower_bound": { + ValidateDiagFunc: validateRegex("^[1-9]\\d*$"), + Optional: true, + Description: "Specifies the range's numeric minimum value.", + Type: schema.TypeString, + }, + "upper_bound": { + ValidateDiagFunc: validateRegex("^[1-9]\\d*$"), + Optional: true, + Description: "Specifies the range's numeric maximum value.", + Type: schema.TypeString, + }, + "match_wildcard": { + Optional: true, + Description: "When matching string expressions, enabling this matches wildcard metacharacters such as `*` and `?`.", + Type: schema.TypeBool, + }, + "match_case_sensitive": { + Optional: true, + Description: "When matching string expressions, enabling this performs a case-sensitive match.", + Type: schema.TypeBool, + }, + }, + }, + }, + "metadata_stage": { + Optional: true, + Type: schema.TypeList, + Description: "Matches how the current rule corresponds to low-level syntax elements in translated XML metadata, indicating progressive stages as each edge server handles the request and response. To use this match, you need to be thoroughly familiar with how Akamai edge servers process requests. Contact your Akamai Technical representative if you need help, and test thoroughly on staging before activating on production. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Compares the current rule with the specified metadata stage.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"cache-hit", "client-done", "client-request", "client-request-body", "client-response", "content-policy", "forward-request", "forward-response", "forward-start", "ipa-response"}, false)), + Optional: true, + Description: "Specifies the metadata stage.", + Type: schema.TypeString, + }, + }, + }, + }, + "origin_timeout": { + Optional: true, + Type: schema.TypeList, + Description: "Matches when the origin responds with a timeout error. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"ORIGIN_TIMED_OUT"}, false)), + Optional: true, + Description: "Specifies a single required `ORIGIN_TIMED_OUT` value.", + Type: schema.TypeString, + }, + }, + }, + }, + "path": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the URL's non-hostname path component. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"MATCHES_ONE_OF", "DOES_NOT_MATCH_ONE_OF"}, false)), + Optional: true, + Description: "Matches the contents of the `values` array.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "Matches the URL path, excluding leading hostname and trailing query parameters. The path is relative to the server root, for example `/blog`. The `value` accepts `*` or `?` wildcard characters, for example `/blog/*/2014`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "match_case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive match.", + Type: schema.TypeBool, + }, + "normalize": { + Optional: true, + Description: "Transforms URLs before comparing them with the provided value. URLs are decoded, and any directory syntax such as `../..` or `//` is stripped as a security measure. This protects URL paths from being accessed by unauthorized users.", + Type: schema.TypeBool, + }, + }, + }, + }, + "query_string_parameter": { + Optional: true, + Type: schema.TypeList, + Description: "Matches query string field names or values. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "parameter_name": { + ValidateDiagFunc: validateRegex("^[^:/?#\\[\\]@&]+$"), + Optional: true, + Description: "The name of the query field, for example, `q` in `?q=string`.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF", "EXISTS", "DOES_NOT_EXIST", "IS_LESS_THAN", "IS_MORE_THAN", "IS_BETWEEN"}, false)), + Optional: true, + Description: "Narrows the match criteria.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "The value of the query field, for example, `string` in `?q=string`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "lower_bound": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "Specifies the match's minimum value.", + Type: schema.TypeInt, + }, + "upper_bound": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "When the `value` is numeric, this field specifies the match's maximum value.", + Type: schema.TypeInt, + }, + "match_wildcard_name": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `parameterName` field.", + Type: schema.TypeBool, + }, + "match_case_sensitive_name": { + Optional: true, + Description: "Sets a case-sensitive match for the `parameterName` field.", + Type: schema.TypeBool, + }, + "match_wildcard_value": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `value` field.", + Type: schema.TypeBool, + }, + "match_case_sensitive_value": { + Optional: true, + Description: "Sets a case-sensitive match for the `value` field.", + Type: schema.TypeBool, + }, + "escape_value": { + Optional: true, + Description: "Matches when the `value` is URL-escaped.", + Type: schema.TypeBool, + }, + }, + }, + }, + "random": { + Optional: true, + Type: schema.TypeList, + Description: "Matches a specified percentage of requests. Use this match to apply behaviors to a percentage of your incoming requests that differ from the remainder, useful for A/b testing, or to offload traffic onto different servers. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "bucket": { + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)), + Optional: true, + Description: "Specify a percentage of random requests to which to apply a behavior. Any remainders do not match.", + Type: schema.TypeInt, + }, + }, + }, + }, + "recovery_config": { + Optional: true, + Type: schema.TypeList, + Description: "Matches on specified origin recovery scenarios. The `originFailureRecoveryPolicy` behavior defines the scenarios that trigger the recovery or retry methods you set in the `originFailureRecoveryMethod` rule. If the origin fails, the system checks the name of the recovery method applied to your policy. It then either redirects the requesting client to a backup origin or returns predefined HTTP response codes. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "config_name": { + ValidateDiagFunc: validateRegex("^[A-Z0-9-]+$"), + Optional: true, + Description: "A unique identifier used for origin failure recovery configurations. This is the recovery method configuration name you apply when setting origin failure recovery methods and scenarios in `originFailureRecoveryMethod` and `originFailureRecoveryPolicy` behaviors. The value can contain alphanumeric characters and dashes.", + Type: schema.TypeString, + }, + }, + }, + }, + "regular_expression": { + Optional: true, + Type: schema.TypeList, + Description: "Matches a regular expression against a string, especially to apply behaviors flexibly based on the contents of dynamic `variables`. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_string": { + Optional: true, + Description: "The string to match, typically the contents of a dynamic variable.", + Type: schema.TypeString, + }, + "regex": { + Optional: true, + Description: "The regular expression (PCRE) to match against the string.", + Type: schema.TypeString, + }, + "case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive regular expression match.", + Type: schema.TypeBool, + }, + }, + }, + }, + "request_cookie": { + Optional: true, + Type: schema.TypeList, + Description: "Match the cookie name or value passed with the request. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "cookie_name": { + ValidateDiagFunc: validateRegex("^[a-zA-Z0-9_\\-*\\.]+$"), + Optional: true, + Description: "The name of the cookie, for example, `visitor` in `visitor:anon`.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT", "EXISTS", "DOES_NOT_EXIST", "IS_BETWEEN"}, false)), + Optional: true, + Description: "Narrows the match criteria.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validateRegex("^[^\\s;]+$"), + Optional: true, + Description: "The cookie's value, for example, `anon` in `visitor:anon`.", + Type: schema.TypeString, + }, + "lower_bound": { + ValidateDiagFunc: validateRegex("^[1-9]\\d*$"), + Optional: true, + Description: "When the `value` is numeric, this field specifies the match's minimum value.", + Type: schema.TypeInt, + }, + "upper_bound": { + ValidateDiagFunc: validateRegex("^[1-9]\\d*$"), + Optional: true, + Description: "When the `value` is numeric, this field specifies the match's maximum value.", + Type: schema.TypeInt, + }, + "match_wildcard_name": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `cookieName` field.", + Type: schema.TypeBool, + }, + "match_case_sensitive_name": { + Optional: true, + Description: "Sets a case-sensitive match for the `cookieName` field.", + Type: schema.TypeBool, + }, + "match_wildcard_value": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `value` field.", + Type: schema.TypeBool, + }, + "match_case_sensitive_value": { + Optional: true, + Description: "Sets a case-sensitive match for the `value` field.", + Type: schema.TypeBool, + }, + }, + }, + }, + "request_header": { + Optional: true, + Type: schema.TypeList, + Description: "Match HTTP header names or values. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "The name of the request header, for example `Accept-Language`.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF", "EXISTS", "DOES_NOT_EXIST"}, false)), + Optional: true, + Description: "Narrows the match criteria.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "The request header's value, for example `en-US` when the header `headerName` is `Accept-Language`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "match_wildcard_name": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `headerName` field.", + Type: schema.TypeBool, + }, + "match_wildcard_value": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `value` field.", + Type: schema.TypeBool, + }, + "match_case_sensitive_value": { + Optional: true, + Description: "Sets a case-sensitive match for the `value` field.", + Type: schema.TypeBool, + }, + }, + }, + }, + "request_method": { + Optional: true, + Type: schema.TypeList, + Description: "Specify the request's HTTP verb. Also supports WebDAV methods and common Akamai operations. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Matches the `value` when set to `IS`, otherwise `IS_NOT` reverses the match.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"GET", "POST", "HEAD", "PUT", "PATCH", "HTTP_DELETE", "AKAMAI_TRANSLATE", "AKAMAI_PURGE", "OPTIONS", "DAV_ACL", "DAV_CHECKOUT", "DAV_COPY", "DAV_DMCREATE", "DAV_DMINDEX", "DAV_DMMKPATH", "DAV_DMMKPATHS", "DAV_DMOVERLAY", "DAV_DMPATCHPATHS", "DAV_LOCK", "DAV_MKCALENDAR", "DAV_MKCOL", "DAV_MOVE", "DAV_PROPFIND", "DAV_PROPPATCH", "DAV_REPORT", "DAV_SETPROCESS", "DAV_SETREDIRECT", "DAV_TRUTHGET", "DAV_UNLOCK"}, false)), + Optional: true, + Description: "Any of these HTTP methods, WebDAV methods, or Akamai operations.", + Type: schema.TypeString, + }, + }, + }, + }, + "request_protocol": { + Optional: true, + Type: schema.TypeList, + Description: "Matches whether the request uses the HTTP or HTTPS protocol. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"HTTP", "HTTPS"}, false)), + Optional: true, + Description: "Specifies the protocol.", + Type: schema.TypeString, + }, + }, + }, + }, + "request_type": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the basic type of request. To use this match, you need to be thoroughly familiar with how Akamai edge servers process requests. Contact your Akamai Technical representative if you need help, and test thoroughly on staging before activating on production. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Specifies whether the request `IS` or `IS_NOT` the type of specified `value`.", + Type: schema.TypeString, + }, + "value": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"CLIENT_REQ", "ESI_FRAGMENT", "EW_SUBREQUEST"}, false)), + Optional: true, + Description: "Specifies the type of request, either a standard `CLIENT_REQ`, an `ESI_FRAGMENT`, or an `EW_SUBREQUEST`.", + Type: schema.TypeString, + }, + }, + }, + }, + "response_header": { + Optional: true, + Type: schema.TypeList, + Description: "Match HTTP header names or values. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "header_name": { + ValidateDiagFunc: validateRegex("^[^()<>@,;:\\\"/\\[\\]?{}\\s]+$"), + Optional: true, + Description: "The name of the response header, for example `Content-Type`.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF", "EXISTS", "DOES_NOT_EXIST", "IS_LESS_THAN", "IS_MORE_THAN", "IS_BETWEEN"}, false)), + Optional: true, + Description: "Narrows the match according to various criteria.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "The response header's value, for example `application/x-www-form-urlencoded` when the header `headerName` is `Content-Type`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "lower_bound": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "When the `value` is numeric, this field specifies the match's minimum value.", + Type: schema.TypeInt, + }, + "upper_bound": { + ValidateDiagFunc: validateRegex("^[0-9]+$"), + Optional: true, + Description: "When the `value` is numeric, this field specifies the match's maximum value.", + Type: schema.TypeInt, + }, + "match_wildcard_name": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `headerName` field.", + Type: schema.TypeBool, + }, + "match_wildcard_value": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `value` field.", + Type: schema.TypeBool, + }, + "match_case_sensitive_value": { + Optional: true, + Description: "When enabled, the match is case-sensitive for the `value` field.", + Type: schema.TypeBool, + }, + }, + }, + }, + "server_location": { + Optional: true, + Type: schema.TypeList, + Description: "The location of the Akamai server handling the request. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "location_type": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COUNTRY", "CONTINENT", "REGION"}, false)), + Optional: true, + Description: "Indicates the geographic scope.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the specified set of values when set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "countries": { + Optional: true, + Description: "ISO 3166-1 country codes, such as `US` or `CN`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "continents": { + Optional: true, + Description: "Continent codes.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "regions": { + Optional: true, + Description: "ISO 3166 country and region codes, for example `US:MA` for Massachusetts or `JP:13` for Tokyo.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "time": { + Optional: true, + Type: schema.TypeList, + Description: "Specifies ranges of times during which the request occurred. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BEGINNING", "BETWEEN", "LASTING", "REPEATING"}, false)), + Optional: true, + Description: "Specifies how to define the range of time.", + Type: schema.TypeString, + }, + "repeat_interval": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Sets the time between each repeating time period's starting points.", + Type: schema.TypeString, + }, + "repeat_duration": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Sets the duration of each repeating time period.", + Type: schema.TypeString, + }, + "lasting_duration": { + ValidateDiagFunc: validateRegex("^[0-9]+[DdHhMmSs]$"), + Optional: true, + Description: "Specifies the end of a time period as a duration relative to the `lastingDate`.", + Type: schema.TypeString, + }, + "lasting_date": { + Optional: true, + Description: "Sets the start of a fixed time period.", + Type: schema.TypeString, + }, + "repeat_begin_date": { + Optional: true, + Description: "Sets the start of the initial time period.", + Type: schema.TypeString, + }, + "apply_daylight_savings_time": { + Optional: true, + Description: "Adjusts the start time plus repeat interval to account for daylight saving time. Applies when the current time and the start time use different systems, daylight and standard, and the two values are in conflict.", + Type: schema.TypeBool, + }, + "begin_date": { + Optional: true, + Description: "Sets the start of a time period.", + Type: schema.TypeString, + }, + "end_date": { + Optional: true, + Description: "Sets the end of a fixed time period.", + Type: schema.TypeString, + }, + }, + }, + }, + "token_authorization": { + Optional: true, + Type: schema.TypeList, + Description: "Match on Auth Token 2.0 verification results. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_SUCCESS", "IS_CUSTOM_FAILURE", "IS_ANY_FAILURE"}, false)), + Optional: true, + Description: "Error match scope.", + Type: schema.TypeString, + }, + "status_list": { + Optional: true, + Description: "", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "user_agent": { + Optional: true, + Type: schema.TypeList, + Description: "Matches the user agent string that helps identify the client browser and device. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the specified set of `values` when set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "values": { + Optional: true, + Description: "The `User-Agent` header's value. For example, `Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "match_wildcard": { + Optional: true, + Description: "Allows `*` and `?` wildcard matches in the `value` field. For example, `*Android*`, `*iPhone5*`, `*Firefox*`, or `*Chrome*`.", + Type: schema.TypeBool, + }, + "match_case_sensitive": { + Optional: true, + Description: "Sets a case-sensitive match for the `value` field.", + Type: schema.TypeBool, + }, + }, + }, + }, + "user_location": { + Optional: true, + Type: schema.TypeList, + Description: "The client browser's approximate geographic location, determined by looking up the IP address in a database. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "field": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"COUNTRY", "CONTINENT", "REGION"}, false)), + Optional: true, + Description: "Indicates the geographic scope.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the specified set of values when set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "country_values": { + Optional: true, + Description: "ISO 3166-1 country codes, such as `US` or `CN`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "continent_values": { + Optional: true, + Description: "Continent codes.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "region_values": { + Optional: true, + Description: "ISO 3166 country and region codes, for example `US:MA` for Massachusetts or `JP:13` for Tokyo.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "check_ips": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BOTH", "CONNECTING", "HEADERS"}, false)), + Optional: true, + Description: "Specifies which IP addresses determine the user's location.", + Type: schema.TypeString, + }, + "use_only_first_x_forwarded_for_ip": { + Optional: true, + Description: "When connecting via a proxy server as determined by the `X-Forwarded-For` header, enabling this option matches the end client specified in the header. Disabling it matches the connecting client's IP address.", + Type: schema.TypeBool, + }, + }, + }, + }, + "user_network": { + Optional: true, + Type: schema.TypeList, + Description: "Matches details of the network over which the request was made, determined by looking up the IP address in a database. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "field": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"NETWORK", "NETWORK_TYPE", "BANDWIDTH"}, false)), + Optional: true, + Description: "The type of information to match.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS_ONE_OF", "IS_NOT_ONE_OF"}, false)), + Optional: true, + Description: "Matches the specified set of values when set to `IS_ONE_OF`, otherwise `IS_NOT_ONE_OF` reverses the match.", + Type: schema.TypeString, + }, + "network_type_values": { + Optional: true, + Description: "", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "network_values": { + Optional: true, + Description: "Any set of specific networks.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "bandwidth_values": { + Optional: true, + Description: "Bandwidth range in bits per second, either `1`, `57`, `257`, `1000`, `2000`, or `5000`.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "check_ips": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"BOTH", "CONNECTING", "HEADERS"}, false)), + Optional: true, + Description: "Specifies which IP addresses determine the user's network.", + Type: schema.TypeString, + }, + "use_only_first_x_forwarded_for_ip": { + Optional: true, + Description: "When connecting via a proxy server as determined by the `X-Forwarded-For` header, enabling this option matches the end client specified in the header. Disabling it matches the connecting client's IP address.", + Type: schema.TypeBool, + }, + }, + }, + }, + "variable_error": { + Optional: true, + Type: schema.TypeList, + Description: "Matches any runtime errors that occur on edge servers based on the configuration of a `setVariable` behavior. See `Support for variables` section for more information on this feature. This criterion can be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "result": { + Optional: true, + Description: "Matches errors for the specified set of `variableNames`, otherwise matches errors from variables outside that set.", + Type: schema.TypeBool, + }, + "variable_names": { + Optional: true, + Description: "The name of the variable whose error triggers the match, or a space- or comma-delimited list of more than one variable name. Note that if you define a variable named `VAR`, the name in this field needs to appear with its added prefix as `PMUSER_VAR`. When such a variable is inserted into other fields, it appears with an additional namespace as `{{user.PMUSER_VAR}}`. See the `setVariable` behavior for details on variable names.", + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "virtual_waiting_room_request": { + Optional: true, + Type: schema.TypeList, + Description: "Helps to customize the requests identified by the `virtualWaitingRoom` behavior. Use this match criteria to define the `originServer` behavior for the waiting room. This criterion cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Specifies the match's logic.", + Type: schema.TypeString, + }, + "match_on": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"WR_ANY", "WR_MAIN_PAGE", "WR_ASSETS"}, false)), + Optional: true, + Description: "Specifies the type of request identified by the `virtualWaitingRoom` behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + "visitor_prioritization_request": { + Optional: true, + Type: schema.TypeList, + Description: "Helps to customize the requests identified by the `visitorPrioritizationFifo` behavior. The basic use case for this match criteria is to define the `originServer` behavior for the waiting room. This criterion cannot be used in includes.", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "locked": { + Optional: true, + Description: "Indicates that your Akamai representative has locked this behavior or criteria so that you can't modify it. This option is for internal usage only.", + Type: schema.TypeBool, + }, + "uuid": { + ValidateDiagFunc: validateRegex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"), + Optional: true, + Description: "A uuid member indicates that at least one of its component behaviors or criteria is advanced and read-only. You need to preserve this uuid as well when modifying the rule tree. This option is for internal usage only.", + Type: schema.TypeString, + }, + "template_uuid": { + Optional: true, + Description: "This option is for internal usage only.", + Type: schema.TypeString, + }, + "match_operator": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"IS", "IS_NOT"}, false)), + Optional: true, + Description: "Specifies the match's logic.", + Type: schema.TypeString, + }, + "match_on": { + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"WR_ANY", "WR_MAIN_PAGE", "WR_ASSETS"}, false)), + Optional: true, + Description: "Specifies the type of request identified by the `visitorPrioritizationFifo` behavior.", + Type: schema.TypeString, + }, + }, + }, + }, + } +} diff --git a/pkg/providers/property/ruleformats/rules_schema_reader.go b/pkg/providers/property/ruleformats/rules_schema_reader.go index 2ae03407f..3cc1671e5 100644 --- a/pkg/providers/property/ruleformats/rules_schema_reader.go +++ b/pkg/providers/property/ruleformats/rules_schema_reader.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v6/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/ruleformats/validations.go b/pkg/providers/property/ruleformats/validations.go index 1dbeaa974..f74bfee28 100644 --- a/pkg/providers/property/ruleformats/validations.go +++ b/pkg/providers/property/ruleformats/validations.go @@ -3,7 +3,7 @@ package ruleformats import ( "fmt" - "github.com/akamai/terraform-provider-akamai/v4/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v5/pkg/common/tf" "github.com/dlclark/regexp2" "github.com/hashicorp/go-cty/cty" diff --git a/pkg/providers/property/testdata/TestDSCPCode/ambiguous_name.tf b/pkg/providers/property/testdata/TestDSCPCode/ambiguous_name.tf deleted file mode 100644 index 57be5f632..000000000 --- a/pkg/providers/property/testdata/TestDSCPCode/ambiguous_name.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_cp_code" "test" { - name = "test cpcode" - contract = "ctr_test" - group = "grp_test" -} diff --git a/pkg/providers/property/testdata/TestDSCPCode/contract_collides_with_id.tf b/pkg/providers/property/testdata/TestDSCPCode/contract_collides_with_id.tf deleted file mode 100644 index 26c26d6cb..000000000 --- a/pkg/providers/property/testdata/TestDSCPCode/contract_collides_with_id.tf +++ /dev/null @@ -1,10 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_cp_code" "test" { - name = "cpc_test2" - contract = "ctr_test" - contract_id = "ctr_test" - group = "grp_test" -} diff --git a/pkg/providers/property/testdata/TestDSCPCode/group_collides_with_id.tf b/pkg/providers/property/testdata/TestDSCPCode/group_collides_with_id.tf deleted file mode 100644 index d8526b859..000000000 --- a/pkg/providers/property/testdata/TestDSCPCode/group_collides_with_id.tf +++ /dev/null @@ -1,10 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_cp_code" "test" { - name = "cpc_test2" - contract = "ctr_test" - group = "grp_test" - group_id = "grp_test_id" -} diff --git a/pkg/providers/property/testdata/TestDSCPCode/match_by_full_id.tf b/pkg/providers/property/testdata/TestDSCPCode/match_by_full_id.tf index e3e13cea5..7b0c19605 100644 --- a/pkg/providers/property/testdata/TestDSCPCode/match_by_full_id.tf +++ b/pkg/providers/property/testdata/TestDSCPCode/match_by_full_id.tf @@ -3,7 +3,7 @@ provider "akamai" { } data "akamai_cp_code" "test" { - name = "cpc_234" - contract = "ctr_test" - group = "grp_test" + name = "cpc_234" + contract_id = "ctr_test" + group_id = "grp_test" } diff --git a/pkg/providers/property/testdata/TestDSCPCode/match_by_name.tf b/pkg/providers/property/testdata/TestDSCPCode/match_by_name.tf index 57be5f632..d180a41df 100644 --- a/pkg/providers/property/testdata/TestDSCPCode/match_by_name.tf +++ b/pkg/providers/property/testdata/TestDSCPCode/match_by_name.tf @@ -3,7 +3,7 @@ provider "akamai" { } data "akamai_cp_code" "test" { - name = "test cpcode" - contract = "ctr_test" - group = "grp_test" + name = "test cpcode" + contract_id = "ctr_test" + group_id = "grp_test" } diff --git a/pkg/providers/property/testdata/TestDSCPCode/match_by_name_output_products.tf b/pkg/providers/property/testdata/TestDSCPCode/match_by_name_output_products.tf index 7d4608136..f3f21ddb2 100644 --- a/pkg/providers/property/testdata/TestDSCPCode/match_by_name_output_products.tf +++ b/pkg/providers/property/testdata/TestDSCPCode/match_by_name_output_products.tf @@ -3,9 +3,9 @@ provider "akamai" { } data "akamai_cp_code" "test" { - name = "test cpcode" - contract = "ctr_test" - group = "grp_test" + name = "test cpcode" + contract_id = "ctr_test" + group_id = "grp_test" } output "products" { diff --git a/pkg/providers/property/testdata/TestDSCPCode/match_by_unprefixed_id.tf b/pkg/providers/property/testdata/TestDSCPCode/match_by_unprefixed_id.tf index b49a37571..69106d951 100644 --- a/pkg/providers/property/testdata/TestDSCPCode/match_by_unprefixed_id.tf +++ b/pkg/providers/property/testdata/TestDSCPCode/match_by_unprefixed_id.tf @@ -3,7 +3,7 @@ provider "akamai" { } data "akamai_cp_code" "test" { - name = "234" - contract = "ctr_test" - group = "grp_test" + name = "234" + contract_id = "ctr_test" + group_id = "grp_test" } diff --git a/pkg/providers/property/testdata/TestDSCPCode/name_collides_with_id.tf b/pkg/providers/property/testdata/TestDSCPCode/name_collides_with_id.tf deleted file mode 100644 index 51c12bce9..000000000 --- a/pkg/providers/property/testdata/TestDSCPCode/name_collides_with_id.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_cp_code" "test" { - name = "cpc_test2" - contract = "ctr_test" - group = "grp_test" -} diff --git a/pkg/providers/property/testdata/TestDSCPCode/no_matches.tf b/pkg/providers/property/testdata/TestDSCPCode/no_matches.tf deleted file mode 100644 index 57be5f632..000000000 --- a/pkg/providers/property/testdata/TestDSCPCode/no_matches.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_cp_code" "test" { - name = "test cpcode" - contract = "ctr_test" - group = "grp_test" -} diff --git a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_id_in_group.tf b/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_id_in_group.tf deleted file mode 100644 index 1a43a4363..000000000 --- a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_id_in_group.tf +++ /dev/null @@ -1,11 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_contract" "akacontract" { - group = "grp_12345" -} - -output "aka_contract" { - value = data.akamai_contract.akacontract.id -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_id_in_group_wo_prefix.tf b/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_id_in_group_wo_prefix.tf deleted file mode 100644 index 20ebbe06c..000000000 --- a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_id_in_group_wo_prefix.tf +++ /dev/null @@ -1,11 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_contract" "akacontract" { - group = "12345" -} - -output "aka_contract" { - value = data.akamai_contract.akacontract.id -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_and_group.tf b/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_and_group.tf index ce16c11dc..5cb2dcb54 100644 --- a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_and_group.tf +++ b/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_and_group.tf @@ -3,7 +3,7 @@ provider "akamai" { } data "akamai_contract" "akacontract" { - group = "Example.com-1-1TJZH5" + group_id = "grp_12345" group_name = "Example.com-1-1TJZH5" } diff --git a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_in_group.tf b/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_in_group.tf deleted file mode 100644 index eabd0f3f2..000000000 --- a/pkg/providers/property/testdata/TestDSContractRequired/ds_contract_with_group_name_in_group.tf +++ /dev/null @@ -1,11 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_contract" "akacontract" { - group = "Example.com-1-1TJZH5" -} - -output "aka_contract" { - value = data.akamai_contract.akacontract.id -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSContractRequired/group.tf b/pkg/providers/property/testdata/TestDSContractRequired/group.tf deleted file mode 100644 index d12544fc3..000000000 --- a/pkg/providers/property/testdata/TestDSContractRequired/group.tf +++ /dev/null @@ -1,36 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_contract" "akacontract" { - group = var.group -} - -data "akamai_group" "akagroup" { - name = var.group - contract_id = data.akamai_contract.akacontract.id -} - -data "akamai_group" "akgroup" { - name = var.group - contract = data.akamai_contract.akacontract.id -} - -variable "group" { - description = "Name of the group associated with this property" - type = string - default = "test" -} - -output "aka_contract" { - value = data.akamai_contract.akacontract.id -} - -output "aka_group" { - value = data.akamai_group.akagroup.id -} -output "ak_group" { - value = data.akamai_group.akgroup.id -} - - diff --git a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-contract-id-and-contract-conflict.tf b/pkg/providers/property/testdata/TestDSGroup/ds-group-w-contract-id-and-contract-conflict.tf deleted file mode 100644 index b633494db..000000000 --- a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-contract-id-and-contract-conflict.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_group" "akagroup" { - name = "Example.com-1-1TJZH5" - contract = "ctr_1234" - contract_id = "ctr_1234" -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-group-name-and-contract.tf b/pkg/providers/property/testdata/TestDSGroup/ds-group-w-group-name-and-contract.tf deleted file mode 100644 index 69d69066e..000000000 --- a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-group-name-and-contract.tf +++ /dev/null @@ -1,8 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_group" "akagroup" { - group_name = "Example.com-1-1TJZH5" - contract = "ctr_1234" -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-group-name-and-name-conflict.tf b/pkg/providers/property/testdata/TestDSGroup/ds-group-w-group-name-and-name-conflict.tf deleted file mode 100644 index ffdedd2a3..000000000 --- a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-group-name-and-name-conflict.tf +++ /dev/null @@ -1,9 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_group" "akagroup" { - name = "group-example.com" - group_name = "group-example.com" - contract = "ctr_1234" -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-name-and-contract.tf b/pkg/providers/property/testdata/TestDSGroup/ds-group-w-name-and-contract.tf deleted file mode 100644 index 422166c5a..000000000 --- a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-name-and-contract.tf +++ /dev/null @@ -1,8 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_group" "akagroup" { - name = "Example.com-1-1TJZH5" - contract = "ctr_1234" -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-name-and-contract_id.tf b/pkg/providers/property/testdata/TestDSGroup/ds-group-w-name-and-contract_id.tf deleted file mode 100644 index 8989e6e55..000000000 --- a/pkg/providers/property/testdata/TestDSGroup/ds-group-w-name-and-contract_id.tf +++ /dev/null @@ -1,8 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -data "akamai_group" "akagroup" { - name = "Example.com-1-1TJZH5" - contract_id = "ctr_1234" -} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestDSGroupNotFound/cp_code.tf b/pkg/providers/property/testdata/TestDSGroupNotFound/cp_code.tf index 4f826aef7..f12daf6ee 100644 --- a/pkg/providers/property/testdata/TestDSGroupNotFound/cp_code.tf +++ b/pkg/providers/property/testdata/TestDSGroupNotFound/cp_code.tf @@ -5,7 +5,7 @@ provider "akamai" { resource "akamai_cp_code" "akacpcode" { contract_id = var.contractid group_id = var.groupid - product = var.product + product_id = var.product name = var.cp_code } @@ -23,7 +23,7 @@ output "aka_cp_code" { value = data.akamai_cp_code.akacpcodeq.id } output "aka_cp_contract" { - value = data.akamai_cp_code.akacpcodeq.contract + value = data.akamai_cp_code.akacpcodeq.contract_id } variable "groupid" { diff --git a/pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules.tf b/pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules_v2023_01_05.tf similarity index 100% rename from pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules.tf rename to pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules_v2023_01_05.tf diff --git a/pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules_v2023_05_30.tf b/pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules_v2023_05_30.tf new file mode 100644 index 000000000..0875fcec1 --- /dev/null +++ b/pkg/providers/property/testdata/TestDSPropertyRulesBuilder/rules_v2023_05_30.tf @@ -0,0 +1,259 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +data "akamai_property_rules_builder" "default" { + rules_v2023_05_30 { + name = "default" + is_secure = false + custom_override { + name = "test" + override_id = "test" + } + advanced_override = "test" + comments = "test" + uuid = "test" + template_uuid = "test" + template_link = "test" + + behavior { + content_characteristics_amd { + catalog_size = "SMALL" + content_type = "ULTRA_HD" + dash = true + hds = true + hls = true + popularity_distribution = "UNKNOWN" + segment_duration_dash = "SEGMENT_DURATION_10S" + segment_duration_dash_custom = 100 + segment_duration_hds = "SEGMENT_DURATION_2S" + segment_duration_hds_custom = 100 + segment_duration_hls = "SEGMENT_DURATION_4S" + segment_duration_hls_custom = 3.14 + segment_duration_smooth = "SEGMENT_DURATION_8S" + segment_duration_smooth_custom = 3.14 + segment_size_dash = "GREATER_THAN_100MB" + segment_size_hds = "TEN_MB_TO_100_MB" + segment_size_hls = "GREATER_THAN_100MB" + segment_size_smooth = "UNKNOWN" + smooth = true + } + } + behavior { + origin { + cache_key_hostname = "ORIGIN_HOSTNAME" + compress = true + enable_true_client_ip = true + forward_host_header = "REQUEST_HOST_HEADER" + http_port = 80 + https_port = 443 + origin_sni = true + origin_type = "CUSTOMER" + true_client_ip_client_setting = false + true_client_ip_header = "True-Client-IP" + use_unique_cache_key = false + verification_mode = "PLATFORM_SETTINGS" + } + } + behavior { + ad_scaler_circuit_breaker { + return_error_response_code_based = "502" + } + } + behavior { + application_load_balancer { + all_down_net_storage { + cp_code = 123 + download_domain_name = "test" + } + failover_origin_map { + from_origin_id = "123" + + } + } + } + behavior { + api_prioritization { + cloudlet_policy { + id = 1337 + name = "test" + } + } + } + + behavior { + caching { + behavior = "NO_STORE" + } + } + + behavior { + sure_route { + enabled = true + force_ssl_forward = false + race_stat_ttl = "30m" + to_host_status = "INCOMING_HH" + type = "PERFORMANCE" + } + } + + behavior { + tiered_distribution { + enabled = true + tiered_distribution_map = "CH2" + } + } + + behavior { + prefetch { + enabled = true + } + } + + behavior { + allow_post { + allow_without_content_length = false + enabled = true + } + } + behavior { + cp_code { + value { + created_date = 1678276597000 + description = "papi.declarativ.test.ipqa" + id = 1048126 + name = "papi.declarativ.test.ipqa" + products = ["Fresca", ] + } + } + } + behavior { + report { + log_accept_language = false + log_cookies = "OFF" + log_custom_log_field = false + log_edge_ip = false + log_host = false + log_referer = false + log_user_agent = true + log_x_forwarded_for = false + } + } + + behavior { + m_pulse { + api_key = "" + buffer_size = "" + config_override = <<-EOT + +EOT + enabled = true + loader_version = "V12" + require_pci = false + + } + } + children = [ + data.akamai_property_rules_builder.content_compression.json, + data.akamai_property_rules_builder.static_content.json, + data.akamai_property_rules_builder.dynamic_content.json, + ] + } +} + +data "akamai_property_rules_builder" "content_compression" { + rules_v2023_05_30 { + name = "Content Compression" + criteria_must_satisfy = "all" + criterion { + content_type { + match_case_sensitive = false + match_operator = "IS_ONE_OF" + match_wildcard = true + values = ["text/*", "application/javascript", "application/x-javascript", "application/x-javascript*", "application/json", "application/x-json", "application/*+json", "application/*+xml", "application/text", "application/vnd.microsoft.icon", "application/vnd-ms-fontobject", "application/x-font-ttf", "application/x-font-opentype", "application/x-font-truetype", "application/xmlfont/eot", "application/xml", "font/opentype", "font/otf", "font/eot", "image/svg+xml", "image/vnd.microsoft.icon", ] + } + } + behavior { + cp_code { + value { + created_date = 1678276597000 + description = "papi.declarativ.test.ipqa" + id = 1048126 + name = "papi.declarativ.test.ipqa" + products = ["Fresca", ] + cp_code_limits { + current_capacity = -143 + limit = 100 + limit_type = "global" + } + } + } + } + behavior { + gzip_response { + behavior = "ALWAYS" + } + } + children = [ + ] + } +} + +data "akamai_property_rules_builder" "static_content" { + rules_v2023_05_30 { + name = "Static Content" + criteria_must_satisfy = "all" + criterion { + file_extension { + match_case_sensitive = false + match_operator = "IS_ONE_OF" + values = ["aif", "aiff", "au", "avi", "bin", "bmp", "cab", "carb", "cct", "cdf", "class", "css", "doc", "dcr", "dtd", "exe", "flv", "gcf", "gff", "gif", "grv", "hdml", "hqx", "ico", "ini", "jpeg", "jpg", "js", "mov", "mp3", "nc", "pct", "pdf", "png", "ppc", "pws", "swa", "swf", "txt", "vbs", "w32", "wav", "wbmp", "wml", "wmlc", "wmls", "wmlsc", "xsd", "zip", "webp", "jxr", "hdp", "wdp", "pict", "tif", "tiff", "mid", "midi", "ttf", "eot", "woff", "woff2", "otf", "svg", "svgz", "webp", "jxr", "jar", "jp2", ] + } + } + behavior { + caching { + behavior = "MAX_AGE" + must_revalidate = false + ttl = "1d" + } + } + behavior { + prefetch { + enabled = false + } + } + behavior { + prefetchable { + enabled = true + } + } + children = [ + ] + } +} + +data "akamai_property_rules_builder" "dynamic_content" { + rules_v2023_05_30 { + name = "Dynamic Content" + criteria_must_satisfy = "all" + criterion { + cacheability { + match_operator = "IS_NOT" + value = "CACHEABLE" + } + } + behavior { + downstream_cache { + behavior = "TUNNEL_ORIGIN" + } + } + + behavior { + restrict_object_caching {} + } + + children = [ + ] + } +} + diff --git a/pkg/providers/property/testdata/TestPropertyActivation/import/resource_property_activation_creation_for_import.tf b/pkg/providers/property/testdata/TestPropertyActivation/import/resource_property_activation_creation_for_import.tf new file mode 100644 index 000000000..7fcb704ce --- /dev/null +++ b/pkg/providers/property/testdata/TestPropertyActivation/import/resource_property_activation_creation_for_import.tf @@ -0,0 +1,11 @@ +provider "akamai" { + edgerc = "../../test/edgerc" +} + +resource "akamai_property_activation" "test" { + property_id = "prp_test" + contact = ["user@example.com"] + version = 1 + note = "property activation note for importing" + auto_acknowledge_rule_warnings = false +} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestPropertyActivation/ok/resource_property_activation_deprecated_arg.tf b/pkg/providers/property/testdata/TestPropertyActivation/ok/resource_property_activation_minimum_args.tf similarity index 56% rename from pkg/providers/property/testdata/TestPropertyActivation/ok/resource_property_activation_deprecated_arg.tf rename to pkg/providers/property/testdata/TestPropertyActivation/ok/resource_property_activation_minimum_args.tf index a253b2f91..df0ab138c 100644 --- a/pkg/providers/property/testdata/TestPropertyActivation/ok/resource_property_activation_deprecated_arg.tf +++ b/pkg/providers/property/testdata/TestPropertyActivation/ok/resource_property_activation_minimum_args.tf @@ -3,7 +3,7 @@ provider "akamai" { } resource "akamai_property_activation" "test" { - property = "test" - contact = ["user@example.com"] - version = 1 + property_id = "test" + contact = ["user@example.com"] + version = 1 } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResCPCode/change_immutable.tf b/pkg/providers/property/testdata/TestResCPCode/change_immutable.tf index f2427406f..3cd2af0b6 100644 --- a/pkg/providers/property/testdata/TestResCPCode/change_immutable.tf +++ b/pkg/providers/property/testdata/TestResCPCode/change_immutable.tf @@ -3,8 +3,8 @@ provider "akamai" { } resource "akamai_cp_code" "test" { - name = "renamed cpcode" - contract = "ctr_2" - group_id = "grp_2" - product = "prd_2" + name = "renamed cpcode" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" } diff --git a/pkg/providers/property/testdata/TestResCPCode/change_name_step1.tf b/pkg/providers/property/testdata/TestResCPCode/change_name_step1.tf index 405065c88..19dafdeae 100644 --- a/pkg/providers/property/testdata/TestResCPCode/change_name_step1.tf +++ b/pkg/providers/property/testdata/TestResCPCode/change_name_step1.tf @@ -3,8 +3,8 @@ provider "akamai" { } resource "akamai_cp_code" "test" { - name = "renamed cpcode" - contract = "ctr_1" - group = "grp_1" - product = "prd_1" + name = "renamed cpcode" + contract_id = "ctr_1" + group_id = "grp_1" + product_id = "prd_1" } diff --git a/pkg/providers/property/testdata/TestResCPCode/change_product_step1.tf b/pkg/providers/property/testdata/TestResCPCode/change_product_step1.tf index 68018109f..612f85181 100644 --- a/pkg/providers/property/testdata/TestResCPCode/change_product_step1.tf +++ b/pkg/providers/property/testdata/TestResCPCode/change_product_step1.tf @@ -3,8 +3,8 @@ provider "akamai" { } resource "akamai_cp_code" "test" { - name = "test cpcode" - contract = "ctr1" - group = "grp1" - product = "prd2" + name = "test cpcode" + contract_id = "ctr1" + group = "grp1" + product = "prd2" } diff --git a/pkg/providers/property/testdata/TestResCPCode/create_new_cp_code_deprecated_attrs.tf b/pkg/providers/property/testdata/TestResCPCode/create_new_cp_code_deprecated_attrs.tf deleted file mode 100644 index ca2ff394f..000000000 --- a/pkg/providers/property/testdata/TestResCPCode/create_new_cp_code_deprecated_attrs.tf +++ /dev/null @@ -1,10 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_cp_code" "test" { - name = "test cpcode" - contract = "ctr_1" - group = "grp_1" - product = "prd_1" -} diff --git a/pkg/providers/property/testdata/TestResCPCode/import_cp_code.tf b/pkg/providers/property/testdata/TestResCPCode/import_cp_code.tf index 18a4852a7..8f491c3a6 100644 --- a/pkg/providers/property/testdata/TestResCPCode/import_cp_code.tf +++ b/pkg/providers/property/testdata/TestResCPCode/import_cp_code.tf @@ -6,5 +6,5 @@ resource "akamai_cp_code" "test" { name = "test cpcode" group_id = "grp_2" contract_id = "ctr_1" - product = "prd_Web_Accel" + product_id = "prd_Web_Accel" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/both_contract_and_contract_id_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/both_contract_and_contract_id_given.tf deleted file mode 100644 index 0c12f34dc..000000000 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/both_contract_and_contract_id_given.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - group_id = "grp_0" - product_id = "prd_0" - - contract = "crt1" - contract_id = "crt2" -} diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/both_group_and_group_id_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/both_group_and_group_id_given.tf deleted file mode 100644 index 5a6112111..000000000 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/both_group_and_group_id_given.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - product_id = "prd_0" - - group = "grp1" - group_id = "grp2" -} diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/both_product_and_product_id_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/both_product_and_product_id_given.tf deleted file mode 100644 index c7eaa752e..000000000 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/both_product_and_product_id_given.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - - product = "prd1" - product_id = "prd2" -} diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/neither_contract_nor_contract_id_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf similarity index 100% rename from pkg/providers/property/testdata/TestResProperty/ConfigError/neither_contract_nor_contract_id_given.tf rename to pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/neither_group_nor_group_id_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf similarity index 98% rename from pkg/providers/property/testdata/TestResProperty/ConfigError/neither_group_nor_group_id_given.tf rename to pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf index 65577fc89..0888de60b 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/neither_group_nor_group_id_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf @@ -6,4 +6,4 @@ resource "akamai_property" "test" { name = "test_property" contract_id = "ctr_0" product_id = "prd_0" -} +} \ No newline at end of file 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 f7fabaa61..f35371b87 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf @@ -6,4 +6,5 @@ resource "akamai_property" "test" { name = "invalid_name_@" contract_id = "ctr_0" group_id = "grp_0" + product_id = "prd_0" } 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 d912777d9..40de3bff3 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 @@ -6,4 +6,5 @@ resource "akamai_property" "test" { name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" contract_id = "ctr_0" group_id = "grp_0" + product_id = "prd_0" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/neither_product_nor_product_id_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf similarity index 100% rename from pkg/providers/property/testdata/TestResProperty/ConfigError/neither_product_nor_product_id_given.tf rename to pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf 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 b603629d5..ca7e492bb 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf @@ -6,7 +6,7 @@ resource "akamai_property" "test" { name = "test_property" contract_id = "ctr_0" group_id = "grp_0" - product = "prd_0" + product_id = "prd_0" 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 1659f0211..c6ff9af2a 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf @@ -6,7 +6,7 @@ resource "akamai_property" "test" { name = "test_property" contract_id = "ctr_0" group_id = "grp_0" - product = "prd_0" + product_id = "prd_0" rules = data.akamai_property_rules_template.akarules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product to product_id/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product to product_id/step0.tf deleted file mode 100644 index 1fd5aa12e..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product to product_id/step0.tf +++ /dev/null @@ -1,23 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product = "prd_0" - - hostnames { - cname_to = "to.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } - - rules = data.akamai_property_rules_template.akarules.json - -} - -data "akamai_property_rules_template" "akarules" { - template_file = "testdata/TestResProperty/Lifecycle/property-snippets/rules1.json" -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product to product_id/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product to product_id/step1.tf deleted file mode 100644 index 1edf20a15..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product to product_id/step1.tf +++ /dev/null @@ -1,23 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" - - hostnames { - cname_to = "to.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } - - rules = data.akamai_property_rules_template.akarules.json - -} - -data "akamai_property_rules_template" "akarules" { - template_file = "testdata/TestResProperty/Lifecycle/property-snippets/rules1.json" -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id to product/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id to product/step0.tf deleted file mode 100644 index 1edf20a15..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id to product/step0.tf +++ /dev/null @@ -1,23 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" - - hostnames { - cname_to = "to.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } - - rules = data.akamai_property_rules_template.akarules.json - -} - -data "akamai_property_rules_template" "akarules" { - template_file = "testdata/TestResProperty/Lifecycle/property-snippets/rules1.json" -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id to product/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id to product/step1.tf deleted file mode 100644 index 1fd5aa12e..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id to product/step1.tf +++ /dev/null @@ -1,23 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product = "prd_0" - - hostnames { - cname_to = "to.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } - - rules = data.akamai_property_rules_template.akarules.json - -} - -data "akamai_property_rules_template" "akarules" { - template_file = "testdata/TestResProperty/Lifecycle/property-snippets/rules1.json" -} 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 65d044dcb..d3406c84f 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 @@ -6,7 +6,7 @@ resource "akamai_property" "test" { name = "test_property" contract_id = "ctr_0" group_id = "grp_0" - product = "prd_0" + product_id = "prd_0" 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 16506e6b6..bd0390d2d 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 @@ -6,7 +6,7 @@ resource "akamai_property" "test" { name = "test_property" contract_id = "ctr_0" group_id = "grp_0" - product = "prd_0" + product_id = "prd_0" rules = data.akamai_property_rules_template.rules.json 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 a05bb6491..1920bc48e 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 @@ -3,10 +3,10 @@ provider "akamai" { } resource "akamai_property" "test" { - name = "test_property" - contract = "0" - group_id = "grp_0" - product_id = "prd_0" + name = "test_property" + contract_id = "0" + group_id = "grp_0" + product_id = "prd_0" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResPropertyVariables/schema_version1_always_fails.tf b/pkg/providers/property/testdata/TestResPropertyVariables/schema_version1_always_fails.tf deleted file mode 100644 index 78f9cc3f7..000000000 --- a/pkg/providers/property/testdata/TestResPropertyVariables/schema_version1_always_fails.tf +++ /dev/null @@ -1,5 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_property_variables" "test" {} diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/creation_before_import_edgehostname.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/creation_before_import_edgehostname.tf index b7566d141..b9d9479ec 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/creation_before_import_edgehostname.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/creation_before_import_edgehostname.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "createhostname" { - contract = "ctr_1" - group = "grp_2" - product = "prd_2" + 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.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname.tf index 1b763bf03..e735968df 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname.tf @@ -3,8 +3,8 @@ provider "akamai" { } resource "akamai_edge_hostname" "importedgehostname" { - contract = "ctr_1" - group = "grp_2" + contract_id = "ctr_1" + group_id = "grp_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV4" } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/invalid_ip.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/invalid_ip.tf deleted file mode 100644 index 7e9f2866c..000000000 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/invalid_ip.tf +++ /dev/null @@ -1,11 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" - edge_hostname = "test.akamaized.net" - ip_behavior = "unknown" -} diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/missing_certificate.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/missing_certificate.tf index affbc7ded..622540724 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/missing_certificate.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/missing_certificate.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.edgekey.net" ip_behavior = "IPV6_PERFORMANCE" } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new.tf index 0e6cb9c85..572172f57 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.aka" ip_behavior = "IPV4" use_cases = <<-EOF diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_error_update_ipv6_performance.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_error_update_ipv6_performance.tf index 45b08488a..499678245 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_error_update_ipv6_performance.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_error_update_ipv6_performance.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV6_PERFORMANCE" status_update_email = ["hello@akamai.com"] diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_ipv4.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_ipv4.tf index b7e3a1d3c..6de1dcba0 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_ipv4.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_ipv4.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV4" } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net.tf index 9e1264c65..345ccc693 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV6_COMPLIANCE" } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_with_both_product_and_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_with_both_product_and_product_id.tf deleted file mode 100644 index 8ca2e679d..000000000 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_with_both_product_and_product_id.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product_id = "prd_2" - product = "prd_2" - 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_akamaized_net_with_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_with_product_id.tf deleted file mode 100644 index dde170626..000000000 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_with_product_id.tf +++ /dev/null @@ -1,15 +0,0 @@ -provider "akamai" { - edgerc = "../../test/edgerc" -} - -resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product_id = "prd_2" - 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_akamaized_net_without_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_without_product_id.tf index d33e945a3..d6a71a2b5 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_without_product_id.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_without_product_id.tf @@ -3,8 +3,8 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" + contract_id = "ctr_2" + group_id = "grp_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV6_COMPLIANCE" } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior.tf index 6a355f1ba..1965bad64 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV6_COMPLIANCE" status_update_email = ["hello@akamai.com"] diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_empty_email.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_empty_email.tf index 252884cad..1f001b8b1 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_empty_email.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_empty_email.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV6_COMPLIANCE" status_update_email = [] diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_no_email.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_no_email.tf index 9e1264c65..345ccc693 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_no_email.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_update_ip_behavior_no_email.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.akamaized.net" ip_behavior = "IPV6_COMPLIANCE" } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net.tf index 09e488263..1461f0d52 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "ctr_2" - group = "grp_2" - product = "prd_2" + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" edge_hostname = "test.edgekey.net" certificate = 123 ip_behavior = "IPV6_PERFORMANCE" diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgesuite_net.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgesuite_net.tf index 559862c8a..b37d7b604 100644 --- a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgesuite_net.tf +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgesuite_net.tf @@ -3,9 +3,9 @@ provider "akamai" { } resource "akamai_edge_hostname" "edgehostname" { - contract = "2" - group = "2" - product = "2" + contract_id = "2" + group_id = "2" + product_id = "2" edge_hostname = "test2.edgesuite.net" certificate = 123 ip_behavior = "IPV6_COMPLIANCE" diff --git a/pkg/providers/providers.go b/pkg/providers/providers.go index 4d218d154..3cbe46a75 100644 --- a/pkg/providers/providers.go +++ b/pkg/providers/providers.go @@ -3,16 +3,16 @@ package providers import ( // This is where providers are import so they can register themselves - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/appsec" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/botman" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cloudlets" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/cps" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/datastream" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/dns" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/edgeworkers" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/gtm" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/iam" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/imaging" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/networklists" - _ "github.com/akamai/terraform-provider-akamai/v4/pkg/providers/property" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/appsec" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/botman" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cloudlets" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/cps" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/datastream" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/dns" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/edgeworkers" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/gtm" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/iam" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/imaging" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/networklists" + _ "github.com/akamai/terraform-provider-akamai/v5/pkg/providers/property" ) diff --git a/pkg/providers/registry/registry.go b/pkg/providers/registry/registry.go index 559d861c0..70ab59b29 100644 --- a/pkg/providers/registry/registry.go +++ b/pkg/providers/registry/registry.go @@ -4,31 +4,50 @@ package registry import ( "sync" - "github.com/akamai/terraform-provider-akamai/v4/pkg/akamai" + "github.com/akamai/terraform-provider-akamai/v5/pkg/subprovider" ) var ( lock sync.Mutex - allProviders []akamai.Subprovider + pluginSubproviders []subprovider.Plugin + frameworkSubproviders []subprovider.Framework ) -// RegisterProvider simply adds the provider to the array -func RegisterProvider(p akamai.Subprovider) { +// RegisterPluginSubprovider registers a terraform-plugin-sdk sub-provider +func RegisterPluginSubprovider(p subprovider.Plugin) { lock.Lock() defer lock.Unlock() - allProviders = append(allProviders, p) + pluginSubproviders = append(pluginSubproviders, p) } -// AllProviders returns all of the registered providers -func AllProviders() []akamai.Subprovider { +// PluginSubproviders returns all of the registered terraform-plugin-sdk sub-providers +func PluginSubproviders() []subprovider.Plugin { lock.Lock() defer lock.Unlock() - out := make([]akamai.Subprovider, len(allProviders)) + out := make([]subprovider.Plugin, len(pluginSubproviders)) + copy(out, pluginSubproviders) - copy(out, allProviders) + return out +} + +// RegisterFrameworkSubprovider registers a terraform-plugin-framework sub-provider +func RegisterFrameworkSubprovider(p subprovider.Framework) { + lock.Lock() + defer lock.Unlock() + + frameworkSubproviders = append(frameworkSubproviders, p) +} + +// FrameworkSubproviders returns all of the registered terraform-plugin-framework sub-providers +func FrameworkSubproviders() []subprovider.Framework { + lock.Lock() + defer lock.Unlock() + + out := make([]subprovider.Framework, len(frameworkSubproviders)) + copy(out, frameworkSubproviders) return out } diff --git a/pkg/subprovider/subprovider.go b/pkg/subprovider/subprovider.go new file mode 100644 index 000000000..5ef4d0288 --- /dev/null +++ b/pkg/subprovider/subprovider.go @@ -0,0 +1,26 @@ +// Package subprovider defines contract for a subprovider +package subprovider + +import ( + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +// Plugin is the interface implemented by the sub-providers using terraform-plugin-sdk +type Plugin interface { + // Resources returns the resources for the sub-provider + Resources() map[string]*schema.Resource + + // DataSources returns the datasources for the sub-provider + DataSources() map[string]*schema.Resource +} + +// Framework is the interface implemented by the sub-providers using terraform-plugin-framework +type Framework interface { + // Resources returns the resources for the sub-provider + Resources() []func() resource.Resource + + // DataSources returns the datasources for the sub-provider + DataSources() []func() datasource.DataSource +} diff --git a/scripts/install_terraform.sh b/scripts/install_terraform.sh index 4771154b2..b0eaf7a3e 100755 --- a/scripts/install_terraform.sh +++ b/scripts/install_terraform.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="1.0.11" +VERSION="1.4.6" [[ -n $(which terraform) ]] && echo "Terraform already installed" && exit 0