From 16c7e98c4bf180b691fc988a7f0e0df9a1af324d Mon Sep 17 00:00:00 2001 From: "Zagrajczuk, Wojciech" Date: Wed, 4 Sep 2024 16:22:29 +0200 Subject: [PATCH 01/54] DXE-3944 Changelog boilerplate --- CHANGELOG.md | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bff0d5aa0..6d643138c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,123 @@ # RELEASE NOTES + +## X.X.X (X X, X) + +#### BREAKING CHANGES: + + + + + + + + + + + + + +#### FEATURES/ENHANCEMENTS: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#### BUG FIXES: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ## 6.4.0 (Sep 04, 2024) From 787e60dd79acfa6788c7f9772156ad9e2e81c200 Mon Sep 17 00:00:00 2001 From: Jakub Bilski Date: Thu, 5 Sep 2024 11:27:13 +0000 Subject: [PATCH 02/54] DXE-4136 Add support for new Terraform version & bump SDKv2/Framework libraries --- CHANGELOG.md | 9 +++++++ build/internal/docker_jenkins.bash | 2 +- go.mod | 21 ++++++++------- go.sum | 42 ++++++++++++++++-------------- scripts/install_terraform.sh | 2 +- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d643138c..15c2d6281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,15 @@ +* Global + * Migrated Terraform to version 1.9.5 + * Updated SDKv2 and framework libraries + + + + + + diff --git a/build/internal/docker_jenkins.bash b/build/internal/docker_jenkins.bash index a089d06c9..6cdb840dd 100755 --- a/build/internal/docker_jenkins.bash +++ b/build/internal/docker_jenkins.bash @@ -26,7 +26,7 @@ COVERAGE_HTML="$COVERAGE_DIR"/index.html WORKDIR="${WORKDIR-$(pwd)}" echo "WORKDIR is $WORKDIR" -TERRAFORM_VERSION="1.7.5" +TERRAFORM_VERSION="1.9.5" STASH_SERVER=git.source.akamai.com GIT_IP=$(dig +short $STASH_SERVER) diff --git a/go.mod b/go.mod index cf505f307..2e78b9b3e 100644 --- a/go.mod +++ b/go.mod @@ -13,14 +13,14 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-hclog v1.6.3 - github.com/hashicorp/terraform-plugin-framework v1.8.0 + github.com/hashicorp/terraform-plugin-framework v1.11.0 github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 - github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 github.com/hashicorp/terraform-plugin-go v0.23.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-mux v0.16.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 - github.com/hashicorp/terraform-plugin-testing v1.9.0 + github.com/hashicorp/terraform-plugin-testing v1.10.0 github.com/iancoleman/strcase v0.3.0 github.com/jedib0t/go-pretty/v6 v6.0.4 github.com/jinzhu/copier v0.3.2 @@ -28,7 +28,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/tj/assert v0.0.3 golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.8.0 ) require ( @@ -46,9 +46,10 @@ require ( github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/hc-install v0.7.0 // indirect + github.com/hashicorp/hc-install v0.8.0 // indirect github.com/hashicorp/hcl/v2 v2.21.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect @@ -73,13 +74,13 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.14.4 // indirect + github.com/zclconf/go-cty v1.15.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.25.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect diff --git a/go.sum b/go.sum index c3bd65481..4f14017bc 100644 --- a/go.sum +++ b/go.sum @@ -86,13 +86,15 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= -github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= +github.com/hashicorp/hc-install v0.8.0 h1:LdpZeXkZYMQhoKPCecJHlKvUkQFixN/nvyR1CdfOLjI= +github.com/hashicorp/hc-install v0.8.0/go.mod h1:+MwJYjDfCruSD/udvBmRB22Nlkwwkwf5sAB6uTIhSaU= github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= @@ -101,12 +103,12 @@ github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVW github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-framework v1.8.0 h1:P07qy8RKLcoBkCrY2RHJer5AEvJnDuXomBgou6fD8kI= -github.com/hashicorp/terraform-plugin-framework v1.8.0/go.mod h1:/CpTukO88PcL/62noU7cuyaSJ4Rsim+A/pa+3rUVufY= +github.com/hashicorp/terraform-plugin-framework v1.11.0 h1:M7+9zBArexHFXDx/pKTxjE6n/2UCXY6b8FIq9ZYhwfE= +github.com/hashicorp/terraform-plugin-framework v1.11.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1/go.mod h1:MsjL1sQ9L7wGwzJ5RjcI6FzEMdyoBnw+XK8ZnOvQOLY= -github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= -github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= +github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E= +github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo= github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= @@ -115,8 +117,8 @@ github.com/hashicorp/terraform-plugin-mux v0.16.0 h1:RCzXHGDYwUwwqfYYWJKBFaS3fQs github.com/hashicorp/terraform-plugin-mux v0.16.0/go.mod h1:PF79mAsPc8CpusXPfEVa4X8PtkB+ngWoiUClMrNZlYo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE= github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg= -github.com/hashicorp/terraform-plugin-testing v1.9.0 h1:xOsQRqqlHKXpFq6etTxih3ubdK3HVDtfE1IY7Rpd37o= -github.com/hashicorp/terraform-plugin-testing v1.9.0/go.mod h1:fhhVx/8+XNJZTD5o3b4stfZ6+q7z9+lIWigIYdT6/44= +github.com/hashicorp/terraform-plugin-testing v1.10.0 h1:2+tmRNhvnfE4Bs8rB6v58S/VpqzGC6RCh9Y8ujdn+aw= +github.com/hashicorp/terraform-plugin-testing v1.10.0/go.mod h1:iWRW3+loP33WMch2P/TEyCxxct/ZEcCGMquSLSCVsrc= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -231,8 +233,8 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= +github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= @@ -242,13 +244,13 @@ go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6m golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -259,8 +261,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -277,8 +279,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -286,8 +288,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/scripts/install_terraform.sh b/scripts/install_terraform.sh index 945eac5e3..c16a33f9a 100755 --- a/scripts/install_terraform.sh +++ b/scripts/install_terraform.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="${TERRAFORM_VERSION:-1.7.5}" +VERSION="${TERRAFORM_VERSION:-1.9.5}" VERSION="${VERSION#v}" if [[ -n $(which terraform) && "$(terraform --version | sed 1q | cut -f2 -d" " | cut -c2-)" == "$VERSION" ]]; then From 2cd69576e28675ec8030c4e53c9f8e0916ef79ba Mon Sep 17 00:00:00 2001 From: Rahul Bhatvedekar Date: Tue, 17 Sep 2024 12:38:56 +0000 Subject: [PATCH 03/54] DXE-3001 Retry CreateProperty on Property Validation Failure Merge in DEVEXP/terraform-provider-akamai from feature/DXE-3001 to develop --- CHANGELOG.md | 10 +++ .../gtm/resource_akamai_gtm_property.go | 45 +++++++++- .../gtm/resource_akamai_gtm_property_test.go | 88 +++++++++++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15c2d6281..e70220550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,16 @@ * Updated SDKv2 and framework libraries +* GTM + * Added retry logic to `akamai_gtm_property` resource to handle errors caused by prolonged creation time, leading to Property Validation Failure with "no datacenter is assigned to map target (all others)" error from the API. + + + + + + + + diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 2d09c4fc0..7eccaadf4 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -7,6 +7,7 @@ import ( "reflect" "sort" "strings" + "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" @@ -14,6 +15,7 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/apex/log" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -539,7 +541,7 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } logger.Debugf("Proposed New Property: [%v]", newProp) - cStatus, err := Client(meta).CreateProperty(ctx, newProp, domain) + cStatus, err := createPropertyWithRetry(ctx, meta, logger, newProp, domain) if err != nil { logger.Errorf("Property Create failed: CreateProperty error: %s", err.Error()) return diag.Errorf("property Create failed: CreateProperty error: %s", err.Error()) @@ -578,6 +580,47 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m } +func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Interface, newProp *gtm.Property, domain string) (*gtm.PropertyResponse, error) { + // Initial backoff interval + retryInterval := time.Second * 10 + // Maximum retry interval + maxRetryTimeout := time.Minute * 10 + + for { + // Attempt to create the property + cStatus, err := Client(meta).CreateProperty(ctx, newProp, domain) + if err == nil { + // Success, return the created property + return cStatus, nil + } + + logger.Errorf("Property Create failed: CreateProperty error: %s", err.Error()) + + // If the error is not "no datacenter is assigned to map target (all others)", return immediately + if !errors.Is(err, gtm.ErrNoDatacenterAssignedToMap) { + return nil, fmt.Errorf("property Create failed: error: %s", err) + } + + select { + case <-time.After(retryInterval): + // exponential backoff + retryInterval = 2 * retryInterval + if retryInterval > maxRetryTimeout { + retryInterval = maxRetryTimeout + } + logger.Debugf("Retrying property creation after %s", retryInterval) + case <-ctx.Done(): + // Handle context timeout or cancellation + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + return nil, fmt.Errorf("timeout waiting for property creation: last error: %s", err) + } + if errors.Is(ctx.Err(), context.Canceled) { + return nil, fmt.Errorf("operation canceled while creating property, last error: %s", err) + } + } + } +} + // Only ever save data from the tf config in the tf state file, to help with // api issues. See func unmarshalResourceData for more info. func resourceGTMv1PropertyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 22d4bb320..e945b70fd 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -1,6 +1,7 @@ package gtm import ( + "context" "net/http" "regexp" "testing" @@ -117,6 +118,93 @@ func TestResGTMProperty(t *testing.T) { }, }, }, + "create property with retry on Property Validation Failure - no datacenter is assigned to map target": { + init: func(t *testing.T, m *gtm.Mock) { + // Simulate a retry scenario + m.On("CreateProperty", + mock.Anything, + getBasicProperty(), + gtmTestDomain, + ).Return(nil, >m.Error{ + Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", + StatusCode: http.StatusBadRequest, + Title: "Property Validation Failure", + Detail: "Invalid configuration for property \"tfexample_prop_1\": no datacenter is assigned to map target (all others)", + }).Once() + + // Simulate successful property creation on the second attempt + mockCreateProperty(m, getBasicProperty(), gtmTestDomain) + mockGetProperty(m, getBasicProperty(), propertyName, gtmTestDomain, 3) + mockDeleteProperty(m, getBasicProperty(), gtmTestDomain) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResGtmProperty/create_basic.tf"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(propertyResourceName, "name", "tfexample_prop_1"), + resource.TestCheckResourceAttr(propertyResourceName, "type", "weighted-round-robin"), + resource.TestCheckResourceAttr(propertyResourceName, "weighted_hash_bits_for_ipv4", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "weighted_hash_bits_for_ipv6", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.http_method", ""), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.http_request_body", ""), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.alternate_ca_certificates.#", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "liveness_test.0.pre_2023_security_posture", "false"), + resource.TestCheckResourceAttr(propertyResourceName, "traffic_target.0.precedence", "0"), + resource.TestCheckResourceAttr(propertyResourceName, "id", "gtm_terra_testdomain.akadns.net:tfexample_prop_1"), + ), + }, + }, + }, + "create property with retry on Property Validation Failure - other errors": { + init: func(t *testing.T, m *gtm.Mock) { + // Simulate a retry scenario + m.On("CreateProperty", + mock.Anything, + getBasicProperty(), + gtmTestDomain, + ).Return(nil, >m.Error{ + Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", + StatusCode: http.StatusBadRequest, + Title: "Property Validation Failure", + Detail: "Invalid configuration for property \"tfexample_prop_1\": no targets found", + }).Once() + + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResGtmProperty/create_basic.tf"), + ExpectError: regexp.MustCompile("CreateProperty error: property Create failed: error: API error"), + }, + }, + }, + "create property with retry - context canceled": { + init: func(t *testing.T, m *gtm.Mock) { + // Simulate a retry scenario + m.On("CreateProperty", + mock.Anything, + getBasicProperty(), + gtmTestDomain, + ).Return(nil, >m.Error{ + Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", + StatusCode: http.StatusBadRequest, + Title: "Property Validation Failure", + Detail: "Invalid configuration for property \"tfexample_prop_1\": no datacenter is assigned to map target (all others)", + }).Once() + + // Simulate context cancellation on the second attempt + m.On("CreateProperty", + mock.Anything, + getBasicProperty(), + gtmTestDomain, + ).Return(nil, context.Canceled).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResGtmProperty/create_basic.tf"), + ExpectError: regexp.MustCompile("CreateProperty error: property Create failed: error: context canceled"), + }, + }, + }, "create property denied": { property: nil, init: func(t *testing.T, m *gtm.Mock) { From caf287d20ef1df4802acc7d088aba3fc54c50a06 Mon Sep 17 00:00:00 2001 From: Piotr Bartosik Date: Wed, 18 Sep 2024 07:31:52 +0000 Subject: [PATCH 04/54] DXE-3907 import of akamai edge hostname does not import the product id Merge in DEVEXP/terraform-provider-akamai from bugfix/DXE-3907-import-of-akamai_edge_hostname-does-not-import-the-product-id to develop --- CHANGELOG.md | 6 +- .../property/resource_akamai_edge_hostname.go | 22 +- .../resource_akamai_edge_hostname_test.go | 443 +++++++++++++++--- ...mport_edgehostname_akamaized_product_id.tf | 11 + .../import_edgehostname_product_id.tf | 12 + .../new_akamaized_net_different_product_id.tf | 15 + .../new_edgekey_net_different_certificate.tf | 16 + 7 files changed, 459 insertions(+), 66 deletions(-) create mode 100644 pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf create mode 100644 pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf create mode 100644 pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf create mode 100644 pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index e70220550..126ab5afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,9 +34,9 @@ - - - +* PAPI + * Added a new optional param to the import id of the `akamai_edge_hostname` resource. + It allows to specify the product ID of the imported hostname and save it in the state. diff --git a/pkg/providers/property/resource_akamai_edge_hostname.go b/pkg/providers/property/resource_akamai_edge_hostname.go index 63a02f356..c7d12815c 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname.go +++ b/pkg/providers/property/resource_akamai_edge_hostname.go @@ -531,13 +531,31 @@ func resourceSecureEdgeHostNameDelete(_ context.Context, d *schema.ResourceData, return nil } +// resourceSecureEdgeHostNameImport accepts the following import ID: +// EdgehostNameID,contractID,groupID[,productID] +// productID is optional and needs to be specified if the resource config contains the product_id +// attribute (which is not the case for the configuration generated by export done with Akamai +// CLI tools). func resourceSecureEdgeHostNameImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { meta := meta.Must(m) client := Client(meta) + logger := meta.Log("PAPI", "resourceSecureEdgeHostNameImport") parts := strings.Split(d.Id(), ",") - if len(parts) < 3 { - return nil, fmt.Errorf("comma-separated list of EdgehostNameID, contractID and groupID has to be supplied in import: %s", d.Id()) + if len(parts) < 3 || len(parts) > 4 { + return nil, fmt.Errorf("expected import identifier with format: "+ + `"EdgehostNameID,contractID,groupID[,productID]". Got: %q`, d.Id()) + } + + if len(parts) == 4 { + if len(parts[3]) == 0 { + return nil, fmt.Errorf("productID is empty for the import ID=%q", d.Id()) + } + productID := str.AddPrefix(parts[3], "prd_") + logger.Debugf("Setting product_id=%s", productID) + if err := d.Set("product_id", productID); err != nil { + return nil, fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) + } } edgehostID := parts[0] diff --git a/pkg/providers/property/resource_akamai_edge_hostname_test.go b/pkg/providers/property/resource_akamai_edge_hostname_test.go index 6d1f04fdb..35cff0cce 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname_test.go +++ b/pkg/providers/property/resource_akamai_edge_hostname_test.go @@ -1688,6 +1688,176 @@ func TestResourceEdgeHostname(t *testing.T) { }, }, }, + "error on updating product id": { + init: func(mp *papi.Mock, _ *hapi.Mock) { + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_2", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + }}, + }, nil).Once() + mp.On("CreateEdgeHostname", mock.Anything, papi.CreateEdgeHostnameRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostname: papi.EdgeHostnameCreate{ + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "akamaized.net", + SecureNetwork: "SHARED_CERT", + IPVersionBehavior: "IPV6_COMPLIANCE", + }, + }).Return(&papi.CreateEdgeHostnameResponse{ + EdgeHostnameID: "ehn_456", + }, nil) + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_2", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_456", + Domain: "test.akamaized.net", + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "akamaized.net", + IPVersionBehavior: "IPV6_COMPLIANCE", + }, + }}, + }, nil) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_akamaized_net.tf")), + }, + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_akamaized_net_different_product_id.tf")), + ExpectError: regexp.MustCompile(`Changes to non-updatable fields 'product_id' and 'certificate' are not permitted`), + }, + }, + }, + "error on updating certificate": { + init: func(mp *papi.Mock, _ *hapi.Mock) { + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV6_PERFORMANCE", + }, + { + ID: "ehn_2", + Domain: "test.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV6_PERFORMANCE", + }, + }}, + }, nil).Once() + mp.On("CreateEdgeHostname", mock.Anything, papi.CreateEdgeHostnameRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostname: papi.EdgeHostnameCreate{ + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "edgekey.net", + SecureNetwork: "ENHANCED_TLS", + IPVersionBehavior: "IPV6_PERFORMANCE", + CertEnrollmentID: 123, + SlotNumber: 123, + }, + }).Return(&papi.CreateEdgeHostnameResponse{ + EdgeHostnameID: "ehn_456", + }, nil) + mp.On("GetEdgeHostnames", mock.Anything, papi.GetEdgeHostnamesRequest{ + ContractID: "ctr_2", + GroupID: "grp_2", + }).Return(&papi.GetEdgeHostnamesResponse{ + ContractID: "ctr_2", + GroupID: "grp_2", + EdgeHostnames: papi.EdgeHostnameItems{Items: []papi.EdgeHostnameGetItem{ + { + ID: "ehn_123", + Domain: "test.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test2", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_2", + Domain: "test3.edgesuite.net", + ProductID: "prd_2", + DomainPrefix: "test3", + DomainSuffix: "edgesuite.net", + IPVersionBehavior: "IPV4", + }, + { + ID: "ehn_456", + Domain: "test.edgekey.net", + ProductID: "prd_2", + DomainPrefix: "test", + DomainSuffix: "edgekey.net", + IPVersionBehavior: "IPV6_PERFORMANCE", + }, + }}, + }, nil) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_edgekey_net.tf")), + }, + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("%s/%s", testDir, "new_edgekey_net_different_certificate.tf")), + ExpectError: regexp.MustCompile(`Changes to non-updatable fields 'product_id' and 'certificate' are not permitted`), + }, + }, + }, "update edge hostname without status email": { init: func(mp *papi.Mock, mh *hapi.Mock) { // 1st step @@ -2134,51 +2304,6 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { UseCases: nil, }, nil) } - expectGetEdgeHostnameHAPI := func(m *hapi.Mock, edgeHostnameID int) *mock.Call { - return m.On("GetEdgeHostname", mock.Anything, hapi.GetCertificateRequest{DNSZone: "edgekey.net", RecordName: "test"}).Return(&hapi.GetEdgeHostnameResponse{ - EdgeHostnameID: edgeHostnameID, - RecordName: "test", - DNSZone: "edgekey.net", - SecurityType: "ENHANCED-TLS", - UseDefaultTTL: true, - UseDefaultMap: true, - IPVersionBehavior: "IPV4", - ProductID: "DSA", - TTL: 21600, - Map: "a;dscb.akamai.net", - SlotNumber: 3250, - Comments: "Created by Property-Manager/PAPI on Tue Feb 21 14:03:36 UTC 2023", - SerialNumber: 1520, - CustomTarget: "", - ChinaCdn: hapi.ChinaCDN{}, - IsEdgeIPBindingEnabled: false, - MapAlias: "", - UseCases: nil, - }, nil) - } - expectGetEdgeHostnameHAPIWithTTL := func(m *hapi.Mock, edgeHostnameID int) *mock.Call { - return m.On("GetEdgeHostname", mock.Anything, hapi.GetCertificateRequest{DNSZone: "edgekey.net", RecordName: "test"}).Return(&hapi.GetEdgeHostnameResponse{ - EdgeHostnameID: edgeHostnameID, - RecordName: "test", - DNSZone: "edgekey.net", - SecurityType: "ENHANCED-TLS", - UseDefaultTTL: false, - UseDefaultMap: true, - IPVersionBehavior: "IPV4", - ProductID: "DSA", - TTL: 56789, - Map: "a;dscb.akamai.net", - SlotNumber: 3250, - Comments: "Created by Property-Manager/PAPI on Tue Feb 21 14:03:36 UTC 2023", - SerialNumber: 1520, - CustomTarget: "", - ChinaCdn: hapi.ChinaCDN{}, - IsEdgeIPBindingEnabled: false, - MapAlias: "", - UseCases: nil, - }, nil) - } - expectGetCertificate := func(m *hapi.Mock) *mock.Call { return m.On("GetCertificate", mock.Anything, hapi.GetCertificateRequest{ RecordName: "test", @@ -2196,7 +2321,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }, nil) } - t.Run("import existing akamaized edgehostname without certificate", func(t *testing.T) { + t.Run("import existing akamaized edgehostname without certificate - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2205,13 +2330,12 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { createEdgeHostnamesAkamaized(client).Once() expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2") expectGetEdgeHostnameAkamaized(client, "ehn_1", "ctr_1", "grp_2").Once() - expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Times(1) + expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Once() useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname_akamaized.tf"), }, { @@ -2223,6 +2347,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { assert.Equal(t, "grp_2", rs.Attributes["group_id"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) assert.Equal(t, "ehn_1", rs.Attributes["id"]) + assert.Equal(t, "", rs.Attributes["product_id"]) assert.Equal(t, "", rs.Attributes["certificate"]) return nil }, @@ -2235,8 +2360,9 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) }) - t.Run("import existing edgehostname with certificate", func(t *testing.T) { + t.Run("import existing edgehostname with certificate - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2245,15 +2371,13 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { createEdgeHostnames(client).Once() expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2") expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() - expectGetEdgeHostnameHAPIByID(clientHapi, 1).Times(3) - expectGetEdgeHostnameHAPI(clientHapi, 1).Times(10) - expectGetCertificate(clientHapi).Times(5) + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() + expectGetCertificate(clientHapi).Once() useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname.tf"), }, { @@ -2265,6 +2389,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { assert.Equal(t, "grp_2", rs.Attributes["group_id"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) assert.Equal(t, "ehn_1", rs.Attributes["id"]) + assert.Equal(t, "", rs.Attributes["product_id"]) assert.Equal(t, "123456", rs.Attributes["certificate"]) return nil }, @@ -2277,8 +2402,9 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) }) - t.Run("import existing edgehostname with missing certificate", func(t *testing.T) { + t.Run("import existing edgehostname with missing certificate - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2287,8 +2413,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { createEdgeHostnames(client).Once() expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2") expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() - expectGetEdgeHostnameHAPIByID(clientHapi, 1).Times(6) - expectGetEdgeHostnameHAPI(clientHapi, 1).Times(10) + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() resp := hapi.Error{ Type: "CERTIFICATE_NOT_FOUND", @@ -2311,7 +2436,6 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname_missing_certificate.tf"), }, { @@ -2323,6 +2447,7 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { assert.Equal(t, "grp_2", rs.Attributes["group_id"]) assert.Equal(t, "ctr_1", rs.Attributes["contract_id"]) assert.Equal(t, "ehn_1", rs.Attributes["id"]) + assert.Equal(t, "", rs.Attributes["product_id"]) assert.Equal(t, "", rs.Attributes["certificate"]) return nil }, @@ -2336,8 +2461,9 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) }) - t.Run("import existing edgehostname with custom ttl", func(t *testing.T) { + t.Run("import existing edgehostname with custom ttl - no product id", func(t *testing.T) { client := &papi.Mock{} clientHapi := &hapi.Mock{} id := "ehn_1,1,2" @@ -2378,14 +2504,12 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() expectGetEdgeHostnameHAPIByIDWithCustomTTL(clientHapi, 1).Times(3) - expectGetEdgeHostnameHAPIWithTTL(clientHapi, 1).Times(10) - expectGetCertificate(clientHapi).Times(5) + expectGetCertificate(clientHapi).Once() useClient(client, clientHapi, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - // please note that import does not support product id, that why we only define it in config for creation Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/creation_before_import_edgehostname_with_ttl.tf"), }, { @@ -2410,6 +2534,203 @@ func TestResourceEdgeHostnames_WithImport(t *testing.T) { }) }) client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing akamaized edgehostname without certificate - product_id supplied", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnamesAkamaized(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnamesAkamaized(client).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostnameAkamaized(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing akamaized edgehostname - product_id without prefix supplied ", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnamesAkamaized(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnamesAkamaized(client).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostnameAkamaized(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByIDAkamaized(clientHapi, 1).Once() + expectGetEdgeHostnamesAkamaizedAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing edgehostname with certificate", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnames(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnames(client).Once() + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() + expectGetCertificate(clientHapi).Once() + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import existing edgehostname with missing certificate", func(t *testing.T) { + client := &papi.Mock{} + clientHapi := &hapi.Mock{} + + // create + expectGetEdgeHostnames(client, "ctr_1", "grp_2").Once() // check if exists: not found + createEdgeHostnames(client).Once() + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Twice() + + // import + expectGetEdgeHostname(client, "ehn_1", "ctr_1", "grp_2").Once() + expectGetEdgeHostnameHAPIByID(clientHapi, 1).Once() + + resp := hapi.Error{ + Type: "CERTIFICATE_NOT_FOUND", + Title: "Certificate Not Found", + Status: 404, + Detail: "Details are not available for this certificate; the certificate is missing or access is denied", + Instance: "/hapi/error-instances/a30f67cc-df20-4e02-bbc3-cf7c204a4aab", + RequestInstance: "http://origin.pulsar.akamai.com/hapi/open/v1/dns-zones/edgekey.net/edge-hostnames/example.com/certificate?depth=ALL&accountSwitchKey=F-AC-1937217#d7aa7348", + Method: "GET", + RequestTime: "2022-11-30T18:51:43.482982Z", + } + err := fmt.Errorf("%s: %s: %w", hapi.ErrGetCertificate, hapi.ErrNotFound, &resp) + clientHapi.On("GetCertificate", mock.Anything, hapi.GetCertificateRequest{ + RecordName: "test", + DNSZone: "edgekey.net", + }).Return(nil, err) + + expectGetEdgeHostnamesAfterCreate(client, "ctr_1", "grp_2").Once() + + useClient(client, clientHapi, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf"), + }, + { + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2", + ResourceName: "akamai_edge_hostname.importedgehostname", + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"certificate"}, + // TODO Remove "certificate" here after implementing wait for EdgeHostname propagation to HAPI in DXE-3821, + }, + }, + }) + }) + client.AssertExpectations(t) + clientHapi.AssertExpectations(t) + }) + t.Run("import error - too few parts of id", func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + ImportState: true, + ImportStateId: "ehn_1,1", + ResourceName: "akamai_edge_hostname.importedgehostname", + ExpectError: regexp.MustCompile("expected import identifier with format: " + + `"EdgehostNameID,contractID,groupID\[,productID]". Got: "ehn_1,1"`), + }, + }, + }) + }) + t.Run("import error - too many parts of id", func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + ImportState: true, + ImportStateId: "ehn_1,1,2,prd_2,foo", + ResourceName: "akamai_edge_hostname.importedgehostname", + ExpectError: regexp.MustCompile("expected import identifier with format: " + + `"EdgehostNameID,contractID,groupID\[,productID]". Got: "ehn_1,1,2,prd_2,foo"`), + }, + }, + }) + }) + t.Run("import error - empty product id", func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf"), + ImportState: true, + ImportStateId: "ehn_1,1,2,", + ResourceName: "akamai_edge_hostname.importedgehostname", + ExpectError: regexp.MustCompile(`productID is empty for the import ID="ehn_1,1,2,"`), + }, + }, + }) }) } diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf new file mode 100644 index 000000000..b19f304ff --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_akamaized_product_id.tf @@ -0,0 +1,11 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "importedgehostname" { + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_2" + edge_hostname = "test.akamaized.net" + ip_behavior = "IPV4" +} diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf new file mode 100644 index 000000000..df4c9ff2e --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/import_edgehostname_product_id.tf @@ -0,0 +1,12 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "importedgehostname" { + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_2" + edge_hostname = "test.edgekey.net" + ip_behavior = "IPV4" + certificate = 123456 +} diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf new file mode 100644 index 000000000..c4862b4b4 --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_akamaized_net_different_product_id.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "edgehostname" { + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_9" + edge_hostname = "test.akamaized.net" + ip_behavior = "IPV6_COMPLIANCE" +} + +output "edge_hostname" { + value = akamai_edge_hostname.edgehostname.edge_hostname +} \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf new file mode 100644 index 000000000..605bf2995 --- /dev/null +++ b/pkg/providers/property/testdata/TestResourceEdgeHostname/new_edgekey_net_different_certificate.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_edge_hostname" "edgehostname" { + contract_id = "ctr_2" + group_id = "grp_2" + product_id = "prd_2" + edge_hostname = "test.edgekey.net" + certificate = 800800 + ip_behavior = "IPV6_PERFORMANCE" +} + +output "edge_hostname" { + value = akamai_edge_hostname.edgehostname.edge_hostname +} \ No newline at end of file From 92ca60146c4b1abc7b37f869b38c5fcbb8740989 Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Wed, 18 Sep 2024 11:09:37 +0000 Subject: [PATCH 05/54] DXE-4112 Refactor akamai_property unit tests --- pkg/common/test/statecheckers.go | 136 + pkg/common/test/statecheckers_test.go | 455 ++ pkg/common/testprovider/provider.go | 40 + pkg/common/testprovider/test_resource.go | 145 + ...urce_akamai_cps_upload_certificate_test.go | 28 +- ...esource_akamai_property_activation_test.go | 27 +- ...resource_akamai_property_bootstrap_test.go | 552 +-- .../resource_akamai_property_helpers_test.go | 681 ++- .../property/resource_akamai_property_test.go | 3799 +++++++++-------- .../ConfigError/contract_id_not_given.tf | 4 +- .../ConfigError/group_id_not_given.tf | 4 +- .../ConfigError/invalid_json_rules.tf | 6 +- .../ConfigError/invalid_name_given.tf | 6 +- .../ConfigError/name_given_too_long.tf | 6 +- .../ConfigError/name_not_given.tf | 6 +- .../ConfigError/product_id_not_given.tf | 4 +- .../TestResProperty/Creation/property.tf | 8 +- .../create/property.tf | 12 +- .../update/property.tf | 12 +- .../creation/property_create.tf | 6 +- .../update/property_update.tf | 6 +- .../contract without prefix/step1.tf | 16 - .../contract_id without prefix/step0.tf | 6 +- .../contract_id without prefix/step1.tf | 6 +- .../forceNewOnNameChange/step0.tf} | 6 +- .../forceNewOnNameChange/step1.tf} | 6 +- .../Lifecycle/group without prefix/step1.tf | 16 - .../step0.tf | 7 +- .../Lifecycle/groupIDUpdate/step1.tf | 16 + .../withHostnames}/step0.tf | 7 +- .../groupIDUpdate/withHostnames/step1.tf | 16 + .../withName}/step0.tf | 9 +- .../Lifecycle/groupIDUpdate/withName/step1.tf | 16 + .../group_id without prefix/step0.tf | 6 +- .../group_id without prefix/step1.tf | 6 +- .../Lifecycle/hostnames/step0.tf | 6 +- .../Lifecycle/hostnames/step1.tf | 6 +- .../new version changed on server/step0.tf | 6 +- .../Lifecycle/no diff/step0.tf | 6 +- .../Lifecycle/no diff/step1.tf | 6 +- .../TestResProperty/Lifecycle/normal/step0.tf | 6 +- .../TestResProperty/Lifecycle/normal/step1.tf | 6 +- .../Lifecycle/product without prefix/step1.tf | 16 - .../product_id without prefix/step0.tf | 6 +- .../product_id without prefix/step1.tf | 6 +- .../Lifecycle/rules custom diff/step0.tf | 6 +- .../Lifecycle/rules custom diff/step1.tf | 6 +- .../Lifecycle/rules diff cpcode/step0.tf | 6 +- .../Lifecycle/rules with variables/step0.tf | 6 +- .../Lifecycle/rules with variables/step1.tf | 6 +- .../Lifecycle/with-propertyID/step0.tf | 8 +- .../Lifecycle/with-propertyID/step1.tf | 8 +- ..._creating_property_with_non-unique_name.tf | 6 +- .../step0.tf | 6 +- ..._update_with_validation_error_for_rules.tf | 6 +- ...perty_with_validation_warning_for_rules.tf | 6 +- 56 files changed, 3419 insertions(+), 2803 deletions(-) create mode 100644 pkg/common/test/statecheckers.go create mode 100644 pkg/common/test/statecheckers_test.go create mode 100644 pkg/common/testprovider/provider.go create mode 100644 pkg/common/testprovider/test_resource.go delete mode 100644 pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf rename pkg/providers/property/testdata/TestResProperty/{property_is_destroyed_and_recreated_when_name_is_changed-step0.tf => Lifecycle/forceNewOnNameChange/step0.tf} (79%) rename pkg/providers/property/testdata/TestResProperty/{property_is_destroyed_and_recreated_when_name_is_changed-step1.tf => Lifecycle/forceNewOnNameChange/step1.tf} (80%) delete mode 100644 pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf rename pkg/providers/property/testdata/TestResProperty/Lifecycle/{product without prefix => groupIDUpdate}/step0.tf (80%) create mode 100644 pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf rename pkg/providers/property/testdata/TestResProperty/Lifecycle/{group without prefix => groupIDUpdate/withHostnames}/step0.tf (80%) create mode 100644 pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf rename pkg/providers/property/testdata/TestResProperty/Lifecycle/{contract without prefix => groupIDUpdate/withName}/step0.tf (71%) create mode 100644 pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf delete mode 100644 pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf diff --git a/pkg/common/test/statecheckers.go b/pkg/common/test/statecheckers.go new file mode 100644 index 000000000..8958f5bec --- /dev/null +++ b/pkg/common/test/statecheckers.go @@ -0,0 +1,136 @@ +// Package test contains reusable structure and functions used during testing of sub-providers +package test + +import ( + "fmt" + "maps" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" +) + +// checkData contains information about expected value of an attribute and whether such attribute should be present. +type checkData struct { + isMissing bool + value string +} + +// StateChecker allows to check the attributes in the terraform state. +type StateChecker struct { + resourceName string + attributes map[string]checkData +} + +// NewStateChecker creates a new instance of a StateChecker that checks attributes for a resource with provided name. +func NewStateChecker(resourceName string) StateChecker { + return StateChecker{ + attributes: map[string]checkData{}, + resourceName: resourceName, + } +} + +// Build processes all attributes and creates checks for them based on assigned values. +func (c StateChecker) Build() resource.TestCheckFunc { + + if len(c.attributes) == 0 { + panic("there must be at least one check in order to build the checker") + } + + var checks []resource.TestCheckFunc + for key, data := range c.attributes { + if data.isMissing { + checks = append(checks, resource.TestCheckNoResourceAttr(c.resourceName, key)) + } else { + checks = append(checks, resource.TestCheckResourceAttr(c.resourceName, key, data.value)) + } + } + + return resource.ComposeAggregateTestCheckFunc(checks...) +} + +// CheckEqual adds a check for provided attribute name and corresponding value. +func (c StateChecker) CheckEqual(attr, val string) StateChecker { + copied := NewStateChecker(c.resourceName) + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + value: val, + } + return copied +} + +// CheckMissing adds a check for a provided attribute name to not be present in the state. +func (c StateChecker) CheckMissing(attr string) StateChecker { + copied := NewStateChecker(c.resourceName) + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + isMissing: true, + } + return copied +} + +// ImportChecker allows to check the attributes in the state after terraform import. +type ImportChecker struct { + attributes map[string]checkData +} + +// NewImportChecker creates a new instance of a ImportChecker that checks attributes for provided resource name after the resource is imported. +func NewImportChecker() ImportChecker { + return ImportChecker{ + attributes: map[string]checkData{}, + } +} + +// Build processes all attributes and creates checks for them based on assigned values. +func (c ImportChecker) Build() resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + if len(c.attributes) == 0 { + panic("there must be at least one check in order to build the checker") + } + + state := s[0] + + for key, data := range c.attributes { + if err := assertAttributeFor(state, key, data); err != nil { + return err + } + } + return nil + } +} + +// CheckEqual adds a check for provided attribute name and corresponding value. +func (c ImportChecker) CheckEqual(attr, val string) ImportChecker { + copied := NewImportChecker() + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + value: val, + } + return copied +} + +// CheckMissing adds a check for a provided attribute name to not be present in the state. +func (c ImportChecker) CheckMissing(attr string) ImportChecker { + copied := NewImportChecker() + maps.Copy(copied.attributes, c.attributes) + copied.attributes[attr] = checkData{ + isMissing: true, + } + return copied +} + +// assertAttributeFor checks whether given attribute is present in the state and has a correct value. +func assertAttributeFor(state *terraform.InstanceState, key string, data checkData) error { + valueInState, exists := state.Attributes[key] + + if data.isMissing && exists { + return fmt.Errorf("attribute %q was present and has a value: %q, but shouldn't be", key, data.value) + } + if !data.isMissing && !exists { + return fmt.Errorf(fmt.Sprintf("attribute %q was not present, but should have a value: %q", key, data.value)) + } + if !data.isMissing && (data.value != valueInState) { + return fmt.Errorf("attribute %q has incorrect value %q, but should have %q", key, valueInState, data.value) + } + + return nil +} diff --git a/pkg/common/test/statecheckers_test.go b/pkg/common/test/statecheckers_test.go new file mode 100644 index 000000000..57ac8c244 --- /dev/null +++ b/pkg/common/test/statecheckers_test.go @@ -0,0 +1,455 @@ +package test + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testprovider" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/assert" +) + +var providerBlock = `provider "akamai" { + edgerc = "../testutils/edgerc" +} +` + +func TestStateChecker(t *testing.T) { + checker := NewStateChecker("akamai_test.sample-resource") + + tests := map[string]struct { + checks resource.TestCheckFunc + config string + error *regexp.Regexp + }{ + "happy path - correct attribute value, two checks passing": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("input", "my output value"). + CheckEqual("output", "my output value"). + Build(), + }, + "happy path - overwrite attribute check with last CheckEqual": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("output", "wrong value"). + CheckEqual("output", "my output value"). + Build(), + }, + "happy path - CheckMissing overwrites CheckEqual for the same attribute": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("not_existing_attribute", "wrong value"). + CheckMissing("not_existing_attribute"). + Build(), + }, + "happy path - CheckEqual overwrites CheckMissing for the same attribute": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("output"). + CheckEqual("output", "my output value"). + Build(), + }, + "happy path - two attributes are missing": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("no_such_attribute"). + CheckMissing("no_such_attribute_2"). + Build(), + }, + "happy path - attribute value is an empty string": { + config: ` + resource "akamai_test" "sample-resource" { + input = "" + }`, + checks: checker.CheckEqual("output", "").Build(), + }, + "happy path - attribute value is a number": { + config: ` + resource "akamai_test" "sample-resource" { + input = "1" + }`, + checks: checker.CheckEqual("output", "1").Build(), + }, + "expect error - check for missing attributes but one is present": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("no_such_attribute"). + CheckMissing("output"). + Build(), + error: regexp.MustCompile("Attribute 'output' found when not expected"), + }, + "expect error - one check fails": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("input", "my output value"). + CheckEqual("output", "my output value - updated"). + Build(), + error: regexp.MustCompile("Attribute 'output' expected \"my output value - updated\", got \"my output value\""), + }, + "expect error - ": { + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("no_such_attribute", "no_such_value"). + Build(), + error: regexp.MustCompile("Attribute 'no_such_attribute' not found"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(testprovider.NewMockSubprovider()), + Steps: []resource.TestStep{ + { + Config: providerBlock + tc.config, + Check: tc.checks, + ExpectError: tc.error, + }, + }, + }) + }) + } +} + +func TestImportChecker(t *testing.T) { + checker := NewImportChecker() + + tests := map[string]struct { + importID string + config string + checks func(s []*terraform.InstanceState) error + error *regexp.Regexp + }{ + "happy path - correct attribute value": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker.CheckEqual("output", "abcdefghijklmnop").Build(), + }, + "happy path - attribute is missing": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker.CheckMissing("no_such_attribute").Build(), + }, + "happy path - attribute value is an empty string": { + importID: "1,", + config: ` + resource "akamai_test" "sample-resource" { + input = "" + }`, + checks: checker.CheckEqual("output", "").Build(), + }, + "happy path - attribute value is a number": { + importID: "1,1", + config: ` + resource "akamai_test" "sample-resource" { + input = "1" + }`, + checks: checker.CheckEqual("output", "1").Build(), + }, + "happy path - overwrite check with correct value": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckEqual("output", "wrong value"). + CheckEqual("output", "abcdefghijklmnop"). + Build(), + }, + "happy path - overwrite check missing with correct value check": { + importID: "1,abcdefghijklmnop", + config: ` + resource "akamai_test" "sample-resource" { + input = "my output value" + }`, + checks: checker. + CheckMissing("output"). + CheckEqual("output", "abcdefghijklmnop"). + Build(), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(testprovider.NewMockSubprovider()), + Steps: []resource.TestStep{ + { + Config: providerBlock + tc.config, + ImportStateCheck: tc.checks, + ImportStateId: tc.importID, + ImportState: true, + ResourceName: "akamai_test.sample-resource", + ExpectError: tc.error, + }, + }, + }) + }) + } +} + +func TestStateCheckerMethods(t *testing.T) { + tests := map[string]struct { + checker StateChecker + expectedAttributes map[string]checkData + error bool + }{ + "basic": { + checker: NewStateChecker("test"). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckMissing("missing"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "missing": { + isMissing: true, + value: "", + }, + }, + }, + "only missing": { + checker: NewStateChecker("test"). + CheckMissing("missing"). + CheckMissing("missing2"). + CheckMissing("missing3"), + expectedAttributes: map[string]checkData{ + "missing": { + isMissing: true, + value: "", + }, + "missing2": { + isMissing: true, + value: "", + }, + "missing3": { + isMissing: true, + value: "", + }, + }, + }, + "only existing attributes": { + checker: NewStateChecker("test"). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckEqual("attr3", "val3"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "attr3": { + isMissing: false, + value: "val3", + }, + }, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + assert.Equal(t, test.expectedAttributes, test.checker.attributes) + }) + } +} + +func TestImportCheckerMethods(t *testing.T) { + importTests := map[string]struct { + checker ImportChecker + expectedAttributes map[string]checkData + }{ + "basic": { + checker: NewImportChecker(). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckMissing("missing"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "missing": { + isMissing: true, + value: "", + }, + }, + }, + "only missing": { + checker: NewImportChecker(). + CheckMissing("missing"). + CheckMissing("missing2"). + CheckMissing("missing3"), + expectedAttributes: map[string]checkData{ + "missing": { + isMissing: true, + value: "", + }, + "missing2": { + isMissing: true, + value: "", + }, + "missing3": { + isMissing: true, + value: "", + }, + }, + }, + "only existing attributes": { + checker: NewImportChecker(). + CheckEqual("attr", "val"). + CheckEqual("attr2", "val2"). + CheckEqual("attr3", "val3"), + expectedAttributes: map[string]checkData{ + "attr": { + isMissing: false, + value: "val", + }, + "attr2": { + isMissing: false, + value: "val2", + }, + "attr3": { + isMissing: false, + value: "val3", + }, + }, + }, + } + + for name, test := range importTests { + t.Run(name, func(t *testing.T) { + assert.Equal(t, test.expectedAttributes, test.checker.attributes) + }) + } +} + +func TestStateCheckersPanic(t *testing.T) { + stateCheck := func() { + _ = NewStateChecker("test").Build() + } + assert.PanicsWithValue(t, "there must be at least one check in order to build the checker", stateCheck) + + importCheck := func() { + checkFunc := NewImportChecker().Build() + + givenState := &terraform.InstanceState{ + Attributes: map[string]string{}, + } + _ = checkFunc([]*terraform.InstanceState{givenState}) + } + assert.PanicsWithValue(t, "there must be at least one check in order to build the checker", importCheck) +} + +func TestAssertAttributeFor(t *testing.T) { + givenState := &terraform.InstanceState{ + Attributes: map[string]string{ + "attr": "val", + }, + } + + tests := map[string]struct { + key string + checkData checkData + expectError error + }{ + "'attr' exists and has correct value - no error": { + key: "attr", + checkData: checkData{ + isMissing: false, + value: "val", + }, + expectError: nil, + }, + "'not-existing-attr' does not exists - no error": { + key: "not-existing-attr", + checkData: checkData{ + isMissing: true, + }, + expectError: nil, + }, + "'not-existing-attr' does not exists, but expecting to exist - expect error": { + key: "not-existing-attr", + checkData: checkData{ + isMissing: false, + value: "val", + }, + expectError: fmt.Errorf(`attribute "not-existing-attr" was not present, but should have a value: "val"`), + }, + "'attr' does exists, but has a different value - expect error": { + key: "attr", + checkData: checkData{ + isMissing: false, + value: "actual value", + }, + expectError: fmt.Errorf(`attribute "attr" has incorrect value "val", but should have "actual value"`), + }, + "'attr' does exists, but should not - expect error": { + key: "attr", + checkData: checkData{ + isMissing: true, + value: "val", + }, + expectError: fmt.Errorf(`attribute "attr" was present and has a value: "val", but shouldn't be`), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + err := assertAttributeFor(givenState, test.key, test.checkData) + if test.expectError != nil { + assert.EqualError(t, err, test.expectError.Error()) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/pkg/common/testprovider/provider.go b/pkg/common/testprovider/provider.go new file mode 100644 index 000000000..1facc7bce --- /dev/null +++ b/pkg/common/testprovider/provider.go @@ -0,0 +1,40 @@ +// Package testprovider is a package containing a terraform provider for internal testing purposes +package testprovider + +import ( + "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +// NewMockSubprovider return the test subprovider used for internal testing +func NewMockSubprovider() subprovider.Subprovider { + return &mockSubprovider{} +} + +type ( + mockSubprovider struct{} +) + +// SDKResources returns the test resources implemented using terraform-plugin-sdk +func (p *mockSubprovider) SDKResources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} + +// SDKDataSources returns the test data sources implemented using terraform-plugin-sdk +func (p *mockSubprovider) SDKDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} + +// FrameworkResources returns the test resources implemented using terraform-plugin-framework +func (p *mockSubprovider) FrameworkResources() []func() resource.Resource { + return []func() resource.Resource{ + NewTestResource, + } +} + +// FrameworkDataSources returns the test data sources implemented using terraform-plugin-framework +func (p *mockSubprovider) FrameworkDataSources() []func() datasource.DataSource { + return []func() datasource.DataSource{} +} diff --git a/pkg/common/testprovider/test_resource.go b/pkg/common/testprovider/test_resource.go new file mode 100644 index 000000000..b79089475 --- /dev/null +++ b/pkg/common/testprovider/test_resource.go @@ -0,0 +1,145 @@ +package testprovider + +import ( + "context" + "strconv" + "strings" + + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &TestResource{} + _ resource.ResourceWithImportState = &TestResource{} +) + +// TestResource represents akamai_test to be used in internal testing +type TestResource struct{} + +// NewTestResource returns new akamai test resource to be used in internal testing +func NewTestResource() resource.Resource { + return &TestResource{} +} + +// testResourceModel is a model for akamai_test_resource resource +type testResourceModel struct { + ID types.Int64 `tfsdk:"id"` + Input types.String `tfsdk:"input"` + Output types.String `tfsdk:"output"` +} + +// Metadata implements resource.Resource. +func (r *TestResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_test" +} + +// Schema implements resource.Resource. +func (r *TestResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "input": schema.StringAttribute{ + Required: true, + Description: "Required attribute, its value is copied to 'output' attribute.", + }, + "output": schema.StringAttribute{ + Computed: true, + Description: "Read-only attribute, its value comes from 'input' attribute.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "id": schema.Int64Attribute{ + Computed: true, + Description: "Resource's unique and randomly generated identifier.", + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.UseStateForUnknown(), + }, + }, + }, + } +} + +// Create implements resource.Resource. +func (r *TestResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating Akamai Test Resource") + + var data *testResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + data.Output = data.Input + data.ID = types.Int64Value(int64(uuid.New().ID())) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// Read implements resource.Resource. +func (r *TestResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading Akamai Test Resource") + + var data *testResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// Update implements resource.Resource. +func (r *TestResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating Akamai Test Resource") + + var data *testResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + data.Output = data.Input + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// Delete implements resource.Resource. +func (r *TestResource) Delete(ctx context.Context, _ resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Deleting Akamai Test Resource") + resp.State.RemoveResource(ctx) +} + +// ImportState implements resource.ResourceWithImportState. +func (r *TestResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing Configuration Resource") + + var data = &testResourceModel{} + + id := strings.Split(req.ID, ",") + if len(id) != 2 { + resp.Diagnostics.AddError("incorrect import ID", "import ID should have format: ,") + return + } + + idInt, err := strconv.ParseInt(id[0], 10, 64) + if err != nil { + resp.Diagnostics.AddError("parsing error", err.Error()) + return + } + data.ID = types.Int64Value(idInt) + data.Input = types.StringValue(id[1]) + data.Output = types.StringValue(id[1]) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go index 1532c00d7..257d1559d 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go @@ -8,10 +8,10 @@ import ( "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -1135,6 +1135,14 @@ func TestUpdateCPSUploadCertificate(t *testing.T) { func TestResourceUploadCertificateImport(t *testing.T) { id := 1 + checker := test.NewImportChecker(). + CheckEqual("certificate_ecdsa_pem", certECDSAForTests). + CheckEqual("trust_chain_ecdsa_pem", trustChainECDSAForTests). + CheckEqual("acknowledge_post_verification_warnings", "false"). + CheckEqual("wait_for_deployment", "false"). + CheckEqual("acknowledge_change_management", "false"). + CheckEqual("auto_approve_warnings.#", "0") + tests := map[string]struct { init func(*cps.Mock) expectedError *regexp.Regexp @@ -1145,20 +1153,10 @@ func TestResourceUploadCertificateImport(t *testing.T) { enrollment := cps.GetEnrollmentResponse{ ValidationType: "third-party", } - mockGetEnrollment(client, id, 2, &enrollment) mockGetChangeHistory(client, id, 2, &enrollment, ECDSA, certECDSAForTests, trustChainECDSAForTests) }, - stateCheck: func(s []*terraform.InstanceState) error { - state := s[0] - assertAttributeFor(state, t, "certificate_ecdsa_pem", certECDSAForTests) - assertAttributeFor(state, t, "trust_chain_ecdsa_pem", trustChainECDSAForTests) - assertAttributeFor(state, t, "acknowledge_post_verification_warnings", "false") - assertAttributeFor(state, t, "wait_for_deployment", "false") - assertAttributeFor(state, t, "acknowledge_change_management", "false") - assertAttributeFor(state, t, "auto_approve_warnings.#", "0") - return nil - }, + stateCheck: checker.Build(), }, "import error when validation type is not third_party": { init: func(client *cps.Mock) { @@ -1207,12 +1205,6 @@ func TestResourceUploadCertificateImport(t *testing.T) { } } -func assertAttributeFor(state *terraform.InstanceState, t *testing.T, key, value string) { - valueInState, exist := state.Attributes[key] - assert.True(t, exist, fmt.Sprintf("attribute '%s' was not present", key)) - assert.Equal(t, value, valueInState, fmt.Sprintf("attribute '%s' has incorrect value %s", key, valueInState)) -} - // copyEnrollmentWithEmptyPendingChanges returns enrollment after enrollment reaches "complete" state - it's pending changes disappear func copyEnrollmentWithEmptyPendingChanges(enrollment cps.GetEnrollmentResponse) *cps.GetEnrollmentResponse { enrollment.PendingChanges = []cps.PendingChange{} diff --git a/pkg/providers/property/resource_akamai_property_activation_test.go b/pkg/providers/property/resource_akamai_property_activation_test.go index 1180f3298..75675a023 100644 --- a/pkg/providers/property/resource_akamai_property_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_test.go @@ -34,7 +34,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // update expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}), nil).Once() - ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() + expectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 2, "STAGING", []string{"user@example.com"}, "property activation note for updating", "atv_update", true, nil).Once() expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for updating", []string{"user@example.com"}, nil).Once() @@ -587,7 +587,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // update - note field not suppressed update of contact field and version expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "property activation note for creating", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}), nil).Once() - ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() + expectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 2, "STAGING", []string{"user@example.com", "user2@example.com"}, "property activation note for updating", "atv_update", true, nil).Once() expectGetActivation(m, "prp_test", "atv_update", 2, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "property activation note for updating", []string{"user@example.com", "user2@example.com"}, nil).Once() @@ -653,7 +653,7 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { // update expectGetRuleTree(m, "prp_test", 2, ruleTreeResponseValid, nil).Once() expectGetActivations(m, "prp_test", generateActivationResponseMock("atv_activation1", "", 1, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}), nil).Once() - ExpectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() + expectGetPropertyVersion(m, "prp_test", "", "", 2, papi.VersionStatusInactive, "").Once() // error on update m.On("CreateActivation", AnyCTX, papi.CreateActivationRequest{ PropertyID: "prp_test", @@ -947,4 +947,25 @@ var ( }, }, nil) } + + // Sets up an expected call to papi.GetPropertyVersion() + expectGetPropertyVersion = func(client *papi.Mock, PropertyID, GroupID, ContractID string, Version int, StagStatus, ProdStatus papi.VersionStatus) *mock.Call { + req := papi.GetPropertyVersionRequest{ + PropertyID: PropertyID, + GroupID: GroupID, + ContractID: ContractID, + PropertyVersion: Version, + } + + res := papi.GetPropertyVersionsResponse{ + PropertyID: PropertyID, + GroupID: GroupID, + ContractID: ContractID, + Version: papi.PropertyVersionGetItem{ + StagingStatus: StagStatus, + ProductionStatus: ProdStatus, + }, + } + return client.On("GetPropertyVersion", AnyCTX, req).Return(&res, nil) + } ) diff --git a/pkg/providers/property/resource_akamai_property_bootstrap_test.go b/pkg/providers/property/resource_akamai_property_bootstrap_test.go index 6c069770d..5b2db8db0 100644 --- a/pkg/providers/property/resource_akamai_property_bootstrap_test.go +++ b/pkg/providers/property/resource_akamai_property_bootstrap_test.go @@ -3,106 +3,99 @@ package property import ( "fmt" "regexp" - "strings" "testing" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) -type testDataForPropertyBootstrap struct { - propertyID string - name string - groupID string - contractID string - productID string - withoutPrefixes bool +var basicDataBootstrap = mockPropertyData{ + propertyID: "prp_123", + propertyName: "property_name", + groupID: "grp_1", + contractID: "ctr_2", + productID: "prd_3", + assetID: "aid_55555", + moveGroup: moveGroup{ + sourceGroupID: 1, + destinationGroupID: 111, + }, } func TestBootstrapResourceCreate(t *testing.T) { t.Parallel() + + baseChecker := test.NewStateChecker("akamai_property_bootstrap.test"). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_1"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("name", "property_name") + tests := map[string]struct { - configPath string - init func(*testing.T, *papi.Mock, testDataForPropertyBootstrap) - mockData testDataForPropertyBootstrap - error *regexp.Regexp + init func(*testing.T, *mockProperty) + steps []resource.TestStep + error *regexp.Regexp }{ "create": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), + Check: baseChecker.Build(), + }, }, }, "create without prefixes": { - configPath: "testdata/TestResPropertyBootstrap/create_without_prefixes.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - withoutPrefixes: true, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create_without_prefixes.tf"), + Check: baseChecker. + CheckEqual("group_id", "1"). + CheckEqual("contract_id", "2"). + CheckEqual("product_id", "3"). + Build(), + }, }, }, "create with interpretCreate error - group not found": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { + init: func(t *testing.T, p *mockProperty) { req := papi.CreatePropertyRequest{ - GroupID: data.groupID, - ContractID: data.contractID, + GroupID: p.groupID, + ContractID: p.contractID, Property: papi.PropertyCreate{ - ProductID: data.productID, - PropertyName: data.name, + ProductID: p.productID, + PropertyName: p.propertyName, }, } - m.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf( + p.papiMock.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf( "%s: %w: %s", papi.ErrCreateProperty, papi.ErrNotFound, "not found")).Once() // mock empty groups - no group has been found, hence the expected error - m.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ + p.papiMock.On("GetGroups", AnyCTX).Return(&papi.GetGroupsResponse{ Groups: papi.GroupItems{ Items: []*papi.Group{}, }, }, nil).Once() }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), + ExpectError: regexp.MustCompile(`Error: group not found: grp_1`), + }, }, - error: regexp.MustCompile(`Error: group not found: grp_1`), }, } @@ -110,23 +103,20 @@ func TestBootstrapResourceCreate(t *testing.T) { name, test := name, test t.Run(name, func(t *testing.T) { t.Parallel() - m := &papi.Mock{} + mp := &mockProperty{ + mockPropertyData: basicDataBootstrap, + papiMock: m, + } if test.init != nil { - test.init(t, m, test.mockData) + test.init(t, mp) } useClient(m, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, test.configPath), - Check: checkPropertyBootstrapAttributes(test.mockData), - ExpectError: test.error, - }, - }, + Steps: test.steps, }) }) @@ -137,11 +127,18 @@ func TestBootstrapResourceCreate(t *testing.T) { func TestBootstrapResourceUpdate(t *testing.T) { t.Parallel() + + baseChecker := test.NewStateChecker("akamai_property_bootstrap.test"). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_1"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("name", "property_name") + tests := map[string]struct { configPathForCreate string configPathForUpdate string - init func(*testing.T, *papi.Mock, *iam.Mock, testDataForPropertyBootstrap) - mockData testDataForPropertyBootstrap + init func(*testing.T, *mockProperty) errorForCreate *regexp.Regexp errorForUpdate *regexp.Regexp updateChecks resource.TestCheckFunc @@ -149,198 +146,89 @@ func TestBootstrapResourceUpdate(t *testing.T) { "create and remove prefixes - no diff": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/create_without_prefixes.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + // read x2 + p.mockGetProperty().Twice() + // read x1 before update + p.mockGetProperty() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - }), + updateChecks: baseChecker.Build(), }, "create and update group id": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_group.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { + init: func(t *testing.T, p *mockProperty) { t.Skip("skipping before moving property is enabled again, see DXE-4176") - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, - data.propertyID).Once() - prp := &papi.Property{ - AssetID: "aid_55555", - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Times(3) - - mockMoveProperty(iamMock, 55555, 1, 111) - - ExpectGetProperty(papiMock, data.propertyID, "grp_111", data.contractID, prp).Twice() - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, "grp_111") - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + p.mockCreateProperty() + // read x2 + p.mockGetProperty().Twice() + // update + p.mockGetProperty() + p.mockMoveProperty() + p.groupID = "grp_111" + // read x2 + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_111", - contractID: "ctr_2", - productID: "prd_3", - }), + updateChecks: baseChecker. + CheckEqual("group_id", "grp_111"). + Build(), }, "create and update name - resource replacement": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", - configPathForUpdate: "testdata/TestResPropertyBootstrap/update_name.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, - data.propertyID).Once() - prp := &papi.Property{ - AssetID: "aid_55555", - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Times(2) - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID).Once() - - ExpectCreateProperty(papiMock, "property_name2", data.groupID, data.contractID, data.productID, - data.propertyID).Once() - - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Once() - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID).Once() - - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + // read x2 + p.mockGetProperty().Twice() + p.mockRemoveProperty() + p.propertyName = "property_name2" + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name2", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - }), + configPathForUpdate: "testdata/TestResPropertyBootstrap/update_name.tf", + updateChecks: baseChecker. + CheckEqual("name", "property_name2"). + Build(), }, "create and update name and group id - resource replacement": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_name_and_group.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { + init: func(t *testing.T, p *mockProperty) { t.Skip("skipping before moving property is enabled again, see DXE-4176") - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, - data.propertyID).Once() - prp := &papi.Property{ - AssetID: "aid_55555", - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp).Times(2) - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID).Once() - - ExpectCreateProperty(papiMock, "property_name2", "grp_93", data.contractID, data.productID, - data.propertyID).Once() - - ExpectGetProperty(papiMock, data.propertyID, "grp_93", data.contractID, prp).Once() - - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, "grp_93").Once() - - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() + p.propertyName = "property_name2" + p.groupID = "grp_93" + p.mockCreateProperty() + p.mockGetProperty() + p.mockRemoveProperty() }, - updateChecks: checkPropertyBootstrapAttributes(testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name2", - groupID: "grp_93", - contractID: "ctr_2", - productID: "prd_3", - }), + updateChecks: baseChecker. + CheckEqual("name", "property_name2"). + CheckEqual("group_id", "grp_93"). + Build(), }, "create and update contract - error": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_contract.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, errorForUpdate: regexp.MustCompile("updating field `contract_id` is not possible"), }, "create and update product - error": { configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_product.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, errorForUpdate: regexp.MustCompile("updating field `product_id` is not possible"), }, @@ -348,24 +236,10 @@ func TestBootstrapResourceUpdate(t *testing.T) { // TODO: remove this test after moving property is enabled again, see DXE-4176 configPathForCreate: "testdata/TestResPropertyBootstrap/create.tf", configPathForUpdate: "testdata/TestResPropertyBootstrap/update_group.tf", - init: func(t *testing.T, papiMock *papi.Mock, iamMock *iam.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(papiMock, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - } - ExpectGetProperty(papiMock, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(papiMock, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + init: func(t *testing.T, p *mockProperty) { + p.mockCreateProperty() + p.mockGetProperty().Twice() + p.mockRemoveProperty() }, errorForUpdate: regexp.MustCompile("updating field `group_id` is not possible"), }, @@ -376,10 +250,16 @@ func TestBootstrapResourceUpdate(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() - papiMock := &papi.Mock{} iamMock := &iam.Mock{} + papiMock := &papi.Mock{} + mp := &mockProperty{ + mockPropertyData: basicDataBootstrap, + papiMock: papiMock, + iamMock: iamMock, + } + if test.init != nil { - test.init(t, papiMock, iamMock, test.mockData) + test.init(t, mp) } useClient(papiMock, nil, func() { @@ -390,7 +270,7 @@ func TestBootstrapResourceUpdate(t *testing.T) { Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, test.configPathForCreate), - Check: checkPropertyBootstrapAttributes(test.mockData), + Check: baseChecker.Build(), ExpectError: test.errorForCreate, }, { @@ -410,89 +290,59 @@ func TestBootstrapResourceUpdate(t *testing.T) { func TestBootstrapResourceImport(t *testing.T) { t.Parallel() + + basicDataWithoutContractAndGroup := mockPropertyData{ + propertyID: "prp_123", + propertyName: "property_name", + productID: "prd_3", + assetID: "aid_55555", + } + + baseChecker := test.NewImportChecker(). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_1"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("name", "property_name") + tests := map[string]struct { - configPath string - init func(*testing.T, *papi.Mock, testDataForPropertyBootstrap) - mockData testDataForPropertyBootstrap + init func(*testing.T, *mockProperty) + mockData mockPropertyData importStateID string + stateCheck func(s []*terraform.InstanceState) error error *regexp.Regexp }{ "import with all attributes": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - LatestVersion: 1, - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) - // import - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectGetPropertyVersion(m, data.propertyID, data.groupID, data.contractID, 1, papi.VersionStatusActive, papi.VersionStatusActive) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + mockData: basicDataBootstrap, + init: func(t *testing.T, p *mockProperty) { + p.mockGetProperty() + p.mockGetPropertyVersion() + // read + p.mockGetProperty() }, + stateCheck: baseChecker. + CheckEqual("product_id", ""). + Build(), importStateID: "prp_123,2,1", }, "import with only property_id": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - LatestVersion: 1, - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) + mockData: basicDataWithoutContractAndGroup, + init: func(t *testing.T, p *mockProperty) { // import - ExpectGetProperty(m, data.propertyID, "", "", prp) - ExpectGetPropertyVersion(m, data.propertyID, data.groupID, data.contractID, 1, papi.VersionStatusActive, papi.VersionStatusActive) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", + p.mockGetProperty() + p.mockGetPropertyVersion() + // read + p.mockGetProperty() }, + stateCheck: baseChecker. + CheckEqual("group_id", ""). + CheckEqual("contract_id", ""). + CheckEqual("product_id", ""). + Build(), importStateID: "123", }, "import with only property_id and contract_id - error": { - configPath: "testdata/TestResPropertyBootstrap/create.tf", - init: func(t *testing.T, m *papi.Mock, data testDataForPropertyBootstrap) { - ExpectCreateProperty(m, data.name, data.groupID, data.contractID, data.productID, data.propertyID) - prp := &papi.Property{ - ContractID: "ctr_2", - GroupID: "grp_1", - ProductID: "prd_3", - PropertyID: "prp_123", - PropertyName: "property_name", - LatestVersion: 1, - } - ExpectGetProperty(m, data.propertyID, data.groupID, data.contractID, prp) - ExpectRemoveProperty(m, data.propertyID, data.contractID, data.groupID) - }, - mockData: testDataForPropertyBootstrap{ - propertyID: "prp_123", - name: "property_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - }, + init: func(t *testing.T, p *mockProperty) {}, importStateID: "123,2", error: regexp.MustCompile("Error: missing group id or contract id"), }, @@ -504,8 +354,13 @@ func TestBootstrapResourceImport(t *testing.T) { t.Parallel() m := &papi.Mock{} + mp := &mockProperty{ + mockPropertyData: test.mockData, + papiMock: m, + } + if test.init != nil { - test.init(t, m, test.mockData) + test.init(t, mp) } useClient(m, nil, func() { @@ -514,15 +369,12 @@ func TestBootstrapResourceImport(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), - Check: checkPropertyBootstrapAttributes(test.mockData), - }, - { - ImportState: true, - ImportStateId: test.importStateID, - ResourceName: "akamai_property_bootstrap.test", - Check: checkPropertyBootstrapAttributes(test.mockData), - ExpectError: test.error, + ImportState: true, + ImportStateId: test.importStateID, + ImportStateCheck: test.stateCheck, + ResourceName: "akamai_property_bootstrap.test", + Config: testutils.LoadFixtureString(t, "testdata/TestResPropertyBootstrap/create.tf"), + ExpectError: test.error, }, }, }) @@ -532,21 +384,3 @@ func TestBootstrapResourceImport(t *testing.T) { }) } } - -func checkPropertyBootstrapAttributes(data testDataForPropertyBootstrap) resource.TestCheckFunc { - if data.withoutPrefixes { - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "id", data.propertyID), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "group_id", strings.TrimPrefix(data.groupID, "grp_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "contract_id", strings.TrimPrefix(data.contractID, "ctr_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "product_id", strings.TrimPrefix(data.productID, "prd_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "name", data.name)) - } - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "id", str.AddPrefix(data.propertyID, "prp_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "group_id", str.AddPrefix(data.groupID, "grp_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "contract_id", str.AddPrefix(data.contractID, "ctr_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "product_id", str.AddPrefix(data.productID, "prd_")), - resource.TestCheckResourceAttr("akamai_property_bootstrap.test", "name", data.name), - ) -} diff --git a/pkg/providers/property/resource_akamai_property_helpers_test.go b/pkg/providers/property/resource_akamai_property_helpers_test.go index e6f43dffc..5983e2d03 100644 --- a/pkg/providers/property/resource_akamai_property_helpers_test.go +++ b/pkg/providers/property/resource_akamai_property_helpers_test.go @@ -1,484 +1,401 @@ package property import ( - "context" + "strconv" + "strings" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/stretchr/testify/mock" ) -// Sets up an expected call to papi.GetGroups(), which returns the given parameters -func ExpectGetGroups(client *papi.Mock, State *[]*papi.Group) *mock.Call { - fn := func(ctx context.Context) (*papi.GetGroupsResponse, error) { - var groups []*papi.Group +type mockProperty struct { + mockPropertyData + papiMock *papi.Mock + iamMock *iam.Mock +} - for _, ptr := range *State { - grp := *ptr - groups = append(groups, &grp) - } +type mockPropertyData struct { + propertyName string + groupID string + contractID string + productID string + propertyID string + assetID string + latestVersion int + createFromVersion int + newVersionID int + ruleTree mockRuleTreeData + versions papi.PropertyVersionItems + hostnames papi.HostnameResponseItems + responseErrors []*papi.Error + responseWarnings []*papi.Error + activations papi.ActivationsItems + createActivation papi.Activation + groups papi.GroupItems + moveGroup moveGroup +} - return &papi.GetGroupsResponse{Groups: papi.GroupItems{Items: groups}}, nil - } +type moveGroup struct { + sourceGroupID int64 + destinationGroupID int64 +} - return client.OnGetGroups(AnyCTX, fn) +type mockRuleTreeData struct { + rules papi.Rules + comments string + ruleFormat string + ruleErrors []papi.RuleError + ruleWarnings []papi.RuleWarnings } -// Sets up an expected call to papi.GetProperty() which returns a value depending on the given State pointer. When nil, -// the PAPI response contains a zero-value papi.Property. Otherwise the response will dynamically contain a copy of -// the State made at the time of the call to papi.Mock.GetProperty(). -func ExpectGetProperty(client *papi.Mock, PropertyID, GroupID, ContractID string, State *papi.Property) *mock.Call { - req := papi.GetPropertyRequest{ - PropertyID: PropertyID, - ContractID: ContractID, - GroupID: GroupID, +func (p *mockProperty) mockCreateProperty(err ...error) *mock.Call { + req := papi.CreatePropertyRequest{ + GroupID: p.groupID, + ContractID: p.contractID, + Property: papi.PropertyCreate{ + ProductID: p.productID, + PropertyName: p.propertyName, + RuleFormat: p.ruleTree.ruleFormat, + }, } - fn := func(context.Context, papi.GetPropertyRequest) (*papi.GetPropertyResponse, error) { - var property papi.Property - - // Duplicate the State - if State != nil { - property = *State - } + if err != nil { + return p.papiMock.On("CreateProperty", AnyCTX, req).Return(nil, err[0]).Once() + } - // Duplicate the pointers - if property.ProductionVersion != nil { - v := *property.ProductionVersion - property.ProductionVersion = &v - } + resp := papi.CreatePropertyResponse{PropertyID: p.propertyID} - if property.StagingVersion != nil { - v := *property.StagingVersion - property.StagingVersion = &v - } - - // although optional in PAPI documentation, ProductID is not being set by PAPI in the response - property.ProductID = "" + return p.papiMock.On("CreateProperty", AnyCTX, req).Return(&resp, nil).Once() +} - return &papi.GetPropertyResponse{Property: &property}, nil +func (p *mockProperty) mockGetGroups() *mock.Call { + resp := &papi.GetGroupsResponse{ + Groups: p.groups, } - return client.OnGetProperty(AnyCTX, req, fn) + return p.papiMock.On("GetGroups", AnyCTX).Return(resp, nil).Once() } -// Sets up an expected call to papi.GetPropertyVersionHostnames() which returns a value depending on the value of the -// pointer to State. When nil or empty, the response contains a nil Items member. Otherwise the response contains a -// copy of the value pointed to by State made at the time of the call to papi.GetPropertyVersionHostnames(). -func ExpectGetPropertyVersionHostnames(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, State *[]papi.Hostname) *mock.Call { - req := papi.GetPropertyVersionHostnamesRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - PropertyVersion: PropertyVersion, - IncludeCertStatus: true, +func (p *mockProperty) mockUpdateRuleTree(err ...error) *mock.Call { + rulesUpdate := papi.RulesUpdate{ + Rules: p.ruleTree.rules, + Comments: p.ruleTree.comments, } - fn := func(context.Context, papi.GetPropertyVersionHostnamesRequest) (*papi.GetPropertyVersionHostnamesResponse, error) { - var Items []papi.Hostname - if len(*State) > 0 { - // Duplicate the State - Items = append(Items, *State...) - } + req := papi.UpdateRulesRequest{ + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + ContractID: p.contractID, + GroupID: p.groupID, + Rules: rulesUpdate, + ValidateRules: true, + } - res := papi.GetPropertyVersionHostnamesResponse{ - ContractID: ContractID, - GroupID: GroupID, - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - Hostnames: papi.HostnameResponseItems{Items: Items}, - } + if err != nil { + return p.papiMock.On("UpdateRuleTree", AnyCTX, req).Return(nil, err[0]).Once() + } - return &res, nil + resp := papi.UpdateRulesResponse{ + PropertyID: p.propertyID, + ContractID: p.contractID, + GroupID: p.groupID, + PropertyVersion: p.latestVersion, + RuleFormat: p.ruleTree.ruleFormat, + Rules: p.ruleTree.rules, + Errors: p.ruleTree.ruleErrors, + Warnings: p.ruleTree.ruleWarnings, } - return client.OnGetPropertyVersionHostnames(AnyCTX, req, fn) + return p.papiMock.On("UpdateRuleTree", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected call to papi.UpdatePropertyVersionHostnames() which returns a constant value based on input -// params. If given, the value pointed to by State will be updated with a copy of the given Hostnames when the call -// to papi.Mock.UpdatePropertyVersionHostnames() is made. -func ExpectUpdatePropertyVersionHostnames(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, Hostnames []papi.Hostname, err error) *mock.Call { +func (p *mockProperty) mockUpdatePropertyVersionHostnames(err ...error) *mock.Call { + // Copy hostnames from mock data and remove unnecessary fields (EdgeHostnameID and CertStatus) that are not used in the request to satisfy mocks. + // Use original mock data for the response. + requestHostnames := make([]papi.Hostname, len(p.hostnames.Items)) + copy(requestHostnames, p.hostnames.Items) + for i := range requestHostnames { + requestHostnames[i].EdgeHostnameID = "" + requestHostnames[i].CertStatus = papi.CertStatusItem{} + } + req := papi.UpdatePropertyVersionHostnamesRequest{ - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - ContractID: ContractID, - GroupID: GroupID, - Hostnames: Hostnames, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + ContractID: p.contractID, + GroupID: p.groupID, + Hostnames: requestHostnames, } - call := client.On("UpdatePropertyVersionHostnames", AnyCTX, req) if err != nil { - return call.Return(&papi.UpdatePropertyVersionHostnamesResponse{}, err) + return p.papiMock.On("UpdatePropertyVersionHostnames", AnyCTX, req).Return(&papi.UpdatePropertyVersionHostnamesResponse{}, err[0]).Once() } - res := papi.UpdatePropertyVersionHostnamesResponse{ - ContractID: ContractID, - GroupID: GroupID, - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - Hostnames: papi.HostnameResponseItems{Items: Hostnames}, + resp := papi.UpdatePropertyVersionHostnamesResponse{ + ContractID: p.contractID, + GroupID: p.groupID, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + Hostnames: p.hostnames, } - return call.Return(&res, nil) + return p.papiMock.On("UpdatePropertyVersionHostnames", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected call to papi.GetPropertyVersions() -func ExpectGetPropertyVersions(client *papi.Mock, PropertyID, PropertyName, ContractID, GroupID string, property *papi.Property, versionItems *papi.PropertyVersionItems) *mock.Call { - req := papi.GetPropertyVersionsRequest{ - PropertyID: PropertyID, - ContractID: ContractID, - GroupID: GroupID, - } - var res *papi.GetPropertyVersionsResponse - fn := func(context.Context, papi.GetPropertyVersionsRequest) (*papi.GetPropertyVersionsResponse, error) { - if property != nil { - ContractID = property.ContractID - GroupID = property.GroupID - } - res = &papi.GetPropertyVersionsResponse{ - PropertyID: PropertyID, - PropertyName: PropertyName, - ContractID: ContractID, - GroupID: GroupID, - Versions: *versionItems, - } - - return res, nil +func (p *mockProperty) mockGetProperty() *mock.Call { + req := papi.GetPropertyRequest{ + PropertyID: p.propertyID, + ContractID: p.contractID, + GroupID: p.groupID, } - - return client.OnGetPropertyVersions(AnyCTX, req, fn) -} - -// Sets up an expected call to papi.GetPropertyVersion() -func ExpectGetPropertyVersion(client *papi.Mock, PropertyID, GroupID, ContractID string, Version int, StagStatus, ProdStatus papi.VersionStatus) *mock.Call { - req := papi.GetPropertyVersionRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - PropertyVersion: Version, - } - - res := papi.GetPropertyVersionsResponse{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - Version: papi.PropertyVersionGetItem{ - StagingStatus: StagStatus, - ProductionStatus: ProdStatus, + resp := papi.GetPropertyResponse{ + Property: &papi.Property{ + AssetID: p.assetID, + ContractID: p.contractID, + GroupID: p.groupID, + LatestVersion: p.latestVersion, + // although optional in PAPI documentation, ProductID is not being set by PAPI in the response + ProductID: p.productID, + PropertyID: p.propertyID, + PropertyName: p.propertyName, + RuleFormat: p.ruleTree.ruleFormat, }, } - return client.On("GetPropertyVersion", AnyCTX, req).Return(&res, nil) -} -// Sets up an expected call to papi.CreatePropertyVersion() -func ExpectCreatePropertyVersion(client *papi.Mock, PropertyID, GroupID, ContractID string, CreateFromVersion, NewVersion int) *mock.Call { - req := papi.CreatePropertyVersionRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - Version: papi.PropertyVersionCreate{ - CreateFromVersion: CreateFromVersion, - }, + if len(p.versions.Items) > 0 && p.versions.Items[0].StagingStatus == papi.VersionStatusActive { + resp.Property.StagingVersion = &p.versions.Items[0].PropertyVersion } - res := papi.CreatePropertyVersionResponse{PropertyVersion: NewVersion} + if len(p.versions.Items) > 0 && p.versions.Items[0].ProductionStatus == papi.VersionStatusActive { + resp.Property.ProductionVersion = &p.versions.Items[0].PropertyVersion + } - return client.On("CreatePropertyVersion", AnyCTX, req).Return(&res, nil) + return p.papiMock.On("GetProperty", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected successful call to papi.CreateProperty() with a constant success response with the given PropertyID -func ExpectCreateProperty(client *papi.Mock, PropertyName, GroupID, ContractID, ProductID, PropertyID string) *mock.Call { - req := papi.CreatePropertyRequest{ - GroupID: GroupID, - ContractID: ContractID, - Property: papi.PropertyCreate{ - ProductID: ProductID, - PropertyName: PropertyName, - }, +func (p *mockProperty) mockGetPropertyVersionHostnames() *mock.Call { + req := papi.GetPropertyVersionHostnamesRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + PropertyVersion: p.latestVersion, + IncludeCertStatus: true, } - res := papi.CreatePropertyResponse{PropertyID: PropertyID} + resp := papi.GetPropertyVersionHostnamesResponse{ + ContractID: p.contractID, + GroupID: p.groupID, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + Hostnames: p.hostnames, + } - return client.On("CreateProperty", AnyCTX, req).Return(&res, nil) + return p.papiMock.On("GetPropertyVersionHostnames", AnyCTX, req).Return(&resp, nil).Once() } -// Sets up an expected call to papi.RemoveProperty() with a constant success response -func ExpectRemoveProperty(client *papi.Mock, PropertyID, ContractID, GroupID string) *mock.Call { - req := papi.RemovePropertyRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, +func (p *mockProperty) mockGetPropertyVersions() *mock.Call { + req := papi.GetPropertyVersionsRequest{ + PropertyID: p.propertyID, + ContractID: p.contractID, + GroupID: p.groupID, + } + resp := &papi.GetPropertyVersionsResponse{ + PropertyID: p.propertyID, + PropertyName: p.propertyName, + ContractID: p.contractID, + GroupID: p.groupID, + AssetID: p.assetID, + Versions: p.versions, } - res := papi.RemovePropertyResponse{} - return client.On("RemoveProperty", AnyCTX, req).Return(&res, nil) + return p.papiMock.On("GetPropertyVersions", AnyCTX, req).Return(resp, nil).Once() } -// Sets up an expected call to papi.GetRuleTree() which returns a value depending on the value of the -// pointer to State and FormatState. -func ExpectGetRuleTree(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, State *papi.RulesUpdate, RuleFormatState *string, - Errors []*papi.Error, Warnings []*papi.Error) *mock.Call { +func (p *mockProperty) mockGetRuleTree() *mock.Call { req := papi.GetRuleTreeRequest{ - PropertyID: PropertyID, - GroupID: GroupID, - ContractID: ContractID, - PropertyVersion: PropertyVersion, + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + PropertyVersion: p.latestVersion, ValidateMode: "full", ValidateRules: true, } - fn := func(context.Context, papi.GetRuleTreeRequest) (*papi.GetRuleTreeResponse, error) { - var Rules papi.RulesUpdate - if State != nil { - Rules = *State - } - - res := papi.GetRuleTreeResponse{ - Response: papi.Response{ - Errors: Errors, - Warnings: Warnings, - }, - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - RuleFormat: *RuleFormatState, - Rules: Rules.Rules, - } - - return &res, nil + resp := papi.GetRuleTreeResponse{ + Response: papi.Response{ + Errors: p.responseErrors, + Warnings: p.responseWarnings, + }, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + RuleFormat: p.ruleTree.ruleFormat, + Rules: p.ruleTree.rules, + Comments: p.ruleTree.comments, } - return client.OnGetRuleTree(AnyCTX, req, fn) + return p.papiMock.On("GetRuleTree", AnyCTX, req).Return(&resp, nil).Once() } -func ExpectUpdateRuleTree(client *papi.Mock, PropertyID, GroupID, ContractID string, PropertyVersion int, State *papi.RulesUpdate, RuleFormat string, RuleError []papi.RuleError) *mock.Call { - var RulesUpdate papi.RulesUpdate - if State != nil { - RulesUpdate = *State - } - var res papi.UpdateRulesResponse - req := papi.UpdateRulesRequest{ - PropertyID: PropertyID, - PropertyVersion: PropertyVersion, - ContractID: ContractID, - GroupID: GroupID, - Rules: RulesUpdate, +// mockGetRuleTreeActivation mocks the GetRuleTree call executed from property_activation resource. It differs with request +// parameters when compared to the GetRuleTree call executed from property resource. +func (p *mockProperty) mockGetRuleTreeActivation() *mock.Call { + req := papi.GetRuleTreeRequest{ + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, ValidateRules: true, } - fn := func(context.Context, papi.UpdateRulesRequest) (*papi.UpdateRulesResponse, error) { + resp := papi.GetRuleTreeResponse{ + Response: papi.Response{ + Errors: p.responseErrors, + Warnings: p.responseWarnings, + }, + PropertyID: p.propertyID, + PropertyVersion: p.latestVersion, + RuleFormat: p.ruleTree.ruleFormat, + Rules: p.ruleTree.rules, + Comments: p.ruleTree.comments, + } - res = papi.UpdateRulesResponse{ - PropertyID: PropertyID, - ContractID: ContractID, - GroupID: GroupID, - PropertyVersion: PropertyVersion, - RuleFormat: RuleFormat, - Rules: RulesUpdate.Rules, - Errors: RuleError, + return p.papiMock.On("GetRuleTree", AnyCTX, req).Return(&resp, nil).Once() +} + +func (p *mockProperty) mockGetPropertyVersion() *mock.Call { + req := papi.GetPropertyVersionRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + PropertyVersion: p.latestVersion, + } + + var ver papi.PropertyVersionGetItem + if len(p.versions.Items) > 0 { + ver = papi.PropertyVersionGetItem{ + StagingStatus: p.versions.Items[0].StagingStatus, + ProductionStatus: p.versions.Items[0].ProductionStatus, + Note: p.versions.Items[0].Note, + PropertyVersion: p.versions.Items[0].PropertyVersion, } - return &res, nil } - return client.OnUpdateRuleTree(AnyCTX, req, fn).Return(&res, nil) + resp := &papi.GetPropertyVersionsResponse{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + Version: ver, + } + return p.papiMock.On("GetPropertyVersion", AnyCTX, req).Return(resp, nil).Once() } -func updateRuleTreeWithVariables(variables []papi.RuleVariable) *papi.RulesUpdate { - return &papi.RulesUpdate{ - Rules: papi.Rules{ - Name: "default", - Children: []papi.Rules{ - { - Name: "change fwd path", - Behaviors: []papi.RuleBehavior{ - { - Name: "baseDirectory", - Options: papi.RuleOptionsMap{ - "value": "/smth/", - }, - }, - }, - Criteria: []papi.RuleBehavior{ - { - Name: "requestHeader", - Locked: false, - Options: papi.RuleOptionsMap{ - "headerName": "Accept-Encoding", - "matchCaseSensitiveValue": true, - "matchOperator": "IS_ONE_OF", - "matchWildcardName": false, - "matchWildcardValue": false, - }, - }, - }, - CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, - }, - { - Name: "caching", - Behaviors: []papi.RuleBehavior{ - { - Name: "caching", - Options: papi.RuleOptionsMap{ - "behavior": "MAX_AGE", - "mustRevalidate": false, - "ttl": "1m", - }, - }, - }, - CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAny, - }, - }, - Behaviors: []papi.RuleBehavior{ - { - Name: "origin", - Options: papi.RuleOptionsMap{ - "cacheKeyHostname": "REQUEST_HOST_HEADER", - "compress": true, - "enableTrueClientIp": true, - "forwardHostHeader": "REQUEST_HOST_HEADER", - "hostname": "test.domain", - "httpPort": float64(80), - "httpsPort": float64(443), - "originCertificate": "", - "originSni": true, - "originType": "CUSTOMER", - "ports": "", - "trueClientIpClientSetting": false, - "trueClientIpHeader": "True-Client-IP", - "verificationMode": "PLATFORM_SETTINGS", - }, - }, - }, - Options: papi.RuleOptions{}, - Variables: variables, - Comments: "The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.", - }, +func (p *mockProperty) mockRemoveProperty(err ...error) *mock.Call { + req := papi.RemovePropertyRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, } -} + resp := papi.RemovePropertyResponse{} -func updateRuleTreeWithVariablesStep1() *papi.RulesUpdate { - return updateRuleTreeWithVariables([]papi.RuleVariable{ - { - Name: "TEST_EMPTY_FIELDS", - Value: ptr.To(""), - Description: ptr.To(""), - Hidden: true, - Sensitive: false, - }, - { - Name: "TEST_NIL_FIELD", - Description: ptr.To(""), - Value: ptr.To(""), - Hidden: true, - Sensitive: false, - }, - }) + if err != nil { + return p.papiMock.On("RemoveProperty", AnyCTX, req).Return(nil, err[0]).Once() + } + + return p.papiMock.On("RemoveProperty", AnyCTX, req).Return(&resp, nil).Once() } -func updateRuleTreeWithVariablesStep0() *papi.RulesUpdate { - return updateRuleTreeWithVariables([]papi.RuleVariable{ - { - Name: "TEST_EMPTY_FIELDS", - Value: ptr.To(""), - Description: ptr.To(""), - Hidden: true, - Sensitive: false, - }, - { - Name: "TEST_NIL_FIELD", - Description: nil, - Value: ptr.To(""), - Hidden: true, - Sensitive: false, +func (p *mockProperty) mockMoveProperty() { + prpID := strings.TrimPrefix(p.assetID, "aid_") + intPropertyID, err := strconv.ParseInt(prpID, 10, 64) + // shouldn't happen, unless wrong format of propertyID is provided + if err != nil { + panic(err) + } + req := iam.MovePropertyRequest{ + PropertyID: intPropertyID, + BodyParams: iam.MovePropertyReqBody{ + DestinationGroupID: p.moveGroup.destinationGroupID, + SourceGroupID: p.moveGroup.sourceGroupID, }, - }) -} + } -type mockPropertyData struct { - propertyName string - groupID string - contractID string - productID string - propertyID string - latestVersion int - assetID string - cnameFrom string - cnameTo string + p.iamMock.On("MoveProperty", AnyCTX, req).Return(nil).Once() } -type mockProperty struct { - mockPropertyData - papiMock *papi.Mock +func (p *mockProperty) mockGetActivations() *mock.Call { + req := papi.GetActivationsRequest{ + PropertyID: p.propertyID, + } + resp := papi.GetActivationsResponse{ + Activations: p.activations, + } + return p.papiMock.On("GetActivations", mock.Anything, req).Return(&resp, nil).Once() } -func (p *mockProperty) mockCreateProperty() *mock.Call { - return ExpectCreateProperty(p.papiMock, p.propertyName, p.groupID, p.contractID, p.productID, p.propertyID) -} +func (p *mockProperty) mockCreateActivation() *mock.Call { + req := papi.CreateActivationRequest{ + PropertyID: p.propertyID, + Activation: papi.Activation{ + ActivationType: p.createActivation.ActivationType, + Network: p.createActivation.Network, + NotifyEmails: p.createActivation.NotifyEmails, + PropertyVersion: p.createActivation.PropertyVersion, + }, + } + resp := papi.CreateActivationResponse{ + ActivationID: p.createActivation.ActivationID, + } -func (p *mockProperty) mockUpdatePropertyVersionHostnames() *mock.Call { - return ExpectUpdatePropertyVersionHostnames(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, - []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: p.cnameFrom, - CnameTo: p.cnameTo, - CertProvisioningType: "DEFAULT", - }}, nil) + return p.papiMock.On("CreateActivation", mock.Anything, req).Return(&resp, nil).Once() } -func (p *mockProperty) mockGetProperty() *mock.Call { - return ExpectGetProperty(p.papiMock, p.propertyID, p.groupID, p.contractID, &papi.Property{ - PropertyName: p.propertyName, - GroupID: p.groupID, - ContractID: p.contractID, - ProductID: p.productID, - PropertyID: p.propertyID, - LatestVersion: p.latestVersion, - AssetID: p.assetID, - }) -} +func (p *mockProperty) mockGetActivation() *mock.Call { + req := papi.GetActivationRequest{ + PropertyID: p.propertyID, + ActivationID: p.createActivation.ActivationID, + } + resp := papi.GetActivationResponse{ + Activation: &p.createActivation, + } -func (p *mockProperty) mockGetPropertyVersionHostnames() *mock.Call { - return ExpectGetPropertyVersionHostnames(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, &[]papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: p.cnameFrom, - CnameTo: p.cnameTo, - CertProvisioningType: "DEFAULT", - }}) + return p.papiMock.On("GetActivation", mock.Anything, req).Return(&resp, nil).Once() } -func (p *mockProperty) mockGetRuleTree() *mock.Call { - ruleFormat := "" - return ExpectGetRuleTree(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, nil, &ruleFormat, nil, nil) -} +func (p *mockProperty) mockCreatePropertyVersion() *mock.Call { + req := papi.CreatePropertyVersionRequest{ + PropertyID: p.propertyID, + GroupID: p.groupID, + ContractID: p.contractID, + Version: papi.PropertyVersionCreate{ + CreateFromVersion: p.createFromVersion, + }, + } -func (p *mockProperty) mockGetPropertyVersion() *mock.Call { - return ExpectGetPropertyVersion(p.papiMock, p.propertyID, p.groupID, p.contractID, p.latestVersion, papi.VersionStatusInactive, - papi.VersionStatusInactive) -} + resp := papi.CreatePropertyVersionResponse{PropertyVersion: p.newVersionID} -func (p *mockProperty) mockRemoveProperty() *mock.Call { - return ExpectRemoveProperty(p.papiMock, p.propertyID, p.contractID, p.groupID) + return p.papiMock.On("CreatePropertyVersion", AnyCTX, req).Return(&resp, nil).Once() } -func mockResourcePropertyCreate(p *mockProperty) { - p.mockCreateProperty().Once() - p.mockUpdatePropertyVersionHostnames().Once() - mockResourcePropertyRead(p) +// mockResourcePropertyCreateWithVersionHostnames represents the creation workflow where the property and hostnames are created +func mockResourcePropertyCreateWithVersionHostnames(p *mockProperty) { + p.mockCreateProperty() + p.mockUpdatePropertyVersionHostnames() } -func mockResourcePropertyRead(p *mockProperty) { - p.mockGetProperty().Once() - p.mockGetPropertyVersionHostnames().Once() - p.mockGetRuleTree().Once() - p.mockGetPropertyVersion().Once() +// mockResourcePropertyFullCreate represents the full creation workflow where the property, hostnames and rule tree are created +func mockResourcePropertyFullCreate(p *mockProperty) { + p.mockCreateProperty() + p.mockUpdatePropertyVersionHostnames() + p.mockUpdateRuleTree() } -func mockMoveProperty(iamMock *iam.Mock, propertyID, srcGroupID, destGroupID int64) { - iamMock.On("MoveProperty", AnyCTX, iam.MovePropertyRequest{ - PropertyID: propertyID, - BodyParams: iam.MovePropertyReqBody{ - DestinationGroupID: destGroupID, - SourceGroupID: srcGroupID, - }}).Return(nil) +// mockResourcePropertyRead represents the read workflow where GetProperty call is used (version of the property is known) +func mockResourcePropertyRead(p *mockProperty, times ...int) { + i := 1 + if len(times) > 0 { + i = times[0] + } + p.mockGetProperty().Times(i) + p.mockGetPropertyVersionHostnames().Times(i) + p.mockGetRuleTree().Times(i) + p.mockGetPropertyVersion().Times(i) } diff --git a/pkg/providers/property/resource_akamai_property_test.go b/pkg/providers/property/resource_akamai_property_test.go index a89e452be..f3e136f14 100644 --- a/pkg/providers/property/resource_akamai_property_test.go +++ b/pkg/providers/property/resource_akamai_property_test.go @@ -7,1889 +7,2020 @@ import ( "net/http" "path" "regexp" + "slices" "strings" "testing" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -func TestResProperty(t *testing.T) { - // These more or less track the state of a Property in PAPI for the lifecycle tests - type TestState struct { - Client *papi.Mock - Property papi.Property - Hostnames []papi.Hostname - VersionItems papi.PropertyVersionItems - Rules papi.RulesUpdate - RuleFormat string - } - - // BehaviorFuncs can be composed to define common patterns of mock PAPI behavior (for Lifecycle tests) - type BehaviorFunc = func(*TestState) - - // Combines many BehaviorFuncs into one - composeBehaviors := func(behaviors ...BehaviorFunc) BehaviorFunc { - return func(State *TestState) { - for _, behave := range behaviors { - behave(State) - } - } - } - - updateRuleTree := func(propertyID, contractID, groupID string, version int, rulesUpdate *papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - ExpectUpdateRuleTree( - state.Client, propertyID, groupID, contractID, version, - rulesUpdate, "", []papi.RuleError{}, - ).Once().Run(func(args mock.Arguments) { - state.Rules = *rulesUpdate - }) - } - } - - setHostnames := func(propertyID string, version int, cnameTo string) BehaviorFunc { - return func(state *TestState) { - newHostnames := []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: "from.test.domain", - CnameTo: cnameTo, - CertProvisioningType: "DEFAULT", - }} - - ExpectUpdatePropertyVersionHostnames(state.Client, propertyID, "grp_0", "ctr_0", version, newHostnames, nil).Once().Run(func(mock.Arguments) { - newResponseHostnames := []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: "from.test.domain", - CnameTo: cnameTo, - CertProvisioningType: "DEFAULT", - EdgeHostnameID: "ehn_123", - CertStatus: papi.CertStatusItem{ - ValidationCname: papi.ValidationCname{ - Hostname: "_acme-challenge.www.example.com", - Target: "{token}.www.example.com.akamai-domain.com", - }, - Staging: []papi.StatusItem{{Status: "PENDING"}}, - Production: []papi.StatusItem{{ - Status: "PENDING", - }, - }, - }, - }} - state.Hostnames = append([]papi.Hostname{}, newResponseHostnames...) - }) - } - } - - setTwoHostnames := func(propertyID string, version int, cnameFrom1, cnameTo1, cnameFrom2, cnameTo2 string) BehaviorFunc { - return func(state *TestState) { - newHostnames := []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom1, - CnameTo: cnameTo1, - CertProvisioningType: "DEFAULT", - }, { - CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom2, - CnameTo: cnameTo2, - CertProvisioningType: "DEFAULT", - }} - - ExpectUpdatePropertyVersionHostnames(state.Client, propertyID, "grp_0", "ctr_0", version, newHostnames, nil).Once().Run(func(mock.Arguments) { - NewResponseHostnames := []papi.Hostname{{ +// TestPropertyLifecycle tests various lifecycle workflows that result in a success +func TestPropertyLifecycle(t *testing.T) { + + // defaultChecker contains basic checks for every test case, that can be built upon + defaultChecker := test.NewStateChecker("akamai_property.test"). + CheckEqual("id", "prp_4"). + CheckEqual("hostnames.0.edge_hostname_id", "ehn_123"). + CheckEqual("name", "test_property"). + CheckEqual("contract_id", "ctr_1"). + CheckEqual("group_id", "grp_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("rule_warnings.#", "0"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("latest_version", "1"). + CheckEqual("staging_version", "0"). + CheckEqual("production_version", "0"). + CheckEqual("rules", `{"rules":{"name":"default","options":{}}}`) + + // basicData holds basic, common data across test cases + basicData := mockPropertyData{ + propertyName: "test_property", + productID: "prd_3", + propertyID: "prp_4", + groupID: "grp_2", + contractID: "ctr_1", + assetID: "aid_5555", + latestVersion: 1, + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, + }, + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom1, - CnameTo: cnameTo1, - CertProvisioningType: "DEFAULT", EdgeHostnameID: "ehn_123", - CertStatus: papi.CertStatusItem{ - ValidationCname: papi.ValidationCname{ - Hostname: "_acme-challenge.www.example.com", - Target: "{token}.www.example.com.akamai-domain.com", - }, - Staging: []papi.StatusItem{{Status: "PENDING"}}, - Production: []papi.StatusItem{{ - Status: "PENDING", - }, - }, - }, - }, { - CnameType: "EDGE_HOSTNAME", - CnameFrom: cnameFrom2, - CnameTo: cnameTo2, + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", CertProvisioningType: "DEFAULT", - EdgeHostnameID: "ehn_123", - CertStatus: papi.CertStatusItem{ - ValidationCname: papi.ValidationCname{ - Hostname: "_acme-challenge.www.example.com", - Target: "{token}.www.example.com.akamai-domain.com", - }, - Staging: []papi.StatusItem{{Status: "PENDING"}}, - Production: []papi.StatusItem{{ - Status: "PENDING", - }, - }, - }, - }} - state.Hostnames = append([]papi.Hostname{}, NewResponseHostnames...) - }) - } - } - - getPropertyVersions := func(propertyID, propertyName, contractID, groupID string, items ...papi.PropertyVersionItems) BehaviorFunc { - return func(state *TestState) { - versionItems := &state.VersionItems - if len(items) > 0 { - versionItems = &items[0] - } - ExpectGetPropertyVersions(state.Client, propertyID, propertyName, contractID, groupID, &state.Property, versionItems) - } - } - - getPropertyVersionResources := func(propertyID, groupID, contractID string, version int, stagStatus, prodStatus papi.VersionStatus) BehaviorFunc { - return func(state *TestState) { - ExpectGetPropertyVersion(state.Client, propertyID, groupID, contractID, version, stagStatus, prodStatus) - } - } - - GetVersionResources := func(propertyID, contractID, groupID string, version int) BehaviorFunc { - return func(state *TestState) { - ExpectGetPropertyVersionHostnames(state.Client, propertyID, groupID, contractID, version, &state.Hostnames) - ExpectGetRuleTree(state.Client, propertyID, groupID, contractID, version, &state.Rules, &state.RuleFormat, nil, nil) - } - } - - GetVersionResourcesDrift := func(propertyID, contractID, groupID string, version int, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - ExpectGetPropertyVersionHostnames(state.Client, propertyID, groupID, contractID, version, &state.Hostnames) - ExpectGetRuleTree(state.Client, propertyID, groupID, contractID, version, &rules, &state.RuleFormat, nil, nil) - } - } - - DeleteProperty := func(propertyID string) BehaviorFunc { - return func(state *TestState) { - ExpectRemoveProperty(state.Client, propertyID, "ctr_0", "grp_0").Once().Run(func(mock.Arguments) { - state.Property = papi.Property{} - state.Rules = papi.RulesUpdate{} - state.Hostnames = nil - state.RuleFormat = "" - state.VersionItems = papi.PropertyVersionItems{} - }) - } - } - - getProperty := func(propertyID string) BehaviorFunc { - return func(state *TestState) { - ExpectGetProperty(state.Client, propertyID, "grp_0", "ctr_0", &state.Property) - } - } - - createProperty := func(propertyName, propertyID string, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - ExpectCreateProperty(state.Client, propertyName, "grp_0", "ctr_0", "prd_0", propertyID).Run(func(mock.Arguments) { - state.Property = papi.Property{ - PropertyName: propertyName, - PropertyID: propertyID, - GroupID: "grp_0", - ContractID: "ctr_0", - ProductID: "prd_0", - LatestVersion: 1, - } - - state.Rules = rules - state.RuleFormat = "v2020-01-01" - getProperty(propertyID)(state) - GetVersionResources(propertyID, "ctr_0", "grp_0", 1)(state) - }).Once() - } - } - - propertyLifecycle := func(propertyName, propertyID, groupID string, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - createProperty(propertyName, propertyID, rules)(state) - GetVersionResources(propertyID, "ctr_0", "grp_0", 1)(state) - DeleteProperty(propertyID)(state) - } + }, + }, + }, } - // propertyLifecycleWithPropertyID covers lifecycle when property_id is set - propertyLifecycleWithPropertyID := func(propertyName, propertyID, groupID string, rules papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - state.Property.PropertyID = "prp_0" - state.Property.LatestVersion = 1 - state.Property.ContractID = "ctr_0" - state.Property.GroupID = "grp_0" - state.Property.PropertyName = "test_property" - state.Rules = rules - state.RuleFormat = "v2020-01-01" - getProperty(propertyID)(state) - GetVersionResources(propertyID, "ctr_0", "grp_0", 1)(state) - // no deletion since it should be covered by property_bootstrap resource - } + // basicDataWithDefaultRules extends basic data with the default rules + basicDataWithDefaultRules := basicData + basicDataWithDefaultRules.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + }, } - propertyLifecycleWithDrift := func(propertyName, propertyID, groupID string, rulesToSend, rulesToReceive papi.RulesUpdate) BehaviorFunc { - return func(state *TestState) { - createProperty(propertyName, propertyID, rulesToSend)(state) - GetVersionResourcesDrift(propertyID, "ctr_0", "grp_0", 1, rulesToReceive)(state) - DeleteProperty(propertyID)(state) - } + // updatedHostname contains details about the updated hostname + updatedHostname := papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from.test.domain", + CnameTo: "to2.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, + }, } - importProperty := func(propertyID string) BehaviorFunc { - return func(state *TestState) { - // Depending on how much of the import ID is given, the initial property lookup may not have group and contract - ExpectGetProperty(state.Client, "prp_0", "grp_0", "ctr_0", &state.Property).Maybe() - ExpectGetProperty(state.Client, "prp_0", "", "", &state.Property).Maybe() - } + // versionStagingActive represents version of property active only on staging network + versionStagingActive := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusActive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, } - advanceVersion := func(propertyID string, fromVersion, toVersion int) BehaviorFunc { - return func(state *TestState) { - ExpectCreatePropertyVersion(state.Client, propertyID, "grp_0", "ctr_0", fromVersion, toVersion).Once().Run(func(mock.Arguments) { - state.Property.LatestVersion = toVersion - }).Run(func(args mock.Arguments) { - state.Property.LatestVersion = toVersion - state.VersionItems.Items = append(state.VersionItems.Items, - papi.PropertyVersionGetItem{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: toVersion, - StagingStatus: papi.VersionStatusInactive, - }) - }) - GetVersionResources(propertyID, "ctr_0", "grp_0", toVersion)(state) - } + // versionProductionActive represents version of property active only on production network + versionProductionActive := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusActive, + PropertyVersion: 1, + }, + }, } - // TestCheckFunc to verify all standard attributes (for Lifecycle tests) - checkAttrs := func(propertyID, cnameTo, latestVersion, stagingVersion, productionVersion, edgeHostnameId, rules string) resource.TestCheckFunc { - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "id", propertyID), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_to", cnameTo), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.edge_hostname_id", edgeHostnameId), - resource.TestCheckResourceAttr("akamai_property.test", "latest_version", latestVersion), - resource.TestCheckResourceAttr("akamai_property.test", "staging_version", stagingVersion), - resource.TestCheckResourceAttr("akamai_property.test", "production_version", productionVersion), - resource.TestCheckResourceAttr("akamai_property.test", "name", "test_property"), - resource.TestCheckResourceAttr("akamai_property.test", "contract_id", "ctr_0"), - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_0"), - resource.TestCheckResourceAttr("akamai_property.test", "product_id", "prd_0"), - resource.TestCheckResourceAttr("akamai_property.test", "rule_warnings.#", "0"), - resource.TestCheckResourceAttr("akamai_property.test", "rules", rules), - ) + // mockLatestVersionNotActive represents a workflow where no property version is active on any of the networks + mockLatestVersionNotActive := func(p *mockProperty) { + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update + p.mockGetPropertyVersion() + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() } - // addPropertyIDAttrCheck adds resource.TestCheckFunc that checks if property_id attribute was set correctly - addPropertyIDAttrCheck := func(checks resource.TestCheckFunc, propertyID string) resource.TestCheckFunc { - return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "property_id", propertyID), - checks, - ) + // mockLatestVersionActiveOnStaging represents a workflow where the second version of property is created and is active on staging network + mockLatestVersionActiveOnStaging := func(p *mockProperty) { + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock staging version active + p.versions = versionStagingActive + // read + mockResourcePropertyRead(p) + // update creates new version with updated hostname and version info + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + p.latestVersion = 2 + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() } - type StepsFunc = func(State *TestState, FixturePath string) []resource.TestStep - - // Defines standard variations of client behaviors for a Lifecycle test - type LifecycleTestCase struct { - Name string - ClientSetup BehaviorFunc - Steps StepsFunc + // mockLatestVersionActiveOnProduction represents a workflow where the second version of property is created and is active on production network + mockLatestVersionActiveOnProduction := func(p *mockProperty) { + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock production version active + p.versions = versionProductionActive + // read + mockResourcePropertyRead(p) + // update creates new version with updated hostname and version info + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + p.latestVersion = 2 + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() } - // Standard test behavior for cases where the property's latest version is deactivated in staging network - latestVersionDeactivatedInStaging := LifecycleTestCase{ - Name: "Latest version is active in staging", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusDeactivated, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusDeactivated, papi.VersionStatusInactive), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusDeactivated, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - StagingVersion := 1 - State.Property.StagingVersion = &StagingVersion - }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "1", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + // grouped tests that always have 2 steps and the config file names are always "step0.tf" and "step1.tf". For different tests, + // add them as separate cases at the end of this function. + tests := map[string]struct { + init func(*testing.T, *mockProperty) + steps []resource.TestStep + checksForCreate resource.TestCheckFunc + checksForUpdate resource.TestCheckFunc + configPlanChecks resource.ConfigPlanChecks + configDir string + }{ + "Lifecycle: property is destroyed and recreated when name is changed": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // delete + p.mockRemoveProperty() + // assign new values for mock data + p.propertyID = "prp_5" + p.propertyName = "renamed_property" + p.hostnames = updatedHostname + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "forceNewOnNameChange", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("id", "prp_5"). + CheckEqual("name", "renamed_property"). + CheckEqual("hostnames.0.cname_to", "to2.test.domain").Build(), }, - } - - // Standard test behavior for cases where the property's latest version is deactivated in production network - latestVersionDeactivatedInProd := LifecycleTestCase{ - Name: "Latest version is active in production", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusDeactivated), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusDeactivated), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusActive, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - ProductionVersion := 1 - State.Property.ProductionVersion = &ProductionVersion - }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "0", "1", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + "Lifecycle: create with propertyID (bootstrap)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + // create (without creation of property, as it was created with bootstrap resource) + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // mock updated hostnames + p.hostnames = updatedHostname + // update + p.mockGetPropertyVersion() + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // no delete as the resource is maintained by bootstrap resource + }, + configDir: "with-propertyID", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is active in staging network - latestVersionActiveInStaging := LifecycleTestCase{ - Name: "Latest version is active in staging", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusActive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusActive), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusInactive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusActive, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - StagingVersion := 1 - State.Property.StagingVersion = &StagingVersion + "Lifecycle: latest version is deactivated in staging (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock activating staging version + p.versions = versionStagingActive + // read + mockResourcePropertyRead(p) + // update creates new version + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + // update mock data with new version info and updated hostname + p.latestVersion = 2 + p.hostnames = updatedHostname + p.versions = papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusActive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + { + StagingStatus: papi.VersionStatusDeactivated, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 2, + }, }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "1", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + } + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is active in production network - latestVersionActiveInProd := LifecycleTestCase{ - Name: "Latest version is active in production", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusActive), - setHostnames("prp_0", 1, "to.test.domain"), - advanceVersion("prp_0", 1, 2), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusActive), - setHostnames("prp_0", 2, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{ - Items: []papi.PropertyVersionGetItem{{ - ProductionStatus: papi.VersionStatusActive, - PropertyVersion: 1, - StagingStatus: papi.VersionStatusInactive, - }}, - } - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - ProductionVersion := 1 - State.Property.ProductionVersion = &ProductionVersion + "Lifecycle: latest version is deactivated in production (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock production version active + p.versions = versionProductionActive + // read + mockResourcePropertyRead(p) + // update creates new version with updated hostname and version info + p.mockGetPropertyVersion() + p.mockCreatePropertyVersion() + p.latestVersion = 2 + p.hostnames = updatedHostname + p.versions = papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusActive, + PropertyVersion: 1, + }, + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusDeactivated, + PropertyVersion: 2, + }, }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "2", "0", "1", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + } + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), }, - } - - // withPropertyID covers case when property was initially created with property_bootstrap resource - withPropertyID := LifecycleTestCase{ - Name: "Create with propertyID", - ClientSetup: composeBehaviors( - propertyLifecycleWithPropertyID("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_0", 1, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: addPropertyIDAttrCheck(checkAttrs("prp_0", "to2.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), "prp_0"), - }, - } + "Lifecycle: latest version is not active (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + mockLatestVersionNotActive(p) + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is not active - latestVersionNotActive := LifecycleTestCase{ - Name: "Latest version not active", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_0", 1, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + "Lifecycle: latest version is active in staging (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "normal", + checksForCreate: defaultChecker. + Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is not active - stagingAndProductionVersionKnownAtPlan := LifecycleTestCase{ - Name: "Latest version not active", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_0", 1, "to2.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to2.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - ConfigPlanChecks: resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{testutils.FieldsKnownAtPlan{FieldsKnown: []string{"staging_version", "production_version"}, FieldsUnknown: []string{"latest_version"}}}}, - }, - } + "Lifecycle: latest version is active in production (normal)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), }, - } - - // This scenario simulates a new version being created outside of terraform and returned on read after the first step (update should be triggered) - changesMadeOutsideOfTerraform := LifecycleTestCase{ - Name: "Latest version not active", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 2, papi.VersionStatusInactive, papi.VersionStatusInactive), - GetVersionResources("prp_0", "ctr_0", "grp_0", 2), - setHostnames("prp_0", 2, "to.test.domain"), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - PreConfig: func() { - State.Property.LatestVersion = 2 - State.Hostnames[0].CnameTo = "changed.test.domain" - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "2", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - } + "Lifecycle: latest version is not active (contract_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + mockLatestVersionNotActive(p) + }, + configDir: "contract_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), }, - } - - // Standard test behavior for cases where the property's latest version is active in staging network - noDiff := LifecycleTestCase{ - Name: "No diff found in update", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{Name: "Default CORS Policy", CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll}}}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, Name: "Default CORS Policy"}}}}), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - } + "Lifecycle: latest version active in staging (contract_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "contract_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), }, - } - - diffCPCode := LifecycleTestCase{ - Name: "Diff cpCode.cpCodeLimits", - ClientSetup: composeBehaviors( - propertyLifecycleWithDrift("test_property", "prp_0", "grp_0", - papi.RulesUpdate{ - Rules: papi.Rules{Behaviors: []papi.RuleBehavior{ - { - Name: "cpCode", - Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "description": "CliTerraformCPCode", - "id": 1.050269e+06, - "name": "DevExpCliTerraformPapiAsSchemaTest", - "products": []interface{}{"Web_App_Accel"}, - }, + "Lifecycle: latest version active in production (contract_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "contract_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), + }, + "Lifecycle: latest version is not active (group_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + mockLatestVersionNotActive(p) + }, + configDir: "group_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), + }, + "Lifecycle: latest version is active in staging (group_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "group_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), + }, + "Lifecycle: latest version is active in production (group_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "group_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), + }, + "Lifecycle: latest version is not active (product_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionNotActive(p) + }, + configDir: "product_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), + }, + "Lifecycle: latest version is active in staging (product_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnStaging(p) + }, + configDir: "product_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("staging_version", "1"). + Build(), + }, + "Lifecycle: latest version is active in production (product_id without prefix)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.createFromVersion = 1 + p.newVersionID = 2 + mockLatestVersionActiveOnProduction(p) + }, + configDir: "product_id without prefix", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + CheckEqual("latest_version", "2"). + CheckEqual("production_version", "1"). + Build(), + }, + "Lifecycle: no diff": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Children: []papi.Rules{ + { + Name: "Default CORS Policy", + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, }, }, }, - Name: "default"}}, - papi.RulesUpdate{ - Rules: papi.Rules{Behaviors: []papi.RuleBehavior{ + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // mock update in rules by changing the order + p.ruleTree.rules = papi.Rules{Children: []papi.Rules{{CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, Name: "Default CORS Policy"}}} + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "no diff", + checksForCreate: defaultChecker. + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + }, + "Lifecycle: rules custom diff": { + /* + rulesCustomDiff tests rulesCustomDiff function which is in resource_akamai_property.go file. + There is an additional field "options":{} in expected attributes, because with UpdateRuleTree(ctx, req) function + this field added automatically into response, even if it does not exist in rules. + */ + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{Behaviors: []papi.RuleBehavior{ { - Name: "cpCode", + Name: "caching", Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "cpCodeLimits": nil, - "description": "CliTerraformCPCode", - "id": 1.050269e+06, - "name": "DevExpCliTerraformPapiAsSchemaTest", - "products": []interface{}{"Web_App_Accel"}, - }, + "behavior": "MAX_AGE", + "mustRevalidate": false, + "ttl": "12d", }, }, }, - Name: "default"}}, - ), - setHostnames("prp_0", 1, "to.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{ - {Name: "cpCode", + Name: "default"}, + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read + mockResourcePropertyRead(p) + // update ttl in rule tree from 12d to 13d + p.ruleTree.rules.Behaviors = []papi.RuleBehavior{ + { + Name: "caching", Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "description": "CliTerraformCPCode", - "id": 1.050269e+06, - "name": "DevExpCliTerraformPapiAsSchemaTest", - "products": []interface{}{"Web_App_Accel"}, - }, + "behavior": "MAX_AGE", + "mustRevalidate": false, + "ttl": "13d", }, }, - }, - Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"behaviors":[{"name":"cpCode","options":{"value":{"cpCodeLimits":null,"description":"CliTerraformCPCode","id":1050269,"name":"DevExpCliTerraformPapiAsSchemaTest","products":["Web_App_Accel"]}}}],"name":"default","options":{}}}`), - }, - } - }, - } - - /* - rulesCustomDiff tests rulesCustomDiff function which is in resource_akamai_property.go file. - There is an additional field "options":{} in expected attributes, because with UpdateRuleTree(ctx, req) function - this field added automatically into response, even if it does not exist in rules. - */ - rulesCustomDiff := LifecycleTestCase{ - Name: "Diff is only in behaviours.options.ttl", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{{Name: "caching", - Options: papi.RuleOptionsMap{"behavior": "MAX_AGE", "mustRevalidate": false, "ttl": "12d"}}}, - Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{{Name: "caching", - Options: papi.RuleOptionsMap{"behavior": "MAX_AGE", "mustRevalidate": false, "ttl": "12d"}}}, - Name: "default"}}), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Behaviors: []papi.RuleBehavior{{Name: "caching", - Options: papi.RuleOptionsMap{"behavior": "MAX_AGE", "mustRevalidate": false, "ttl": "13d"}}}, - Name: "default"}}), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"12d"}}],"name":"default","options":{}}}`), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"13d"}}],"name":"default","options":{}}}`), - }, - } - }, - } - - noDiffForHostnames := LifecycleTestCase{ - Name: "No diff found in update", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{Name: "Default CORS Policy", CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll}}}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setTwoHostnames("prp_0", 1, "from1.test.domain", "to1.test.domain", "from2.test.domain", "to2.test.domain"), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{Rules: papi.Rules{Children: []papi.Rules{{CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, Name: "Default CORS Policy"}}}}), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to1.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - { - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to1.test.domain", "1", "0", "0", "ehn_123", - `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`), - }, - } + } + // update + p.mockGetPropertyVersion() + p.mockUpdateRuleTree() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "rules custom diff", + checksForCreate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"12d"}}],"name":"default","options":{}}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"13d"}}],"name":"default","options":{}}}`). + Build(), }, - } - - variablesInRuleTree := LifecycleTestCase{ - Name: "Variables in property rule tree", - ClientSetup: composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - GetVersionResources("prp_0", "ctr_0", "grp_0", 1), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, updateRuleTreeWithVariablesStep0()), - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, updateRuleTreeWithVariablesStep1()), - ), - Steps: func(State *TestState, FixturePath string) []resource.TestStep { - return []resource.TestStep{ - { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{{PropertyVersion: 1, ProductionStatus: papi.VersionStatusInactive}}} - }, - Config: testutils.LoadFixtureString(t, "%s/step0.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"behaviors\":[{\"name\":\"origin\",\"options\":{\"cacheKeyHostname\":\"REQUEST_HOST_HEADER\",\"compress\":true,\"enableTrueClientIp\":true,\"forwardHostHeader\":\"REQUEST_HOST_HEADER\",\"hostname\":\"test.domain\",\"httpPort\":80,\"httpsPort\":443,\"originCertificate\":\"\",\"originSni\":true,\"originType\":\"CUSTOMER\",\"ports\":\"\",\"trueClientIpClientSetting\":false,\"trueClientIpHeader\":\"True-Client-IP\",\"verificationMode\":\"PLATFORM_SETTINGS\"}}],\"children\":[{\"behaviors\":[{\"name\":\"baseDirectory\",\"options\":{\"value\":\"/smth/\"}}],\"criteria\":[{\"name\":\"requestHeader\",\"options\":{\"headerName\":\"Accept-Encoding\",\"matchCaseSensitiveValue\":true,\"matchOperator\":\"IS_ONE_OF\",\"matchWildcardName\":false,\"matchWildcardValue\":false}}],\"name\":\"change fwd path\",\"options\":{},\"criteriaMustSatisfy\":\"all\"},{\"behaviors\":[{\"name\":\"caching\",\"options\":{\"behavior\":\"MAX_AGE\",\"mustRevalidate\":false,\"ttl\":\"1m\"}}],\"name\":\"caching\",\"options\":{},\"criteriaMustSatisfy\":\"any\"}],\"comments\":\"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.\",\"name\":\"default\",\"options\":{},\"variables\":[{\"description\":\"\",\"hidden\":true,\"name\":\"TEST_EMPTY_FIELDS\",\"sensitive\":false,\"value\":\"\"},{\"description\":null,\"hidden\":true,\"name\":\"TEST_NIL_FIELD\",\"sensitive\":false,\"value\":\"\"}]}}"), - }, - { - PreConfig: func() { - State.Property.LatestVersion = 1 + "Lifecycle: no diff for hostnames (hostnames)": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Children: []papi.Rules{ + { + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, + Name: "Default CORS Policy", + }, + }, }, - Config: testutils.LoadFixtureString(t, "%s/step1.tf", FixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"behaviors\":[{\"name\":\"origin\",\"options\":{\"cacheKeyHostname\":\"REQUEST_HOST_HEADER\",\"compress\":true,\"enableTrueClientIp\":true,\"forwardHostHeader\":\"REQUEST_HOST_HEADER\",\"hostname\":\"test.domain\",\"httpPort\":80,\"httpsPort\":443,\"originCertificate\":\"\",\"originSni\":true,\"originType\":\"CUSTOMER\",\"ports\":\"\",\"trueClientIpClientSetting\":false,\"trueClientIpHeader\":\"True-Client-IP\",\"verificationMode\":\"PLATFORM_SETTINGS\"}}],\"children\":[{\"behaviors\":[{\"name\":\"baseDirectory\",\"options\":{\"value\":\"/smth/\"}}],\"criteria\":[{\"name\":\"requestHeader\",\"options\":{\"headerName\":\"Accept-Encoding\",\"matchCaseSensitiveValue\":true,\"matchOperator\":\"IS_ONE_OF\",\"matchWildcardName\":false,\"matchWildcardValue\":false}}],\"name\":\"change fwd path\",\"options\":{},\"criteriaMustSatisfy\":\"all\"},{\"behaviors\":[{\"name\":\"caching\",\"options\":{\"behavior\":\"MAX_AGE\",\"mustRevalidate\":false,\"ttl\":\"1m\"}}],\"name\":\"caching\",\"options\":{},\"criteriaMustSatisfy\":\"any\"}],\"comments\":\"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.\",\"name\":\"default\",\"options\":{},\"variables\":[{\"description\":\"\",\"hidden\":true,\"name\":\"TEST_EMPTY_FIELDS\",\"sensitive\":false,\"value\":\"\"},{\"description\":\"\",\"hidden\":true,\"name\":\"TEST_NIL_FIELD\",\"sensitive\":false,\"value\":\"\"}]}}"), - }, - } - }, - } - - // Test Schema Configuration - - // Run a test case to verify schema validations - assertConfigError := func(t *testing.T, flaw, rx string) func(t *testing.T) { - - fixtureName := strings.ReplaceAll(flaw, " ", "_") - - return func(t *testing.T) { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/ConfigError/%s.tf", fixtureName), - ExpectError: regexp.MustCompile(rx), - }}, - }) - } - } - - // Test Lifecycle - - // Run a happy-path test case that goes through a complete create-update-destroy cycle - assertLifecycle := func(t *testing.T, name, variant string, tc LifecycleTestCase) func(t *testing.T) { - - fixturePrefix := fmt.Sprintf("testdata/%s/Lifecycle/%s", t.Name(), variant) - - return func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - State := &TestState{Client: client} - tc.ClientSetup(State) - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - IsUnitTest: true, - Steps: tc.Steps(State, fixturePrefix), - }) - }) - - client.AssertExpectations(t) - } - } - - // Test Import - // Run a test case that verifies the resource can be imported by the given ID - assertImportableWithOptions := func(t *testing.T, testName, importID, fileName, rules string, setup []BehaviorFunc) func(t *testing.T) { - - fixturePath := fmt.Sprintf("testdata/%s/Importable/%s", t.Name(), fileName) - - return func(t *testing.T) { - - client := &papi.Mock{} - client.Test(T{t}) - - parameters := strings.Split(importID, ",") - var propertyBootstrap bool - if parameters[len(parameters)-1] == "property-bootstrap" { - propertyBootstrap = true - parameters = parameters[:len(parameters)-1] - } - numberParameters := len(parameters) - lastParameter := parameters[len(parameters)-1] - if propertyBootstrap { - setup = append(setup, propertyLifecycleWithPropertyID("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}})) - } else { - setup = append(setup, propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}})) - } - setup = append(setup, - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - importProperty("prp_0"), - ) - if (numberParameters == 2 || numberParameters == 4) && !isDefaultVersion(lastParameter) { - var contractID, groupID string - if numberParameters == 4 { - contractID = "ctr_0" - groupID = "grp_0" } - if numberParameters == 2 { - setup = append(setup, getPropertyVersions("prp_0", "test_property", "ctr_0", "grp_0")) - } - setup = append(setup, getPropertyVersions("prp_0", "test_property", contractID, groupID)) - } - s := composeBehaviors(setup...) - tc := LifecycleTestCase{ - Name: "Importable", - ClientSetup: s, - Steps: func(State *TestState, _ string) []resource.TestStep { - return []resource.TestStep{ + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - Config: testutils.LoadFixtureString(t, fixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", rules), + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from1.test.domain", + CnameTo: "to1.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", }, - // this step is used to refresh state with updated staging/production statuses { - PreConfig: func() { - State.VersionItems = papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from2.test.domain", + CnameTo: "to2.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, + }, + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x2 - refresh as nothing other than the order of hostnames changed + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "hostnames", + checksForCreate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to1.test.domain"). + CheckEqual("hostnames.1.cname_to", "to2.test.domain"). + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to1.test.domain"). + CheckEqual("hostnames.1.cname_to", "to2.test.domain"). + CheckEqual("rules", `{"rules":{"children":[{"name":"Default CORS Policy","options":{},"criteriaMustSatisfy":"all"}],"name":"","options":{}}}`). + Build(), + }, + "Lifecycle: rules with variables": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + Children: []papi.Rules{ + { + Name: "change fwd path", + Behaviors: []papi.RuleBehavior{ { - PropertyVersion: 1, - StagingStatus: papi.VersionStatusActive, - ProductionStatus: papi.VersionStatusActive, + Name: "baseDirectory", + Options: papi.RuleOptionsMap{ + "value": "/smth/", + }, }, - }} - stagingVersion := 1 - State.Property.StagingVersion = &stagingVersion - + }, + Criteria: []papi.RuleBehavior{ + { + Name: "requestHeader", + Locked: false, + Options: papi.RuleOptionsMap{ + "headerName": "Accept-Encoding", + "matchCaseSensitiveValue": true, + "matchOperator": "IS_ONE_OF", + "matchWildcardName": false, + "matchWildcardValue": false, + }, + }, + }, + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAll, + }, + { + Name: "caching", + Behaviors: []papi.RuleBehavior{ + { + Name: "caching", + Options: papi.RuleOptionsMap{ + "behavior": "MAX_AGE", + "mustRevalidate": false, + "ttl": "1m", + }, + }, + }, + CriteriaMustSatisfy: papi.RuleCriteriaMustSatisfyAny, }, - Config: testutils.LoadFixtureString(t, fixturePath), - Check: checkAttrs("prp_0", "to.test.domain", "1", "1", "0", "ehn_123", rules), - }, - { - ImportState: true, - ImportStateVerify: true, - ImportStateId: importID, - ResourceName: "akamai_property.test", - Config: testutils.LoadFixtureString(t, fixturePath), - ImportStateVerifyIgnore: []string{"product", "read_version"}, - Check: addPropertyIDAttrCheck(checkAttrs("prp_0", "to.test.domain", "1", "1", "0", "ehn_123", rules), "prp_0"), }, - } - }, - } - State := &TestState{Client: client} - tc.ClientSetup(State) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: tc.Steps(State, ""), - }) - }) - - client.AssertExpectations(t) - } - } - - assertImportable := func(t *testing.T, testName, importID string) func(t *testing.T) { - return assertImportableWithOptions(t, testName, importID, "importable.tf", "{\"rules\":{\"name\":\"default\",\"options\":{}}}", []BehaviorFunc{}) - } - - // assertImportableWithBootstrap covers imports when property-bootstrap flag is provided - assertImportableWithBootstrap := func(t *testing.T, testName, importID string) func(t *testing.T) { - return assertImportableWithOptions(t, testName, importID, "importable-with-bootstrap.tf", "{\"rules\":{\"name\":\"default\",\"options\":{}}}", []BehaviorFunc{}) - } - - suppressLogging(t, func() { - - // Test Schema Configuration - - t.Run("Schema Configuration Error: name not given", assertConfigError(t, "name not given", `"name" is required`)) - t.Run("Schema Configuration Error: contract_id not given", assertConfigError(t, "contract_id not given", `Missing required argument`)) - t.Run("Schema Configuration Error: group_id not given", assertConfigError(t, "group_id not given", `Missing required argument`)) - t.Run("Schema Configuration Error: product_id not given", assertConfigError(t, "product_id not given", `Missing required argument`)) - t.Run("Schema Configuration Error: invalid json rules", assertConfigError(t, "invalid json rules", `rules are not valid JSON`)) - t.Run("Schema Configuration Error: invalid name given", assertConfigError(t, "invalid name given", `a name must only contain letters, numbers, and these characters: . _ -`)) - t.Run("Schema Configuration Error: name given too long", assertConfigError(t, "name given too long", `a name must be longer than 0 characters and shorter than 86 characters`)) - - // Test Lifecycle - - // In the tests below update for hostnames is triggered - t.Run("Lifecycle: create with propertyID", assertLifecycle(t, t.Name(), "with-propertyID", withPropertyID)) - t.Run("Lifecycle: latest version is not active (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionActiveInProd)) - t.Run("Lifecycle: latest version is deactivated in staging (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionDeactivatedInStaging)) - t.Run("Lifecycle: latest version is deactivated in production (normal)", assertLifecycle(t, t.Name(), "normal", latestVersionDeactivatedInProd)) - t.Run("Lifecycle: latest version is not active (contract_id without prefix)", assertLifecycle(t, t.Name(), "contract_id without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version active in staging (contract_id without prefix)", assertLifecycle(t, t.Name(), "contract_id without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version active in production (contract_id without prefix)", assertLifecycle(t, t.Name(), "contract_id without prefix", latestVersionActiveInProd)) - t.Run("Lifecycle: latest version is not active (group_id without prefix)", assertLifecycle(t, t.Name(), "group_id without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (group_id without prefix)", assertLifecycle(t, t.Name(), "group_id without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (group_id without prefix)", assertLifecycle(t, t.Name(), "group_id without prefix", latestVersionActiveInProd)) - t.Run("Lifecycle: latest version is not active (product_id without prefix)", assertLifecycle(t, t.Name(), "product_id without prefix", latestVersionNotActive)) - t.Run("Lifecycle: latest version is active in staging (product_id without prefix)", assertLifecycle(t, t.Name(), "product_id without prefix", latestVersionActiveInStaging)) - t.Run("Lifecycle: latest version is active in production (product_id without prefix)", assertLifecycle(t, t.Name(), "product_id without prefix", latestVersionActiveInProd)) - - t.Run("Lifecycle: no diff", assertLifecycle(t, t.Name(), "no diff", noDiff)) - t.Run("Lifecycle: diff cpCode", assertLifecycle(t, t.Name(), "rules diff cpcode", diffCPCode)) - - // Update for rules - t.Run("Lifecycle: rules custom diff", assertLifecycle(t, t.Name(), "rules custom diff", rulesCustomDiff)) - - t.Run("Lifecycle: no diff for hostnames (hostnames)", assertLifecycle(t, t.Name(), "hostnames", noDiffForHostnames)) - - // Update for hostnames - t.Run("Lifecycle: new version changed on server", assertLifecycle(t, t.Name(), "new version changed on server", changesMadeOutsideOfTerraform)) - - // Update for rules - t.Run("Lifecycle: rules with variables", assertLifecycle(t, t.Name(), "rules with variables", variablesInRuleTree)) - - // Update for hostnames - t.Run("Lifecycle: Verify staging_version and production_version known at plan", assertLifecycle(t, t.Name(), "normal", stagingAndProductionVersionKnownAtPlan)) - - // Test Import - - t.Run("Importable: property_id with ds", assertImportableWithOptions(t, "property_id", "prp_0", "importable_with_property_rules_builder.tf", - "{\"rules\":{\"behaviors\":[{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"no new line\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\\n\\tline with new line before and after + tab\\n\"}}],\"name\":\"default\",\"options\":{}}}", - []BehaviorFunc{ - updateRuleTree("prp_0", "ctr_0", "grp_0", 1, - &papi.RulesUpdate{ - Rules: papi.Rules{ - Name: "default", - Behaviors: []papi.RuleBehavior{ - {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "no new line"}}, - {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": ""}}, - {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "\n\tline with new line before and after + tab\n"}}, + Behaviors: []papi.RuleBehavior{ + { + Name: "origin", + Options: papi.RuleOptionsMap{ + "cacheKeyHostname": "REQUEST_HOST_HEADER", + "compress": true, + "enableTrueClientIp": true, + "forwardHostHeader": "REQUEST_HOST_HEADER", + "hostname": "test.domain", + "httpPort": float64(80), + "httpsPort": float64(443), + "originCertificate": "", + "originSni": true, + "originType": "CUSTOMER", + "ports": "", + "trueClientIpClientSetting": false, + "trueClientIpHeader": "True-Client-IP", + "verificationMode": "PLATFORM_SETTINGS", + }, }, - }})}, - )) - t.Run("Importable: property_id with property-bootstrap", assertImportableWithBootstrap(t, "property_id", "prp_0,property-bootstrap")) - t.Run("Importable: property_id", assertImportable(t, "property_id", "prp_0")) - t.Run("Importable: property_id and ver_# version", assertImportable(t, "property_id and ver_# version", "prp_0,ver_1")) - t.Run("Importable: property_id and # version", assertImportable(t, "property_id and # version", "prp_0,1")) - t.Run("Importable: property_id and latest", assertImportable(t, "property_id and latest", "prp_0,latest")) - t.Run("Importable: property_id and network", assertImportable(t, "property_id and network", "prp_0,staging")) - t.Run("Importable: unprefixed property_id", assertImportable(t, "unprefixed property_id", "0")) - t.Run("Importable: unprefixed property_id and # version", assertImportable(t, "unprefixed property_id and # version", "0,1")) - t.Run("Importable: unprefixed property_id and ver_# version", assertImportable(t, "unprefixed property_id and ver_# version", "0,ver_1")) - t.Run("Importable: unprefixed property_id and network", assertImportable(t, "unprefixed property_id and network", "0,p")) - t.Run("Importable: property_id and contract_id and group_id", assertImportable(t, "property_id and contract_id and group_id", "prp_0,ctr_0,grp_0")) - t.Run("Importable: property_id, contract_id, group_id and empty version", assertImportable(t, "property_id, contract_id, group_id and empty version", "prp_0,ctr_0,grp_0,")) - t.Run("Importable: property_id, contract_id, group_id and latest", assertImportable(t, "property_id, contract_id, group_id and latest", "prp_0,ctr_0,grp_0,latest")) - t.Run("Importable: property_id, contract_id, group_id and ver_# version", assertImportable(t, "property_id, contract_id, group_id and ver_# version", "prp_0,ctr_0,grp_0,ver_1")) - t.Run("Importable: property_id, contract_id, group_id and # version", assertImportable(t, "property_id, contract_id, group_id and # version", "prp_0,ctr_0,grp_0,1")) - t.Run("Importable: property_id, contract_id, group_id and network", assertImportable(t, "property_id, contract_id, group_id and network", "prp_0,ctr_0,grp_0,staging")) - t.Run("Importable: unprefixed property_id and contract_id and group_id", assertImportable(t, "unprefixed property_id and contract_id and group_id", "0,0,0")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and # version", assertImportable(t, "unprefixed property_id and contract_id, group_id and # version", "0,0,0,1")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and ver_# version", assertImportable(t, "unprefixed property_id and contract_id, group_id and ver_# version", "0,0,0,ver_1")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and latest", assertImportable(t, "unprefixed property_id and contract_id, group_id and latest", "0,0,0,latest")) - t.Run("Importable: unprefixed property_id and contract_id, group_id and network", assertImportable(t, "unprefixed property_id and contract_id, group_id and network", "0,0,0,production")) - - // Test Delete - - t.Run("property is destroyed and recreated when name is changed", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - setup := composeBehaviors( - propertyLifecycle("test_property", "prp_0", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - propertyLifecycle("renamed_property", "prp_1", "grp_0", - papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getPropertyVersionResources("prp_1", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive), - setHostnames("prp_0", 1, "to.test.domain"), - setHostnames("prp_1", 1, "to2.test.domain"), - ) - setup(&TestState{Client: client}) - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/%s-step0.tf", t.Name()), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), }, - { - Config: testutils.LoadFixtureString(t, "testdata/%s-step1.tf", t.Name()), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_1"), - resource.TestCheckResourceAttr("akamai_property.test", "name", "renamed_property"), - ), + Options: papi.RuleOptions{}, + Variables: []papi.RuleVariable{ + { + Name: "TEST_EMPTY_FIELDS", + Value: ptr.To(""), + Description: ptr.To(""), + Hidden: true, + Sensitive: false, + }, + { + Name: "TEST_NIL_FIELD", + Description: nil, + Value: ptr.To(""), + Hidden: true, + Sensitive: false, + }, }, + Comments: "The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.", }, - }) - }) - - client.AssertExpectations(t) - }) - - t.Run("error when deleting active property", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - setup := composeBehaviors( - createProperty("test_property", "prp_0", papi.RulesUpdate{Rules: papi.Rules{Name: "default"}}), - getProperty("prp_0"), - GetVersionResources("prp_0", "ctr_0", "grp_0", 1), - getPropertyVersionResources("prp_0", "grp_0", "ctr_0", 1, "ctr_0", "grp_0"), - setHostnames("prp_0", 1, "to.test.domain"), - ) - setup(&TestState{Client: client}) - - // First call to remove is not successful - req := papi.RemovePropertyRequest{ - PropertyID: "prp_0", - ContractID: "ctr_0", - GroupID: "grp_0", - } - - err := fmt.Errorf(`cannot remove active property "prp_0"`) - client.On("RemoveProperty", AnyCTX, req).Return(nil, err).Once() - - // Second call will be successful (TF test case requires last state to be empty or it's a failed test) - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0").Once() - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/%s/step0.tf", t.Name()), - Check: checkAttrs("prp_0", "to.test.domain", "1", "0", "0", "ehn_123", - "{\"rules\":{\"name\":\"default\",\"options\":{}}}"), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/%s/step1.tf", t.Name()), - ExpectError: regexp.MustCompile(`cannot remove active property`), - }, + } + // create + mockResourcePropertyFullCreate(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update with new rules variables (description in TEST_NIL_FIELD is "", was nil) + p.mockGetPropertyVersion() + p.ruleTree.rules.Variables = []papi.RuleVariable{ + { + Name: "TEST_EMPTY_FIELDS", + Value: ptr.To(""), + Description: ptr.To(""), + Hidden: true, + Sensitive: false, }, - }) - }) - - client.AssertExpectations(t) - }) - - // Test validation - - t.Run("error validations when updating property with rules tree", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_1", - ) - - var err error = &papi.Error{ - StatusCode: 400, - Type: "/papi/v1/errors/validation.required_behavior", - Title: "Missing required behavior in default rule", - Detail: "In order for this property to work correctly behavior Content Provider Code needs to be present in the default section", - Instance: "/papi/v1/properties/prp_173136/versions/3/rules#err_100", - BehaviorName: "cpCode", - } - var req = papi.UpdateRulesRequest{ - PropertyID: "prp_1", - ContractID: "ctr_0", - GroupID: "grp_0", - PropertyVersion: 1, - Rules: papi.RulesUpdate{Rules: papi.Rules{ - Name: "update rule tree", - }}, - ValidateRules: true, - } - client.On("UpdateRuleTree", AnyCTX, req).Return(nil, err).Once() - - ExpectRemoveProperty(client, "prp_1", "", "") - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ + { + Name: "TEST_NIL_FIELD", + Description: ptr.To(""), + Value: ptr.To(""), + Hidden: true, + Sensitive: false, + }, + } + p.mockUpdateRuleTree() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "rules with variables", + checksForCreate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"origin","options":{"cacheKeyHostname":"REQUEST_HOST_HEADER","compress":true,"enableTrueClientIp":true,"forwardHostHeader":"REQUEST_HOST_HEADER","hostname":"test.domain","httpPort":80,"httpsPort":443,"originCertificate":"","originSni":true,"originType":"CUSTOMER","ports":"","trueClientIpClientSetting":false,"trueClientIpHeader":"True-Client-IP","verificationMode":"PLATFORM_SETTINGS"}}],"children":[{"behaviors":[{"name":"baseDirectory","options":{"value":"/smth/"}}],"criteria":[{"name":"requestHeader","options":{"headerName":"Accept-Encoding","matchCaseSensitiveValue":true,"matchOperator":"IS_ONE_OF","matchWildcardName":false,"matchWildcardValue":false}}],"name":"change fwd path","options":{},"criteriaMustSatisfy":"all"},{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"1m"}}],"name":"caching","options":{},"criteriaMustSatisfy":"any"}],"comments":"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.","name":"default","options":{},"variables":[{"description":"","hidden":true,"name":"TEST_EMPTY_FIELDS","sensitive":false,"value":""},{"description":null,"hidden":true,"name":"TEST_NIL_FIELD","sensitive":false,"value":""}]}}`). + Build(), + checksForUpdate: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"origin","options":{"cacheKeyHostname":"REQUEST_HOST_HEADER","compress":true,"enableTrueClientIp":true,"forwardHostHeader":"REQUEST_HOST_HEADER","hostname":"test.domain","httpPort":80,"httpsPort":443,"originCertificate":"","originSni":true,"originType":"CUSTOMER","ports":"","trueClientIpClientSetting":false,"trueClientIpHeader":"True-Client-IP","verificationMode":"PLATFORM_SETTINGS"}}],"children":[{"behaviors":[{"name":"baseDirectory","options":{"value":"/smth/"}}],"criteria":[{"name":"requestHeader","options":{"headerName":"Accept-Encoding","matchCaseSensitiveValue":true,"matchOperator":"IS_ONE_OF","matchWildcardName":false,"matchWildcardValue":false}}],"name":"change fwd path","options":{},"criteriaMustSatisfy":"all"},{"behaviors":[{"name":"caching","options":{"behavior":"MAX_AGE","mustRevalidate":false,"ttl":"1m"}}],"name":"caching","options":{},"criteriaMustSatisfy":"any"}],"comments":"The behaviors in the Default Rule apply to all requests for the property hostname(s) unless another rule overrides the Default Rule settings.","name":"default","options":{},"variables":[{"description":"","hidden":true,"name":"TEST_EMPTY_FIELDS","sensitive":false,"value":""},{"description":"","hidden":true,"name":"TEST_NIL_FIELD","sensitive":false,"value":""}]}}`). + Build(), + }, + "Lifecycle: Verify staging_version and production_version known at plan": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update + p.mockGetPropertyVersion() + p.hostnames = updatedHostname + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + configDir: "normal", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("hostnames.0.cname_to", "to2.test.domain"). + Build(), + configPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + testutils.FieldsKnownAtPlan{ + FieldsKnown: []string{"staging_version", "production_version"}, + FieldsUnknown: []string{"latest_version"}, + }, + }, + }, + }, + "Lifecycle: update group id - in place": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.moveGroup = moveGroup{ + sourceGroupID: 2, + destinationGroupID: 222, + } + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before read + mockResourcePropertyRead(p) + // update - moving the property + p.mockMoveProperty() + p.groupID = "grp_222" + // read x1 + mockResourcePropertyRead(p) + // delete + p.mockRemoveProperty() + }, + configDir: "groupIDUpdate", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("group_id", "grp_222"). + Build(), + }, + "Lifecycle: update group id and hostnames - in place": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.moveGroup = moveGroup{ + sourceGroupID: 2, + destinationGroupID: 222, + } + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + // update - moving the property + // readout for obtaining assetID + p.mockGetProperty() + p.mockMoveProperty() + p.groupID = "grp_222" + // waiting for new groupID + p.mockGetProperty() + // readout for general version calculations + p.mockGetPropertyVersion() + // change in hostnames detected + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_update_with_validation_error_for_rules.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckNoResourceAttr("akamai_property.test", "rules")), - ExpectError: regexp.MustCompile(`validation.required_behavior`), + CnameFrom: "from2.test.domain", + CnameTo: "to.test.domain", + CertProvisioningType: "DEFAULT", + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "ehn_123", }, }, + } + p.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty().Once() + }, + configDir: "groupIDUpdate/withHostnames", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("group_id", "grp_222"). + Build(), + }, + "Lifecycle: update group id and name - recreate": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithDefaultRules + p.moveGroup = moveGroup{ + sourceGroupID: 2, + destinationGroupID: 222, + } + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // read x1 before update + mockResourcePropertyRead(p) + p.mockRemoveProperty().Once() + // recreate the resource + p.propertyName = "dummy_name2" + p.groupID = "grp_222" + // recreate new property + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty().Once() + }, + configDir: "groupIDUpdate/withName", + checksForCreate: defaultChecker.Build(), + checksForUpdate: defaultChecker. + CheckEqual("group_id", "grp_222"). + CheckEqual("name", "dummy_name2"). + Build(), + }, + } + + for name, test := range tests { + // TODO: Once DXE-4176 is done, un-skip those tests + testsToSkip := []string{"Lifecycle: update group id - in place", "Lifecycle: update group id and hostnames - in place", "Lifecycle: update group id and name - recreate"} + t.Run(name, func(t *testing.T) { + if slices.Contains(testsToSkip, name) { + t.Skip() + } else { + papiMock := &papi.Mock{} + iamMock := &iam.Mock{} + mp := mockProperty{ + papiMock: papiMock, + iamMock: iamMock, + } + test.init(t, &mp) + + useClient(papiMock, nil, func() { + useIam(iamMock, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/%s/step0.tf", test.configDir), + Check: test.checksForCreate, + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/%s/step1.tf", test.configDir), + Check: test.checksForUpdate, + ConfigPlanChecks: test.configPlanChecks, + }, + }, + }) + }) }) - }) - client.AssertExpectations(t) + papiMock.AssertExpectations(t) + } }) - t.Run("validation warning when creating property with rules tree", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_1", - ) - rules := papi.Rules{ + } + + // separate tests as they require different number of steps or filenames + t.Run("Lifecycle: diff cpCode", func(t *testing.T) { + papiMock := &papi.Mock{} + mp := &mockProperty{ + papiMock: papiMock, + mockPropertyData: basicData, + } + mp.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ Behaviors: []papi.RuleBehavior{ { - Name: "origin", + Name: "cpCode", Options: papi.RuleOptionsMap{ - "hostname": "1.2.3.4", - "httpPort": float64(80), - "httpsPort": float64(443), + "value": map[string]interface{}{ + "description": "CliTerraformCPCode", + "id": 1.050269e+06, + "name": "DevExpCliTerraformPapiAsSchemaTest", + "products": []interface{}{"Web_App_Accel"}, + }, }, }, }, - } - var req = papi.UpdateRulesRequest{ - PropertyID: "prp_1", - ContractID: "ctr_0", - GroupID: "grp_0", - PropertyVersion: 1, - Rules: papi.RulesUpdate{Rules: rules}, - ValidateRules: true, - } - warning := papi.RuleWarnings{ - Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", - ErrorLocation: "#/rules/behaviors/1", - Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", - } - client.On("UpdateRuleTree", AnyCTX, req).Return(&papi.UpdateRulesResponse{ - AccountID: "", - ContractID: "ctr_0", - Comments: "", - GroupID: "grp_0", - PropertyID: "prp_1", - PropertyVersion: 1, - Etag: "", - RuleFormat: "", - Rules: rules, - Errors: nil, - Warnings: []papi.RuleWarnings{warning}, - }, nil).Once() - ExpectGetProperty( - client, "prp_1", "grp_0", "ctr_0", - &papi.Property{ - PropertyID: "prp_1", GroupID: "grp_0", ContractID: "ctr_0", LatestVersion: 1, - PropertyName: "test_property", - }, - ) - - ExpectGetPropertyVersionHostnames( - client, "prp_1", "grp_0", "ctr_0", 1, - &[]papi.Hostname{}, - ).Times(2) - ruleFormat := "" - ExpectGetRuleTree( - client, "prp_1", "grp_0", "ctr_0", 1, - &papi.RulesUpdate{ - Rules: rules, - }, &ruleFormat, nil, []*papi.Error{ - { - Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", - ErrorLocation: "#/rules/behaviors/1", - Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", + Name: "default", + }, + } + // create + mockResourcePropertyFullCreate(mp) + // mock rules in the format that API returns to test custom diff functionality on rules (notice `"cpCodeLimits": nil`, which was not present in the request. + mp.ruleTree.rules = papi.Rules{Behaviors: []papi.RuleBehavior{ + { + Name: "cpCode", + Options: papi.RuleOptionsMap{ + "value": map[string]interface{}{ + "cpCodeLimits": nil, + "description": "CliTerraformCPCode", + "id": 1.050269e+06, + "name": "DevExpCliTerraformPapiAsSchemaTest", + "products": []interface{}{"Web_App_Accel"}, }, - }) - ExpectGetPropertyVersion(client, "prp_1", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) + }, + }, + }, + Name: "default"} + // read x2 + mockResourcePropertyRead(mp, 2) + // delete + mp.mockRemoveProperty() - ExpectRemoveProperty(client, "prp_1", "ctr_0", "grp_0") - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_with_validation_warning_for_rules.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "rule_warnings.0.detail", "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.")), - }, + useClient(papiMock, nil, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf"), + Check: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"cpCode","options":{"value":{"cpCodeLimits":null,"description":"CliTerraformCPCode","id":1050269,"name":"DevExpCliTerraformPapiAsSchemaTest","products":["Web_App_Accel"]}}}],"name":"default","options":{}}}`). + Build(), }, - }) + }, }) - - client.AssertExpectations(t) }) + }) - t.Run("validation - when updating a property hostnames to empty it should return error", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_0", - ) - - ExpectGetPropertyVersions(client, "prp_0", "test_property", "ctr_0", "grp_0", nil, &papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + t.Run("Lifecycle: new version changed on server", func(t *testing.T) { + papiMock := &papi.Mock{} + mp := &mockProperty{ + papiMock: papiMock, + mockPropertyData: basicDataWithDefaultRules, + } + // create + mockResourcePropertyCreateWithVersionHostnames(mp) + // read x2 + mockResourcePropertyRead(mp, 2) + // simulate remote change outside terraform, only for response data - new version with updated CnameTo. + mp.latestVersion = 2 + mp.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - PropertyVersion: 1, - StagingStatus: papi.VersionStatusInactive, - ProductionStatus: papi.VersionStatusInactive, - }, - }}) - - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{{ CnameType: "EDGE_HOSTNAME", - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CnameFrom: "from.test.domain", + CnameTo: "changed.test.domain", CertProvisioningType: "DEFAULT", - }}, nil, - ).Once() - - ExpectGetProperty( - client, "prp_0", "grp_0", "ctr_0", - &papi.Property{ - PropertyID: "prp_0", GroupID: "grp_0", ContractID: "ctr_0", LatestVersion: 1, - PropertyName: "test_property", + EdgeHostnameID: "ehn_123", }, - ) - - ExpectGetPropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - &[]papi.Hostname{{ - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", - CertProvisioningType: "DEFAULT", - }}, - ).Times(3) - - ruleFormat := "" - ExpectGetRuleTree( - client, "prp_0", "grp_0", "ctr_0", 1, - &papi.RulesUpdate{}, &ruleFormat, nil, nil) - - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0") - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{}, nil, - ).Once() - - ExpectGetPropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - &[]papi.Hostname{}, - ).Twice() - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), - Check: resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.#", "0"), - ), - ExpectError: regexp.MustCompile("hostnames exist on server and cannot be updated to empty for property with id 'prp_0'. Provide at least one hostname to update existing list of hostnames associated to this property"), - }, - }, - }) - }) - }) - - t.Run("validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' with secure-by-default enabled but remaining default certs == 0 it should return error", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_0", - ) - - ExpectGetPropertyVersions(client, "prp_0", "test_property", "ctr_0", "grp_0", nil, &papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + }, + } + mp.versions = papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ { - PropertyVersion: 1, StagingStatus: papi.VersionStatusInactive, ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 2, }, - }}) - - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{{ + }, + } + // read x1 - remote, updated state + mockResourcePropertyRead(mp) + // update + mp.mockGetPropertyVersion() + // such drift should invoke update function, which should use value from config which should replace the remote value. + // Hence, CnameTo is assigned the value from config for the mock data. + mp.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { CnameType: "EDGE_HOSTNAME", - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", CertProvisioningType: "DEFAULT", - }}, &papi.Error{ - StatusCode: http.StatusTooManyRequests, - Remaining: ptr.To(0), - LimitKey: "DEFAULT_CERTS_PER_CONTRACT", + EdgeHostnameID: "ehn_123", }, - ).Once() - - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0") + }, + } + mp.mockUpdatePropertyVersionHostnames() + // read x2 + mockResourcePropertyRead(mp, 2) + // delete + mp.mockRemoveProperty() - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), - Check: resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as the limit for DEFAULT certificates has been reached"), - }, + useClient(papiMock, nil, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf"), + Check: defaultChecker.Build(), }, - }) + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf"), + Check: defaultChecker. + CheckEqual("latest_version", "2"). + Build(), + }, + }, }) }) + }) +} + +// TestPropertyImports tests import functionality of property resource +func TestPropertyImport(t *testing.T) { + // Based on importID, different API calls are being made in the Import and Read functions. If the importID allows to + // reconcile specific property version, GetProperty calls are being executed in Import and Read operations. If the property version + // is unknown, GetPropertyVersions is being used instead of GetProperty. + + // mockPropertyImportKnownVersion gathers API calls that are being executed when property version is known. + // Uses GetProperty calls. + mockPropertyImportKnownVersion := func(p *mockProperty) { + // import + p.mockGetProperty() + // read + mockResourcePropertyRead(p) + } - t.Run("validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' not having enabled secure-by-default it should return error", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) + // mockPropertyImportKnownVersion gathers API calls that are being executed when property version is unknown. + // Uses GetPropertyVersions calls. + mockPropertyImportUnknownVersion := func(p *mockProperty) { + // import + p.mockGetPropertyVersions() + // read + p.mockGetPropertyVersions() + p.mockGetPropertyVersionHostnames() + p.mockGetRuleTree() + p.mockGetPropertyVersion() + } - ExpectCreateProperty( - client, "test_property", "grp_0", - "ctr_0", "prd_0", "prp_0", - ) + // mockPropertyImportKnownVersionAfterImport gather API calls that are being executed when property version is provided and known + // read function, but not during import: hence there is a single call to GetPropertyVersions in import. + mockPropertyImportKnownVersionAfterImport := func(p *mockProperty) { + // import + p.mockGetPropertyVersions() + // read (notice that here one GetPropertyVersions call is omitted) + p.mockGetPropertyVersionHostnames() + p.mockGetRuleTree() + p.mockGetPropertyVersion() + } - ExpectGetPropertyVersions(client, "prp_0", "test_property", "ctr_0", "grp_0", nil, &papi.PropertyVersionItems{Items: []papi.PropertyVersionGetItem{ + // basicData holds basic, common data across test cases + basicData := mockPropertyData{ + propertyID: "prp_4", + groupID: "grp_2", + contractID: "ctr_1", + latestVersion: 1, + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - PropertyVersion: 1, - StagingStatus: papi.VersionStatusInactive, + CnameTo: "to.test.domain", + EdgeHostnameID: "ehn_123", + }, + }, + }, + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusActive, ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, }, - }}) + }, + }, + } - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusInactive, papi.VersionStatusInactive) + // basicDataWithoutGroupAndContract does not contain group and contract parameters for cases where they are not part of importID + basicDataWithoutGroupAndContract := basicData + basicDataWithoutGroupAndContract.groupID = "" + basicDataWithoutGroupAndContract.contractID = "" + + // defaultChecker builds basic, common checks across test cases + defaultChecker := test.NewImportChecker(). + CheckEqual("id", "prp_4"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("hostnames.0.edge_hostname_id", "ehn_123"). + CheckEqual("latest_version", "1"). + CheckEqual("staging_version", "1"). + CheckEqual("production_version", "0"). + CheckEqual("rules", `{"rules":{"name":"","options":{}}}`) - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{{ - CnameType: "EDGE_HOSTNAME", - CnameFrom: "terraform.provider.myu877.test.net", - CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", - CertProvisioningType: "DEFAULT", - }}, &papi.Error{ - StatusCode: http.StatusForbidden, - Type: "https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/default-cert-provisioning-unavailable", - }, - ).Once() + tests := map[string]struct { + importID string + config string + init func(*testing.T, *mockProperty) + stateCheck func(s []*terraform.InstanceState) error + }{ + "Importable: property_id with ds": { + importID: "prp_4", + config: "testdata/TestResProperty/Importable/importable_with_property_rules_builder.tf", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + Behaviors: []papi.RuleBehavior{ + {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "no new line"}}, + {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": ""}}, + {Name: "mPulse", Options: papi.RuleOptionsMap{"configOverride": "\n\tline with new line before and after + tab\n"}}, + }, + }, + } + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.CheckEqual("rules", "{\"rules\":{\"behaviors\":[{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"no new line\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\"}},{\"name\":\"mPulse\",\"options\":{\"configOverride\":\"\\n\\tline with new line before and after + tab\\n\"}}],\"name\":\"default\",\"options\":{}}}").Build(), + }, + "Importable: property_id with property-bootstrap": { + importID: "prp_4,property-bootstrap", + config: "testdata/TestResProperty/Importable/importable-with-bootstrap.tf", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id": { + importID: "prp_4", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and ver_# version": { + importID: "prp_4,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and # version": { + importID: "prp_4,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and latest": { + importID: "prp_4,latest", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and network": { + importID: "prp_4,staging", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id": { + importID: "4", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportKnownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and # version": { + importID: "4,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and ver_# version": { + importID: "4,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and network": { + importID: "4,s", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicDataWithoutGroupAndContract + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id and contract_id and group_id": { + importID: "prp_4,ctr_1,grp_2", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and empty version": { + importID: "prp_4,ctr_1,grp_2,", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and latest": { + importID: "prp_4,ctr_1,grp_2,latest", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and ver_# version": { + importID: "prp_4,ctr_1,grp_2,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and # version": { + importID: "prp_4,ctr_1,grp_2,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: property_id, contract_id, group_id and network": { + importID: "prp_4,ctr_1,grp_2,staging", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id and group_id": { + importID: "4,1,2", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and # version": { + importID: "4,1,2,1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and ver_# version": { + importID: "4,1,2,ver_1", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportKnownVersionAfterImport(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and latest": { + importID: "4,1,2,latest", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + // read + mockResourcePropertyRead(p) + }, + stateCheck: defaultChecker.Build(), + }, + "Importable: un-prefixed property_id and contract_id, group_id and network": { + importID: "4,1,2,staging", + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + mockPropertyImportUnknownVersion(p) + }, + stateCheck: defaultChecker.Build(), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + papiMock := &papi.Mock{} + mp := mockProperty{ + papiMock: papiMock, + } + test.init(t, &mp) - ExpectRemoveProperty(client, "prp_0", "ctr_0", "grp_0") + // use default config file if custom is not specified + if test.config == "" { + test.config = "testdata/TestResProperty/Importable/importable.tf" + } - useClient(client, nil, func() { + useClient(papiMock, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), - Check: resource.TestCheckResourceAttr("akamai_property.test", "id", "prp_0"), - ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as secure-by-default is not enabled in this account"), + ImportStateCheck: test.stateCheck, + ImportStateId: test.importID, + ImportState: true, + ResourceName: "akamai_property.test", + Config: testutils.LoadFixtureString(t, test.config), + ImportStateVerifyIgnore: []string{"product", "read_version"}, }, }, }) }) - }) - - // Other tests - t.Run("error when the given group is not found", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - - req := papi.CreatePropertyRequest{ - ContractID: "ctr_0", - GroupID: "grp_0", - Property: papi.PropertyCreate{ - ProductID: "prd_0", - PropertyName: "property_name", - }, - } - - var err error = &papi.Error{ - StatusCode: 404, - Title: "Not Found", - Detail: "The system was unable to locate the requested resource", - Type: "https://problems.luna.akamaiapis.net/papi/v0/http/not-found", - Instance: "https://akaa-hqgqowhpmkw32kmt-t3owzo37wb5dkern.luna-dev.akamaiapis.net/papi/v1/properties?contractId=ctr_0\\u0026groupId=grp_0#c3fe5f9b0c4a14d1", - } - - client.On("CreateProperty", AnyCTX, req).Return(nil, err).Once() + papiMock.AssertExpectations(t) + }) + } +} - // the papi GetGroups call should not return any matching group - var Groups []*papi.Group - ExpectGetGroups(client, &Groups).Once() +// TestPropertyErrors tests various cases where we should expect an error or validation is triggered +func TestPropertyErrors(t *testing.T) { + // basicData holds basic, common data across test cases + basicData := mockPropertyData{ + propertyName: "test_property", + contractID: "ctr_1", + productID: "prd_3", + groupID: "grp_2", + propertyID: "prp_4", + latestVersion: 1, + } - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Creation/property.tf"), - ExpectError: regexp.MustCompile("group not found: grp_0"), - }}, - }) - }) + defaultChecker := test.NewStateChecker("akamai_property.test"). + CheckEqual("id", "prp_4"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("hostnames.0.edge_hostname_id", "ehn_123"). + CheckEqual("latest_version", "1"). + CheckEqual("staging_version", "0"). + CheckEqual("production_version", "0"). + CheckEqual("name", "test_property"). + CheckEqual("contract_id", "ctr_1"). + CheckEqual("group_id", "grp_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("rule_warnings.#", "0"). + CheckEqual("rules", `{"rules":{"name":"default","options":{}}}`) + + inactiveVersions := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, + } - client.AssertExpectations(t) - }) + defaultHostname := papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, + }, + } - t.Run("error when creating property with non-unique name", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) + defaultRuleTree := mockRuleTreeData{ + rules: papi.Rules{ + Name: "default", + }, + } - req := papi.CreatePropertyRequest{ - ContractID: "ctr_0", - GroupID: "grp_0", - Property: papi.PropertyCreate{ - PropertyName: "test_property", - ProductID: "prd_0", + tests := map[string]struct { + init func(*testing.T, *mockProperty) + steps []resource.TestStep + }{ + "error when the given group is not found": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + err := &papi.Error{ + StatusCode: 404, + Title: "Not Found", + Detail: "The system was unable to locate the requested resource", + Type: "https://problems.luna.akamaiapis.net/papi/v0/http/not-found", + Instance: "https://akaa-hqgqowhpmkw32kmt-t3owzo37wb5dkern.luna-dev.akamaiapis.net/papi/v1/properties?contractId=ctr_0\\u0026groupId=grp_0#c3fe5f9b0c4a14d1", + } + p.mockCreateProperty(err) + p.mockGetGroups() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/Creation/property.tf"), + ExpectError: regexp.MustCompile("group not found: grp_2"), }, - } - - client.On("CreateProperty", AnyCTX, req).Return(nil, fmt.Errorf("given property name is not unique")) - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ + }, + }, + "error when creating property with non-unique name": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + err := fmt.Errorf("given property name is not unique") + p.mockCreateProperty(err) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf"), + ExpectError: regexp.MustCompile(`property name is not unique`), + }, + }, + }, + "error when deleting active property": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.versions = inactiveVersions + p.hostnames = defaultHostname + p.ruleTree = defaultRuleTree + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // refresh before update + mockResourcePropertyRead(p) + // First call to remove is not successful because property is active + err := fmt.Errorf(`cannot remove active property "prp_4"`) + p.mockRemoveProperty(err) + // Second call will be successful (TF test case requires last state to be empty or it's a failed test) + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/error_when_deleting_active_property/step0.tf"), + Check: defaultChecker.Build(), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/error_when_deleting_active_property/step1.tf"), + ExpectError: regexp.MustCompile(`cannot remove active property`), + }, + }, + }, + "error validations when updating property with rules tree": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{ + Name: "update rule tree", + }, + } + // create + p.mockCreateProperty() + err := &papi.Error{ + StatusCode: 400, + Type: "/papi/v1/errors/validation.required_behavior", + Title: "Missing required behavior in default rule", + Detail: "In order for this property to work correctly behavior Content Provider Code needs to be present in the default section", + Instance: "/papi/v1/properties/prp_173136/versions/3/rules#err_100", + BehaviorName: "cpCode", + } + // expect an error while updating rule tree + p.mockUpdateRuleTree(err) + // contract and group are not set in the state, so the property deletion is performed without those attributes + p.contractID = "" + p.groupID = "" + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_update_with_validation_error_for_rules.tf"), + ExpectError: regexp.MustCompile(`validation.required_behavior`), + }, + }, + }, + "validation warning when creating property with rules tree": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.versions = inactiveVersions + p.ruleTree = mockRuleTreeData{ + ruleFormat: "", + ruleWarnings: []papi.RuleWarnings{ { - Config: testutils.LoadFixtureString(t, "testdata/%s.tf", t.Name()), - Check: resource.TestCheckNoResourceAttr("akamai_property.test", "id"), - ExpectError: regexp.MustCompile(`property name is not unique`), + Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", + ErrorLocation: "#/rules/behaviors/1", + Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", }, }, - }) - }) - - client.AssertExpectations(t) - }) - - ruleTreeRes := papi.GetRuleTreeResponse{ - Rules: papi.Rules{ - Name: "default", - Children: []papi.Rules{ - { - Name: "Static Content", + rules: papi.Rules{ Behaviors: []papi.RuleBehavior{ { - Name: "prefetch", - Options: papi.RuleOptionsMap{"enabled": false}, - }, - }, - }, - }, - Behaviors: []papi.RuleBehavior{ - { - Name: "cpCode", - Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "id": float64(12345), - "description": "WAA Example.com", - "products": []interface{}{ - "Web_App_Accel", + Name: "origin", + Options: papi.RuleOptionsMap{ + "hostname": "1.2.3.4", + "httpPort": float64(80), + "httpsPort": float64(443), }, - "name": "WAA Example.com", }, }, }, - }, - Options: papi.RuleOptions{IsSecure: true}, - }, - } - - propertyReadCtx := func(client *papi.Mock, stagStatus, prodStatus papi.VersionStatus) { - ExpectGetProperty( - client, "prp_0", "grp_0", "ctr_0", - &papi.Property{ - PropertyID: "prp_0", GroupID: "grp_0", ContractID: "ctr_0", LatestVersion: 1, - PropertyName: "dxe-2406-issue-example", - }, - ).Once() - ExpectGetPropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - &[]papi.Hostname{ + } + p.responseWarnings = []*papi.Error{ { - CnameFrom: "dxe-2406-issue-example-second.com", - CnameTo: "dxe-2406-issue-example-second.com.example.net", - CertProvisioningType: "CPS_MANAGED", + Type: "https://problems.luna.akamaiapis.net/papi/v0/validation/validation_message.ip_address_origin", + ErrorLocation: "#/rules/behaviors/1", + Detail: "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead.", }, - { - CnameFrom: "dxe-2406-issue.com", - CnameTo: "dxe-2406-issue.com.example.net", - CertProvisioningType: "CPS_MANAGED", + } + // create + p.mockCreateProperty() + p.mockUpdateRuleTree() + // read x2 + mockResourcePropertyRead(p, 2) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/property_with_validation_warning_for_rules.tf"), + Check: defaultChecker. + CheckEqual("rule_warnings.#", "1"). + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"origin","options":{"hostname":"1.2.3.4","httpPort":80,"httpsPort":443}}],"name":"","options":{}}}`). + CheckEqual("rule_warnings.0.detail", "Using an IP address for the `Origin Server` is not recommended. IP addresses may be changed or reassigned without notice which can severely impact your property or cause a DoS. Please use a properly formatted hostname instead."). + CheckMissing("hostnames.0.cname_to"). + CheckMissing("hostnames.0.edge_hostname_id"). + Build(), + }, + }, + }, + "validation - when updating a property hostnames to empty it should return error": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "terraform.provider.myu877.test.net", + CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CertProvisioningType: "DEFAULT", + EdgeHostnameID: "ehn_123", + }, }, + } + p.ruleTree = mockRuleTreeData{ + rules: papi.Rules{}, + ruleFormat: "", + } + p.versions = inactiveVersions + // create + mockResourcePropertyCreateWithVersionHostnames(p) + // read x2 + mockResourcePropertyRead(p, 2) + // refresh - read + mockResourcePropertyRead(p) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), + Check: defaultChecker. + CheckEqual("rules", `{"rules":{"name":"","options":{}}}`). + CheckEqual("hostnames.0.cname_to", "terraform.provider.myu877.test.net.edgesuite.net"). + CheckEqual("hostnames.#", "1"). + Build(), }, - ).Once() - client.On("GetRuleTree", mock.Anything, papi.GetRuleTreeRequest{ - PropertyID: "prp_0", - GroupID: "grp_0", - ContractID: "ctr_0", - PropertyVersion: 1, - ValidateMode: "full", - ValidateRules: true, - }).Return(&ruleTreeRes, nil).Once() - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, stagStatus, prodStatus).Once() - } - - getActivations := func(client *papi.Mock) { - expectGetActivations(client, "prp_0", papi.GetActivationsResponse{ - Activations: papi.ActivationsItems{ - Items: []*papi.Activation{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf"), + ExpectError: regexp.MustCompile("hostnames exist on server and cannot be updated to empty for property with id 'prp_4'. Provide at least one hostname to update existing list of hostnames associated to this property"), + }, + }, + }, + "validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' with secure-by-default enabled but remaining default certs == 0 it should return error": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ { - ActivationID: "act_123", - PropertyID: "prp_0", - PropertyVersion: 1, - Network: papi.ActivationNetworkStaging, - Status: papi.ActivationStatusActive, - ActivationType: papi.ActivationTypeActivate, - SubmitDate: "2020-10-28T15:04:05Z", - NotifyEmails: []string{"dummy-user@akamai.com"}, + CnameType: "EDGE_HOSTNAME", + CnameFrom: "terraform.provider.myu877.test.net", + CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CertProvisioningType: "DEFAULT", }, }, + } + // create + p.mockCreateProperty() + err := &papi.Error{ + StatusCode: http.StatusTooManyRequests, + Remaining: ptr.To(0), + LimitKey: "DEFAULT_CERTS_PER_CONTRACT", + } + p.mockUpdatePropertyVersionHostnames(err) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), + ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as the limit for DEFAULT certificates has been reached"), }, - }, nil).Once() - } - - // Update for hostnames and rules - t.Run("400 from UpdatePropertyVersionHostnames - incorrect/invalid edge hostname", func(t *testing.T) { - client := &papi.Mock{} - client.Test(T{t}) - ruleFormat := "" - - // first step - // create property - ExpectCreateProperty(client, "dxe-2406-issue-example", "grp_0", "ctr_0", "prd_0", "prp_0").Once() - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 1, - []papi.Hostname{ - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue-example-second.com", - CnameTo: "dxe-2406-issue-example-second.com.example.net", - CertProvisioningType: "CPS_MANAGED", + }, + }, + "validation - when updating a property hostnames with cert_provisioning_type = 'DEFAULT' not having enabled secure-by-default it should return error": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = basicData + p.hostnames = papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "terraform.provider.myu877.test.net", + CnameTo: "terraform.provider.myu877.test.net.edgesuite.net", + CertProvisioningType: "DEFAULT", + }, }, - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue.com", - CnameTo: "dxe-2406-issue.com.example.net", - CertProvisioningType: "CPS_MANAGED", - }}, nil, - ).Once() - ExpectUpdateRuleTree(client, "prp_0", "grp_0", "ctr_0", 1, - &papi.RulesUpdate{ - Rules: papi.Rules{ - Name: "default", - Children: []papi.Rules{ - { - Name: "Static Content", - Behaviors: []papi.RuleBehavior{ - { - Name: "prefetch", - Options: papi.RuleOptionsMap{"enabled": false}, + } + p.versions = inactiveVersions + // create + p.mockCreateProperty() + err := &papi.Error{ + StatusCode: http.StatusForbidden, + Type: "https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/default-cert-provisioning-unavailable", + } + p.mockUpdatePropertyVersionHostnames(err) + // delete + p.mockRemoveProperty() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf"), + ExpectError: regexp.MustCompile("updating hostnames: not possible to use cert_provisioning_type = 'DEFAULT' as secure-by-default is not enabled in this account"), + }, + }, + }, + "400 from UpdatePropertyVersionHostnames - incorrect/invalid edge hostname": { + init: func(t *testing.T, p *mockProperty) { + // set initial data + p.mockPropertyData = mockPropertyData{ + propertyName: "dxe-2406-issue-example", + groupID: "grp_2", + contractID: "ctr_1", + productID: "prd_3", + propertyID: "prp_4", + latestVersion: 1, + ruleTree: mockRuleTreeData{ + ruleFormat: "", + rules: papi.Rules{ + Name: "default", + Children: []papi.Rules{ + { + Name: "Static Content", + Behaviors: []papi.RuleBehavior{ + { + Name: "prefetch", + Options: papi.RuleOptionsMap{"enabled": false}, + }, }, }, }, - }, - Behaviors: []papi.RuleBehavior{ - { - Name: "cpCode", - Options: papi.RuleOptionsMap{ - "value": map[string]interface{}{ - "id": float64(12345), - "description": "WAA Example.com", - "products": []interface{}{ - "Web_App_Accel", + Behaviors: []papi.RuleBehavior{ + { + Name: "cpCode", + Options: papi.RuleOptionsMap{ + "value": map[string]interface{}{ + "id": float64(12345), + "description": "WAA Example.com", + "products": []interface{}{ + "Web_App_Accel", + }, + "name": "WAA Example.com", }, - "name": "WAA Example.com", }, }, }, + Options: papi.RuleOptions{IsSecure: true}, }, - Options: papi.RuleOptions{IsSecure: true}, - }}, ruleFormat, []papi.RuleError{}).Once() - - // read property - propertyReadCtx(client, papi.VersionStatusInactive, papi.VersionStatusInactive) - - // create activation - expectGetRuleTree(client, "prp_0", 1, ruleTreeRes, nil).Once() - expectGetActivations(client, "prp_0", papi.GetActivationsResponse{}, nil).Once() - client.On("CreateActivation", mock.Anything, mock.Anything).Return(&papi.CreateActivationResponse{ActivationID: "act_123"}, nil).Once() - expectGetActivation(client, "prp_0", "act_123", 1, papi.ActivationNetworkStaging, papi.ActivationStatusActive, papi.ActivationTypeActivate, "", []string{"dummy-user@akamai.com"}, nil).Once() - - // read property - propertyReadCtx(client, papi.VersionStatusActive, papi.VersionStatusActive) - - // activation read - getActivations(client) - - // read property - propertyReadCtx(client, papi.VersionStatusActive, papi.VersionStatusActive) - - // activation read - getActivations(client) - - // second step - // property update returns an error on the invalid edgehostname - ExpectGetPropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, papi.VersionStatusActive, papi.VersionStatusActive).Once() - ExpectCreatePropertyVersion(client, "prp_0", "grp_0", "ctr_0", 1, 2) - - ExpectUpdatePropertyVersionHostnames( - client, "prp_0", "grp_0", "ctr_0", 2, - []papi.Hostname{ - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue-example-second.com", - CnameTo: "dxe-2406-issue-example-second.com.example.net", - CertProvisioningType: "CPS_MANAGED", }, - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "dxe-2406-issue.com", - CnameTo: "dxe-2406-issue.com.example.net", - CertProvisioningType: "CPS_MANAGED", + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + }, + }, }, - { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "does-not-exist.com", - CnameTo: "does-not-exist.com.example.net", - CertProvisioningType: "CPS_MANAGED", - }}, fmt.Errorf("%w: request failed: %s", papi.ErrUpdatePropertyVersionHostnames, errors.New("{\n \"type\": \"https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/bad-cnameto\",\n \"title\": \"Bad `cnameTo`\",\n \"detail\": \"The System could not find cnameTo value `does-not-exist.com.example.net`.\",\n \"instance\": \"host/papi/v1/properties/prp_0/versions/2/hostnames?contractId=ctr_0&groupId=grp_0&includeCertStatus=false&validateHostnames=false#efba6490291100b1\",\n \"status\": 400\n}")), - ).Once() - - // terraform clean up - terraform test framework attempts to run destroy plan, if an error is returned on second step - // activation and property deletion - getActivations(client) - client.On("CreateActivation", mock.Anything, mock.Anything).Return(&papi.CreateActivationResponse{ - ActivationID: "act_123", - }, nil).Once() - expectGetActivation(client, "prp_0", "act_123", 1, papi.ActivationNetworkStaging, papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "", []string{"dummy-user@akamai.com"}, nil).Once() - client.On("RemoveProperty", mock.Anything, mock.Anything).Return(&papi.RemovePropertyResponse{ - Message: "removed", - }, nil).Once() - - useClient(client, nil, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.akaproperty", "id", "prp_0"), - resource.TestCheckResourceAttr("akamai_property.akaproperty", "hostnames.#", "2"), - ), + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue-example-second.com", + CnameTo: "dxe-2406-issue-example-second.com.example.net", + CertProvisioningType: "CPS_MANAGED", + EdgeHostnameID: "ehn_123", + }, + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue.com", + CnameTo: "dxe-2406-issue.com.example.net", + CertProvisioningType: "CPS_MANAGED", + }, }, + }, + createActivation: papi.Activation{ + ActivationID: "act_123", + ActivationType: papi.ActivationTypeActivate, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + NotifyEmails: []string{"dummy-user@akamai.com"}, + PropertyVersion: 1, + }, + groups: papi.GroupItems{ + Items: []*papi.Group{}, + }, + activations: papi.ActivationsItems{ + Items: []*papi.Activation{}, + }, + } + // akamai_property - create + mockResourcePropertyFullCreate(p) + // akamai_property - read x2 + mockResourcePropertyRead(p, 2) + // akamai_property_activation - create activation + p.mockGetRuleTreeActivation().Once() // GetRuleTree request in activation resources is different from GetRuleTree in property resource + p.mockGetActivations() // no activation + p.mockCreateActivation() + // modify mock data to reflect newly created activation + p.activations = papi.ActivationsItems{ + Items: []*papi.Activation{ { - Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.akaproperty", "id", "prp_0"), - resource.TestCheckResourceAttr("akamai_property.akaproperty", "hostnames.#", "3"), - ), - ExpectError: regexp.MustCompile("Error: updating hostnames: request failed:"), + ActivationID: p.createActivation.ActivationID, + ActivationType: papi.ActivationTypeActivate, + GroupID: p.groupID, + PropertyName: p.propertyName, + PropertyID: p.propertyID, + PropertyVersion: p.createActivation.PropertyVersion, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + NotifyEmails: p.createActivation.NotifyEmails, }, }, - }) - }) - - client.AssertExpectations(t) - }) - }) -} - -func TestGroupIDUpdate(t *testing.T) { - t.Skip("skipping before moving property is enabled again, see DXE-4176") - baseData := mockPropertyData{ - propertyName: "dummy_name", - groupID: "grp_1", - contractID: "ctr_2", - productID: "prd_3", - propertyID: "prp_12345", - latestVersion: 1, - assetID: "aid_55555", - cnameFrom: "from.test.domain", - cnameTo: "to.test.domain", - } - - baseCheckName := resource.TestCheckResourceAttr("akamai_property.test", "name", "dummy_name") - baseCheckGroupID := resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_1") - baseCheckCnameFrom := resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_from", "from.test.domain") - - commonBaseChecks := resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "contract_id", "ctr_2"), - resource.TestCheckResourceAttr("akamai_property.test", "product_id", "prd_3"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_to", "to.test.domain"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cert_provisioning_type", "DEFAULT")) + } + p.mockGetActivation() - tests := map[string]struct { - init func(*testing.T, *mockProperty, *iam.Mock) - configPathForUpdate string - updateChecks resource.TestCheckFunc - }{ - "update group id - in place": { - init: func(t *testing.T, p *mockProperty, iamMock *iam.Mock) { - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - // second refresh - mockResourcePropertyRead(p) + activatedVersion := papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + ProductionStatus: papi.VersionStatusActive, + StagingStatus: papi.VersionStatusActive, + }, + }, + } + p.versions = activatedVersion - // moving the property - // readout for obtaining assetID - p.mockGetProperty().Once() - mockMoveProperty(iamMock, 55555, 1, 111) - p.groupID = "grp_111" - // waiting for new groupID - p.mockGetProperty().Once() - // final read from the update function - mockResourcePropertyRead(p) + // akamai_property_activation - read x2 + p.mockGetActivations().Twice() - // refresh + // akamai_property - read before update mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() - }, - configPathForUpdate: "testdata/TestGroupIDUpdate/update_group_id.tf", + // second step + // property update returns an error on the invalid edgehostname + p.mockGetPropertyVersion() + p.createFromVersion = 1 + p.newVersionID = 2 + p.mockCreatePropertyVersion() + // after creating new version, update latest version of the property to reflect that change + p.latestVersion = p.newVersionID + + // prepare updated hostnames + updatedHostnames := papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue-example-second.com", + CnameTo: "dxe-2406-issue-example-second.com.example.net", + CertProvisioningType: "CPS_MANAGED", + EdgeHostnameID: "ehn_123", + }, + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "dxe-2406-issue.com", + CnameTo: "dxe-2406-issue.com.example.net", + CertProvisioningType: "CPS_MANAGED", + }, + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "does-not-exist.com", + CnameTo: "does-not-exist.com.example.net", + CertProvisioningType: "CPS_MANAGED", + }, + }, + } + p.hostnames = updatedHostnames - updateChecks: resource.ComposeTestCheckFunc( - baseCheckName, - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_111"), - baseCheckCnameFrom, - commonBaseChecks), - }, - "update group id and hostnames - in place": { - init: func(t *testing.T, p *mockProperty, iamMock *iam.Mock) { - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - // second refresh - mockResourcePropertyRead(p) + // return an error while updating property version hostnames + err := fmt.Errorf("%w: request failed: %s", papi.ErrUpdatePropertyVersionHostnames, errors.New("{\n \"type\": \"https://problems.luna.akamaiapis.net/papi/v0/property-version-hostname/bad-cnameto\",\n \"title\": \"Bad `cnameTo`\",\n \"detail\": \"The System could not find cnameTo value `does-not-exist.com.example.net`.\",\n \"instance\": \"host/papi/v1/properties/prp_0/versions/2/hostnames?contractId=ctr_0&groupId=grp_0&includeCertStatus=false&validateHostnames=false#efba6490291100b1\",\n \"status\": 400\n}")) + p.mockUpdatePropertyVersionHostnames(err) - // moving the property - // readout for obtaining assetID - p.mockGetProperty().Once() - mockMoveProperty(iamMock, 55555, 1, 111) - p.groupID = "grp_111" - // waiting for new groupID - p.mockGetProperty().Once() - // readout for general version calculations - p.mockGetPropertyVersion().Once() - // change in hostnames detected - p.cnameFrom = "from2.test.domain" - p.mockUpdatePropertyVersionHostnames().Once() - // final read from the update function - mockResourcePropertyRead(p) + // terraform clean up - terraform test framework attempts to run destroy plan, if an error is returned on second step - // refresh - mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() + // activation and property deletion + // update current activations of given property + p.activations = papi.ActivationsItems{ + Items: []*papi.Activation{ + { + ActivationID: "act_123", + PropertyID: "prp_4", + PropertyVersion: 1, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + ActivationType: papi.ActivationTypeActivate, + SubmitDate: "2020-10-28T15:04:05Z", + NotifyEmails: []string{"dummy-user@akamai.com"}, + }, + }, + } + p.mockGetActivations() + // mock deactivate type activation for delete activation resource + p.createActivation = papi.Activation{ + ActivationID: "act_123", + ActivationType: papi.ActivationTypeDeactivate, + Network: papi.ActivationNetworkStaging, + Status: papi.ActivationStatusActive, + NotifyEmails: []string{"dummy-user@akamai.com"}, + PropertyVersion: 1, + } + // akamai_property_activation - delete + p.mockCreateActivation() + p.mockGetActivation() + // akamai_property - delete + p.mockRemoveProperty() }, - - configPathForUpdate: "testdata/TestGroupIDUpdate/update_group_id_and_hostnames.tf", - - updateChecks: resource.ComposeTestCheckFunc( - baseCheckName, - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_111"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_from", "from2.test.domain"), - commonBaseChecks), - }, - "update group id and name - recreate": { - init: func(t *testing.T, p *mockProperty, iamMock *iam.Mock) { - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - // second refresh - mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() - - // recreate the resource - p.propertyName = "dummy_name2" - p.groupID = "grp_111" - mockResourcePropertyCreate(p) - // refresh - mockResourcePropertyRead(p) - p.mockRemoveProperty().Once() + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf"), + Check: defaultChecker. + CheckEqual("rules", `{"rules":{"behaviors":[{"name":"cpCode","options":{"value":{"description":"WAA Example.com","id":12345,"name":"WAA Example.com","products":["Web_App_Accel"]}}}],"children":[{"behaviors":[{"name":"prefetch","options":{"enabled":false}}],"name":"Static Content","options":{}}],"name":"default","options":{"is_secure":true}}}`). + CheckEqual("name", "dxe-2406-issue-example"). + CheckEqual("hostnames.0.cname_to", "dxe-2406-issue-example-second.com.example.net"). + CheckEqual("hostnames.#", "2"). + Build(), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf"), + ExpectError: regexp.MustCompile("Error: updating hostnames: request failed:"), + }, }, - - configPathForUpdate: "testdata/TestGroupIDUpdate/update_group_id_and_name.tf", - - updateChecks: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "name", "dummy_name2"), - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_111"), - baseCheckCnameFrom, - commonBaseChecks), }, } + for name, test := range tests { t.Run(name, func(t *testing.T) { papiMock := &papi.Mock{} - iamMock := &iam.Mock{} mp := mockProperty{ - papiMock: papiMock, - mockPropertyData: baseData, + papiMock: papiMock, } - test.init(t, &mp, iamMock) + test.init(t, &mp) useClient(papiMock, nil, func() { - useIam(iamMock, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestGroupIDUpdate/base.tf"), - Check: resource.ComposeTestCheckFunc( - baseCheckName, - baseCheckGroupID, - baseCheckCnameFrom, - commonBaseChecks), - }, - { - Config: testutils.LoadFixtureString(t, test.configPathForUpdate), - Check: test.updateChecks, - }, - }, - }) + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: test.steps, }) }) papiMock.AssertExpectations(t) - iamMock.AssertExpectations(t) }) } } +// TestSchemaConfiguration tests errors when invalid HCL configuration is provided +func TestSchemaConfiguration(t *testing.T) { + assertConfigError := func(t *testing.T, flaw, rx string) func(t *testing.T) { + fixtureName := strings.ReplaceAll(flaw, " ", "_") + + return func(t *testing.T) { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, "testdata/TestResProperty/ConfigError/%s.tf", fixtureName), + ExpectError: regexp.MustCompile(rx), + }}, + }) + } + } + + t.Run("Schema Configuration Error: name not given", assertConfigError(t, "name not given", `"name" is required`)) + t.Run("Schema Configuration Error: contract_id not given", assertConfigError(t, "contract_id not given", `Missing required argument`)) + t.Run("Schema Configuration Error: group_id not given", assertConfigError(t, "group_id not given", `Missing required argument`)) + t.Run("Schema Configuration Error: product_id not given", assertConfigError(t, "product_id not given", `Missing required argument`)) + t.Run("Schema Configuration Error: invalid json rules", assertConfigError(t, "invalid json rules", `rules are not valid JSON`)) + t.Run("Schema Configuration Error: invalid name given", assertConfigError(t, "invalid name given", `a name must only contain letters, numbers, and these characters: . _ -`)) + t.Run("Schema Configuration Error: name given too long", assertConfigError(t, "name given too long", `a name must be longer than 0 characters and shorter than 86 characters`)) +} + // TODO: remove this test after moving property is enabled again, see DXE-4176 func TestGroupIDUpdateError(t *testing.T) { baseData := mockPropertyData{ @@ -1900,8 +2031,18 @@ func TestGroupIDUpdateError(t *testing.T) { propertyID: "prp_12345", latestVersion: 1, assetID: "aid_55555", - cnameFrom: "from.test.domain", - cnameTo: "to.test.domain", + hostnames: papi.HostnameResponseItems{ + Items: []papi.Hostname{ + { + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "", + CnameFrom: "from.test.domain", + CnameTo: "to.test.domain", + CertProvisioningType: "DEFAULT", + CertStatus: papi.CertStatusItem{}, + }, + }, + }, } papiMock := &papi.Mock{} @@ -1909,11 +2050,12 @@ func TestGroupIDUpdateError(t *testing.T) { papiMock: papiMock, mockPropertyData: baseData, } - mockResourcePropertyCreate(&mp) - // refresh - mockResourcePropertyRead(&mp) - // second refresh + mockResourcePropertyCreateWithVersionHostnames(&mp) + // read x2 + mockResourcePropertyRead(&mp, 2) + // read x1 before update mockResourcePropertyRead(&mp) + // delete mp.mockRemoveProperty().Once() useClient(papiMock, nil, func() { @@ -1922,14 +2064,15 @@ func TestGroupIDUpdateError(t *testing.T) { Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "testdata/TestGroupIDUpdate/base.tf"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("akamai_property.test", "name", "dummy_name"), - resource.TestCheckResourceAttr("akamai_property.test", "group_id", "grp_1"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_from", "from.test.domain"), - resource.TestCheckResourceAttr("akamai_property.test", "contract_id", "ctr_2"), - resource.TestCheckResourceAttr("akamai_property.test", "product_id", "prd_3"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cname_to", "to.test.domain"), - resource.TestCheckResourceAttr("akamai_property.test", "hostnames.0.cert_provisioning_type", "DEFAULT")), + Check: test.NewStateChecker("akamai_property.test"). + CheckEqual("name", "dummy_name"). + CheckEqual("group_id", "grp_1"). + CheckEqual("hostnames.0.cname_from", "from.test.domain"). + CheckEqual("contract_id", "ctr_2"). + CheckEqual("product_id", "prd_3"). + CheckEqual("hostnames.0.cname_to", "to.test.domain"). + CheckEqual("hostnames.0.cert_provisioning_type", "DEFAULT"). + Build(), }, { Config: testutils.LoadFixtureString(t, "testdata/TestGroupIDUpdate/update_group_id.tf"), @@ -1940,180 +2083,118 @@ func TestGroupIDUpdateError(t *testing.T) { }) } -func TestPropertyResource_versionNotesLifecycle(t *testing.T) { +func TestPropertyResource_VersionNotesLifecycle(t *testing.T) { testdataDir := "testdata/TestResProperty/Lifecycle/versionNotes" - resourceName := "akamai_property.test" - - name := "test_property" - ruleFormat := "v2023-01-05" - ctr, grp, prd, id := "ctr_123", "grp_123", "prd_123", "prp_123" - propertyVersion := 1 - versionNotes1, versionNotes2, versionNotes3 := "lifecycleTest", "updatedNotes", "updatedNotes2" - rulesFile1And2, rulesFile3, rulesFile4And5 := "01_02_rules.json", "03_rules.json", "04_05_rules.json" - - client := &papi.Mock{} - - mockRead := func(notes string, rules papi.Rules) testutils.MockCalls { - getPropertyCall := client.On("GetProperty", mock.Anything, papi.GetPropertyRequest{ - PropertyID: id, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.GetPropertyResponse{ - Property: &papi.Property{ - ContractID: ctr, - GroupID: grp, - PropertyID: id, - PropertyName: name, - LatestVersion: propertyVersion, - }, - }, nil) - - getHostnamesCall := client.On("GetPropertyVersionHostnames", mock.Anything, papi.GetPropertyVersionHostnamesRequest{ - ContractID: ctr, - GroupID: grp, - PropertyID: id, - PropertyVersion: propertyVersion, - IncludeCertStatus: true, - }).Return(&papi.GetPropertyVersionHostnamesResponse{}, nil) - - getRuleTreeCall := client.On("GetRuleTree", mock.Anything, papi.GetRuleTreeRequest{ - PropertyID: id, - ContractID: ctr, - GroupID: grp, - PropertyVersion: propertyVersion, - ValidateRules: true, - ValidateMode: papi.RuleValidateModeFull, - }).Return(&papi.GetRuleTreeResponse{ - Rules: rules, - Comments: notes, - RuleFormat: ruleFormat, - }, nil) - - getPropertyVersionCall := client.On("GetPropertyVersion", mock.Anything, papi.GetPropertyVersionRequest{ - PropertyID: id, - PropertyVersion: propertyVersion, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - Note: notes, - ProductID: prd, - ProductionStatus: papi.VersionStatusInactive, - StagingStatus: papi.VersionStatusInactive, - }, - }, nil) - - return testutils.MockCalls{getPropertyCall, getHostnamesCall, getRuleTreeCall, getPropertyVersionCall} - } - - mockUpdate := func(currentNotes, newNotes string, rules papi.Rules) { - client.On("GetPropertyVersion", mock.Anything, papi.GetPropertyVersionRequest{ - PropertyID: id, - PropertyVersion: propertyVersion, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - Note: currentNotes, - ProductID: prd, - ProductionStatus: papi.VersionStatusInactive, - StagingStatus: papi.VersionStatusInactive, - }, - }, nil).Once() - - client.On("UpdateRuleTree", mock.Anything, papi.UpdateRulesRequest{ - PropertyID: id, - GroupID: grp, - ContractID: ctr, - PropertyVersion: propertyVersion, - Rules: papi.RulesUpdate{ - Rules: rules, - Comments: newNotes, - }, - ValidateRules: true, - }).Return(&papi.UpdateRulesResponse{}, nil).Once() - } - - // step 1 - create + read + plan - client.On("CreateProperty", mock.Anything, papi.CreatePropertyRequest{ - ContractID: ctr, - GroupID: grp, - Property: papi.PropertyCreate{ - ProductID: prd, - PropertyName: name, - RuleFormat: ruleFormat, - }, - }).Return(&papi.CreatePropertyResponse{ - PropertyID: id, - }, nil).Once() + rulesFile1And2, rulesFile4And5, rulesFile3 := "01_02_rules.json", "04_05_rules.json", "03_rules.json" rulesJSON := testutils.LoadFixtureBytes(t, path.Join(testdataDir, rulesFile1And2)) var rules1And2 papi.RulesUpdate err := json.Unmarshal(rulesJSON, &rules1And2) require.NoError(t, err) - client.On("UpdateRuleTree", mock.Anything, papi.UpdateRulesRequest{ - PropertyID: id, - GroupID: grp, - ContractID: ctr, - PropertyVersion: propertyVersion, - Rules: papi.RulesUpdate{ - Rules: rules1And2.Rules, - Comments: versionNotes1, + checker := test.NewStateChecker("akamai_property.test"). + CheckEqual("id", "prp_123"). + CheckEqual("group_id", "grp_123"). + CheckEqual("contract_id", "ctr_123"). + CheckEqual("latest_version", "1") + + papiMock := &papi.Mock{} + basicData := mockPropertyData{ + propertyName: "test_property", + groupID: "grp_123", + contractID: "ctr_123", + productID: "prd_123", + propertyID: "prp_123", + latestVersion: 1, + assetID: "", + versions: papi.PropertyVersionItems{ + Items: []papi.PropertyVersionGetItem{ + { + StagingStatus: papi.VersionStatusInactive, + ProductionStatus: papi.VersionStatusInactive, + PropertyVersion: 1, + Note: versionNotes1, + }, + }, }, - ValidateRules: true, - }).Return(&papi.UpdateRulesResponse{}, nil).Once() + ruleTree: mockRuleTreeData{ + rules: rules1And2.Rules, + comments: versionNotes1, + ruleFormat: "v2023-01-05", + }, + } - mockRead(versionNotes1, rules1And2.Rules).Times(2) + prp := &mockProperty{ + mockPropertyData: basicData, + papiMock: papiMock, + } + + // --- step 1 --- + // create + prp.mockCreateProperty() + prp.mockUpdateRuleTree() + + // read x2 + mockResourcePropertyRead(prp, 2) - // step 2 - refresh + plan - mockRead(versionNotes2, rules1And2.Rules).Times(1) + // --- step 2 --- updated only notes - no triggered update + prp.versions.Items[0].Note = versionNotes2 + prp.ruleTree.comments = versionNotes2 - // step 3 - refresh + update + read + plan - mockRead(versionNotes2, rules1And2.Rules).Times(1) + // refresh x2 - no diff + mockResourcePropertyRead(prp, 2) + // --- step 3 --- var rules3 papi.RulesUpdate rulesJSON = testutils.LoadFixtureBytes(t, path.Join(testdataDir, rulesFile3)) err = json.Unmarshal(rulesJSON, &rules3) require.NoError(t, err) + // update with new notes and rules + prp.versions.Items[0].Note = versionNotes3 + prp.ruleTree.rules = rules3.Rules + prp.ruleTree.comments = versionNotes3 + mockResourcePropertyRead(prp) - mockUpdate(versionNotes3, "updatedNotes2", rules3.Rules) + prp.mockGetPropertyVersion() + prp.mockUpdateRuleTree() - mockRead(versionNotes3, rules3.Rules).Times(2) - - // step 4 - refresh + update + read + plan - mockRead(versionNotes3, rules3.Rules).Times(1) + // read x2 + mockResourcePropertyRead(prp, 2) + // --- step 4 --- + // update with new notes and rules var rules4And5 papi.RulesUpdate rulesJSON = testutils.LoadFixtureBytes(t, path.Join(testdataDir, rulesFile4And5)) err = json.Unmarshal(rulesJSON, &rules4And5) require.NoError(t, err) + prp.ruleTree.comments = rules4And5.Comments + prp.ruleTree.rules = rules4And5.Rules + prp.versions.Items[0].Note = rules4And5.Comments + mockResourcePropertyRead(prp) + prp.mockGetPropertyVersion() + prp.mockUpdateRuleTree() - mockUpdate(versionNotes3, rules4And5.Comments, rules4And5.Rules) - - mockRead(rules4And5.Comments, rules4And5.Rules).Times(2) + // read x2 + mockResourcePropertyRead(prp, 2) - // step 5 - refresh + plan - mockRead(rules4And5.Comments, rules4And5.Rules).Times(1) + // --- step 5 --- same config, no diff + // read x2 + mockResourcePropertyRead(prp, 2) - // cleanup - client.On("RemoveProperty", mock.Anything, papi.RemovePropertyRequest{ - PropertyID: id, - ContractID: ctr, - GroupID: grp, - }).Return(&papi.RemovePropertyResponse{}, nil) + // delete + prp.mockRemoveProperty() - useClient(client, nil, func() { + useClient(papiMock, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "01_with_notes_and_comments.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckResourceAttrJSON(resourceName, "rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "01_expected_rules.json"))), - resource.TestCheckResourceAttr("akamai_property.test", "version_notes", "lifecycleTest"), - ), + Check: checker. + CheckEqual("version_notes", "lifecycleTest"). + CheckEqual("rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "01_expected_rules.json"))). + Build(), }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "02_update_notes_no_diff.tf")), @@ -2121,17 +2202,17 @@ func TestPropertyResource_versionNotesLifecycle(t *testing.T) { }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "03_update_notes_and_rules.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckResourceAttrJSON(resourceName, "rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "03_expected_rules.json"))), - resource.TestCheckResourceAttr("akamai_property.test", "version_notes", "updatedNotes2"), - ), + Check: checker. + CheckEqual("version_notes", "updatedNotes2"). + CheckEqual("rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "03_expected_rules.json"))). + Build(), }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "04_05_remove_notes_update_comments.tf")), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckResourceAttrJSON(resourceName, "rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "04_expected_rules.json"))), - resource.TestCheckResourceAttr("akamai_property.test", "version_notes", "Rules_04"), - ), + Check: checker. + CheckEqual("version_notes", "Rules_04"). + CheckEqual("rules", testutils.LoadFixtureString(t, path.Join(testdataDir, "04_expected_rules.json"))). + Build(), }, { Config: testutils.LoadFixtureString(t, path.Join(testdataDir, "04_05_remove_notes_update_comments.tf")), @@ -2140,8 +2221,6 @@ func TestPropertyResource_versionNotesLifecycle(t *testing.T) { }, }) }) - - client.AssertExpectations(t) } func TestValidatePropertyName(t *testing.T) { diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf index ab7690ef8..1434ddf5c 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/contract_id_not_given.tf @@ -4,6 +4,6 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - product_id = "prd_0" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf index 563001ab0..0776e80e9 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/group_id_not_given.tf @@ -4,6 +4,6 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - product_id = "prd_0" + contract_id = "ctr_1" + product_id = "prd_3" } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf index 987bc1840..2a4a1895b 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_json_rules.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + group_id = "grp_2" + contract_id = "ctr_1" + product_id = "prd_3" rules = "abc" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf index c610bbb1a..562281569 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/invalid_name_given.tf @@ -4,7 +4,7 @@ provider "akamai" { resource "akamai_property" "test" { name = "invalid_name_@" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf index adc625338..c7fc5e281 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_given_too_long.tf @@ -4,7 +4,7 @@ provider "akamai" { resource "akamai_property" "test" { name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf index d3f34c9fc..a6ef4c620 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/name_not_given.tf @@ -3,7 +3,7 @@ provider "akamai" { } resource "akamai_property" "test" { - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } diff --git a/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf b/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf index 302298122..6f3cbb8b5 100644 --- a/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf +++ b/pkg/providers/property/testdata/TestResProperty/ConfigError/product_id_not_given.tf @@ -4,6 +4,6 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" + contract_id = "ctr_1" + group_id = "grp_2" } diff --git a/pkg/providers/property/testdata/TestResProperty/Creation/property.tf b/pkg/providers/property/testdata/TestResProperty/Creation/property.tf index b9730bec7..ca1fd4420 100644 --- a/pkg/providers/property/testdata/TestResProperty/Creation/property.tf +++ b/pkg/providers/property/testdata/TestResProperty/Creation/property.tf @@ -4,8 +4,8 @@ provider "akamai" { resource "akamai_property" "prop" { - name = "property_name" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf index 0894ac5b8..bf340c6de 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property.tf @@ -6,11 +6,11 @@ data "akamai_property_rules_template" "akarules" { template_file = "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/create/property-snippets/rules.json" } -resource "akamai_property" "akaproperty" { +resource "akamai_property" "test" { name = "dxe-2406-issue-example" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "dxe-2406-issue-example-second.com.example.net" cname_from = "dxe-2406-issue-example-second.com" @@ -28,6 +28,6 @@ resource "akamai_property" "akaproperty" { resource "akamai_property_activation" "aka_property_activate" { contact = ["dummy-user@akamai.com"] network = "STAGING" - property_id = akamai_property.akaproperty.id - version = akamai_property.akaproperty.latest_version + property_id = akamai_property.test.id + version = akamai_property.test.latest_version } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf index b59a450b9..e55ca368f 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property.tf @@ -6,11 +6,11 @@ data "akamai_property_rules_template" "akarules" { template_file = "testdata/TestResProperty/CreationUpdateIncorrectEdgeHostname/update/property-snippets/rules.json" } -resource "akamai_property" "akaproperty" { +resource "akamai_property" "test" { name = "dxe-2406-issue-example" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "dxe-2406-issue-example-second.com.example.net" cname_from = "dxe-2406-issue-example-second.com" @@ -33,6 +33,6 @@ resource "akamai_property" "akaproperty" { resource "akamai_property_activation" "aka_property_activate" { contact = ["dummy-user@akamai.com"] network = "STAGING" - property_id = akamai_property.akaproperty.id - version = akamai_property.akaproperty.latest_version + property_id = akamai_property.test.id + version = akamai_property.test.latest_version } \ No newline at end of file diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf index 8f918efa1..c083aca14 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/creation/property_create.tf @@ -20,17 +20,17 @@ resource "akamai_property" "test" { variable "groupid" { description = "Name of the group associated with this property" - default = "grp_0" + default = "grp_2" } variable "contractid" { description = "Contract ID associated with this property" - default = "ctr_0" + default = "ctr_1" } variable "productid" { description = "Name of the product used to configure this property" - default = "prd_0" + default = "prd_3" } variable "propertyname" { diff --git a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf index 7d1fb4d46..a6ad1491b 100644 --- a/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf +++ b/pkg/providers/property/testdata/TestResProperty/CreationUpdateNoHostnames/update/property_update.tf @@ -15,17 +15,17 @@ resource "akamai_property" "test" { variable "groupid" { description = "Name of the group associated with this property" - default = "grp_0" + default = "grp_2" } variable "contractid" { description = "Contract ID associated with this property" - default = "ctr_0" + default = "ctr_1" } variable "productid" { description = "Name of the product used to configure this property" - default = "prd_0" + default = "prd_3" } variable "propertyname" { diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf deleted file mode 100644 index 416e92125..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step1.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract = "0" - group_id = "grp_0" - product_id = "prd_0" - - hostnames { - cname_to = "to2.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf index d302c7fb0..8779241a7 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf index 5b9a64878..68429a323 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract_id without prefix/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step0.tf similarity index 79% rename from pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step0.tf index f6adb0e3e..bef0fe547 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step1.tf similarity index 80% rename from pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step1.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step1.tf index 005957624..72e1e25c1 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_is_destroyed_and_recreated_when_name_is_changed-step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/forceNewOnNameChange/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "renamed_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf deleted file mode 100644 index 613a77357..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step1.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group = "0" - product_id = "prd_0" - - hostnames { - cname_to = "to2.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step0.tf similarity index 80% rename from pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step0.tf index 6b22b46c5..171fc92e3 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step0.tf @@ -4,14 +4,13 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product = "0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" cert_provisioning_type = "DEFAULT" } - } diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf new file mode 100644 index 000000000..6143e388b --- /dev/null +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/step1.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_property" "test" { + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_222" + product_id = "prd_3" + + hostnames { + cname_to = "to.test.domain" + cname_from = "from.test.domain" + cert_provisioning_type = "DEFAULT" + } +} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step0.tf similarity index 80% rename from pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step0.tf index 76313fcce..171fc92e3 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step0.tf @@ -4,14 +4,13 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group = "0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" cert_provisioning_type = "DEFAULT" } - } diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf new file mode 100644 index 000000000..050ff3207 --- /dev/null +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withHostnames/step1.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_property" "test" { + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_222" + product_id = "prd_3" + + hostnames { + cname_to = "to.test.domain" + cname_from = "from2.test.domain" + cert_provisioning_type = "DEFAULT" + } +} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step0.tf similarity index 71% rename from pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step0.tf rename to pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step0.tf index 339719108..171fc92e3 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/contract without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step0.tf @@ -3,15 +3,14 @@ provider "akamai" { } resource "akamai_property" "test" { - name = "test_property" - contract = "0" - group_id = "grp_0" - product_id = "prd_0" + name = "test_property" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" cname_from = "from.test.domain" cert_provisioning_type = "DEFAULT" } - } diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf new file mode 100644 index 000000000..a93aadc03 --- /dev/null +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/groupIDUpdate/withName/step1.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_property" "test" { + name = "dummy_name2" + contract_id = "ctr_1" + group_id = "grp_222" + product_id = "prd_3" + + hostnames { + cname_to = "to.test.domain" + cname_from = "from.test.domain" + cert_provisioning_type = "DEFAULT" + } +} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf index f5b017c50..b6f905105 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf index bdcf7ff9a..9c2578edf 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/group_id without prefix/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf index 8ad44067f..c1181a481 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to1.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf index 861115922..925bb126f 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/hostnames/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf index 0ad095277..367a24127 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/new version changed on server/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf index 133ee1144..eb41d388c 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.akarules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf index b3e4efd8a..35f6e0af8 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/no diff/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.akarules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf index 0ad095277..367a24127 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf index 2257fe2a6..b3bb0ac95 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/normal/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf deleted file mode 100644 index 1ccc9f023..000000000 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product without prefix/step1.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_property" "test" { - name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product = "0" - - hostnames { - cname_to = "to2.test.domain" - cname_from = "from.test.domain" - cert_provisioning_type = "DEFAULT" - } -} diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf index b0122f5f5..525b8951a 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf index d40e358ed..4e568c189 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/product_id without prefix/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "3" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf index 27a7ef95f..624ff7557 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.rules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf index 75e8e0e66..9891f4382 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules custom diff/step1.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.rules.json diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf index 088113c23..098aad8b8 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules diff cpcode/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = data.akamai_property_rules_template.rules.json hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf index d6e318787..62372f6cd 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step0.tf @@ -3,10 +3,10 @@ provider "akamai" { } resource "akamai_property" "test" { - contract_id = "ctr_0" - group_id = "grp_0" name = "test_property" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = jsonencode( { "rules" : { diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf index 4a44b64a4..df829d446 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/rules with variables/step1.tf @@ -3,10 +3,10 @@ provider "akamai" { } resource "akamai_property" "test" { - contract_id = "ctr_0" - group_id = "grp_0" name = "test_property" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" rules = jsonencode( { "rules" : { diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf index 04b57b61f..72337a4bc 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step0.tf @@ -4,10 +4,10 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" - property_id = "prp_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" + property_id = "prp_4" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf index 8e3489304..dd4a8ba2b 100644 --- a/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf +++ b/pkg/providers/property/testdata/TestResProperty/Lifecycle/with-propertyID/step1.tf @@ -4,10 +4,10 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" - property_id = "prp_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" + property_id = "prp_4" hostnames { cname_to = "to2.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf b/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf index 897b9ca49..73f22d658 100644 --- a/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf +++ b/pkg/providers/property/testdata/TestResProperty/error_when_creating_property_with_non-unique_name.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "ctr_0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf b/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf index d302c7fb0..8779241a7 100644 --- a/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf +++ b/pkg/providers/property/testdata/TestResProperty/error_when_deleting_active_property/step0.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - contract_id = "0" - group_id = "grp_0" - product_id = "prd_0" + contract_id = "1" + group_id = "grp_2" + product_id = "prd_3" hostnames { cname_to = "to.test.domain" diff --git a/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf b/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf index b7ea3909e..6e955eab7 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf +++ b/pkg/providers/property/testdata/TestResProperty/property_update_with_validation_error_for_rules.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" # Fetch the newly created property depends_on = [ akamai_property.test diff --git a/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf b/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf index 92a3bc333..6e736e616 100644 --- a/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf +++ b/pkg/providers/property/testdata/TestResProperty/property_with_validation_warning_for_rules.tf @@ -4,9 +4,9 @@ provider "akamai" { resource "akamai_property" "test" { name = "test_property" - group_id = "grp_0" - contract_id = "ctr_0" - product_id = "prd_0" + contract_id = "ctr_1" + group_id = "grp_2" + product_id = "prd_3" # Fetch the newly created property depends_on = [ akamai_property.test From 3ce805e0ec0b5a4ecd8e513aa401a61905cf2182 Mon Sep 17 00:00:00 2001 From: "Zagrajczuk, Wojciech" Date: Tue, 3 Sep 2024 16:21:22 +0200 Subject: [PATCH 06/54] DXE-4184 Fix for retriable library to fix empty body during resign --- pkg/retryablehttp/client.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/retryablehttp/client.go b/pkg/retryablehttp/client.go index c8fe8f453..29c6661ed 100644 --- a/pkg/retryablehttp/client.go +++ b/pkg/retryablehttp/client.go @@ -651,6 +651,14 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } } + // First attempt was already signed + if attempt > 1 { + if err := c.PrepareRetry(req.Request); err != nil { + prepareErr = err + break + } + } + if c.RequestLogHook != nil { switch v := logger.(type) { case LeveledLogger: @@ -742,10 +750,6 @@ func (c *Client) Do(req *Request) (*http.Response, error) { httpreq := *req.Request req.Request = &httpreq - if err := c.PrepareRetry(req.Request); err != nil { - prepareErr = err - break - } } // this is the closest we have to success criteria From 0fc0e394902e0372bf308037cbfed25cbb359453 Mon Sep 17 00:00:00 2001 From: Piotr Bartosik Date: Wed, 17 Jul 2024 13:35:38 +0000 Subject: [PATCH 07/54] DXE-3910 handle retries for 429 code with X-RateLimit-Next --- CHANGELOG.md | 15 ++ internal/test/test.go | 89 ++++++++ pkg/akamai/configure_context.go | 102 +++++++-- pkg/akamai/configure_context_test.go | 304 +++++++++++++++++++++++++++ 4 files changed, 496 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 126ab5afa..f9af362e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -210,6 +210,21 @@ * Added new optional field `ttl` to `akamai_edge_hostname` resource. When it is used, creation or update takes longer as resource has to synchronize its state with HAPI. + + + + + +* PAPI + * Added support for status code `429 Too Many Requests` containing `X-RateLimit-Next` header. + When `X-RateLimit-Next` is present, the wait time before retry is calculated as the time + difference between this header and the `Date` header. + + + + + + #### BUG FIXES: * Appsec diff --git a/internal/test/test.go b/internal/test/test.go index 7c8210fbf..f9c4191df 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -2,9 +2,13 @@ package test import ( + "math/rand" + "net/http" + "sync" "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -15,3 +19,88 @@ func NewTimeFromString(t *testing.T, s string) time.Time { require.NoError(t, err) return parsedTime } + +// XRateLimitHTTPHandler first returns status 429 with the X-RateLimit-Next header set to +// time.Now() plus a random value between 1 and 5 seconds. It keeps sending 429 until the +// X-RateLimit-Next point in time. Then it starts to return SuccessCode and SuccessBody +// indefinitely. +type XRateLimitHTTPHandler struct { + T *testing.T + SuccessCode int + SuccessBody string + + mutex sync.Mutex + availableAt time.Time + returnedCodes []int + returnTimes []time.Time +} + +func (h *XRateLimitHTTPHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { + av := h.AvailableAt() + + if av.IsZero() { + busyInterval := time.Duration(1+rand.Intn(4)) * time.Second + h.setAvailableAt(time.Now().Add(busyInterval)) + h.setTooManyRequests(w) + return + } + + now := time.Now() + if now.Before(av) { + h.setTooManyRequests(w) + } else { + h.setStatusCode(w, h.SuccessCode) + _, err := w.Write([]byte(h.SuccessBody)) + assert.NoError(h.T, err) + } +} + +// AvailableAt returns the point in time at which the handler stops returning status code 429 +func (h *XRateLimitHTTPHandler) AvailableAt() time.Time { + h.mutex.Lock() + defer h.mutex.Unlock() + return h.availableAt +} + +// ReturnedCodes returns a list of status codes from subsequent handler responses +func (h *XRateLimitHTTPHandler) ReturnedCodes() []int { + h.mutex.Lock() + defer h.mutex.Unlock() + res := make([]int, len(h.returnedCodes)) + copy(res, h.returnedCodes) + return res +} + +// ReturnTimes returns a list of times at which subsequent responses were written +func (h *XRateLimitHTTPHandler) ReturnTimes() []time.Time { + h.mutex.Lock() + defer h.mutex.Unlock() + res := make([]time.Time, len(h.returnTimes)) + copy(res, h.returnTimes) + return res +} + +func (h *XRateLimitHTTPHandler) setTooManyRequests(w http.ResponseWriter) { + // Do not use Add() to avoid canonicalization to X-Ratelimit-Next + nextStr := h.availableAt.Format(time.RFC3339Nano) + w.Header()["X-RateLimit-Next"] = []string{nextStr} + h.setStatusCode(w, http.StatusTooManyRequests) + body := "Your request did not succeed as this operation has reached the limit " + + "for your account. Please try after " + nextStr + _, err := w.Write([]byte(body)) + assert.NoError(h.T, err) +} + +func (h *XRateLimitHTTPHandler) setStatusCode(w http.ResponseWriter, statusCode int) { + w.WriteHeader(statusCode) + h.mutex.Lock() + defer h.mutex.Unlock() + h.returnedCodes = append(h.returnedCodes, statusCode) + h.returnTimes = append(h.returnTimes, time.Now()) +} + +func (h *XRateLimitHTTPHandler) setAvailableAt(availableAt time.Time) { + h.mutex.Lock() + defer h.mutex.Unlock() + h.availableAt = availableAt +} diff --git a/pkg/akamai/configure_context.go b/pkg/akamai/configure_context.go index 0dcfcf19e..dc68c220b 100644 --- a/pkg/akamai/configure_context.go +++ b/pkg/akamai/configure_context.go @@ -16,6 +16,7 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/retryablehttp" + "github.com/apex/log" "github.com/google/uuid" "github.com/spf13/cast" ) @@ -62,6 +63,90 @@ func sessionWithoutRetry(opts []session.Option) (session.Session, error) { return session.New(opts...) } +func overrideRetryPolicy(basePolicy retryablehttp.CheckRetry) retryablehttp.CheckRetry { + return func(ctx context.Context, resp *http.Response, err error) (bool, error) { + + // do not retry on context.Canceled or context.DeadlineExceeded + if ctx.Err() != nil { + return false, ctx.Err() + } + + // Retry all PAPI requests resulting status code 429 + // The backoff time is calculated in getXRateLimitBackoff + is429 := resp != nil && resp.StatusCode == http.StatusTooManyRequests + if is429 && strings.HasPrefix(resp.Request.URL.Path, "/papi/") { + return true, nil + } + + var urlErr *url.Error + if (resp != nil && resp.Request.Method == http.MethodGet) || + (resp == nil && errors.As(err, &urlErr) && strings.ToUpper(urlErr.Op) == http.MethodGet) { + + if resp != nil && resp.StatusCode == http.StatusConflict { + return true, nil + } + return basePolicy(ctx, resp, err) + } + return false, nil + } +} + +// Note that Date's resolution is seconds (e.g. Mon, 01 Jul 2024 14:32:14 GMT), +// while X-RateLimit-Next's resolution is milliseconds (2024-07-01T14:32:28.645Z). +// This may cause the wait time to be inflated by at most one second, like for the +// actual server response time around 2024-07-01T14:32:14.999Z. This is acceptable behavior +// as retry does not occur earlier than expected. +func getXRateLimitBackoff(resp *http.Response, logger log.Interface) (time.Duration, bool) { + nextHeader := resp.Header.Get("X-RateLimit-Next") + if nextHeader == "" { + return 0, false + } + next, err := time.Parse(time.RFC3339Nano, nextHeader) + if err != nil { + if logger != nil { + logger.WithError(err).Error("Could not parse X-RateLimit-Next header") + } + return 0, false + } + + dateHeader := resp.Header.Get("Date") + if dateHeader == "" { + if logger != nil { + logger.Warnf("No Date header for X-RateLimit-Next: %s", nextHeader) + } + return 0, false + } + date, err := time.Parse(time.RFC1123, dateHeader) + if err != nil { + if logger != nil { + logger.WithError(err).Error("Could not parse Date header") + } + return 0, false + } + + // Next in the past does not make sense + if next.Before(date) { + if logger != nil { + logger.Warnf("X-RateLimit-Next: %s before Date: %s", nextHeader, dateHeader) + } + return 0, false + } + return next.Sub(date), true +} + +func overrideBackoff(baseBackoff retryablehttp.Backoff, logger log.Interface) retryablehttp.Backoff { + return func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { + if resp != nil { + if resp.StatusCode == http.StatusTooManyRequests { + if wait, ok := getXRateLimitBackoff(resp, logger); ok { + return wait + } + } + } + return baseBackoff(min, max, attemptNum, resp) + } +} + func sessionWithRetry(cfg contextConfig, opts []session.Option) (session.Session, error) { if cfg.retryMax == 0 { cfg.retryMax = 10 @@ -97,20 +182,9 @@ func sessionWithRetry(cfg contextConfig, opts []session.Option) (session.Session return sess.Sign(req) } - retryClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) { - var urlErr *url.Error - if (resp != nil && resp.Request.Method == http.MethodGet) || - (resp == nil && errors.As(err, &urlErr) && strings.ToUpper(urlErr.Op) == http.MethodGet) { - if ctx.Err() != nil { - return false, ctx.Err() - } - if resp != nil && resp.StatusCode == http.StatusConflict { - return true, nil - } - return retryablehttp.DefaultRetryPolicy(ctx, resp, err) - } - return false, nil - } + retryClient.CheckRetry = overrideRetryPolicy(retryablehttp.DefaultRetryPolicy) + + retryClient.Backoff = overrideBackoff(retryablehttp.DefaultBackoff, sess.Log(cfg.ctx)) return sess, nil } diff --git a/pkg/akamai/configure_context_test.go b/pkg/akamai/configure_context_test.go index 2d318a0f9..19210cc32 100644 --- a/pkg/akamai/configure_context_test.go +++ b/pkg/akamai/configure_context_test.go @@ -1,10 +1,24 @@ package akamai import ( + "context" + "crypto/tls" + "crypto/x509" + "errors" + "net/http" + "net/http/httptest" + "net/url" + "strings" "testing" "time" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/retryablehttp" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func Test_validateRetryConfiguration(t *testing.T) { @@ -101,3 +115,293 @@ func Test_validateRetryConfiguration(t *testing.T) { }) } } + +func newRequest(t *testing.T, method, url string) *http.Request { + r, err := http.NewRequest(method, url, nil) + assert.NoError(t, err) + return r +} + +func TestOverrideRetryPolicy(t *testing.T) { + basePolicy := func(ctx context.Context, resp *http.Response, err error) (bool, error) { + return false, errors.New("base policy: dummy, not implemented") + } + policy := overrideRetryPolicy(basePolicy) + + tests := map[string]struct { + ctx context.Context + resp *http.Response + err error + expectedResult bool + expectedError string + }{ + "should retry for PAPI GET with status 429": { + ctx: context.Background(), + resp: &http.Response{ + Request: newRequest(t, http.MethodGet, "/papi/v1/sth"), + StatusCode: http.StatusTooManyRequests, + }, + expectedResult: true, + }, + "should retry for PAPI POST with status 429": { + ctx: context.Background(), + resp: &http.Response{ + Request: newRequest(t, http.MethodPost, "/papi/v1/sth"), + StatusCode: http.StatusTooManyRequests, + }, + expectedResult: true, + }, + "should not retry for PAPI POST with other 4xx status": { + ctx: context.Background(), + resp: &http.Response{ + Request: newRequest(t, http.MethodPost, "/papi/v1/sth"), + StatusCode: http.StatusBadRequest, + }, + expectedResult: false, + }, + "should retry for GET with status 409 conflict": { + ctx: context.Background(), + resp: &http.Response{ + Request: &http.Request{Method: http.MethodGet}, + StatusCode: http.StatusConflict, + }, + expectedResult: true, + }, + "should call base policy for other GETs": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodGet}}, + expectedError: "base policy: dummy, not implemented", + }, + "should forward context error when present": { + ctx: func() context.Context { + ctx, cancel := context.WithCancel(context.Background()) + cancel() + return ctx + }(), + resp: &http.Response{Request: &http.Request{Method: http.MethodGet}}, + expectedError: "context canceled", + }, + "should not retry for POST": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodPost}}, + expectedResult: false, + }, + "should not retry for PUT": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodPut}}, + expectedResult: false, + }, + "should not retry for PATCH": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodPatch}}, + expectedResult: false, + }, + "should not retry for HEAD": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodHead}}, + expectedResult: false, + }, + "should not retry for DELETE": { + ctx: context.Background(), + resp: &http.Response{Request: &http.Request{Method: http.MethodDelete}}, + expectedResult: false, + }, + } + for name, tst := range tests { + t.Run(name, func(t *testing.T) { + shouldRetry, err := policy(tst.ctx, tst.resp, tst.err) + if len(tst.expectedError) > 0 { + assert.ErrorContains(t, err, tst.expectedError) + } else { + assert.NoError(t, err) + assert.Equal(t, tst.expectedResult, shouldRetry) + } + }) + } +} + +func stat429ResponseWaiting(wait time.Duration) *http.Response { + res := http.Response{ + StatusCode: http.StatusTooManyRequests, + Header: http.Header{}, + } + + now := time.Now().UTC().Round(time.Second) + date := strings.Replace(now.Format(time.RFC1123), "UTC", "GMT", 1) + res.Header.Add("Date", date) + if wait != 0 { + // Add: allow to canonicalize to X-Ratelimit-Next or the header won't be recognized + res.Header.Add("X-RateLimit-Next", now.Add(wait).Format(time.RFC3339Nano)) + } + return &res +} + +func Test_overrideBackoff(t *testing.T) { + baseWait := time.Duration(24) * time.Hour + baseBackoff := func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { + return baseWait + } + backoff := overrideBackoff(baseBackoff, nil) + + tests := map[string]struct { + resp *http.Response + expectedResult time.Duration + }{ + "correctly calculates backoff from X-RateLimit-Next": { + resp: stat429ResponseWaiting(time.Duration(5729) * time.Millisecond), + expectedResult: time.Duration(5729) * time.Millisecond, + }, + "falls back for next in the past": { + resp: stat429ResponseWaiting(-time.Duration(5729) * time.Millisecond), + expectedResult: baseWait, + }, + "falls back for no X-RateLimit-Next header": { + resp: stat429ResponseWaiting(0), + expectedResult: baseWait, + }, + "falls back for invalid X-RateLimit-Next header": { + resp: func() *http.Response { + r := stat429ResponseWaiting(time.Duration(5729) * time.Millisecond) + r.Header.Set("X-RateLimit-Next", "2024-07-01T14:32:28.645???") + return r + }(), + expectedResult: baseWait, + }, + "falls back for no Date header": { + resp: func() *http.Response { + r := stat429ResponseWaiting(time.Duration(5729) * time.Millisecond) + r.Header.Del("Date") + return r + }(), + expectedResult: baseWait, + }, + "falls back for invalid Date header": { + resp: func() *http.Response { + r := stat429ResponseWaiting(time.Duration(5729) * time.Millisecond) + r.Header.Set("Date", "Mon, 01 Jul 2024 99:99:99 GMT") + return r + }(), + expectedResult: baseWait, + }, + } + for name, tst := range tests { + t.Run(name, func(t *testing.T) { + wait := backoff(1, 30, 1, tst.resp) + assert.Equal(t, tst.expectedResult, wait) + }) + } +} + +func mockSession(t *testing.T, mockServer *httptest.Server) session.Session { + serverURL, err := url.Parse(mockServer.URL) + require.NoError(t, err) + config := edgegrid.Config{Host: serverURL.Host} + + meta, err := configureContext(contextConfig{ + edgegridConfig: &config, + ctx: context.Background(), + }) + assert.NoError(t, err) + + certPool := x509.NewCertPool() + certPool.AddCert(mockServer.Certificate()) + rt := meta.Session().Client().Transport.(*retryablehttp.RoundTripper) + transport := rt.Client.HTTPClient.Transport.(*http.Transport) + transport.TLSClientConfig = &tls.Config{ + RootCAs: certPool, + } + + return meta.Session() +} + +func TestXRateLimitGet(t *testing.T) { + xrlHandler := test.XRateLimitHTTPHandler{ + T: t, + SuccessCode: http.StatusOK, + SuccessBody: ` + { + "properties": { + "items": [ + { + "accountId": "dummy_account_id", + "contractId": "ctr_test1", + "groupId": "grp_test1", + "propertyId": "prp_test1", + "propertyName": "my_property", + "latestVersion": 1, + "stagingVersion": null, + "productionVersion": null, + "assetId": "12345678" + } + ] + } + }`, + } + + mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/papi/v1/properties/prp_test1?contractId=ctr_test1&groupId=grp_test1", r.URL.String()) + assert.Equal(t, http.MethodGet, r.Method) + xrlHandler.ServeHTTP(w, r) + })) + defer mockServer.Close() + + client := papi.Client(mockSession(t, mockServer)) + result, err := client.GetProperty(context.Background(), papi.GetPropertyRequest{ + ContractID: "ctr_test1", + GroupID: "grp_test1", + PropertyID: "prp_test1", + }) + require.NoError(t, err) + assert.Equal(t, "my_property", result.Property.PropertyName) + // We expect exactly two requests to the server: + // - the first resulting in code 429 + // - the second after a proper backoff, resulting in status 200 + assert.Equal(t, []int{http.StatusTooManyRequests, http.StatusOK}, xrlHandler.ReturnedCodes()) + assert.Less(t, + xrlHandler.ReturnTimes()[1], + xrlHandler.AvailableAt().Add(time.Duration(time.Millisecond)*1100)) +} + +func TestXRateLimitPost(t *testing.T) { + xrlHandler := test.XRateLimitHTTPHandler{ + T: t, + SuccessCode: http.StatusCreated, + SuccessBody: ` + { + "activationLink": "/papi/v1/properties/prp_12345/activations/dummy_activation?contractId=ctr_test1&groupId=grp_test1" + }`, + } + + mockServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/papi/v1/properties/prp_12345/activations?contractId=ctr_test1&groupId=grp_test1", r.URL.String()) + assert.Equal(t, http.MethodPost, r.Method) + xrlHandler.ServeHTTP(w, r) + })) + defer mockServer.Close() + + client := papi.Client(mockSession(t, mockServer)) + result, err := client.CreateActivation(context.Background(), papi.CreateActivationRequest{ + PropertyID: "prp_12345", + ContractID: "ctr_test1", + GroupID: "grp_test1", + Activation: papi.Activation{ + PropertyVersion: 1, + Network: papi.ActivationNetworkStaging, + UseFastFallback: false, + NotifyEmails: []string{ + "you@example.com", + "them@example.com", + }, + AcknowledgeWarnings: []string{"foobarbaz"}, + }, + }) + require.NoError(t, err) + assert.Equal(t, "dummy_activation", result.ActivationID) + // We expect exactly two requests to the server: + // - the first resulting in code 429 + // - the second after a proper backoff, resulting in status 201 + assert.Equal(t, []int{http.StatusTooManyRequests, http.StatusCreated}, xrlHandler.ReturnedCodes()) + assert.Less(t, + xrlHandler.ReturnTimes()[1], + xrlHandler.AvailableAt().Add(time.Duration(time.Millisecond)*1100)) +} From 4594d426a54e68b2bf23ee78e13ab76d657f8edb Mon Sep 17 00:00:00 2001 From: "Dzhafarov, Dawid" Date: Fri, 13 Sep 2024 13:28:56 +0200 Subject: [PATCH 08/54] DXE-4184 Add unit test for POST retries using request body --- CHANGELOG.md | 19 ++------ internal/test/test.go | 4 +- pkg/retryablehttp/client.go | 2 +- pkg/retryablehttp/client_test.go | 77 +++++++++++++++++++++++++++++--- 4 files changed, 79 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9af362e4..86db31a70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,10 @@ +* PAPI + * Added support for status code `429 Too Many Requests` containing `X-RateLimit-Next` header. + When `X-RateLimit-Next` is present, the wait time before retry is calculated as the time + difference between this header and the `Date` header. @@ -210,21 +214,6 @@ * Added new optional field `ttl` to `akamai_edge_hostname` resource. When it is used, creation or update takes longer as resource has to synchronize its state with HAPI. - - - - - -* PAPI - * Added support for status code `429 Too Many Requests` containing `X-RateLimit-Next` header. - When `X-RateLimit-Next` is present, the wait time before retry is calculated as the time - difference between this header and the `Date` header. - - - - - - #### BUG FIXES: * Appsec diff --git a/internal/test/test.go b/internal/test/test.go index f9c4191df..e6c811ff3 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -21,7 +21,7 @@ func NewTimeFromString(t *testing.T, s string) time.Time { } // XRateLimitHTTPHandler first returns status 429 with the X-RateLimit-Next header set to -// time.Now() plus a random value between 1 and 5 seconds. It keeps sending 429 until the +// time.Now() plus a random value between 1 and 5 milliseconds. It keeps sending 429 until the // X-RateLimit-Next point in time. Then it starts to return SuccessCode and SuccessBody // indefinitely. type XRateLimitHTTPHandler struct { @@ -39,7 +39,7 @@ func (h *XRateLimitHTTPHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request av := h.AvailableAt() if av.IsZero() { - busyInterval := time.Duration(1+rand.Intn(4)) * time.Second + busyInterval := time.Duration(1+rand.Intn(4)) * time.Millisecond h.setAvailableAt(time.Now().Add(busyInterval)) h.setTooManyRequests(w) return diff --git a/pkg/retryablehttp/client.go b/pkg/retryablehttp/client.go index 29c6661ed..ad3328491 100644 --- a/pkg/retryablehttp/client.go +++ b/pkg/retryablehttp/client.go @@ -652,7 +652,7 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } // First attempt was already signed - if attempt > 1 { + if attempt > 1 && c.PrepareRetry != nil { if err := c.PrepareRetry(req.Request); err != nil { prepareErr = err break diff --git a/pkg/retryablehttp/client_test.go b/pkg/retryablehttp/client_test.go index a751d3fd2..66e0f0ed0 100644 --- a/pkg/retryablehttp/client_test.go +++ b/pkg/retryablehttp/client_test.go @@ -6,6 +6,8 @@ package retryablehttp import ( "bytes" "context" + "crypto/sha256" + "encoding/base64" "errors" "fmt" "io" @@ -373,6 +375,22 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { client.PrepareRetry = func(req *http.Request) error { prepareChecks++ req.Header.Set("foo", strconv.Itoa(prepareChecks)) + + // if the method is POST or PUT, set a header based on request body content + if req.Method == "POST" || req.Method == "PUT" { + bodyBytes, err := io.ReadAll(req.Body) + if err != nil { + t.Fatalf("could not read request body: %s", err) + } + preparedBody := string(bodyBytes) + + if len(preparedBody) > 0 { + sum := sha256.Sum256([]byte(preparedBody)) + contentHash := base64.StdEncoding.EncodeToString(sum[:]) + req.Header.Set("content_hash", contentHash) + } + } + return nil } @@ -385,6 +403,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { var shouldSucceed bool tests := []struct { name string + method string + requestBody string handler ResponseHandlerFunc expectedChecks int // often 2x number of attempts since we check twice expectedPrepareChecks int @@ -392,12 +412,14 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { }{ { name: "nil handler", + method: http.MethodGet, handler: nil, expectedChecks: 1, expectedPrepareChecks: 0, }, { - name: "handler always succeeds", + name: "handler always succeeds", + method: http.MethodGet, handler: func(*http.Response) error { return nil }, @@ -405,7 +427,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedPrepareChecks: 0, }, { - name: "handler always fails in a retryable way", + name: "handler always fails in a retryable way", + method: http.MethodGet, handler: func(*http.Response) error { return errors.New("retryable failure") }, @@ -413,7 +436,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedPrepareChecks: 2, }, { - name: "handler always fails in a nonretryable way", + name: "handler always fails in a nonretryable way", + method: http.MethodGet, handler: func(*http.Response) error { return errors.New("nonretryable failure") }, @@ -421,7 +445,8 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedPrepareChecks: 0, }, { - name: "handler succeeds on second attempt", + name: "handler succeeds on second attempt", + method: http.MethodGet, handler: func(*http.Response) error { if shouldSucceed { return nil @@ -432,6 +457,34 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { expectedChecks: 4, expectedPrepareChecks: 1, }, + { + name: "POST - handler succeeds on second attempt, using body for PrepareRetry", + method: http.MethodPost, + requestBody: "dummy data", + handler: func(response *http.Response) error { + if shouldSucceed { + return nil + } + shouldSucceed = true + return errors.New("retryable failure") + }, + expectedChecks: 4, + expectedPrepareChecks: 1, + }, + { + name: "PUT - handler succeeds on second attempt, using body for PrepareRetry", + method: http.MethodPut, + requestBody: "dummy data", + handler: func(response *http.Response) error { + if shouldSucceed { + return nil + } + shouldSucceed = true + return errors.New("retryable failure") + }, + expectedChecks: 4, + expectedPrepareChecks: 1, + }, } for _, tt := range tests { @@ -439,8 +492,16 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { checks = 0 prepareChecks = 0 shouldSucceed = false + var req *Request + var err error + // Create the request - req, err := NewRequest("GET", ts.URL, nil) + if tt.requestBody != "" { + req, err = NewRequest(tt.method, ts.URL, strings.NewReader(tt.requestBody)) + } else { + req, err = NewRequest(tt.method, ts.URL, nil) + } + if err != nil { t.Fatalf("err: %v", err) } @@ -471,6 +532,12 @@ func TestClient_Do_WithPrepareRetry(t *testing.T) { t.Fatalf("expected changes in request header 'foo' '%s', but got '%s'", expectedHeader, header) } + if tt.method == "POST" || tt.method == "PUT" { + headerFromContent := req.Request.Header.Get("content_hash") + if headerFromContent == "" { + t.Fatalf("expected 'content_hash' header to exist, but it does not") + } + } }) } } From f585e07c87d1a095b8281b41ad386df3c6da2309 Mon Sep 17 00:00:00 2001 From: Rahul Bhatvedekar Date: Tue, 24 Sep 2024 17:13:35 +0000 Subject: [PATCH 09/54] DXE-3346 Upgrade AlpineLinux to 3.19 for builds. Merge in DEVEXP/terraform-provider-akamai from feature/DXE-3346 to develop --- build/internal/package/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/internal/package/Dockerfile b/build/internal/package/Dockerfile index 535c19678..5901a0d8f 100644 --- a/build/internal/package/Dockerfile +++ b/build/internal/package/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21.12-alpine3.20 +FROM golang:1.21.12-alpine3.19 ENV PROVIDER_VERSION="1.0.0" \ CGO_ENABLED=0 \ From b0cda9cf1c3d223fc4d6476b85af324631243288 Mon Sep 17 00:00:00 2001 From: shristis Date: Tue, 27 Feb 2024 16:33:41 +0530 Subject: [PATCH 10/54] DXE-3526 Adjust property struct for data and resoucres to API real behaviour --- CHANGELOG.md | 3 +- .../property/data_akamai_properties.go | 20 ++++++-- .../property/data_akamai_properties_test.go | 50 ++++++++++++++++--- .../property/resource_akamai_property.go | 16 +++--- 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86db31a70..a6c3a67f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ #### BREAKING CHANGES: - +* PAPI + * Modified resource `akamai_properties` to properly populate fields `product_id`, `rule_format` and `note` diff --git a/pkg/providers/property/data_akamai_properties.go b/pkg/providers/property/data_akamai_properties.go index aa41c0bcb..54d5675bb 100644 --- a/pkg/providers/property/data_akamai_properties.go +++ b/pkg/providers/property/data_akamai_properties.go @@ -81,31 +81,41 @@ func dataPropertiesRead(ctx context.Context, d *schema.ResourceData, m interface // setting concatenated id to uniquely identify data d.SetId(groupID + contractID) - if err := d.Set("properties", sliceResponseProperties(propertiesResponse)); err != nil { + properties, err := sliceResponseProperties(ctx, meta, propertiesResponse) + if err != nil { + return diag.FromErr(err) + } + + if err := d.Set("properties", properties); err != nil { return diag.Errorf("error setting properties: %s", err) } return nil } -func sliceResponseProperties(propertiesResponse *papi.GetPropertiesResponse) []map[string]interface{} { +func sliceResponseProperties(ctx context.Context, meta meta.Meta, propertiesResponse *papi.GetPropertiesResponse) ([]map[string]interface{}, error) { var properties []map[string]interface{} for _, item := range propertiesResponse.Properties.Items { + + propVersion, err := getPropertyVersion(ctx, meta, item) + if err != nil { + return nil, err + } property := map[string]interface{}{ "contract_id": item.ContractID, "group_id": item.GroupID, "latest_version": item.LatestVersion, "note": item.Note, - "product_id": item.ProductID, + "product_id": propVersion.Version.ProductID, "production_version": decodeVersion(item.ProductionVersion), "property_id": item.PropertyID, "property_name": item.PropertyName, - "rule_format": item.RuleFormat, + "rule_format": propVersion.Version.RuleFormat, "staging_version": decodeVersion(item.StagingVersion), } properties = append(properties, property) } - return properties + return properties, nil } func decodeVersion(version interface{}) int { diff --git a/pkg/providers/property/data_akamai_properties_test.go b/pkg/providers/property/data_akamai_properties_test.go index 18a53e459..a3de9c344 100644 --- a/pkg/providers/property/data_akamai_properties_test.go +++ b/pkg/providers/property/data_akamai_properties_test.go @@ -14,13 +14,25 @@ func TestDataProperties(t *testing.T) { t.Run("list properties", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items) + properties := decodePropertyItems(props.Items, "rule_format", "prd_1") client.On("GetProperties", mock.Anything, papi.GetPropertiesRequest{GroupID: "grp_test", ContractID: "ctr_test"}, ).Return(&papi.GetPropertiesResponse{Properties: props}, nil) + res := &papi.GetPropertyVersionsResponse{ + Version: papi.PropertyVersionGetItem{ + ProductID: "prd_1", + RuleFormat: "rule_format", + }, + } + + client.On("GetPropertyVersion", + mock.Anything, + mock.Anything, + ).Return(res, nil) + useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), @@ -37,13 +49,25 @@ func TestDataProperties(t *testing.T) { t.Run("list properties without group prefix", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items) + properties := decodePropertyItems(props.Items, "rule_format", "prd_1") client.On("GetProperties", mock.Anything, papi.GetPropertiesRequest{GroupID: "grp_test", ContractID: "ctr_test"}, ).Return(&papi.GetPropertiesResponse{Properties: props}, nil) + res := &papi.GetPropertyVersionsResponse{ + Version: papi.PropertyVersionGetItem{ + ProductID: "prd_1", + RuleFormat: "rule_format", + }, + } + + client.On("GetPropertyVersion", + mock.Anything, + mock.Anything, + ).Return(res, nil) + useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), @@ -60,13 +84,25 @@ func TestDataProperties(t *testing.T) { t.Run("list properties without contract prefix", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items) + properties := decodePropertyItems(props.Items, "rule_format", "prd_1") client.On("GetProperties", mock.Anything, papi.GetPropertiesRequest{GroupID: "grp_test", ContractID: "ctr_test"}, ).Return(&papi.GetPropertiesResponse{Properties: props}, nil) + res := &papi.GetPropertyVersionsResponse{ + Version: papi.PropertyVersionGetItem{ + ProductID: "prd_1", + RuleFormat: "rule_format", + }, + } + + client.On("GetPropertyVersion", + mock.Anything, + mock.Anything, + ).Return(res, nil) + useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), @@ -91,11 +127,9 @@ func buildPapiProperties() []*papi.Property { GroupID: "grp_test", LatestVersion: 1, Note: fmt.Sprintf("note%v", i), - ProductID: "prd1", ProductionVersion: nil, PropertyID: fmt.Sprintf("prp%v", i), PropertyName: fmt.Sprintf("prpname%v", i), - RuleFormat: "latest", StagingVersion: nil, } } @@ -121,7 +155,7 @@ func buildAggregatedTest(properties []map[string]interface{}, id, groupID, contr return resource.ComposeAggregateTestCheckFunc(testVar...) } -func decodePropertyItems(items []*papi.Property) []map[string]interface{} { +func decodePropertyItems(items []*papi.Property, ruleFormat, productID string) []map[string]interface{} { properties := make([]map[string]interface{}, 0) for _, item := range items { prop := map[string]interface{}{ @@ -129,11 +163,11 @@ func decodePropertyItems(items []*papi.Property) []map[string]interface{} { "group_id": item.GroupID, "latest_version": item.LatestVersion, "note": item.Note, - "product_id": item.ProductID, + "product_id": productID, "production_version": decodeVersion(item.ProductionVersion), "property_id": item.PropertyID, "property_name": item.PropertyName, - "rule_format": item.RuleFormat, + "rule_format": ruleFormat, "staging_version": decodeVersion(item.StagingVersion), } properties = append(properties, prop) diff --git a/pkg/providers/property/resource_akamai_property.go b/pkg/providers/property/resource_akamai_property.go index 068270225..8b1b39f2e 100644 --- a/pkg/providers/property/resource_akamai_property.go +++ b/pkg/providers/property/resource_akamai_property.go @@ -492,7 +492,6 @@ func resourcePropertyCreate(ctx context.Context, d *schema.ResourceData, m inter PropertyID: propertyID, ContractID: contractID, GroupID: groupID, - ProductID: productID, LatestVersion: 1, } @@ -572,6 +571,7 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa if err != nil { return diag.FromErr(err) } + if v == 0 { // use latest version unless "read_version" != 0 v = property.LatestVersion @@ -626,7 +626,6 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa if err != nil { return diag.FromErr(err) } - property.ProductID = res.Version.ProductID rulesJSON, err := json.Marshal(rules) if err != nil { @@ -648,8 +647,8 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa "read_version": readVersionID, "version_notes": res.Version.Note, } - if property.ProductID != "" { - attrs["product_id"] = property.ProductID + if res.Version.ProductID != "" { + attrs["product_id"] = res.Version.ProductID } if err := tf.SetAttrs(d, attrs); err != nil { return diag.FromErr(err) @@ -706,7 +705,6 @@ func resourcePropertyUpdate(ctx context.Context, d *schema.ResourceData, m inter PropertyName: d.Get("name").(string), ContractID: d.Get("contract_id").(string), GroupID: d.Get("group_id").(string), - ProductID: d.Get("product_id").(string), LatestVersion: d.Get("latest_version").(int), StagingVersion: stagingVersion, ProductionVersion: productionVersion, @@ -925,13 +923,13 @@ func resourcePropertyImport(ctx context.Context, d *schema.ResourceData, m inter return []*schema.ResourceData{d}, nil } - var err error var property *papi.Property + var err error var v int if !isDefaultVersion(version) { - property, v, err = fetchProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID, version) + property, v, err = fetchProperty(ctx, client, propertyID, groupID, contractID, version) } else { - property, err = fetchLatestProperty(ctx, Client(meta.Must(m)), propertyID, groupID, contractID) + property, err = fetchLatestProperty(ctx, client, propertyID, groupID, contractID) } if err != nil { return nil, err @@ -1135,8 +1133,6 @@ func fetchProperty(ctx context.Context, client papi.PAPI, propertyID, groupID, c ProductionVersion: getNetworkActiveVersionNumber(res.Versions.Items, papi.ActivationNetworkProduction), AssetID: res.AssetID, Note: versionItem.Note, - ProductID: versionItem.ProductID, - RuleFormat: versionItem.RuleFormat, } logger.Debug("property versions fetched") From e332d30c082dca06c62b7aaa2a81291cf625815b Mon Sep 17 00:00:00 2001 From: Jakub Bilski Date: Thu, 25 Apr 2024 11:52:56 +0000 Subject: [PATCH 11/54] DXE-3640 Refactor response/request/objects struct names in GTM and DNS (Terraform) --- pkg/providers/dns/data_authorities_set.go | 5 +- .../dns/data_authorities_set_test.go | 4 +- pkg/providers/dns/data_dns_record_set.go | 10 +- pkg/providers/dns/data_dns_record_set_test.go | 8 +- .../dns/resource_akamai_dns_record.go | 87 +- .../dns/resource_akamai_dns_record_test.go | 134 +-- pkg/providers/dns/resource_akamai_dns_zone.go | 80 +- .../dns/resource_akamai_dns_zone_test.go | 43 +- pkg/providers/gtm/data_akamai_gtm_asmap.go | 9 +- .../gtm/data_akamai_gtm_asmap_test.go | 26 +- pkg/providers/gtm/data_akamai_gtm_cidrmap.go | 9 +- .../gtm/data_akamai_gtm_cidrmap_test.go | 23 +- .../gtm/data_akamai_gtm_datacenter.go | 5 +- .../gtm/data_akamai_gtm_datacenter_test.go | 14 +- .../gtm/data_akamai_gtm_datacenters.go | 5 +- .../gtm/data_akamai_gtm_datacenters_test.go | 12 +- .../gtm/data_akamai_gtm_default_datacenter.go | 1 - pkg/providers/gtm/data_akamai_gtm_domain.go | 40 +- .../gtm/data_akamai_gtm_domain_test.go | 41 +- pkg/providers/gtm/data_akamai_gtm_domains.go | 2 +- .../gtm/data_akamai_gtm_domains_test.go | 10 +- pkg/providers/gtm/data_akamai_gtm_resource.go | 9 +- .../gtm/data_akamai_gtm_resource_test.go | 14 +- .../gtm/data_akamai_gtm_resources.go | 5 +- .../gtm/data_akamai_gtm_resources_test.go | 17 +- .../gtm/resource_akamai_gtm_asmap.go | 81 +- .../gtm/resource_akamai_gtm_asmap_test.go | 238 +++-- .../gtm/resource_akamai_gtm_cidrmap.go | 85 +- .../gtm/resource_akamai_gtm_cidrmap_test.go | 180 +++- .../gtm/resource_akamai_gtm_datacenter.go | 46 +- .../resource_akamai_gtm_datacenter_test.go | 79 +- .../gtm/resource_akamai_gtm_domain.go | 107 +- .../gtm/resource_akamai_gtm_domain_test.go | 299 ++++-- .../gtm/resource_akamai_gtm_geomap.go | 89 +- .../gtm/resource_akamai_gtm_geomap_test.go | 231 ++++- .../gtm/resource_akamai_gtm_property.go | 141 ++- .../gtm/resource_akamai_gtm_property_test.go | 920 ++++++++++++++++-- .../gtm/resource_akamai_gtm_resource.go | 93 +- .../gtm/resource_akamai_gtm_resource_test.go | 205 +++- .../TestResGtmDatacenter/create_basic.tf | 4 + .../testdata/TestResGtmDomain/create_basic.tf | 2 +- .../create_basic_with_sign_and_serve.tf | 2 +- .../order/email_notification_list/create.tf | 2 +- .../order/email_notification_list/reorder.tf | 2 +- .../testdata/TestResGtmDomain/update_basic.tf | 2 +- .../TestResGtmProperty/create_basic.tf | 1 - 46 files changed, 2573 insertions(+), 849 deletions(-) diff --git a/pkg/providers/dns/data_authorities_set.go b/pkg/providers/dns/data_authorities_set.go index 04fa16cf3..017be1d30 100644 --- a/pkg/providers/dns/data_authorities_set.go +++ b/pkg/providers/dns/data_authorities_set.go @@ -6,6 +6,7 @@ import ( "sort" "strings" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -49,7 +50,9 @@ func dataSourceAuthoritiesSetRead(ctx context.Context, d *schema.ResourceData, m logger.WithField("contractid", contractID).Debug("Start Searching for authority records") - ns, err := inst.Client(meta).GetNameServerRecordList(ctx, contractID) + ns, err := inst.Client(meta).GetNameServerRecordList(ctx, dns.GetNameServerRecordListRequest{ + ContractIDs: contractID, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, diff --git a/pkg/providers/dns/data_authorities_set_test.go b/pkg/providers/dns/data_authorities_set_test.go index bb1ce65af..885784f4f 100644 --- a/pkg/providers/dns/data_authorities_set_test.go +++ b/pkg/providers/dns/data_authorities_set_test.go @@ -23,7 +23,7 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { client.On("GetNameServerRecordList", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), + mock.AnythingOfType("dns.GetNameServerRecordListRequest"), ).Return(authorities, nil) useClient(client, func() { @@ -71,7 +71,7 @@ func TestDataSourceAuthoritiesSet_basic(t *testing.T) { client.On("GetNameServerRecordList", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), + mock.AnythingOfType("dns.GetNameServerRecordListRequest"), ).Return(nil, errors.New("invalid contract")) useClient(client, func() { diff --git a/pkg/providers/dns/data_dns_record_set.go b/pkg/providers/dns/data_dns_record_set.go index cb4cd5e95..04f33e200 100644 --- a/pkg/providers/dns/data_dns_record_set.go +++ b/pkg/providers/dns/data_dns_record_set.go @@ -5,11 +5,11 @@ import ( "fmt" "sort" - "github.com/apex/log" - + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -72,7 +72,11 @@ func dataSourceDNSRecordSetRead(ctx context.Context, d *schema.ResourceData, m i }).Debug("Start Searching for records") // Warning or Errors can be collected in a slice type var diags diag.Diagnostics - rdata, err := inst.Client(meta).GetRdata(ctx, zone, host, recordType) + rdata, err := inst.Client(meta).GetRdata(ctx, dns.GetRdataRequest{ + Name: zone, + Zone: host, + RecordType: recordType, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, diff --git a/pkg/providers/dns/data_dns_record_set_test.go b/pkg/providers/dns/data_dns_record_set_test.go index 5b00190ed..6e793afc9 100644 --- a/pkg/providers/dns/data_dns_record_set_test.go +++ b/pkg/providers/dns/data_dns_record_set_test.go @@ -22,9 +22,7 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { client.On("GetRdata", mock.Anything, // ctx is irrelevant for this test - "exampleterraform.io", - "exampleterraform.io", - "A", + mock.AnythingOfType("dns.GetRdataRequest"), ).Return(rdata, nil) useClient(client, func() { @@ -87,9 +85,7 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { client.On("GetRdata", mock.Anything, // ctx is irrelevant for this test - "exampleterraform.io", - "exampleterraform.io", - "A", + mock.AnythingOfType("dns.GetRdataRequest"), ).Return(nil, errors.New("invalid zone")) useClient(client, func() { diff --git a/pkg/providers/dns/resource_akamai_dns_record.go b/pkg/providers/dns/resource_akamai_dns_record.go index 4268acb13..5141fd83b 100644 --- a/pkg/providers/dns/resource_akamai_dns_record.go +++ b/pkg/providers/dns/resource_akamai_dns_record.go @@ -18,12 +18,11 @@ import ( "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/dns/internal/txtrecord" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/dns/internal/txtrecord" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -599,7 +598,11 @@ func getRecordLock(recordType string) *sync.Mutex { func bumpSoaSerial(ctx context.Context, d *schema.ResourceData, meta meta.Meta, zone, host string, logger log.Interface) (*dns.RecordBody, error) { // Get SOA Record - recordset, err := inst.Client(meta).GetRecord(ctx, zone, host, "SOA") + recordset, err := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: "SOA", + }) if err != nil { return nil, fmt.Errorf("error looking up SOA record for %s: %w", host, err) } @@ -620,18 +623,30 @@ func bumpSoaSerial(ctx context.Context, d *schema.ResourceData, meta meta.Meta, } // Record op function -func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBody, zone string, rlock bool) error { +func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBody, zone string, rlock []bool) error { var e error switch fn { case "Create": - e = inst.Client(meta).CreateRecord(ctx, rec, zone, rlock) + e = inst.Client(meta).CreateRecord(ctx, dns.CreateRecordRequest{ + Zone: zone, + Record: rec, + RecLock: rlock, + }) case "Update": - e = inst.Client(meta).UpdateRecord(ctx, rec, zone, rlock) + e = inst.Client(meta).UpdateRecord(ctx, dns.UpdateRecordRequest{ + Zone: zone, + Record: rec, + RecLock: rlock, + }) case "Delete": - e = inst.Client(meta).DeleteRecord(ctx, rec, zone, rlock) + e = inst.Client(meta).DeleteRecord(ctx, dns.DeleteRecordRequest{ + Zone: zone, + RecordType: rec.RecordType, + RecLock: rlock, + }) default: e = fmt.Errorf("Invalid operation [%s]", fn) @@ -640,7 +655,7 @@ func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBod return e } -func executeRecordFunction(ctx context.Context, meta meta.Meta, name string, d *schema.ResourceData, fn string, rec *dns.RecordBody, zone, host, recordType string, logger log.Interface, rlock bool) error { +func executeRecordFunction(ctx context.Context, meta meta.Meta, name string, d *schema.ResourceData, fn string, rec *dns.RecordBody, zone, host, recordType string, logger log.Interface, rlock []bool) error { logger.Debugf("executeRecordFunction - zone: %s, host: %s, recordtype: %s", zone, host, recordType) // DNS API can have Concurrency issues @@ -733,7 +748,11 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte if recordType == RRTypeSoa { logger.Debug("Attempting to create a SOA record") // A default SOA is created automagically when the primary zone is created ... - if _, err := inst.Client(meta).GetRecord(ctx, zone, host, recordType); err == nil { + if _, err := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }); err == nil { // Record exists serial, err := tf.GetIntValue("serial", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { @@ -771,7 +790,11 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte // First try to get the zone from the API logger.Debugf("Searching for records [%s]", zone) rdata := make([]string, 0) - recordSet, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + recordSet, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -790,7 +813,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte // record not found/404 we will create a new logger.Debug("Creating new record") // Save the zone to the API - e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -801,7 +824,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte } else { logger.Debug("Updating record") if len(rdata) > 0 { - e = executeRecordFunction(ctx, meta, "CREATE", d, "Update", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "CREATE", d, "Update", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -811,7 +834,7 @@ func resourceDNSRecordCreate(ctx context.Context, d *schema.ResourceData, m inte } } else { logger.Debug("Saving record") - e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "CREATE", d, "Create", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -903,7 +926,11 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte if recordType == RRTypeSoa { // need to get current serial and increment as part of update - record, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + record, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -942,7 +969,11 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte // First try to get the zone from the API logger.Debugf("UPDATE Searching for records [%s]", zone) rdata := make([]string, 0, 0) - recordset, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + recordset, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -970,13 +1001,13 @@ func resourceDNSRecordUpdate(ctx context.Context, d *schema.ResourceData, m inte logger.Errorf("UPDATE [ERROR] %s", e.Error()) logger.Debugf("UPDATE Creating new record") // Save the zone to the API - e = executeRecordFunction(ctx, meta, "UPDATE", d, "Create", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "UPDATE", d, "Create", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return diag.FromErr(e) } } else { logger.Debug("UPDATE Updating record") - e = executeRecordFunction(ctx, meta, "UPDATE", d, "Update", &recordCreate, zone, host, recordType, logger, false) + e = executeRecordFunction(ctx, meta, "UPDATE", d, "Update", &recordCreate, zone, host, recordType, logger, []bool{false}) if e != nil { return diag.FromErr(e) } @@ -1060,7 +1091,11 @@ func resourceDNSRecordRead(ctx context.Context, d *schema.ResourceData, m interf "recordtype": recordType, }).Info("READ Searching for zone records") - record, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + record, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -1255,7 +1290,11 @@ func resourceDNSRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.R // Get recordset logger.Debugf("Searching for zone Recordset. %s", idParts) - recordset, e := inst.Client(meta).GetRecord(ctx, zone, recordName, recordType) + recordset, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: recordName, + RecordType: recordType, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok || apiError.StatusCode != http.StatusNotFound { @@ -1367,7 +1406,7 @@ func resourceDNSRecordDelete(ctx context.Context, d *schema.ResourceData, m inte // Warning: Delete will expunge the ENTIRE Recordset regardless of whether user thought they were removing an instance - if err := executeRecordFunction(ctx, meta, "DELETE", d, "Delete", &recordcreate, zone, host, recordType, logger, false); err != nil { + if err := executeRecordFunction(ctx, meta, "DELETE", d, "Delete", &recordcreate, zone, host, recordType, logger, []bool{false}); err != nil { return diag.FromErr(err) } d.SetId("") @@ -1555,7 +1594,11 @@ func newRecordCreate(ctx context.Context, meta meta.Meta, d *schema.ResourceData return dns.RecordBody{}, err } logger.Debugf("MX record targets to process: %v", target) - recordset, e := inst.Client(meta).GetRecord(ctx, zone, host, recordType) + recordset, e := inst.Client(meta).GetRecord(ctx, dns.GetRecordRequest{ + Zone: zone, + Name: host, + RecordType: recordType, + }) rdata := make([]string, 0, 0) if e != nil { logger.Debugf("MX Get Error Type: %T", e) diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index 4994337f5..b59241f49 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -21,8 +21,6 @@ import ( func TestResDnsRecord(t *testing.T) { dnsClient := dns.Client(session.Must(session.New())) - var rec *dns.RecordBody - notFound := &dns.Error{ StatusCode: http.StatusNotFound, } @@ -31,60 +29,92 @@ func TestResDnsRecord(t *testing.T) { t.Run("lifecycle test", func(t *testing.T) { client := &dns.Mock{} - getCall := client.On("GetRecord", + // read + client.On("GetRecord", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), - ).Return(nil, notFound) + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(nil, notFound).Once() + + // create + client.On("CreateRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.CreateRecordRequest"), + ).Return(nil).Once() - parseCall := client.On("ParseRData", + // read + client.On("GetRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ + Name: "", + RecordType: "", + TTL: 0, + Active: false, + Target: nil, + }, nil).Once() + + retCreate := dnsClient.ParseRData(context.Background(), "A", []string{"10.0.0.2", "10.0.0.3"}) + + client.On("ParseRData", mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("[]string"), - ).Return(nil) + ).Return(retCreate).Times(3) - procCall := client.On("ProcessRdata", + client.On("ProcessRdata", mock.Anything, // ctx is irrelevant for this test mock.AnythingOfType("[]string"), mock.AnythingOfType("string"), - ).Return(nil, nil) + ).Return([]string{"A"}, nil).Times(4) - updateArguments := func(args mock.Arguments) { - rec = args.Get(1).(*dns.RecordBody) - getCall.ReturnArguments = mock.Arguments{rec, nil} - parseCall.ReturnArguments = mock.Arguments{ - dnsClient.ParseRData(context.Background(), rec.RecordType, rec.Target), - } - procCall.ReturnArguments = mock.Arguments{rec.Target, nil} - } + client.On("GetRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ + Name: "", + RecordType: "", + TTL: 0, + Active: false, + Target: nil, + }, nil).Times(3) - client.On("CreateRecord", + // update + client.On("UpdateRecord", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), + mock.AnythingOfType("dns.UpdateRecordRequest"), + ).Return(nil).Once() + + // read + client.On("GetRecord", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ + Name: "", + RecordType: "", + TTL: 0, + Active: false, + Target: nil, + }, nil).Times(2) + + retUpdate := dnsClient.ParseRData(context.Background(), "A", []string{"10.0.0.4", "10.0.0.5"}) + + client.On("ParseRData", mock.Anything, - ).Return(nil).Run(func(args mock.Arguments) { - updateArguments(args) - }) + mock.AnythingOfType("string"), + mock.AnythingOfType("[]string"), + ).Return(retUpdate).Times(2) - client.On("UpdateRecord", + client.On("ProcessRdata", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*dns.RecordBody"), + mock.AnythingOfType("[]string"), mock.AnythingOfType("string"), - mock.Anything, - ).Return(nil).Run(func(args mock.Arguments) { - updateArguments(args) - }) + ).Return([]string{"A"}, nil).Times(2) + // delete client.On("DeleteRecord", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), - ).Return(nil).Run(func(mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{nil, notFound} - }) + mock.AnythingOfType("dns.DeleteRecordRequest"), + ).Return(nil).Once() dataSourceName := "akamai_dns_record.a_record" @@ -119,30 +149,18 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", + mock.AnythingOfType("dns.GetRecordRequest"), ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "exampleterraform.io", - RecordType: "TXT", - TTL: 300, - Active: false, - Target: []string{target1, target2}, - }, - "exampleterraform.io", - []bool{false}, + mock.AnythingOfType("dns.CreateRecordRequest"), ).Return(nil) client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -166,10 +184,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + mock.AnythingOfType("dns.GetRecordRequest"), + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -179,9 +195,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + mock.AnythingOfType("dns.DeleteRecordRequest"), ).Return(nil) resourceName := "akamai_dns_record.txt_record" diff --git a/pkg/providers/dns/resource_akamai_dns_zone.go b/pkg/providers/dns/resource_akamai_dns_zone.go index eb9931895..d50e07516 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone.go +++ b/pkg/providers/dns/resource_akamai_dns_zone.go @@ -10,13 +10,11 @@ import ( "strings" "time" - "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/apex/log" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -185,7 +183,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte } // First try to get the zone from the API logger.Debugf("Searching for zone [%s]", hostname) - zone, e := inst.Client(meta).GetZone(ctx, hostname) + zone, e := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e == nil { // Not a good idea to overwrite an existing zone. Needs to be imported. @@ -208,7 +208,11 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte // no existing zone. logger.Debugf("Creating new zone: %v", zoneCreate) - e = inst.Client(meta).CreateZone(ctx, zoneCreate, zoneQueryString, true) + e = inst.Client(meta).CreateZone(ctx, dns.CreateZoneRequest{ + CreateZone: zoneCreate, + ZoneQueryString: zoneQueryString, + ClearConn: []bool{true}, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -219,7 +223,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte if strings.ToUpper(zoneType) == "PRIMARY" { time.Sleep(2 * time.Second) // Indirectly create NS and SOA records - e = inst.Client(meta).SaveChangelist(ctx, zoneCreate) + e = inst.Client(meta).SaveChangeList(ctx, dns.SaveChangeListRequest{ + Zone: zoneCreate.Zone, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -228,7 +234,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte }) } time.Sleep(time.Second) - e = inst.Client(meta).SubmitChangelist(ctx, zoneCreate) + e = inst.Client(meta).SubmitChangeList(ctx, dns.SubmitChangeListRequest{ + Zone: zoneCreate.Zone, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -237,7 +245,9 @@ func resourceDNSv2ZoneCreate(ctx context.Context, d *schema.ResourceData, m inte }) } } - zone, e = inst.Client(meta).GetZone(ctx, hostname) + zone, e = inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -283,7 +293,9 @@ func resourceDNSv2ZoneRead(ctx context.Context, d *schema.ResourceData, m interf } // find the zone first logger.Debugf("Searching for zone [%s]", hostname) - zone, e := inst.Client(meta).GetZone(ctx, hostname) + zone, e := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e != nil { apiError, ok := e.(*dns.Error) if ok && apiError.StatusCode == http.StatusNotFound { @@ -315,7 +327,9 @@ func resourceDNSv2ZoneRead(ctx context.Context, d *schema.ResourceData, m interf }) } // Need updated state - zone, err = inst.Client(meta).GetZone(ctx, hostname) + zone, err = inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -358,22 +372,15 @@ func resourceDNSv2ZoneUpdate(ctx context.Context, d *schema.ResourceData, m inte if err != nil { return diag.FromErr(err) } - contract, err := tf.GetStringValue("contract", d) - if err != nil { - return diag.FromErr(err) - } - group, err := tf.GetStringValue("group", d) - if err != nil { - return diag.FromErr(err) - } zoneType, err := tf.GetStringValue("type", d) if err != nil { return diag.FromErr(err) } - zoneQueryString := dns.ZoneQueryString{Contract: contract, Group: group} logger.Debugf("Searching for zone [%s]", hostname) - zone, e := inst.Client(meta).GetZone(ctx, hostname) + zone, e := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if e != nil { apiError, ok := e.(*dns.Error) if !ok && apiError.StatusCode != http.StatusOK { @@ -396,7 +403,9 @@ func resourceDNSv2ZoneUpdate(ctx context.Context, d *schema.ResourceData, m inte } // Save the zone to the API logger.Debugf("Saving zone %v", zoneCreate) - e = inst.Client(meta).UpdateZone(ctx, zoneCreate, zoneQueryString) + e = inst.Client(meta).UpdateZone(ctx, dns.UpdateZoneRequest{ + CreateZone: zoneCreate, + }) if e != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -429,7 +438,9 @@ func resourceDNSv2ZoneImport(d *schema.ResourceData, m interface{}) ([]*schema.R // find the zone first logger.Debugf("Searching for zone [%s]", hostname) - zone, err := inst.Client(meta).GetZone(ctx, hostname) + zone, err := inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if err != nil { return nil, err } @@ -441,7 +452,9 @@ func resourceDNSv2ZoneImport(d *schema.ResourceData, m interface{}) ([]*schema.R return nil, err } // Need updated state - zone, err = inst.Client(meta).GetZone(ctx, hostname) + zone, err = inst.Client(meta).GetZone(ctx, dns.GetZoneRequest{ + Zone: hostname, + }) if err != nil { return nil, err } @@ -492,7 +505,7 @@ func validateZoneType(v interface{}, _ cty.Path) diag.Diagnostics { } // populate zone state based on API response. -func populateDNSv2ZoneState(d *schema.ResourceData, zoneresp *dns.ZoneResponse) error { +func populateDNSv2ZoneState(d *schema.ResourceData, zoneresp *dns.GetZoneResponse) error { if err := d.Set("contract", zoneresp.ContractID); err != nil { return fmt.Errorf("%w: %s", tf.ErrValueSet, err.Error()) @@ -664,13 +677,16 @@ func checkDNSv2Zone(d tf.ResourceDataFetcher) error { } // Util func to create SOA and NS records -func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.ZoneResponse, logger log.Interface) error { +func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.GetZoneResponse, logger log.Interface) error { logger.Debugf("Checking SOA and NS records exist for zone %s", zone.Zone) - var resp *dns.RecordSetResponse + var resp *dns.GetRecordSetsResponse var err error if zone.ActivationState != "NEW" { // See if SOA and NS recs exist already. Both or none. - resp, err = inst.Client(meta).GetRecordSets(ctx, zone.Zone, dns.RecordSetQueryArgs{Types: "SOA,NS"}) + resp, err = inst.Client(meta).GetRecordSets(ctx, dns.GetRecordSetsRequest{ + Zone: zone.Zone, + QueryArgs: &dns.RecordSetQueryArgs{Types: "SOA,NS"}, + }) if err != nil { return err } @@ -680,7 +696,9 @@ func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.Zon } logger.Warnf("SOA and NS records don't exist. Creating ...") - nameservers, err := inst.Client(meta).GetNameServerRecordList(ctx, zone.ContractID) + nameservers, err := inst.Client(meta).GetNameServerRecordList(ctx, dns.GetNameServerRecordListRequest{ + ContractIDs: zone.ContractID, + }) if err != nil { return err } @@ -692,7 +710,11 @@ func checkZoneSOAandNSRecords(ctx context.Context, meta meta.Meta, zone *dns.Zon rs.RecordSets = append(rs.RecordSets, createNSRecord(zone.Zone, nameservers, logger)) // create recordSets - err = inst.Client(meta).CreateRecordSets(ctx, rs, zone.Zone, true) + err = inst.Client(meta).CreateRecordSets(ctx, dns.CreateRecordSetsRequest{ + Zone: zone.Zone, + RecordSets: rs, + RecLock: []bool{true}, + }) return err } diff --git a/pkg/providers/dns/resource_akamai_dns_zone_test.go b/pkg/providers/dns/resource_akamai_dns_zone_test.go index 9b240356c..0743c8851 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone_test.go +++ b/pkg/providers/dns/resource_akamai_dns_zone_test.go @@ -14,7 +14,7 @@ import ( ) func TestResDNSZone(t *testing.T) { - zone := &dns.ZoneResponse{ + zone := &dns.GetZoneResponse{ ContractID: "ctr1", Zone: "primaryexampleterraform.io", Type: "primary", @@ -22,7 +22,9 @@ func TestResDNSZone(t *testing.T) { SignAndServe: false, ActivationState: "PENDING", } - recordSetsResp := &dns.RecordSetResponse{RecordSets: make([]dns.RecordSet, 2, 2)} + recordSetsResp := &dns.GetRecordSetsResponse{ + RecordSets: make([]dns.RecordSet, 2, 2), + } t.Run("when group is not provided and there is no group for the user ", func(t *testing.T) { client := &dns.Mock{} @@ -79,34 +81,31 @@ func TestResDNSZone(t *testing.T) { getCall := client.On("GetZone", mock.Anything, - zone.Zone, + mock.AnythingOfType("dns.GetZoneRequest"), ).Return(nil, &dns.Error{ StatusCode: http.StatusNotFound, }) client.On("CreateZone", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), - mock.AnythingOfType("dns.ZoneQueryString"), - true, + mock.AnythingOfType("dns.CreateZoneRequest"), ).Return(nil).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{zone, nil} }) - client.On("SaveChangelist", + client.On("SaveChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SaveChangeListRequest"), ).Return(nil) - client.On("SubmitChangelist", + client.On("SubmitChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SubmitChangeListRequest"), ).Return(nil) client.On("GetRecordSets", mock.Anything, - zone.Zone, - mock.AnythingOfType("[]dns.RecordSetQueryArgs"), + mock.AnythingOfType("dns.GetRecordSetsRequest"), ).Return(recordSetsResp, nil) dataSourceName := "akamai_dns_zone.test_without_group" @@ -196,42 +195,38 @@ func TestResDNSZone(t *testing.T) { getCall := client.On("GetZone", mock.Anything, - zone.Zone, + mock.AnythingOfType("dns.GetZoneRequest"), ).Return(nil, &dns.Error{ StatusCode: http.StatusNotFound, }) client.On("CreateZone", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), - mock.AnythingOfType("dns.ZoneQueryString"), - true, + mock.AnythingOfType("dns.CreateZoneRequest"), ).Return(nil).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{zone, nil} }) client.On("UpdateZone", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), - mock.AnythingOfType("dns.ZoneQueryString"), + mock.AnythingOfType("dns.UpdateZoneRequest"), ).Return(nil).Run(func(args mock.Arguments) { zone.Comment = "This is an updated test primary zone" }) - client.On("SaveChangelist", + client.On("SaveChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SaveChangeListRequest"), ).Return(nil) - client.On("SubmitChangelist", + client.On("SubmitChangeList", mock.Anything, - mock.AnythingOfType("*dns.ZoneCreate"), + mock.AnythingOfType("dns.SubmitChangeListRequest"), ).Return(nil) client.On("GetRecordSets", mock.Anything, - zone.Zone, - mock.AnythingOfType("[]dns.RecordSetQueryArgs"), + mock.AnythingOfType("dns.GetRecordSetsRequest"), ).Return(recordSetsResp, nil) dataSourceName := "akamai_dns_zone.primary_test_zone" diff --git a/pkg/providers/gtm/data_akamai_gtm_asmap.go b/pkg/providers/gtm/data_akamai_gtm_asmap.go index c5eb90f7f..4dbd12594 100644 --- a/pkg/providers/gtm/data_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/data_akamai_gtm_asmap.go @@ -145,7 +145,10 @@ func (d *asMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, } client := Client(d.meta) - asMap, err := client.GetASMap(ctx, data.Name.ValueString(), data.Domain.ValueString()) + asMap, err := client.GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: data.Name.ValueString(), + DomainName: data.Domain.ValueString(), + }) if err != nil { resp.Diagnostics.AddError("fetching GTM ASMap failed: ", err.Error()) return @@ -157,7 +160,7 @@ func (d *asMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, } -func (m *asMapDataSourceModel) setAttributes(asMap *gtm.ASMap) { +func (m *asMapDataSourceModel) setAttributes(asMap *gtm.GetASMapResponse) { m.Name = types.StringValue(asMap.Name) m.DefaultDatacenter = newDefaultDatacenter(*asMap.DefaultDatacenter) m.setAssignments(asMap.Assignments) @@ -165,7 +168,7 @@ func (m *asMapDataSourceModel) setAttributes(asMap *gtm.ASMap) { m.ID = types.StringValue("gtm_asmap") } -func (m *asMapDataSourceModel) setAssignments(assignments []*gtm.ASAssignment) { +func (m *asMapDataSourceModel) setAssignments(assignments []gtm.ASAssignment) { toBaseTypesInt64Slice := func(n []int64) []basetypes.Int64Value { out := make([]basetypes.Int64Value, 0, len(n)) for _, number := range n { diff --git a/pkg/providers/gtm/data_akamai_gtm_asmap_test.go b/pkg/providers/gtm/data_akamai_gtm_asmap_test.go index 41f22fb4e..ace6e17c2 100644 --- a/pkg/providers/gtm/data_akamai_gtm_asmap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_asmap_test.go @@ -21,13 +21,16 @@ func TestDataGTMASMap(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetASMap", mock.Anything, "map1", "test.domain.net").Return(>m.ASMap{ + m.On("GetASMap", mock.Anything, gtm.GetASMapRequest{ + ASMapName: "map1", + DomainName: "test.domain.net", + }).Return(>m.GetASMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestDefaultDatacenterNickname", DatacenterID: 1, }, - Assignments: []*gtm.ASAssignment{{ + Assignments: []gtm.ASAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestAssignmentNickname", DatacenterID: 1, @@ -38,7 +41,7 @@ func TestDataGTMASMap(t *testing.T) { 3, }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Href: "href.test", Rel: "TestRel", }}, @@ -71,7 +74,10 @@ func TestDataGTMASMap(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetASMap", mock.Anything, "map1", "test.domain.net").Return( + m.On("GetASMap", mock.Anything, gtm.GetASMapRequest{ + ASMapName: "map1", + DomainName: "test.domain.net", + }).Return( nil, fmt.Errorf("test error")) }, expectError: regexp.MustCompile("test error"), @@ -79,17 +85,21 @@ func TestDataGTMASMap(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetASMap", mock.Anything, "map1", "test.domain.net").Return(>m.ASMap{ + m.On("GetASMap", mock.Anything, gtm.GetASMapRequest{ + ASMapName: "map1", + DomainName: "test.domain.net", + }).Return(>m.GetASMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestDefaultDatacenterNickname", DatacenterID: 1, }, - Assignments: []*gtm.ASAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.ASAssignment{}, + Links: []gtm.Link{{ Href: "href.test", Rel: "TestRel", - }}, + }, + }, }, nil) }, diff --git a/pkg/providers/gtm/data_akamai_gtm_cidrmap.go b/pkg/providers/gtm/data_akamai_gtm_cidrmap.go index ed504b0d0..9a6ac308c 100644 --- a/pkg/providers/gtm/data_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/data_akamai_gtm_cidrmap.go @@ -139,7 +139,10 @@ func (d *cidrMapDataSource) Read(ctx context.Context, req datasource.ReadRequest } client := Client(d.meta) - cidrMap, err := client.GetCIDRMap(ctx, data.Name.ValueString(), data.Domain.ValueString()) + cidrMap, err := client.GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: data.Domain.ValueString(), + MapName: data.Name.ValueString(), + }) if err != nil { resp.Diagnostics.AddError("fetching GTM CIDRmap failed: ", err.Error()) return @@ -154,7 +157,7 @@ func (d *cidrMapDataSource) Read(ctx context.Context, req datasource.ReadRequest resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (m *cidrMapDataSourceModel) setAttributes(ctx context.Context, cidrMap *gtm.CIDRMap) diag.Diagnostics { +func (m *cidrMapDataSourceModel) setAttributes(ctx context.Context, cidrMap *gtm.GetCIDRMapResponse) diag.Diagnostics { m.Name = types.StringValue(cidrMap.Name) m.DefaultDatacenter = newDefaultDatacenter(*cidrMap.DefaultDatacenter) m.Links = getLinks(cidrMap.Links) @@ -167,7 +170,7 @@ func (m *cidrMapDataSourceModel) setAttributes(ctx context.Context, cidrMap *gtm return nil } -func (m *cidrMapDataSourceModel) setAssignments(ctx context.Context, assignments []*gtm.CIDRAssignment) diag.Diagnostics { +func (m *cidrMapDataSourceModel) setAssignments(ctx context.Context, assignments []gtm.CIDRAssignment) diag.Diagnostics { for _, a := range assignments { blocks, diags := types.SetValueFrom(ctx, types.StringType, a.Blocks) if diags.HasError() { diff --git a/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go index 3b2f3faa8..abe05b5cd 100644 --- a/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go @@ -21,13 +21,16 @@ func TestDataGTMCIDRmap(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetCIDRMap", mock.Anything, "mapTest", "test.cidrmap.domain.net").Return(>m.CIDRMap{ + m.On("GetCIDRMap", mock.Anything, gtm.GetCIDRMapRequest{ + MapName: "mapTest", + DomainName: "test.cidrmap.domain.net", + }).Return(>m.GetCIDRMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.CIDRAssignment{{ + Assignments: []gtm.CIDRAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments", DatacenterID: 1, @@ -37,7 +40,7 @@ func TestDataGTMCIDRmap(t *testing.T) { "test2", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, @@ -69,7 +72,10 @@ func TestDataGTMCIDRmap(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetCIDRMap", mock.Anything, "mapTest", "test.cidrmap.domain.net").Return( + m.On("GetCIDRMap", mock.Anything, gtm.GetCIDRMapRequest{ + MapName: "mapTest", + DomainName: "test.cidrmap.domain.net", + }).Return( nil, fmt.Errorf("error")) }, expectError: regexp.MustCompile("error"), @@ -77,14 +83,17 @@ func TestDataGTMCIDRmap(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetCIDRMap", mock.Anything, "mapTest", "test.cidrmap.domain.net").Return(>m.CIDRMap{ + m.On("GetCIDRMap", mock.Anything, gtm.GetCIDRMapRequest{ + MapName: "mapTest", + DomainName: "test.cidrmap.domain.net", + }).Return(>m.GetCIDRMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.CIDRAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.CIDRAssignment{}, + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_datacenter.go index 553e29103..e92339baa 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter.go @@ -159,7 +159,10 @@ func dataGTMDatacenterRead(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("could not get 'datacenter_id' attribute: %s", err) } - dc, err := client.GetDatacenter(ctx, dcID, domain) + dc, err := client.GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { return diag.Errorf("could not get datacenter: %s", err) } diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go index 1b9c84eb5..9f49ae785 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go @@ -42,7 +42,10 @@ func TestDataGTMDatacenter(t *testing.T) { }, "error - GetDatacenter fail": { init: func(_ *testing.T, m *gtm.Mock, data testDataForGTMDatacenter) { - m.On("GetDatacenter", mock.Anything, data.datacenterID, data.domain).Return( + m.On("GetDatacenter", mock.Anything, gtm.GetDatacenterRequest{ + DatacenterID: data.datacenterID, + DomainName: data.domain, + }).Return( nil, fmt.Errorf("GetDatacenter error")).Once() }, mockData: testGTMDatacenter, @@ -138,7 +141,7 @@ type testDataForGTMDatacenter struct { serverMonitorPool string cloudServerTargeting bool cloudServerHostHeaderOverride bool - links []*gtm.Link + links []gtm.Link } var ( @@ -162,7 +165,10 @@ var ( StateOrProvince: data.stateOrProvince, Virtual: data.virtual, } - client.On("GetDatacenter", mock.Anything, data.datacenterID, data.domain).Return(&dc, nil).Times(timesToRun) + client.On("GetDatacenter", mock.Anything, gtm.GetDatacenterRequest{ + DatacenterID: data.datacenterID, + DomainName: data.domain, + }).Return(&dc, nil).Times(timesToRun) } testGTMDatacenter = testDataForGTMDatacenter{ @@ -186,7 +192,7 @@ var ( serverMonitorPool: "serverMonitorPool", cloudServerTargeting: true, cloudServerHostHeaderOverride: true, - links: []*gtm.Link{ + links: []gtm.Link{ { Rel: "rel1", Href: "href1", diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters.go b/pkg/providers/gtm/data_akamai_gtm_datacenters.go index fe767d684..9a71fa03c 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters.go @@ -3,6 +3,7 @@ package gtm import ( "context" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" @@ -161,14 +162,14 @@ func dataGTMDatacentersRead(ctx context.Context, d *schema.ResourceData, m inter return diag.FromErr(err) } - datacenters, err := client.ListDatacenters(ctx, domain) + datacenters, err := client.ListDatacenters(ctx, gtm.ListDatacentersRequest{DomainName: domain}) if err != nil { return diag.FromErr(err) } datacentersAttrs := make([]interface{}, len(datacenters)) for i, dc := range datacenters { - dcAttrs := getDatacenterAttributes(dc) + dcAttrs := getDatacenterAttributes(&dc) dcAttrs["datacenter_id"] = dc.DatacenterID datacentersAttrs[i] = dcAttrs } diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go index 6092b5147..e90c74836 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go @@ -42,7 +42,9 @@ func TestDataGTMDatacenters(t *testing.T) { }, "error - ListDatacenters fail": { init: func(t *testing.T, m *gtm.Mock, data testDataForGTMDatacenters) { - m.On("ListDatacenters", mock.Anything, data.domain).Return( + m.On("ListDatacenters", mock.Anything, gtm.ListDatacentersRequest{ + DomainName: data.domain, + }).Return( nil, fmt.Errorf("ListDatacenters error")).Once() }, mockData: testGTMDatacenters, @@ -148,10 +150,10 @@ var ( // mockListDatacenters mocks ListDatacenters call with provided data mockListDatacenters = func(t *testing.T, client *gtm.Mock, data testDataForGTMDatacenters, timesToRun int) { - var dcs []*gtm.Datacenter + var dcs []gtm.Datacenter for _, data := range data.datacenters { - dc := >m.Datacenter{ + dc := gtm.Datacenter{ City: data.city, CloneOf: data.cloneOf, CloudServerHostHeaderOverride: data.cloudServerHostHeaderOverride, @@ -172,6 +174,8 @@ var ( dcs = append(dcs, dc) } - client.On("ListDatacenters", mock.Anything, data.domain).Return(dcs, nil).Times(timesToRun) + client.On("ListDatacenters", mock.Anything, gtm.ListDatacentersRequest{ + DomainName: data.domain, + }).Return(dcs, nil).Times(timesToRun) } ) diff --git a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go index ee983598e..284ef8497 100644 --- a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go @@ -6,7 +6,6 @@ import ( "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/gtm/data_akamai_gtm_domain.go b/pkg/providers/gtm/data_akamai_gtm_domain.go index bc7c67b4b..081e907da 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domain.go +++ b/pkg/providers/gtm/data_akamai_gtm_domain.go @@ -1208,7 +1208,9 @@ func (d *domainDataSource) Read(ctx context.Context, request datasource.ReadRequ } client := Client(d.meta) - domain, err := client.GetDomain(ctx, data.Name.ValueString()) + domain, err := client.GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: data.Name.ValueString(), + }) if err != nil { response.Diagnostics.AddError("fetching domain failed", err.Error()) return @@ -1222,7 +1224,7 @@ func (d *domainDataSource) Read(ctx context.Context, request datasource.ReadRequ response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func populateDomain(ctx context.Context, domain *gtm.Domain) (*domainDataSourceModel, diag.Diagnostics) { +func populateDomain(ctx context.Context, domain *gtm.GetDomainResponse) (*domainDataSourceModel, diag.Diagnostics) { emailNotificationList, diags := types.ListValueFrom(ctx, types.StringType, domain.EmailNotificationList) if diags.HasError() { return nil, diags @@ -1290,7 +1292,7 @@ func populateDomain(ctx context.Context, domain *gtm.Domain) (*domainDataSourceM return domainModel, nil } -func getLinks(links []*gtm.Link) []link { +func getLinks(links []gtm.Link) []link { var result []link if links != nil { result = make([]link, len(links)) @@ -1304,7 +1306,7 @@ func getLinks(links []*gtm.Link) []link { return result } -func getASMaps(maps []*gtm.ASMap) []asMap { +func getASMaps(maps []gtm.ASMap) []asMap { var result []asMap for _, am := range maps { asMapInstance := asMap{ @@ -1321,7 +1323,7 @@ func getASMaps(maps []*gtm.ASMap) []asMap { if am.Assignments != nil { asMapInstance.Assignments = make([]asMapAssignment, len(am.Assignments)) for i, asg := range am.Assignments { - asMapInstance.Assignments[i] = populateASMapAssignment(asg) + asMapInstance.Assignments[i] = populateASMapAssignment(&asg) } } result = append(result, asMapInstance) @@ -1329,7 +1331,7 @@ func getASMaps(maps []*gtm.ASMap) []asMap { return result } -func getCIDRMaps(ctx context.Context, maps []*gtm.CIDRMap) ([]cidrMap, diag.Diagnostics) { +func getCIDRMaps(ctx context.Context, maps []gtm.CIDRMap) ([]cidrMap, diag.Diagnostics) { var result []cidrMap for _, cm := range maps { cidrMapInstance := cidrMap{ @@ -1347,7 +1349,7 @@ func getCIDRMaps(ctx context.Context, maps []*gtm.CIDRMap) ([]cidrMap, diag.Diag if cm.Assignments != nil { cidrMapInstance.Assignments = make([]cidrMapAssignment, len(cm.Assignments)) for i, asg := range cm.Assignments { - popCIDRMapAssignment, diags := populateCIDRMapAssignment(ctx, asg) + popCIDRMapAssignment, diags := populateCIDRMapAssignment(ctx, &asg) if diags.HasError() { return nil, diags } @@ -1359,7 +1361,7 @@ func getCIDRMaps(ctx context.Context, maps []*gtm.CIDRMap) ([]cidrMap, diag.Diag return result, nil } -func getGeographicMaps(ctx context.Context, maps []*gtm.GeoMap) ([]geographicMap, diag.Diagnostics) { +func getGeographicMaps(ctx context.Context, maps []gtm.GeoMap) ([]geographicMap, diag.Diagnostics) { var result []geographicMap for _, gm := range maps { geoMapInstance := geographicMap{ @@ -1377,7 +1379,7 @@ func getGeographicMaps(ctx context.Context, maps []*gtm.GeoMap) ([]geographicMap if gm.Assignments != nil { geoMapInstance.Assignments = make([]geographicMapAssignment, len(gm.Assignments)) for i, asg := range gm.Assignments { - popGeoMap, diags := populateGeographicMapAssignment(ctx, asg) + popGeoMap, diags := populateGeographicMapAssignment(ctx, &asg) if diags.HasError() { return nil, diags } @@ -1389,7 +1391,7 @@ func getGeographicMaps(ctx context.Context, maps []*gtm.GeoMap) ([]geographicMap return result, nil } -func getDatacenters(ctx context.Context, datacenters []*gtm.Datacenter) ([]datacenter, diag.Diagnostics) { +func getDatacenters(ctx context.Context, datacenters []gtm.Datacenter) ([]datacenter, diag.Diagnostics) { var result []datacenter for _, dc := range datacenters { dataCenterInstance := datacenter{ @@ -1426,7 +1428,7 @@ func getDatacenters(ctx context.Context, datacenters []*gtm.Datacenter) ([]datac return result, nil } -func getProperties(ctx context.Context, properties []*gtm.Property) ([]property, diag.Diagnostics) { +func getProperties(ctx context.Context, properties []gtm.Property) ([]property, diag.Diagnostics) { var result []property for _, prop := range properties { propertyInstance := property{ @@ -1516,8 +1518,8 @@ func getStatus(st *gtm.ResponseStatus) *status { PassingValidation: types.BoolValue(st.PassingValidation), } if st.Links != nil { - statusInstance.Links = make([]link, len(*st.Links)) - for i, l := range *st.Links { + statusInstance.Links = make([]link, len(st.Links)) + for i, l := range st.Links { statusInstance.Links[i] = link{ Rel: types.StringValue(l.Rel), Href: types.StringValue(l.Href), @@ -1527,7 +1529,7 @@ func getStatus(st *gtm.ResponseStatus) *status { return &statusInstance } -func getResources(resources []*gtm.Resource) []domainResource { +func getResources(resources []gtm.Resource) []domainResource { var result []domainResource for _, res := range resources { resource := domainResource{ @@ -1574,7 +1576,7 @@ func getResources(resources []*gtm.Resource) []domainResource { return result } -func populateLivenessTest(lt *gtm.LivenessTest) (livenessTest, diag.Diagnostics) { +func populateLivenessTest(lt gtm.LivenessTest) (livenessTest, diag.Diagnostics) { altCACerts, diags := types.ListValueFrom(context.TODO(), types.StringType, lt.AlternateCACertificates) if diags.HasError() { return livenessTest{}, diags @@ -1616,7 +1618,7 @@ func populateLivenessTest(lt *gtm.LivenessTest) (livenessTest, diag.Diagnostics) return ltModel, diags } -func populateHTTPHeaders(headers []*gtm.HTTPHeader) []httpHeader { +func populateHTTPHeaders(headers []gtm.HTTPHeader) []httpHeader { result := make([]httpHeader, len(headers)) for i, h := range headers { result[i] = httpHeader{ @@ -1627,7 +1629,7 @@ func populateHTTPHeaders(headers []*gtm.HTTPHeader) []httpHeader { return result } -func populateStaticRRSet(ctx context.Context, s *gtm.StaticRRSet) (staticRRSet, diag.Diagnostics) { +func populateStaticRRSet(ctx context.Context, s gtm.StaticRRSet) (staticRRSet, diag.Diagnostics) { Rdata, diags := types.ListValueFrom(ctx, types.StringType, s.Rdata) if diags.HasError() { return staticRRSet{}, diags @@ -1639,7 +1641,7 @@ func populateStaticRRSet(ctx context.Context, s *gtm.StaticRRSet) (staticRRSet, }, diags } -func populateLinks(links []*gtm.Link) []link { +func populateLinks(links []gtm.Link) []link { result := make([]link, len(links)) for i, l := range links { result[i] = link{ @@ -1650,7 +1652,7 @@ func populateLinks(links []*gtm.Link) []link { return result } -func populateTrafficTarget(ctx context.Context, t *gtm.TrafficTarget) (trafficTarget, diag.Diagnostics) { +func populateTrafficTarget(ctx context.Context, t gtm.TrafficTarget) (trafficTarget, diag.Diagnostics) { servers, diags := types.ListValueFrom(ctx, types.StringType, t.Servers) if diags.HasError() { return trafficTarget{}, diags diff --git a/pkg/providers/gtm/data_akamai_gtm_domain_test.go b/pkg/providers/gtm/data_akamai_gtm_domain_test.go index 07688d3b8..c1b288b6d 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domain_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_domain_test.go @@ -5,9 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -24,7 +23,9 @@ func TestDataGtmDomain(t *testing.T) { "success - response is ok": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetDomain", mock.Anything, "test.cli.devexp-terraform.akadns.net").Return(>m.Domain{ + m.On("GetDomain", mock.Anything, gtm.GetDomainRequest{ + DomainName: "test.cli.devexp-terraform.akadns.net", + }).Return(>m.GetDomainResponse{ Name: "test.cli.devexp-terraform.akadns.net", CNameCoalescingEnabled: false, DefaultErrorPenalty: 75, @@ -47,7 +48,7 @@ func TestDataGtmDomain(t *testing.T) { PropagationStatus: "DENIED", PropagationStatusDate: "2023-01-25T10:21:00.000+00:00", }, - Resources: []*gtm.Resource{{ + Resources: []gtm.Resource{{ AggregationType: "latest", Description: "terraform test resource", Type: "XML load object via HTTP", @@ -55,12 +56,12 @@ func TestDataGtmDomain(t *testing.T) { UpperBound: 100, }, }, - ASMaps: []*gtm.ASMap{{ + ASMaps: []gtm.ASMap{{ DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 3133, Nickname: "Default (all others)", }, - Assignments: []*gtm.ASAssignment{{ + Assignments: []gtm.ASAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "New Zone 1", DatacenterID: 3133, @@ -72,18 +73,18 @@ func TestDataGtmDomain(t *testing.T) { }, }}, Name: "New Map 1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/as-maps/DevExpAutomatedTest_6Qil38", }}, }, }, - CIDRMaps: []*gtm.CIDRMap{{ + CIDRMaps: []gtm.CIDRMap{{ DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 3133, Nickname: "All Other CIDR Blocks", }, - Assignments: []*gtm.CIDRAssignment{{ + Assignments: []gtm.CIDRAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "New Zone 1", DatacenterID: 3133, @@ -93,18 +94,18 @@ func TestDataGtmDomain(t *testing.T) { }, }}, Name: "New Map 1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/cidr-maps/New%20Map%201", }}, }, }, - GeographicMaps: []*gtm.GeoMap{{ + GeographicMaps: []gtm.GeoMap{{ DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 3131, Nickname: "terraform_datacenter_test", }, - Assignments: []*gtm.GeoAssignment{{ + Assignments: []gtm.GeoAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "terraform_datacenter_test_1", DatacenterID: 3133, @@ -114,31 +115,31 @@ func TestDataGtmDomain(t *testing.T) { }, }}, Name: "tfexample_geo_2", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/geographic-maps/tfexample_geo_2", }}, }, }, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "properties", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/properties", }, { Rel: "resources", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/resources"}, }, - Properties: []*gtm.Property{{ + Properties: []gtm.Property{{ BalanceByDownloadScore: false, DynamicTTL: 60, GhostDemandReporting: false, HandoutMode: "Normal", LastModified: "2023-01-25T09:58:09.000+00:00", Name: "property", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/test.cli.devexp-terraform.akadns.net/properties/property", Rel: "self", }}, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { AnswersRequired: false, DisableNonstandardPortWarning: false, @@ -156,7 +157,7 @@ func TestDataGtmDomain(t *testing.T) { TestObjectProtocol: "HTTP", }, }, - TrafficTargets: []*gtm.TrafficTarget{{ + TrafficTargets: []gtm.TrafficTarget{{ DatacenterID: 3131, Enabled: true, Servers: []string{ @@ -257,7 +258,9 @@ func TestDataGtmDomain(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetDomain", mock.Anything, "test.cli.devexp-terraform.akadns.net").Return(nil, fmt.Errorf("oops")) + m.On("GetDomain", mock.Anything, gtm.GetDomainRequest{ + DomainName: "test.cli.devexp-terraform.akadns.net", + }).Return(nil, fmt.Errorf("oops")) }, expectError: regexp.MustCompile("oops"), }, diff --git a/pkg/providers/gtm/data_akamai_gtm_domains.go b/pkg/providers/gtm/data_akamai_gtm_domains.go index 1da3f6c08..0f38c6baa 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domains.go +++ b/pkg/providers/gtm/data_akamai_gtm_domains.go @@ -175,7 +175,7 @@ func (d *domainsDataSource) Read(ctx context.Context, request datasource.ReadReq response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func getDomains(domainList []*gtm.DomainItem) []domain { +func getDomains(domainList []gtm.DomainItem) []domain { var result []domain for _, dom := range domainList { domain := domain{ diff --git a/pkg/providers/gtm/data_akamai_gtm_domains_test.go b/pkg/providers/gtm/data_akamai_gtm_domains_test.go index 483f20a12..69b309249 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domains_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_domains_test.go @@ -22,7 +22,7 @@ func TestDataGTMDomains(t *testing.T) { "success - response is ok": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListDomains", mock.Anything).Return([]*gtm.DomainItem{ + m.On("ListDomains", mock.Anything).Return([]gtm.DomainItem{ { Name: "test1.terraformtesting.net", LastModified: "2023-02-01T09:36:28.000+00:00", @@ -33,7 +33,7 @@ func TestDataGTMDomains(t *testing.T) { SignAndServe: false, Status: "2023-02-01 09:47 GMT: Current configuration has been propagated to all GTM nameservers", AcgID: "TestACGID-1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test-domain.net/config-gtm/v1/domains/test1.terraformtesting.net", }, @@ -49,7 +49,7 @@ func TestDataGTMDomains(t *testing.T) { SignAndServe: false, Status: "2023-12-21 08:37 GMT: Current configuration has been propagated to all GTM nameservers", AcgID: "TestACGID-1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test-domain.net/config-gtm/v1/domains/test2.terraformtesting.net", }, @@ -65,7 +65,7 @@ func TestDataGTMDomains(t *testing.T) { SignAndServe: false, Status: "2023-12-22 08:46 GMT: Current configuration has been propagated to all GTM nameservers", AcgID: "TestACGID-1", - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test-domain.net/config-gtm/v1/domains/test3.terraformtesting.net", }, @@ -85,7 +85,7 @@ func TestDataGTMDomains(t *testing.T) { "no domains found": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListDomains", mock.Anything).Return([]*gtm.DomainItem{}, nil) + m.On("ListDomains", mock.Anything).Return([]gtm.DomainItem{}, nil) }, }, "error response from api": { diff --git a/pkg/providers/gtm/data_akamai_gtm_resource.go b/pkg/providers/gtm/data_akamai_gtm_resource.go index 1c4bf2d3b..86fd64a3f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resource.go +++ b/pkg/providers/gtm/data_akamai_gtm_resource.go @@ -195,7 +195,10 @@ func (d *resourceDataSource) Read(ctx context.Context, request datasource.ReadRe } client := Client(d.meta) - resource, err := client.GetResource(ctx, data.ResourceName.ValueString(), data.Domain.ValueString()) + resource, err := client.GetResource(ctx, gtm.GetResourceRequest{ + DomainName: data.Domain.ValueString(), + ResourceName: data.ResourceName.ValueString(), + }) if err != nil { response.Diagnostics.AddError("fetching GTM resource failed:", err.Error()) return @@ -206,7 +209,7 @@ func (d *resourceDataSource) Read(ctx context.Context, request datasource.ReadRe response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func (m *resourceDataSourceModel) setAttributes(resource *gtm.Resource) { +func (m *resourceDataSourceModel) setAttributes(resource *gtm.GetResourceResponse) { m.AggregationType = types.StringValue(resource.AggregationType) m.ConstrainedProperty = types.StringValue(resource.ConstrainedProperty) @@ -224,7 +227,7 @@ func (m *resourceDataSourceModel) setAttributes(resource *gtm.Resource) { m.ID = types.StringValue(resource.Name) } -func (m *resourceDataSourceModel) setResourceInstances(resourceInstances []*gtm.ResourceInstance) { +func (m *resourceDataSourceModel) setResourceInstances(resourceInstances []gtm.ResourceInstance) { for _, res := range resourceInstances { resourceInstanceObject := resourceInstance{ diff --git a/pkg/providers/gtm/data_akamai_gtm_resource_test.go b/pkg/providers/gtm/data_akamai_gtm_resource_test.go index 04a22adad..53ef8c2e7 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resource_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_resource_test.go @@ -22,7 +22,10 @@ func TestDataGTMResource(t *testing.T) { "happy path - GTM data resource should be returned": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetResource", mock.Anything, "resource1", "test.domain.net").Return(>m.Resource{ + m.On("GetResource", mock.Anything, gtm.GetResourceRequest{ + ResourceName: "resource1", + DomainName: "test.domain.net", + }).Return(>m.GetResourceResponse{ Type: "XML load object via HTTP", LeastSquaresDecay: 0, Description: "terraform test resource", @@ -32,13 +35,13 @@ func TestDataGTMResource(t *testing.T) { Name: "property", MaxUMultiplicativeIncrement: 0, DecayRate: 0, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://akaa-ouijhfns55qwgfuc-knsod5nrjl2w2gmt.luna-dev.akamaiapis.net/config-gtm/v1/domains/" + "test.cli.domain.net/resources/resource1", }, }, - ResourceInstances: []*gtm.ResourceInstance{{ + ResourceInstances: []gtm.ResourceInstance{{ DatacenterID: 3131, UseDefaultLoadObject: false, LoadObject: gtm.LoadObject{ @@ -71,7 +74,10 @@ func TestDataGTMResource(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetResource", mock.Anything, "resource1", "test.domain.net").Return( + m.On("GetResource", mock.Anything, gtm.GetResourceRequest{ + ResourceName: "resource1", + DomainName: "test.domain.net", + }).Return( nil, fmt.Errorf("oops")) }, expectError: regexp.MustCompile("oops"), diff --git a/pkg/providers/gtm/data_akamai_gtm_resources.go b/pkg/providers/gtm/data_akamai_gtm_resources.go index 7199dfc1c..0c8dcb02f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resources.go +++ b/pkg/providers/gtm/data_akamai_gtm_resources.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -147,7 +148,9 @@ func (d *resourcesDataSource) Read(ctx context.Context, request datasource.ReadR } client := Client(d.meta) - resources, err := client.ListResources(ctx, data.Domain.ValueString()) + resources, err := client.ListResources(ctx, gtm.ListResourcesRequest{ + DomainName: data.Domain.ValueString(), + }) if err != nil { response.Diagnostics.AddError("fetching GTM resources failed:", err.Error()) return diff --git a/pkg/providers/gtm/data_akamai_gtm_resources_test.go b/pkg/providers/gtm/data_akamai_gtm_resources_test.go index 5e24c8a16..a856314cb 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resources_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_resources_test.go @@ -22,7 +22,10 @@ func TestDataGTMResources(t *testing.T) { "happy path - GTM data resources should be returned": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListResources", mock.Anything, "test.domain.net").Return([]*gtm.Resource{ + m.On("ListResources", mock.Anything, + gtm.ListResourcesRequest{ + DomainName: "test.domain.net", + }).Return([]gtm.Resource{ { Type: "XML load object via HTTP", LeastSquaresDecay: 0, @@ -33,13 +36,13 @@ func TestDataGTMResources(t *testing.T) { Name: "property1", MaxUMultiplicativeIncrement: 0, DecayRate: 0, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self", Href: "https://test.domain1.net/config-gtm/v1/domains/" + "test.cli.domain.net/resources/resource1", }, }, - ResourceInstances: []*gtm.ResourceInstance{{ + ResourceInstances: []gtm.ResourceInstance{{ DatacenterID: 3131, UseDefaultLoadObject: false, LoadObject: gtm.LoadObject{ @@ -60,13 +63,13 @@ func TestDataGTMResources(t *testing.T) { Name: "property2", MaxUMultiplicativeIncrement: 0, DecayRate: 0, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "self1", Href: "https://test.domain1.net/config-gtm/v1/domains/" + "test.cli.domain.net/resources/resource2", }, }, - ResourceInstances: []*gtm.ResourceInstance{{ + ResourceInstances: []gtm.ResourceInstance{{ DatacenterID: 3132, UseDefaultLoadObject: false, LoadObject: gtm.LoadObject{ @@ -95,7 +98,9 @@ func TestDataGTMResources(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListResources", mock.Anything, "test.domain.net").Return( + m.On("ListResources", mock.Anything, gtm.ListResourcesRequest{ + DomainName: "test.domain.net", + }).Return( nil, fmt.Errorf("oops")) }, expectError: regexp.MustCompile("oops"), diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap.go b/pkg/providers/gtm/resource_akamai_gtm_asmap.go index 347fbc97c..ca70ec467 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap.go @@ -102,7 +102,10 @@ func validateDefaultDC(ctx context.Context, meta meta.Meta, ddcField []interface if !ok || dcID == 0 { return fmt.Errorf("default Datacenter ID invalid") } - dc, err := Client(meta).GetDatacenter(ctx, dcID, domain) + dc, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DomainName: domain, + DatacenterID: dcID, + }) if dc == nil { if err != nil { apiError, ok := err.(*gtm.Error) @@ -170,7 +173,10 @@ func resourceGTMv1ASMapCreate(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("Proposed New asMap: [%v]", newAS) - cStatus, err := Client(meta).CreateASMap(ctx, newAS, domain) + cStatus, err := Client(meta).CreateASMap(ctx, gtm.CreateASMapRequest{ + ASMap: newAS, + DomainName: domain, + }) if err != nil { return append(diags, diag.Diagnostic{ Severity: diag.Error, @@ -231,7 +237,10 @@ func resourceGTMv1ASMapRead(ctx context.Context, d *schema.ResourceData, m inter if err != nil { return diag.FromErr(err) } - as, err := Client(meta).GetASMap(ctx, asMap, domain) + as, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("asMap Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -263,7 +272,10 @@ func resourceGTMv1ASMapUpdate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } // Get existingASmap - existAs, err := Client(meta).GetASMap(ctx, asMap, domain) + existAs, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("asMap Update read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -273,9 +285,13 @@ func resourceGTMv1ASMapUpdate(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("asMap BEFORE: %v", existAs) - populateASMapObject(d, existAs, m) + newAs := createASMapStruct(existAs) + populateASMapObject(d, newAs, m) logger.Debugf("asMap PROPOSED: %v", existAs) - uStat, err := Client(meta).UpdateASMap(ctx, existAs, domain) + uStat, err := Client(meta).UpdateASMap(ctx, gtm.UpdateASMapRequest{ + ASMap: newAs, + DomainName: domain, + }) if err != nil { logger.Errorf("asMap pdate: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -285,10 +301,10 @@ func resourceGTMv1ASMapUpdate(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("asMap Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -332,7 +348,10 @@ func resourceGTMv1ASMapImport(ctx context.Context, d *schema.ResourceData, m int if err != nil { return []*schema.ResourceData{d}, err } - as, err := Client(meta).GetASMap(ctx, asMap, domain) + as, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { return nil, err } @@ -366,7 +385,10 @@ func resourceGTMv1ASMapDelete(ctx context.Context, d *schema.ResourceData, m int logger.Errorf("[ERROR] ASMap Delete: %s", err.Error()) return diag.FromErr(err) } - existAs, err := Client(meta).GetASMap(ctx, asMap, domain) + existAs, err := Client(meta).GetASMap(ctx, gtm.GetASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("ASMap Delete: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -375,8 +397,12 @@ func resourceGTMv1ASMapDelete(ctx context.Context, d *schema.ResourceData, m int Detail: err.Error(), }) } - logger.Debugf("Deleting ASmap: %v", existAs) - uStat, err := Client(meta).DeleteASMap(ctx, existAs, domain) + newAs := createASMapStruct(existAs) + logger.Debugf("Deleting ASmap: %v", newAs) + uStat, err := Client(meta).DeleteASMap(ctx, gtm.DeleteASMapRequest{ + ASMapName: asMap, + DomainName: domain, + }) if err != nil { logger.Errorf("ASMap Delete: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -386,10 +412,10 @@ func resourceGTMv1ASMapDelete(ctx context.Context, d *schema.ResourceData, m int }) } logger.Debugf("asMap Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -429,8 +455,8 @@ func populateNewASMapObject(d *schema.ResourceData, m interface{}) (*gtm.ASMap, asObj := >m.ASMap{ Name: asMapName, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]*gtm.ASAssignment, 1), - Links: make([]*gtm.Link, 1), + Assignments: make([]gtm.ASAssignment, 1), + Links: make([]gtm.Link, 1), } populateASMapObject(d, asObj, m) @@ -448,7 +474,7 @@ func populateASMapObject(d *schema.ResourceData, as *gtm.ASMap, m interface{}) { } // Populate Terraform state from provided ASMap object -func populateTerraformASMapState(d *schema.ResourceData, as *gtm.ASMap, m interface{}) { +func populateTerraformASMapState(d *schema.ResourceData, as *gtm.GetASMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASMapState") @@ -469,7 +495,7 @@ func populateASAssignmentsObject(d *schema.ResourceData, as *gtm.ASMap, m interf if asAssignmentsList, err := tf.GetListValue("assignment", d); err != nil { logger.Errorf("Assignment not set: %s", err.Error()) } else { - asAssignmentsObjList := make([]*gtm.ASAssignment, len(asAssignmentsList)) // create new object list + asAssignmentsObjList := make([]gtm.ASAssignment, len(asAssignmentsList)) // create new object list for i, v := range asAssignmentsList { asMap := v.(map[string]interface{}) asAssignment := gtm.ASAssignment{} @@ -486,14 +512,14 @@ func populateASAssignmentsObject(d *schema.ResourceData, as *gtm.ASMap, m interf } asAssignment.ASNumbers = ls } - asAssignmentsObjList[i] = &asAssignment + asAssignmentsObjList[i] = asAssignment } as.Assignments = asAssignmentsObjList } } // create and populate Terraform asMap assignments schema -func populateTerraformASAssignmentsState(d *schema.ResourceData, asm *gtm.ASMap, m interface{}) { +func populateTerraformASAssignmentsState(d *schema.ResourceData, asm *gtm.GetASMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASAssignmentsState") @@ -539,7 +565,7 @@ func populateASDefaultDCObject(d *schema.ResourceData, as *gtm.ASMap, m interfac } // create and populate Terraform asMap default_datacenter schema -func populateTerraformASDefaultDCState(d *schema.ResourceData, as *gtm.ASMap, m interface{}) { +func populateTerraformASDefaultDCState(d *schema.ResourceData, as *gtm.GetASMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformASDefaultDCState") @@ -664,6 +690,19 @@ func asNumbersEqual(old, new interface{}) bool { return true } +// createASMapStruct converts response from GetASMapResponse into ASMap +func createASMapStruct(asmap *gtm.GetASMapResponse) *gtm.ASMap { + if asmap != nil { + return >m.ASMap{ + DefaultDatacenter: asmap.DefaultDatacenter, + Assignments: asmap.Assignments, + Name: asmap.Name, + Links: asmap.Links, + } + } + return nil +} + // resolveAttrName resolves specific assignment attribute, based on a resource func resolveAttrName(list []interface{}) (string, error) { if len(list) == 0 { diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go index 0a0f45a7c..5e0dfea7f 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go @@ -20,49 +20,52 @@ func TestResGTMASMap(t *testing.T) { getCall := client.On("GetASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetASMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.ASMapResponse{} - resp.Resource = &asmap - resp.Status = &pendingResponseStatus + resp := asmap client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(>m.ASMapResponse{ - Resource: &asmap, - Status: >m.ResponseStatus{}, + mock.AnythingOfType("gtm.CreateASMapRequest"), + ).Return(>m.CreateASMapResponse{ + Resource: asMapCreate.Resource, + Status: asMapCreate.Status, }, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{resp.Resource, nil} + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetASMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetASMapRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.UpdateASMapRequest"), + ).Return(updateASMapResponseStatus, nil) + + client.On("GetASMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetASMapRequest"), + ).Return(&asMapUpdate, nil).Times(3) client.On("DeleteASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteASMapRequest"), + ).Return(deleteASMapResponseStatus, nil) dataSourceName := "akamai_gtm_asmap.tfexample_as_1" @@ -96,16 +99,14 @@ func TestResGTMASMap(t *testing.T) { client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateASMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -126,21 +127,17 @@ func TestResGTMASMap(t *testing.T) { t.Run("create asmap denied", func(t *testing.T) { client := >m.Mock{} - asmap, dc := getASMapTestData() - - dr := gtm.ASMapResponse{} - dr.Resource = &asmap + dr := gtm.CreateASMapResponse{} + dr.Resource = asMapCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateASMapRequest"), ).Return(&dr, nil) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -165,35 +162,31 @@ func TestResGTMASMap(t *testing.T) { client.On("GetDatacenter", mock.Anything, - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("CreateASMap", mock.Anything, - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(>m.ASMapResponse{ - Resource: &asmap, - Status: >m.ResponseStatus{}, + mock.AnythingOfType("gtm.CreateASMapRequest"), + ).Return(>m.CreateASMapResponse{ + Resource: asMapCreate.Resource, + Status: asMapCreate.Status, }, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("GetASMap", mock.Anything, - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetASMapRequest"), ).Return(&asmap, nil) client.On("DeleteASMap", mock.Anything, - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteASMapRequest"), + ).Return(deleteASMapResponseStatus, nil) dataSourceName := "akamai_gtm_asmap.tfexample_as_1" @@ -320,60 +313,161 @@ func TestGTMASMapOrder(t *testing.T) { // getASMapMocks mocks creation and deletion of a resource func getASMapMocks() *gtm.Mock { - asmap, dc := getASMapTestData() - client := >m.Mock{} mockGetAsMap := client.On("GetASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetASMapRequest"), ).Return(nil, >m.Error{StatusCode: http.StatusNotFound}) - resp := gtm.ASMapResponse{} - resp.Resource = &asMapDiffOrder - resp.Status = &pendingResponseStatus + resp := asMapDiffOrder client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("CreateASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), - mock.AnythingOfType("string"), - ).Return(>m.ASMapResponse{ - Resource: &asmap, - Status: >m.ResponseStatus{}, + mock.AnythingOfType("gtm.CreateASMapRequest"), + ).Return(>m.CreateASMapResponse{ + Resource: asMapCreate.Resource, + Status: asMapCreate.Status, }, nil).Run(func(args mock.Arguments) { - mockGetAsMap.ReturnArguments = mock.Arguments{resp.Resource, nil} + mockGetAsMap.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteASMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.ASMap"), + mock.AnythingOfType("gtm.DeleteASMapRequest"), mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + ).Return(deleteASMapResponseStatus, nil) return client } var ( + updateASMapResponseStatus = >m.UpdateASMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + deleteASMapResponseStatus = >m.DeleteASMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + getDomainStatusResponseStatus = >m.GetDomainStatusResponse{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + } + + asMapCreate = gtm.CreateASMapResponse{ + Resource: >m.ASMap{ + Name: "tfexample_as_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.ASAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + ASNumbers: []int64{12222, 16702, 17334}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + ASNumbers: []int64{12229, 16703, 17335}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + asMapUpdate = gtm.GetASMapResponse{ + Name: "tfexample_as_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.ASAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + ASNumbers: []int64{12223, 16701, 17333}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3133, + Nickname: "tfexample_dc_3", + }, + ASNumbers: []int64{12228, 16704, 17336}, + }, + }, + } + // asMapDiffOrder represents AsMap structure with values used in tests of the order of assignments and as_numbers - asMapDiffOrder = gtm.ASMap{ + asMapDiffOrder = gtm.GetASMapResponse{ Name: "tfexample_as_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.ASAssignment{ + Assignments: []gtm.ASAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -399,14 +493,14 @@ var ( } ) -func getASMapTestData() (gtm.ASMap, gtm.Datacenter) { - asmap := gtm.ASMap{ +func getASMapTestData() (gtm.GetASMapResponse, gtm.Datacenter) { + asmap := gtm.GetASMapResponse{ Name: "tfexample_as_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.ASAssignment{ + Assignments: []gtm.ASAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go index d4c868905..61d74dd9b 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go @@ -6,9 +6,8 @@ import ( "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -117,7 +116,10 @@ func resourceGTMv1CIDRMapCreate(ctx context.Context, d *schema.ResourceData, m i newCidr := populateNewCIDRMapObject(meta, d, m) logger.Debugf("Proposed New CidrMap: [%v]", newCidr) - cStatus, err := Client(meta).CreateCIDRMap(ctx, newCidr, domain) + cStatus, err := Client(meta).CreateCIDRMap(ctx, gtm.CreateCIDRMapRequest{ + CIDR: newCidr, + DomainName: domain, + }) if err != nil { logger.Errorf("cidrMap Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -180,7 +182,10 @@ func resourceGTMv1CIDRMapRead(ctx context.Context, d *schema.ResourceData, m int logger.Errorf("Invalid cidrMap ID: %s", d.Id()) return diag.FromErr(err) } - cidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + cidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { logger.Errorf("cidrMap Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -212,7 +217,10 @@ func resourceGTMv1CIDRMapUpdate(ctx context.Context, d *schema.ResourceData, m i return diag.FromErr(err) } // Get existingCidrMap - existCidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + existCidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { logger.Errorf("cidrMap Update read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -221,10 +229,14 @@ func resourceGTMv1CIDRMapUpdate(ctx context.Context, d *schema.ResourceData, m i Detail: err.Error(), }) } - logger.Debugf("Updating cidrMap BEFORE: %v", existCidr) - populateCIDRMapObject(d, existCidr, m) + newCidr := createCIDRMapStruct(existCidr) + logger.Debugf("Updating cidrMap BEFORE: %v", newCidr) + populateCIDRMapObject(d, newCidr, m) logger.Debugf("Updating cidrMap PROPOSED: %v", existCidr) - uStat, err := Client(meta).UpdateCIDRMap(ctx, existCidr, domain) + uStat, err := Client(meta).UpdateCIDRMap(ctx, gtm.UpdateCIDRMapRequest{ + CIDR: newCidr, + DomainName: domain, + }) if err != nil { logger.Errorf("cidrMap Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -234,10 +246,10 @@ func resourceGTMv1CIDRMapUpdate(ctx context.Context, d *schema.ResourceData, m i }) } logger.Debugf("CidrMap Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -281,7 +293,10 @@ func resourceGTMv1CIDRMapImport(d *schema.ResourceData, m interface{}) ([]*schem if err != nil { return []*schema.ResourceData{d}, err } - cidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + cidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { return nil, err } @@ -315,7 +330,10 @@ func resourceGTMv1CIDRMapDelete(ctx context.Context, d *schema.ResourceData, m i logger.Errorf("Invalid cidrMap ID: %s", d.Id()) return diag.FromErr(err) } - existCidr, err := Client(meta).GetCIDRMap(ctx, cidrMap, domain) + existCidr, err := Client(meta).GetCIDRMap(ctx, gtm.GetCIDRMapRequest{ + DomainName: domain, + MapName: cidrMap, + }) if err != nil { logger.Errorf("CidrMapDelete cidrMap doesn't exist: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -324,8 +342,12 @@ func resourceGTMv1CIDRMapDelete(ctx context.Context, d *schema.ResourceData, m i Detail: err.Error(), }) } - logger.Debugf("Deleting cidrMap: %v", existCidr) - uStat, err := Client(meta).DeleteCIDRMap(ctx, existCidr, domain) + newCidr := createCIDRMapStruct(existCidr) + logger.Debugf("Deleting cidrMap: %v", newCidr) + uStat, err := Client(meta).DeleteCIDRMap(ctx, gtm.DeleteCIDRMapRequest{ + MapName: cidrMap, + DomainName: domain, + }) if err != nil { logger.Errorf("cidrMap Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -335,10 +357,10 @@ func resourceGTMv1CIDRMapDelete(ctx context.Context, d *schema.ResourceData, m i }) } logger.Debugf("cidrMap Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { + if uStat.Status.PropagationStatus == "DENIED" { return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -380,8 +402,8 @@ func populateNewCIDRMapObject(meta meta.Meta, d *schema.ResourceData, m interfac cidrObj := >m.CIDRMap{ Name: cidrMapName, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]*gtm.CIDRAssignment, 0), - Links: make([]*gtm.Link, 1), + Assignments: make([]gtm.CIDRAssignment, 0), + Links: make([]gtm.Link, 1), } populateCIDRMapObject(d, cidrObj, m) @@ -398,7 +420,7 @@ func populateCIDRMapObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m interfac } // Populate Terraform state from provided CIDRMap object -func populateTerraformCIDRMapState(d *schema.ResourceData, cidr *gtm.CIDRMap, m interface{}) { +func populateTerraformCIDRMapState(d *schema.ResourceData, cidr *gtm.GetCIDRMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrMapState") @@ -418,7 +440,7 @@ func populateCIDRAssignmentsObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m // pull apart List if cassgns := d.Get("assignment"); cassgns != nil { cidrAssignmentsList := cassgns.([]interface{}) - cidrAssignmentsObjList := make([]*gtm.CIDRAssignment, len(cidrAssignmentsList)) // create new object list + cidrAssignmentsObjList := make([]gtm.CIDRAssignment, len(cidrAssignmentsList)) // create new object list for i, v := range cidrAssignmentsList { cidrMap := v.(map[string]interface{}) cidrAssignment := gtm.CIDRAssignment{} @@ -435,18 +457,18 @@ func populateCIDRAssignmentsObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m } cidrAssignment.Blocks = ls } - cidrAssignmentsObjList[i] = &cidrAssignment + cidrAssignmentsObjList[i] = cidrAssignment } cidr.Assignments = cidrAssignmentsObjList } } // create and populate Terraform cidrMap assignments schema -func populateTerraformCIDRAssignmentsState(d *schema.ResourceData, cidr *gtm.CIDRMap, m interface{}) { +func populateTerraformCIDRAssignmentsState(d *schema.ResourceData, cidr *gtm.GetCIDRMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCidrAssignmentsState") - objectInventory := make(map[int]*gtm.CIDRAssignment, len(cidr.Assignments)) + objectInventory := make(map[int]gtm.CIDRAssignment, len(cidr.Assignments)) if len(cidr.Assignments) > 0 { for _, aObj := range cidr.Assignments { objectInventory[aObj.DatacenterID] = aObj @@ -460,7 +482,7 @@ func populateTerraformCIDRAssignmentsState(d *schema.ResourceData, cidr *gtm.CID a := aMap.(map[string]interface{}) objIndex := a["datacenter_id"].(int) aObject := objectInventory[objIndex] - if aObject == nil { + if &aObject == nil { logger.Warnf("Cidr Assignment %d NOT FOUND in returned GTM Object", a["datacenter_id"]) continue } @@ -514,7 +536,7 @@ func populateCIDRDefaultDCObject(d *schema.ResourceData, cidr *gtm.CIDRMap, m in } // create and populate Terraform cidrMap default_datacenter schema -func populateTerraformCIDRDefaultDCState(d *schema.ResourceData, cidr *gtm.CIDRMap, m interface{}) { +func populateTerraformCIDRDefaultDCState(d *schema.ResourceData, cidr *gtm.GetCIDRMapResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformCIDRDefaultDCState") @@ -529,6 +551,19 @@ func populateTerraformCIDRDefaultDCState(d *schema.ResourceData, cidr *gtm.CIDRM } } +// createCIDRMapStruct converts response from GetCIDRMapResponse into CIDRMap +func createCIDRMapStruct(cidr *gtm.GetCIDRMapResponse) *gtm.CIDRMap { + if cidr != nil { + return >m.CIDRMap{ + DefaultDatacenter: cidr.DefaultDatacenter, + Assignments: cidr.Assignments, + Name: cidr.Name, + Links: cidr.Links, + } + } + return nil +} + // blocksEqual checks whether blocks are equal func blocksEqual(old, new interface{}) bool { logger := logger.Get("Akamai GTM", "blocksEqual") diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go index 5f6600176..a49e882ea 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go @@ -19,45 +19,51 @@ func TestResGTMCIDRMap(t *testing.T) { getCall := client.On("GetCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetCIDRMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.CIDRMapResponse{} - resp.Resource = &cidr - resp.Status = &pendingResponseStatus + resp := cidr client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{resp.Resource, nil} + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), + ).Return(>m.CreateCIDRMapResponse{ + Resource: cidrCreate.Resource, + Status: cidrCreate.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetCIDRMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetCIDRMapRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.UpdateCIDRMapRequest"), + ).Return(updateCIDRMapResponseStatus, nil) + + client.On("GetCIDRMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetCIDRMapRequest"), + ).Return(&cidrUpdate, nil).Times(3) client.On("DeleteCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteCIDRMapRequest"), + ).Return(deleteCIDRMapResponseStatus, nil) dataSourceName := "akamai_gtm_cidrmap.tfexample_cidrmap_1" @@ -89,16 +95,14 @@ func TestResGTMCIDRMap(t *testing.T) { client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -119,19 +123,17 @@ func TestResGTMCIDRMap(t *testing.T) { t.Run("create cidrmap denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.CIDRMapResponse{} - dr.Resource = &cidr + dr := gtm.CreateCIDRMapResponse{} + dr.Resource = cidrCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), ).Return(&dr, nil) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -252,52 +254,49 @@ func getCIDRMapMocks() *gtm.Mock { mockGetCIDRMap := client.On("GetCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetCIDRMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.CIDRMapResponse{} - resp.Resource = &cidrMapDiffOrder - resp.Status = &pendingResponseStatus + resp := cidrMapDiffOrder client.On("CreateCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - mockGetCIDRMap.ReturnArguments = mock.Arguments{resp.Resource, nil} + mock.AnythingOfType("gtm.CreateCIDRMapRequest"), + ).Return(>m.CreateCIDRMapResponse{ + Resource: cidrCreate.Resource, + Status: cidrCreate.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetCIDRMap.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteCIDRMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.CIDRMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteCIDRMapRequest"), + ).Return(deleteCIDRMapResponseStatus, nil) return client } var ( // cidrMapDiffOrder is a gtm.CidrMap structure used in tests of order of assignments and block in gtm_cidrmap resource - cidrMapDiffOrder = gtm.CIDRMap{ + cidrMapDiffOrder = gtm.GetCIDRMapResponse{ Name: "tfexample_cidrmap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.CIDRAssignment{ + Assignments: []gtm.CIDRAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -322,13 +321,45 @@ var ( }, } - cidr = gtm.CIDRMap{ + cidrCreate = gtm.CreateCIDRMapResponse{ + Resource: >m.CIDRMap{ + Name: "tfexample_cidrmap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.CIDRAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + Blocks: []string{"1.2.3.9/24"}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + cidr = gtm.GetCIDRMapResponse{ Name: "tfexample_cidrmap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.CIDRAssignment{ + Assignments: []gtm.CIDRAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -338,4 +369,53 @@ var ( }, }, } + + cidrUpdate = gtm.GetCIDRMapResponse{ + Name: "tfexample_cidrmap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.CIDRAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + Blocks: []string{"1.2.3.9/16"}, + }, + }, + } + + updateCIDRMapResponseStatus = >m.UpdateCIDRMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deleteCIDRMapResponseStatus = >m.DeleteCIDRMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go index df415cbfc..c9e8437da 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go @@ -10,7 +10,6 @@ import ( "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -188,7 +187,10 @@ func resourceGTMv1DatacenterCreate(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } logger.Debugf("Proposed New Datacenter: [%v]", newDC) - cStatus, err := Client(meta).CreateDatacenter(ctx, newDC, domain) + cStatus, err := Client(meta).CreateDatacenter(ctx, gtm.CreateDatacenterRequest{ + DomainName: domain, + Datacenter: newDC, + }) if err != nil { logger.Errorf("Datacenter Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -259,7 +261,10 @@ func resourceGTMv1DatacenterRead(ctx context.Context, d *schema.ResourceData, m Detail: err.Error(), }) } - dc, err := Client(meta).GetDatacenter(ctx, dcID, domain) + dc, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -296,7 +301,10 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, }) } // Get existing datacenter - existDC, err := Client(meta).GetDatacenter(ctx, dcID, domain) + existDC, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -310,7 +318,10 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } logger.Debugf("Updating Datacenter PROPOSED: %v", existDC) - uStat, err := Client(meta).UpdateDatacenter(ctx, existDC, domain) + uStat, err := Client(meta).UpdateDatacenter(ctx, gtm.UpdateDatacenterRequest{ + Datacenter: existDC, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -320,8 +331,8 @@ func resourceGTMv1DatacenterUpdate(ctx context.Context, d *schema.ResourceData, }) } logger.Debugf("Datacenter Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) } @@ -363,7 +374,10 @@ func resourceGTMv1DatacenterImport(d *schema.ResourceData, m interface{}) ([]*sc if err != nil { return nil, fmt.Errorf("Invalid Datacenter resource ID") } - dc, err := Client(meta).GetDatacenter(ctx, dcID, domain) + dc, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Import error: %s", err.Error()) return nil, err @@ -402,7 +416,10 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, }) } // Get existing datacenter - existDC, err := Client(meta).GetDatacenter(ctx, dcID, domain) + existDC, err := Client(meta).GetDatacenter(ctx, gtm.GetDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("DatacenterDelete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -412,7 +429,10 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, }) } logger.Debugf("Deleting Datacenter: %v", existDC) - uStat, err := Client(meta).DeleteDatacenter(ctx, existDC, domain) + uStat, err := Client(meta).DeleteDatacenter(ctx, gtm.DeleteDatacenterRequest{ + DatacenterID: dcID, + DomainName: domain, + }) if err != nil { logger.Errorf("Datacenter Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -422,11 +442,11 @@ func resourceGTMv1DatacenterDelete(ctx context.Context, d *schema.ResourceData, }) } logger.Debugf("Datacenter Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go index c1f0b32f1..b61402ab0 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go @@ -20,10 +20,10 @@ var dc = gtm.Datacenter{ DefaultLoadObject: >m.LoadObject{ LoadObject: "/test", LoadObjectPort: 80, - LoadServers: make([]string, 0), + LoadServers: []string{"1.2.3.4", "1.2.3.9"}, }, Latitude: 64.808, - Links: []*gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/datacenters/3132", Rel: "self", @@ -42,41 +42,36 @@ func TestResGTMDatacenter(t *testing.T) { getCall := client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.DatacenterResponse{} - resp.Resource = &dc - resp.Status = &pendingResponseStatus + resp := dc client.On("CreateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Datacenter), nil} + mock.AnythingOfType("gtm.CreateDatacenterRequest"), + ).Return(>m.CreateDatacenterResponse{ + Resource: &dc, + Status: &pendingResponseStatus, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Datacenter), nil} - }) + mock.AnythingOfType("gtm.UpdateDatacenterRequest"), + ).Return(updateDatacenterResponseStatus, nil) client.On("DeleteDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDatacenterRequest"), + ).Return(deleteDatacenterResponseStatus, nil) dataSourceName := "akamai_gtm_datacenter.tfexample_dc_1" @@ -110,8 +105,7 @@ func TestResGTMDatacenter(t *testing.T) { client.On("CreateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateDatacenterRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -134,13 +128,12 @@ func TestResGTMDatacenter(t *testing.T) { t.Run("create datacenter denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.DatacenterResponse{} + dr := gtm.CreateDatacenterResponse{} dr.Resource = &dc dr.Status = &deniedResponseStatus client.On("CreateDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Datacenter"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateDatacenterRequest"), ).Return(&dr, nil) useClient(client, func() { @@ -158,3 +151,37 @@ func TestResGTMDatacenter(t *testing.T) { client.AssertExpectations(t) }) } + +var ( + updateDatacenterResponseStatus = >m.UpdateDatacenterResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deleteDatacenterResponseStatus = >m.DeleteDatacenterResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } +) diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain.go b/pkg/providers/gtm/resource_akamai_gtm_domain.go index 881442e1c..e09c7c459 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain.go @@ -192,16 +192,16 @@ func resourceGTMv1Domain() *schema.Resource { } // GetQueryArgs retrieves optional query args. contractId, groupId [and accountSwitchKey] supported. -func GetQueryArgs(d *schema.ResourceData) (map[string]string, error) { +func GetQueryArgs(d *schema.ResourceData) (*gtm.DomainQueryArgs, error) { - qArgs := make(map[string]string) + qArgs := gtm.DomainQueryArgs{} contractName, err := tf.GetStringValue("contract", d) if err != nil { return nil, fmt.Errorf("contract not present in resource data: %v", err.Error()) } contract := strings.TrimPrefix(contractName, "ctr_") if contract != "" && len(contract) > 0 { - qArgs["contractId"] = contract + qArgs.ContractID = contract } groupName, err := tf.GetStringValue("group", d) if err != nil { @@ -209,10 +209,10 @@ func GetQueryArgs(d *schema.ResourceData) (map[string]string, error) { } groupID := strings.TrimPrefix(groupName, "grp_") if groupID != "" && len(groupID) > 0 { - qArgs["gid"] = groupID + qArgs.GroupID = groupID } - return qArgs, nil + return &qArgs, nil } // Create a new GTM Domain @@ -246,7 +246,10 @@ func resourceGTMv1DomainCreate(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - cStatus, err := Client(meta).CreateDomain(ctx, newDom, queryArgs) + cStatus, err := Client(meta).CreateDomain(ctx, gtm.CreateDomainRequest{ + Domain: newDom, + QueryArgs: queryArgs, + }) if err != nil { // Errored. Let's see if special hack if !HashiAcc { @@ -330,7 +333,9 @@ func resourceGTMv1DomainRead(ctx context.Context, d *schema.ResourceData, m inte logger.Debugf("Reading Domain: %s", d.Id()) var diags diag.Diagnostics // retrieve the domain - dom, err := Client(meta).GetDomain(ctx, d.Id()) + dom, err := Client(meta).GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: d.Id(), + }) if err != nil { logger.Errorf("Domain Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -357,7 +362,9 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in logger.Debugf("Updating Domain: %s", d.Id()) var diags diag.Diagnostics // Get existing domain - existDom, err := Client(meta).GetDomain(ctx, d.Id()) + existDom, err := Client(meta).GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: d.Id(), + }) if err != nil { logger.Errorf("Domain Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -367,11 +374,12 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("Updating Domain BEFORE: %v", existDom) - err = populateDomainObject(d, existDom, m) + newDom := createDomainStruct(existDom) + err = populateDomainObject(d, newDom, m) if err != nil { return diag.FromErr(err) } - logger.Debugf("Updating Domain PROPOSED: %v", existDom) + logger.Debugf("Updating Domain PROPOSED: %v", newDom) //existDom := populateNewDomainObject(d) args, err := GetQueryArgs(d) if err != nil { @@ -382,7 +390,11 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - uStat, err := Client(meta).UpdateDomain(ctx, existDom, args) + + uStat, err := Client(meta).UpdateDomain(ctx, gtm.UpdateDomainRequest{ + Domain: newDom, + QueryArgs: args, + }) if err != nil { logger.Errorf("Domain Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -392,11 +404,11 @@ func resourceGTMv1DomainUpdate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -441,7 +453,9 @@ func resourceGTMv1DomainDelete(ctx context.Context, d *schema.ResourceData, m in logger.Debugf("Deleting GTM Domain: %s", d.Id()) var diags diag.Diagnostics // Get existing domain - existDom, err := Client(meta).GetDomain(ctx, d.Id()) + existDom, err := Client(meta).GetDomain(ctx, gtm.GetDomainRequest{ + DomainName: d.Id(), + }) if err != nil { logger.Errorf("Domain Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -450,7 +464,10 @@ func resourceGTMv1DomainDelete(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - uStat, err := Client(meta).DeleteDomain(ctx, existDom) + logger.Debugf("Deleting Domain: %v", existDom) + uStat, err := Client(meta).DeleteDomain(ctx, gtm.DeleteDomainRequest{ + DomainName: d.Id(), + }) if err != nil { // Errored. Let's see if special hack if !HashiAcc { @@ -748,7 +765,7 @@ func populateDomainObject(d *schema.ResourceData, dom *gtm.Domain, m interface{} } // Populate Terraform state from provided Domain object -func populateTerraformState(d *schema.ResourceData, dom *gtm.Domain, m interface{}) { +func populateTerraformState(d *schema.ResourceData, dom *gtm.GetDomainResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformState") @@ -800,6 +817,58 @@ func populateTerraformState(d *schema.ResourceData, dom *gtm.Domain, m interface } } +// createDomainStruct converts response from GetDomainResponse into Domain +func createDomainStruct(domain *gtm.GetDomainResponse) *gtm.Domain { + if domain != nil { + return >m.Domain{ + Name: domain.Name, + Type: domain.Type, + ASMaps: domain.ASMaps, + Resources: domain.Resources, + DefaultUnreachableThreshold: domain.DefaultUnreachableThreshold, + EmailNotificationList: domain.EmailNotificationList, + MinPingableRegionFraction: domain.MinPingableRegionFraction, + DefaultTimeoutPenalty: domain.DefaultTimeoutPenalty, + Datacenters: domain.Datacenters, + ServermonitorLivenessCount: domain.ServermonitorLivenessCount, + RoundRobinPrefix: domain.RoundRobinPrefix, + ServermonitorLoadCount: domain.ServermonitorLoadCount, + PingInterval: domain.PingInterval, + MaxTTL: domain.MaxTTL, + LoadImbalancePercentage: domain.LoadImbalancePercentage, + DefaultHealthMax: domain.DefaultHealthMax, + LastModified: domain.LastModified, + Status: domain.Status, + MapUpdateInterval: domain.MapUpdateInterval, + MaxProperties: domain.MaxProperties, + MaxResources: domain.MaxResources, + DefaultSSLClientPrivateKey: domain.DefaultSSLClientPrivateKey, + DefaultErrorPenalty: domain.DefaultErrorPenalty, + Links: domain.Links, + Properties: domain.Properties, + MaxTestTimeout: domain.MaxTestTimeout, + CNameCoalescingEnabled: domain.CNameCoalescingEnabled, + DefaultHealthMultiplier: domain.DefaultHealthMultiplier, + ServermonitorPool: domain.ServermonitorPool, + LoadFeedback: domain.LoadFeedback, + MinTTL: domain.MinTTL, + GeographicMaps: domain.GeographicMaps, + CIDRMaps: domain.CIDRMaps, + DefaultMaxUnreachablePenalty: domain.DefaultMaxUnreachablePenalty, + DefaultHealthThreshold: domain.DefaultHealthThreshold, + LastModifiedBy: domain.LastModifiedBy, + ModificationComments: domain.ModificationComments, + MinTestInterval: domain.MinTestInterval, + PingPacketSize: domain.PingPacketSize, + DefaultSSLClientCertificate: domain.DefaultSSLClientCertificate, + EndUserMappingEnabled: domain.EndUserMappingEnabled, + SignAndServe: domain.SignAndServe, + SignAndServeAlgorithm: domain.SignAndServeAlgorithm, + } + } + return nil +} + // Util function to wait for change deployment. return true if complete. false if not - error or nil (timeout) func waitForCompletion(ctx context.Context, domain string, m interface{}) (bool, error) { meta := meta.Must(m) @@ -816,7 +885,9 @@ func waitForCompletion(ctx context.Context, domain string, m interface{}) (bool, logger.Debugf("WAIT: Sleep Interval [%v]", sleepInterval/time.Second) logger.Debugf("WAIT: Sleep Timeout [%v]", sleepTimeout/time.Second) for { - propStat, err := Client(meta).GetDomainStatus(ctx, domain) + propStat, err := Client(meta).GetDomainStatus(ctx, gtm.GetDomainStatusRequest{ + DomainName: domain, + }) if err != nil { return false, fmt.Errorf("GetDomainStatus error: %s", err.Error()) } diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go index 8a16a73a3..86d0bdb1c 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go @@ -5,9 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -20,39 +19,52 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - dr := gtm.DomainResponse{} - dr.Resource = &testDomain - dr.Status = &pendingResponseStatus + dr := testCreateDomain client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testCreateDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) + client.On("GetDomain", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetDomainRequest"), + ).Return(&testCreateDomain, nil).Times(3) + client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} - }) + gtm.UpdateDomainRequest{ + Domain: testUpdateDomain, + QueryArgs: >m.DomainQueryArgs{ + ContractID: "1-2ABCDEF", + GroupID: "123ABC", + }, + }, + ).Return(&updateDomainResponseStatus, nil) + + client.On("GetDomain", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetDomainRequest"), + ).Return(&testUpdateGetDomain, nil).Times(3) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -90,31 +102,31 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &testDomainWithSignAndServe - dr.Status = &pendingResponseStatus + dr := testDomainWithSignAndServe client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testGetDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -142,31 +154,31 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &testDomain - dr.Status = &pendingResponseStatus + dr := testGetDomain client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testGetDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -198,8 +210,7 @@ func TestResGTMDomain(t *testing.T) { client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), + mock.AnythingOfType("gtm.CreateDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -222,13 +233,12 @@ func TestResGTMDomain(t *testing.T) { t.Run("create domain denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.DomainResponse{} - dr.Resource = &testDomain + dr := gtm.CreateDomainResponse{} + dr.Resource = testDomain dr.Status = &deniedResponseStatus client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), + mock.AnythingOfType("gtm.CreateDomainRequest"), ).Return(&dr, nil) useClient(client, func() { @@ -251,31 +261,31 @@ func TestResGTMDomain(t *testing.T) { getCall := client.On("GetDomain", mock.Anything, - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &testDomain - dr.Status = &pendingResponseStatus + dr := testGetDomain client.On("CreateDomain", mock.Anything, - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: testDomain, + Status: testGetDomain.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Times(2) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil).Times(2) client.On("DeleteDomain", mock.Anything, - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -360,38 +370,38 @@ func getGTMDomainMocks() *gtm.Mock { mockGetDomain := client.On("GetDomain", mock.Anything, // ctx is irrelevant for this test - gtmTestDomain, + mock.AnythingOfType("gtm.GetDomainRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - dr := gtm.DomainResponse{} - dr.Resource = &domainWithOrderedEmails - dr.Status = &pendingResponseStatus + dr := domainWithOrderedEmails client.On("CreateDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - mock.AnythingOfType("map[string]string"), - ).Return(&dr, nil).Run(func(args mock.Arguments) { - mockGetDomain.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Domain), nil} + mock.AnythingOfType("gtm.CreateDomainRequest"), + ).Return(>m.CreateDomainResponse{ + Resource: domainWithOrderedEmailsDomain, + Status: domainWithOrderedEmails.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetDomain.ReturnArguments = mock.Arguments{&dr, nil} }) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteDomain", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Domain"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteDomainRequest"), + ).Return(&deleteDomainResponseStatus, nil) return client } var ( // datacenters is gtm.Datacenter structure used in tests - datacenters = []*gtm.Datacenter{ + datacenters = []gtm.Datacenter{ { City: "Snæfellsjökull", CloudServerTargeting: false, @@ -404,7 +414,7 @@ var ( LoadServers: make([]string, 0), }, Latitude: 64.808, - Links: []*gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/datacenters/3132", Rel: "self", @@ -418,7 +428,7 @@ var ( } // links is gtm.link structure used in tests - links = []*gtm.Link{ + links = []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net", Rel: "self", @@ -446,7 +456,7 @@ var ( } // properties is gtm.Property structure used in tests - properties = []*gtm.Property{ + properties = []gtm.Property{ { BackupCName: "", BackupIP: "", @@ -462,13 +472,13 @@ var ( HealthThreshold: 0, IPv6: false, LastModified: "2019-04-25T14:53:12.000+00:00", - Links: []*gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/properties/test_property", Rel: "self", }, }, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { DisableNonstandardPortWarning: false, HTTPError3xx: true, @@ -496,7 +506,7 @@ var ( StaticTTL: 600, StickinessBonusConstant: 0, StickinessBonusPercentage: 50, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -518,7 +528,7 @@ var ( // testStatus is gtm.ResponseStatus structure used in tests testStatus = >m.ResponseStatus{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", @@ -530,8 +540,27 @@ var ( PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", } + domainWithOrderedEmailsDomain = >m.Domain{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: []string{"email1@nomail.com", "email2@nomail.com", "email3@nomail.com"}, + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 10.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + // domainWithOrderedEmails is a gtm.Domain structure used in testing of email_notification_order list - domainWithOrderedEmails = gtm.Domain{ + domainWithOrderedEmails = gtm.GetDomainResponse{ Datacenters: datacenters, DefaultErrorPenalty: 75, DefaultSSLClientCertificate: "", @@ -550,7 +579,83 @@ var ( Type: "weighted", } - testDomain = gtm.Domain{ + testDomain = >m.Domain{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 10.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testUpdateGetDomain = gtm.GetDomainResponse{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 20.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testUpdateDomain = >m.Domain{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 20.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testGetDomain = gtm.GetDomainResponse{ + Datacenters: datacenters, + DefaultErrorPenalty: 75, + DefaultSSLClientCertificate: "", + DefaultSSLClientPrivateKey: "", + DefaultTimeoutPenalty: 25, + EmailNotificationList: make([]string, 0), + LastModified: "2019-04-25T14:53:12.000+00:00", + LastModifiedBy: "operator", + Links: links, + LoadFeedback: false, + LoadImbalancePercentage: 10.0, + ModificationComments: "Edit Property test_property", + Name: gtmTestDomain, + Properties: properties, + Status: testStatus, + Type: "weighted", + } + + testCreateDomain = gtm.GetDomainResponse{ Datacenters: datacenters, DefaultErrorPenalty: 75, DefaultSSLClientCertificate: "", @@ -569,7 +674,7 @@ var ( Type: "weighted", } - testDomainWithSignAndServe = gtm.Domain{ + testDomainWithSignAndServe = gtm.GetDomainResponse{ Datacenters: datacenters, DefaultErrorPenalty: 75, DefaultSSLClientCertificate: "", @@ -592,7 +697,7 @@ var ( deniedResponseStatus = gtm.ResponseStatus{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", @@ -606,7 +711,7 @@ var ( pendingResponseStatus = gtm.ResponseStatus{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", @@ -618,9 +723,25 @@ var ( PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", } - completeResponseStatus = gtm.ResponseStatus{ + updateDomainResponseStatus = gtm.UpdateDomainResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deleteDomainResponseStatus = gtm.DeleteDomainResponse{ ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", - Links: &[]gtm.Link{ + Links: []gtm.Link{ { Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", Rel: "self", diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap.go b/pkg/providers/gtm/resource_akamai_gtm_geomap.go index 0313252ca..d8551eda2 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap.go @@ -7,9 +7,8 @@ import ( "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" - "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" + "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -128,7 +127,10 @@ func resourceGTMv1GeoMapCreate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("Proposed New geoMap: [%v]", newGeo) - cStatus, err := Client(meta).CreateGeoMap(ctx, newGeo, domain) + cStatus, err := Client(meta).CreateGeoMap(ctx, gtm.CreateGeoMapRequest{ + GeoMap: newGeo, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -193,7 +195,10 @@ func resourceGTMv1GeoMapRead(ctx context.Context, d *schema.ResourceData, m inte logger.Errorf("Invalid geoMap ID") return diag.FromErr(err) } - geo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + geo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Read error: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -231,7 +236,10 @@ func resourceGTMv1GeoMapUpdate(ctx context.Context, d *schema.ResourceData, m in return diag.FromErr(err) } // Get existingGeoMap - existGeo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + existGeo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -240,10 +248,14 @@ func resourceGTMv1GeoMapUpdate(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - logger.Debugf("Updating geoMap BEFORE: %v", existGeo) - populateGeoMapObject(d, existGeo, m) + newGeo := createGeoMapStruct(existGeo) + logger.Debugf("Updating geoMap BEFORE: %v", newGeo) + populateGeoMapObject(d, newGeo, m) logger.Debugf("Updating geoMap PROPOSED: %v", existGeo) - uStat, err := Client(meta).UpdateGeoMap(ctx, existGeo, domain) + uStat, err := Client(meta).UpdateGeoMap(ctx, gtm.UpdateGeoMapRequest{ + GeoMap: newGeo, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -253,11 +265,11 @@ func resourceGTMv1GeoMapUpdate(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("geoMap Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -304,7 +316,10 @@ func resourceGTMv1GeoMapImport(d *schema.ResourceData, m interface{}) ([]*schema if err != nil { return []*schema.ResourceData{d}, err } - geo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + geo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { return nil, err } @@ -344,7 +359,10 @@ func resourceGTMv1GeoMapDelete(ctx context.Context, d *schema.ResourceData, m in logger.Errorf("Invalid geoMap ID: %s", d.Id()) return diag.FromErr(err) } - existGeo, err := Client(meta).GetGeoMap(ctx, geoMap, domain) + existGeo, err := Client(meta).GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -353,8 +371,12 @@ func resourceGTMv1GeoMapDelete(ctx context.Context, d *schema.ResourceData, m in Detail: err.Error(), }) } - logger.Debugf("Deleting geoMap: %v", existGeo) - uStat, err := Client(meta).DeleteGeoMap(ctx, existGeo, domain) + newGeo := createGeoMapStruct(existGeo) + logger.Debugf("Deleting geoMap: %v", newGeo) + uStat, err := Client(meta).DeleteGeoMap(ctx, gtm.DeleteGeoMapRequest{ + MapName: geoMap, + DomainName: domain, + }) if err != nil { logger.Errorf("geoMap Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -364,11 +386,11 @@ func resourceGTMv1GeoMapDelete(ctx context.Context, d *schema.ResourceData, m in }) } logger.Debugf("geoMap Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -409,8 +431,8 @@ func populateNewGeoMapObject(d *schema.ResourceData, m interface{}) (*gtm.GeoMap geoObj := >m.GeoMap{ Name: name, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]*gtm.GeoAssignment, 1), - Links: make([]*gtm.Link, 1), + Assignments: make([]gtm.GeoAssignment, 1), + Links: make([]gtm.Link, 1), } populateGeoMapObject(d, geoObj, m) @@ -427,7 +449,7 @@ func populateGeoMapObject(d *schema.ResourceData, geo *gtm.GeoMap, m interface{} } // Populate Terraform state from provided GeoMap object -func populateTerraformGeoMapState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) error { +func populateTerraformGeoMapState(d *schema.ResourceData, geo *gtm.GetGeoMapResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoMapState") @@ -449,7 +471,7 @@ func populateGeoAssignmentsObject(d *schema.ResourceData, geo *gtm.GeoMap, m int // pull apart List geoAssignmentsList, err := tf.GetListValue("assignment", d) if err == nil { - geoAssignmentsObjList := make([]*gtm.GeoAssignment, len(geoAssignmentsList)) // create new object list + geoAssignmentsObjList := make([]gtm.GeoAssignment, len(geoAssignmentsList)) // create new object list for i, v := range geoAssignmentsList { geoMap, ok := v.(map[string]interface{}) if !ok { @@ -470,18 +492,18 @@ func populateGeoAssignmentsObject(d *schema.ResourceData, geo *gtm.GeoMap, m int } geoAssignment.Countries = ls } - geoAssignmentsObjList[i] = &geoAssignment + geoAssignmentsObjList[i] = geoAssignment } geo.Assignments = geoAssignmentsObjList } } // create and populate Terraform geoMap assignments schema -func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) error { +func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GetGeoMapResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoAssignmentsState") - objectInventory := make(map[int]*gtm.GeoAssignment, len(geo.Assignments)) + objectInventory := make(map[int]gtm.GeoAssignment, len(geo.Assignments)) if len(geo.Assignments) > 0 { for _, aObj := range geo.Assignments { objectInventory[aObj.DatacenterID] = aObj @@ -495,7 +517,7 @@ func populateTerraformGeoAssignmentsState(d *schema.ResourceData, geo *gtm.GeoMa a := aMap.(map[string]interface{}) objIndex := a["datacenter_id"].(int) aObject := objectInventory[objIndex] - if aObject == nil { + if &aObject == nil { logger.Warnf("Geo Assignment %d NOT FOUND in returned GTM Object", a["datacenter_id"]) continue } @@ -552,7 +574,7 @@ func populateGeoDefaultDCObject(d *schema.ResourceData, geo *gtm.GeoMap, m inter } // create and populate Terraform geoMap default_datacenter schema -func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GeoMap, m interface{}) error { +func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GetGeoMapResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformGeoDefault") @@ -569,6 +591,19 @@ func populateTerraformGeoDefaultDCState(d *schema.ResourceData, geo *gtm.GeoMap, return nil } +// createGeoMapStruct converts response from GetGeoMapResponse into GeoMap +func createGeoMapStruct(geo *gtm.GetGeoMapResponse) *gtm.GeoMap { + if geo != nil { + return >m.GeoMap{ + DefaultDatacenter: geo.DefaultDatacenter, + Assignments: geo.Assignments, + Name: geo.Name, + Links: geo.Links, + } + } + return nil +} + // countriesEqual checks whether countries are equal func countriesEqual(old, new interface{}) bool { logger := logger.Get("Akamai GTM", "countriesEqual") diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go index f211c6bf0..40bf9e8b7 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go @@ -13,8 +13,8 @@ import ( func TestResGTMGeoMap(t *testing.T) { dc := gtm.Datacenter{ - DatacenterID: geo.DefaultDatacenter.DatacenterID, - Nickname: geo.DefaultDatacenter.Nickname, + DatacenterID: geomap.DefaultDatacenter.DatacenterID, + Nickname: geomap.DefaultDatacenter.Nickname, } t.Run("create geomap", func(t *testing.T) { @@ -22,47 +22,51 @@ func TestResGTMGeoMap(t *testing.T) { getCall := client.On("GetGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetGeoMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.GeoMapResponse{} - resp.Resource = &geo - resp.Status = &pendingResponseStatus + resp := geomap client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.GeoMap), nil} + mock.AnythingOfType("gtm.CreateGeoMapRequest"), + ).Return(>m.CreateGeoMapResponse{ + Resource: geoMapCreate.Resource, + Status: geoMapCreate.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetGeoMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetGeoMapRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.GeoMap), nil} - }) + mock.AnythingOfType("gtm.UpdateGeoMapRequest"), + ).Return(updateGeoMapResponseStatus, nil) + + client.On("GetGeoMap", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetGeoMapRequest"), + ).Return(&geomapUpdate, nil).Times(3) client.On("DeleteGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteGeoMapRequest"), + ).Return(deleteGeoMapResponseStatus, nil) dataSourceName := "akamai_gtm_geomap.tfexample_geomap_1" @@ -94,16 +98,14 @@ func TestResGTMGeoMap(t *testing.T) { client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateGeoMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -124,19 +126,17 @@ func TestResGTMGeoMap(t *testing.T) { t.Run("create geomap denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.GeoMapResponse{} - dr.Resource = &geo + dr := gtm.CreateGeoMapResponse{} + dr.Resource = geoMapCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateGeoMapRequest"), ).Return(&dr, nil) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) useClient(client, func() { @@ -250,52 +250,49 @@ func getGeoMapMocks() *gtm.Mock { mockGetGeoMap := client.On("GetGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetGeoMapRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.GeoMapResponse{} - resp.Resource = &geoDiffOrder - resp.Status = &pendingResponseStatus + resp := geoDiffOrder client.On("CreateGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - mockGetGeoMap.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.GeoMap), nil} + mock.AnythingOfType("gtm.CreateGeoMapRequest"), + ).Return(>m.CreateGeoMapResponse{ + Resource: geoMapCreateDiif.Resource, + Status: geoMapCreateDiif.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetGeoMap.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("GetDatacenter", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("int"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetDatacenterRequest"), ).Return(&dc, nil) client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("DeleteGeoMap", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.GeoMap"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteGeoMapRequest"), + ).Return(deleteGeoMapResponseStatus, nil) return client } var ( // geoDiffOrder is gtm.GeoMap structure used in testing of the assignments order - geoDiffOrder = gtm.GeoMap{ + geoDiffOrder = gtm.GetGeoMapResponse{ Name: "tfexample_geomap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.GeoAssignment{ + Assignments: []gtm.GeoAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -320,13 +317,59 @@ var ( }, } - geo = gtm.GeoMap{ + geoMapCreateDiif = gtm.CreateGeoMapResponse{ + Resource: >m.GeoMap{ + Name: "tfexample_geomap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.GeoAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + Countries: []string{"GB", "PL", "US", "FR"}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + Countries: []string{"GB", "AU"}, + }, + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3133, + Nickname: "tfexample_dc_3", + }, + Countries: []string{"GB", "BG", "CN", "MC", "TR"}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + geomap = gtm.GetGeoMapResponse{ Name: "tfexample_geomap_1", DefaultDatacenter: >m.DatacenterBase{ DatacenterID: 5400, Nickname: "default datacenter", }, - Assignments: []*gtm.GeoAssignment{ + Assignments: []gtm.GeoAssignment{ { DatacenterBase: gtm.DatacenterBase{ DatacenterID: 3131, @@ -336,4 +379,84 @@ var ( }, }, } + + geomapUpdate = gtm.GetGeoMapResponse{ + Name: "tfexample_geomap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.GeoAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3132, + Nickname: "tfexample_dc_2", + }, + Countries: []string{"US"}, + }, + }, + } + + geoMapCreate = gtm.CreateGeoMapResponse{ + Resource: >m.GeoMap{ + Name: "tfexample_geomap_1", + DefaultDatacenter: >m.DatacenterBase{ + DatacenterID: 5400, + Nickname: "default datacenter", + }, + Assignments: []gtm.GeoAssignment{ + { + DatacenterBase: gtm.DatacenterBase{ + DatacenterID: 3131, + Nickname: "tfexample_dc_1", + }, + Countries: []string{"GB"}, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + updateGeoMapResponseStatus = >m.UpdateGeoMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + deleteGeoMapResponseStatus = >m.DeleteGeoMapResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 7eccaadf4..7395c5c48 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -541,7 +541,10 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } logger.Debugf("Proposed New Property: [%v]", newProp) - cStatus, err := createPropertyWithRetry(ctx, meta, logger, newProp, domain) + cStatus, err := Client(meta).CreateProperty(ctx, gtm.CreatePropertyRequest{ + Property: newProp, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Create failed: CreateProperty error: %s", err.Error()) return diag.Errorf("property Create failed: CreateProperty error: %s", err.Error()) @@ -588,7 +591,10 @@ func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Int for { // Attempt to create the property - cStatus, err := Client(meta).CreateProperty(ctx, newProp, domain) + cStatus, err := Client(meta).CreateProperty(ctx, gtm.CreatePropertyRequest{ + Property: newProp, + DomainName: domain, + }) if err == nil { // Success, return the created property return cStatus, nil @@ -638,7 +644,10 @@ func resourceGTMv1PropertyRead(ctx context.Context, d *schema.ResourceData, m in if err != nil { return diag.FromErr(err) } - prop, err := Client(meta).GetProperty(ctx, property, domain) + prop, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if errors.Is(err, gtm.ErrNotFound) { d.SetId("") return nil @@ -669,26 +678,33 @@ func resourceGTMv1PropertyUpdate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } // Get existing property - existProp, err := Client(meta).GetProperty(ctx, property, domain) + existProp, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Update failed: GetProperty error: %s", err.Error()) return diag.Errorf("property Update failed: GetProperty error: %s", err.Error()) } + newProp := createPropertyStruct(existProp) logger.Debugf("Updating Property BEFORE: %v", existProp) - err = populatePropertyObject(d, existProp, m) + err = populatePropertyObject(d, newProp, m) if err != nil { return diag.FromErr(err) } logger.Debugf("Updating Property PROPOSED: %v", existProp) - uStat, err := Client(meta).UpdateProperty(ctx, existProp, domain) + uStat, err := Client(meta).UpdateProperty(ctx, gtm.UpdatePropertyRequest{ + Property: newProp, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Update failed: UpdateProperty error: %s", err.Error()) return diag.Errorf("property Update failed: UpdateProperty error: %s", err.Error()) } logger.Debugf("Property Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Debugf(uStat.Message) - return diag.FromErr(fmt.Errorf(uStat.Message)) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Debugf(uStat.Status.Message) + return diag.FromErr(fmt.Errorf(uStat.Status.Message)) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -729,7 +745,10 @@ func resourceGTMv1PropertyImport(d *schema.ResourceData, m interface{}) ([]*sche if err != nil { return []*schema.ResourceData{d}, err } - prop, err := Client(meta).GetProperty(ctx, property, domain) + prop, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { return nil, fmt.Errorf("property Import failed: GetProperty error: %s", err.Error()) } @@ -762,21 +781,28 @@ func resourceGTMv1PropertyDelete(ctx context.Context, d *schema.ResourceData, m if err != nil { return diag.FromErr(err) } - existProp, err := Client(meta).GetProperty(ctx, property, domain) + existProp, err := Client(meta).GetProperty(ctx, gtm.GetPropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Delete failed: GetProperty error: %s", err.Error()) return diag.Errorf("property Delete failed: GetProperty error: %s", err.Error()) } - logger.Debugf("Deleting Property: %v", existProp) - uStat, err := Client(meta).DeleteProperty(ctx, existProp, domain) + newProp := createPropertyStruct(existProp) + logger.Debugf("Deleting Property: %v", newProp) + uStat, err := Client(meta).DeleteProperty(ctx, gtm.DeletePropertyRequest{ + PropertyName: property, + DomainName: domain, + }) if err != nil { logger.Errorf("Property Delete failed: DeleteProperty error: %s", err.Error()) return diag.Errorf("property Delete failed: DeleteProperty error: %s", err.Error()) } logger.Debugf("Property Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) - return diag.FromErr(fmt.Errorf(uStat.Message)) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) + return diag.FromErr(fmt.Errorf(uStat.Status.Message)) } waitOnComplete, err := tf.GetBoolValue("wait_on_complete", d) @@ -1020,8 +1046,8 @@ func populateNewPropertyObject(d *schema.ResourceData, m interface{}) (*gtm.Prop } propObj := >m.Property{ Name: name, - TrafficTargets: make([]*gtm.TrafficTarget, 0), - LivenessTests: make([]*gtm.LivenessTest, 0), + TrafficTargets: make([]gtm.TrafficTarget, 0), + LivenessTests: make([]gtm.LivenessTest, 0), } err = populatePropertyObject(d, propObj, m) @@ -1030,7 +1056,7 @@ func populateNewPropertyObject(d *schema.ResourceData, m interface{}) (*gtm.Prop } // Populate Terraform state from provided Property object -func populateTerraformPropertyState(d *schema.ResourceData, prop *gtm.Property, m interface{}) { +func populateTerraformPropertyState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformPropertyState") @@ -1096,10 +1122,10 @@ func populateTrafficTargetObject(d *schema.ResourceData, prop *gtm.Property, m i // pull apart List traffTargList, err := tf.GetInterfaceArrayValue("traffic_target", d) if err == nil { - trafficObjList := make([]*gtm.TrafficTarget, len(traffTargList)) // create new object list + trafficObjList := make([]gtm.TrafficTarget, len(traffTargList)) // create new object list for i, v := range traffTargList { ttMap := v.(map[string]interface{}) - trafficTarget := >m.TrafficTarget{} + trafficTarget := gtm.TrafficTarget{} trafficTarget.DatacenterID = ttMap["datacenter_id"].(int) trafficTarget.Precedence = ptr.To(ttMap["precedence"].(int)) trafficTarget.Enabled = ttMap["enabled"].(bool) @@ -1121,11 +1147,11 @@ func populateTrafficTargetObject(d *schema.ResourceData, prop *gtm.Property, m i } // create and populate Terraform traffic_targets schema -func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.Property, m interface{}) error { +func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformTrafficTargetState") - objectInventory := make(map[int]*gtm.TrafficTarget, len(prop.TrafficTargets)) + objectInventory := make(map[int]gtm.TrafficTarget, len(prop.TrafficTargets)) if len(prop.TrafficTargets) > 0 { for _, aObj := range prop.TrafficTargets { objectInventory[aObj.DatacenterID] = aObj @@ -1140,7 +1166,7 @@ func populateTerraformTrafficTargetState(d *schema.ResourceData, prop *gtm.Prope tt := ttMap.(map[string]interface{}) objIndex := tt["datacenter_id"].(int) ttObject := objectInventory[objIndex] - if ttObject == nil { + if &ttObject == nil { logger.Warnf("Property TrafficTarget %d NOT FOUND in returned GTM Object", tt["datacenter_id"]) continue } @@ -1182,10 +1208,10 @@ func populateStaticRRSetObject(d *schema.ResourceData, prop *gtm.Property) { // pull apart List staticSetList, err := tf.GetInterfaceArrayValue("static_rr_set", d) if err == nil { - staticObjList := make([]*gtm.StaticRRSet, len(staticSetList)) // create new object list + staticObjList := make([]gtm.StaticRRSet, len(staticSetList)) // create new object list for i, v := range staticSetList { recMap := v.(map[string]interface{}) - record := >m.StaticRRSet{ + record := gtm.StaticRRSet{ TTL: recMap["ttl"].(int), Type: recMap["type"].(string), } @@ -1203,11 +1229,11 @@ func populateStaticRRSetObject(d *schema.ResourceData, prop *gtm.Property) { } // create and populate Terraform static_rr_sets schema -func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.Property, m interface{}) error { +func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformStaticRRSetState") - objectInventory := make(map[string]*gtm.StaticRRSet, len(prop.StaticRRSets)) + objectInventory := make(map[string]gtm.StaticRRSet, len(prop.StaticRRSets)) if len(prop.StaticRRSets) > 0 { for _, aObj := range prop.StaticRRSets { objectInventory[aObj.Type] = aObj @@ -1222,7 +1248,7 @@ func populateTerraformStaticRRSetState(d *schema.ResourceData, prop *gtm.Propert rr := rrMap.(map[string]interface{}) objIndex := rr["type"].(string) rrObject := objectInventory[objIndex] - if rrObject == nil { + if &rrObject == nil { logger.Warnf("Property StaticRRSet %s NOT FOUND in returned GTM Object", rr["type"]) continue } @@ -1253,11 +1279,11 @@ func populateLivenessTestObject(d *schema.ResourceData, prop *gtm.Property) { liveTestList, err := tf.GetInterfaceArrayValue("liveness_test", d) if err == nil { - liveTestObjList := make([]*gtm.LivenessTest, len(liveTestList)) // create new object list + liveTestObjList := make([]gtm.LivenessTest, len(liveTestList)) // create new object list for i, l := range liveTestList { v := l.(map[string]interface{}) - lt := >m.LivenessTest{ + lt := gtm.LivenessTest{ Name: v["name"].(string), TestObjectProtocol: v["test_object_protocol"].(string), TestInterval: v["test_interval"].(int), @@ -1291,10 +1317,10 @@ func populateLivenessTestObject(d *schema.ResourceData, prop *gtm.Property) { } httpHeaderList := v["http_header"].([]interface{}) if httpHeaderList != nil { - headerObjList := make([]*gtm.HTTPHeader, len(httpHeaderList)) // create new object list + headerObjList := make([]gtm.HTTPHeader, len(httpHeaderList)) // create new object list for i, h := range httpHeaderList { recMap := h.(map[string]interface{}) - record := >m.HTTPHeader{ + record := gtm.HTTPHeader{ Name: recMap["name"].(string), Value: recMap["value"].(string), } @@ -1317,11 +1343,11 @@ func populateLivenessTestObject(d *schema.ResourceData, prop *gtm.Property) { } // create and populate Terraform liveness_test schema -func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.Property, m interface{}) error { +func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.GetPropertyResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformLivenessTestState") - objectInventory := make(map[string]*gtm.LivenessTest, len(prop.LivenessTests)) + objectInventory := make(map[string]gtm.LivenessTest, len(prop.LivenessTests)) if len(prop.LivenessTests) > 0 { for _, aObj := range prop.LivenessTests { objectInventory[aObj.Name] = aObj @@ -1336,7 +1362,7 @@ func populateTerraformLivenessTestState(d *schema.ResourceData, prop *gtm.Proper lt := ltMap.(map[string]interface{}) objIndex := lt["name"].(string) ltObject := objectInventory[objIndex] - if ltObject == nil { + if <Object == nil { logger.Warnf("Property LivenessTest %s NOT FOUND in returned GTM Object", lt["name"]) continue } @@ -1530,6 +1556,49 @@ func trafficTargetDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { return true } +// createPropertyStruct converts response from GetPropertyResponse into Property +func createPropertyStruct(prop *gtm.GetPropertyResponse) *gtm.Property { + if prop != nil { + return >m.Property{ + Name: prop.CName, + Type: prop.Type, + IPv6: prop.IPv6, + ScoreAggregationType: prop.ScoreAggregationType, + StickinessBonusPercentage: prop.StickinessBonusPercentage, + StickinessBonusConstant: prop.StickinessBonusConstant, + HealthThreshold: prop.HealthThreshold, + UseComputedTargets: prop.UseComputedTargets, + BackupIP: prop.BackupIP, + BalanceByDownloadScore: prop.BalanceByDownloadScore, + StaticTTL: prop.StaticTTL, + StaticRRSets: prop.StaticRRSets, + LastModified: prop.LastModified, + UnreachableThreshold: prop.UnreachableThreshold, + MinLiveFraction: prop.MinLiveFraction, + HealthMultiplier: prop.HealthMultiplier, + DynamicTTL: prop.DynamicTTL, + MaxUnreachablePenalty: prop.MaxUnreachablePenalty, + MapName: prop.Name, + HandoutLimit: prop.HandoutLimit, + HandoutMode: prop.HandoutMode, + FailoverDelay: prop.FailoverDelay, + BackupCName: prop.BackupIP, + FailbackDelay: prop.FailbackDelay, + LoadImbalancePercentage: prop.LoadImbalancePercentage, + HealthMax: prop.HealthMax, + GhostDemandReporting: prop.GhostDemandReporting, + Comments: prop.Comments, + CName: prop.CName, + WeightedHashBitsForIPv4: prop.WeightedHashBitsForIPv4, + WeightedHashBitsForIPv6: prop.WeightedHashBitsForIPv6, + TrafficTargets: prop.TrafficTargets, + Links: prop.Links, + LivenessTests: prop.LivenessTests, + } + } + return nil +} + func livenessTestsDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { oldLTests, newLTests := d.GetChange("liveness_test") oldLivenessTest := oldLTests.([]any) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index e945b70fd..4e4d05c48 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -15,8 +15,39 @@ import ( var ( propertyResourceName = "akamai_gtm_property.tfexample_prop_1" - propertyName = "tfexample_prop_1" updatedPropertyName = "tfexample_prop_1-updated" + + updatePropertyResponseStatus = >m.UpdatePropertyResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + deletePropertyResponseStatus = >m.DeletePropertyResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) func TestResGTMProperty(t *testing.T) { @@ -28,16 +59,16 @@ func TestResGTMProperty(t *testing.T) { "create property": { property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getBasicProperty(), gtmTestDomain) + mockCreateProperty(m, getBasicProperty()) // read - mockGetProperty(m, getBasicProperty(), propertyName, gtmTestDomain, 4) + mockGetProperty(m, getBasicPropertyResponse(), 4) // update - mockUpdateProperty(m, getUpdatedProperty(), gtmTestDomain) + mockUpdateProperty(m) // read - mockGetDomainStatus(m, gtmTestDomain, 2) - mockGetProperty(m, getUpdatedProperty(), propertyName, gtmTestDomain, 3) + mockGetDomainStatus(m, 2) + mockGetProperty(m, getBasicPropertyResponseUpdate(), 3) // delete - mockDeleteProperty(m, getUpdatedProperty(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -75,11 +106,11 @@ func TestResGTMProperty(t *testing.T) { "create property with additional liveness test fields": { property: getBasicPropertyWithLivenessTests(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getBasicPropertyWithLivenessTests(), gtmTestDomain) + mockCreateProperty(m, getBasicPropertyWithLivenessTests()) // read - mockGetProperty(m, getBasicPropertyWithLivenessTests(), propertyName, gtmTestDomain, 3) + mockGetProperty(m, getBasicPropertyResponseWithLivenessTests(), 3) // delete - mockDeleteProperty(m, getBasicPropertyWithLivenessTests(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -105,8 +136,7 @@ func TestResGTMProperty(t *testing.T) { // bad request status code returned m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -210,14 +240,13 @@ func TestResGTMProperty(t *testing.T) { init: func(t *testing.T, m *gtm.Mock) { // create // denied response status returned - deniedResponse := gtm.PropertyResponse{ + deniedResponse := gtm.CreatePropertyResponse{ Resource: getBasicProperty(), Status: &deniedResponseStatus, } m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(&deniedResponse, nil).Once() }, steps: []resource.TestStep{ @@ -231,18 +260,20 @@ func TestResGTMProperty(t *testing.T) { property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { // create 1st property - mockCreateProperty(m, getBasicProperty(), gtmTestDomain) + mockCreateProperty(m, getBasicProperty()) // read - mockGetProperty(m, getBasicProperty(), propertyName, gtmTestDomain, 4) + mockGetProperty(m, getBasicPropertyResponse(), 4) // force new -> delete 1st property and recreate 2nd with updated name - mockDeleteProperty(m, getBasicProperty(), gtmTestDomain) + mockDeleteProperty(m) propertyWithUpdatedName := getBasicProperty() propertyWithUpdatedName.Name = updatedPropertyName - mockCreateProperty(m, propertyWithUpdatedName, gtmTestDomain) + propertyResponseWithUpdatedName := getBasicPropertyResponse() + propertyResponseWithUpdatedName.Name = updatedPropertyName + mockCreateProperty(m, propertyWithUpdatedName) // read - mockGetProperty(m, propertyWithUpdatedName, updatedPropertyName, gtmTestDomain, 3) + mockGetProperty(m, propertyResponseWithUpdatedName, 3) // delete - mockDeleteProperty(m, propertyWithUpdatedName, gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -283,11 +314,14 @@ func TestResGTMProperty(t *testing.T) { propertyWithLivenessTest := getBasicProperty() propertyWithLivenessTest.LivenessTests[0].TestObject = "" propertyWithLivenessTest.LivenessTests[0].TestObjectProtocol = "SNMP" - mockCreateProperty(m, propertyWithLivenessTest, gtmTestDomain) + propertyResponseWithLivenessTest := getBasicPropertyResponse() + propertyResponseWithLivenessTest.LivenessTests[0].TestObject = "" + propertyResponseWithLivenessTest.LivenessTests[0].TestObjectProtocol = "SNMP" + mockCreateProperty(m, propertyWithLivenessTest) // read - mockGetProperty(m, propertyWithLivenessTest, propertyName, gtmTestDomain, 3) + mockGetProperty(m, propertyResponseWithLivenessTest, 3) // delete - mockDeleteProperty(m, propertyWithLivenessTest, gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -327,11 +361,11 @@ func TestResGTMProperty(t *testing.T) { "create property with 'ranked-failover' type and allow single empty precedence value": { property: getRankedFailoverPropertyWithPrecedence(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence()) // read - mockGetProperty(m, getRankedFailoverPropertyWithPrecedence(), propertyName, gtmTestDomain, 3) + mockGetProperty(m, getRankedFailoverPropertyResponseWithPrecedence(), 3) // delete - mockDeleteProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -354,11 +388,11 @@ func TestResGTMProperty(t *testing.T) { "create property with 'ranked-failover' type and 0 set as precedence value": { property: getRankedFailoverPropertyWithPrecedence(), init: func(t *testing.T, m *gtm.Mock) { - mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockCreateProperty(m, getRankedFailoverPropertyWithPrecedence()) // read - mockGetProperty(m, getRankedFailoverPropertyWithPrecedence(), propertyName, gtmTestDomain, 3) + mockGetProperty(m, getRankedFailoverPropertyResponseWithPrecedence(), 3) // delete - mockDeleteProperty(m, getRankedFailoverPropertyWithPrecedence(), gtmTestDomain) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { @@ -431,7 +465,7 @@ func TestResourceGTMTrafficTargetOrder(t *testing.T) { planOnly bool }{ "second apply - no diff": { - client: getMocks(), + client: getMocksSecondApply(), pathForCreate: "testdata/TestResGtmProperty/create_multiple_traffic_targets.tf", pathForUpdate: "testdata/TestResGtmProperty/create_multiple_traffic_targets.tf", nonEmptyPlan: false, @@ -445,7 +479,7 @@ func TestResourceGTMTrafficTargetOrder(t *testing.T) { planOnly: true, }, "re-ordered traffic target with no datacenter_id - no diff": { - client: getMocks(), + client: getMocksWithoutDatacenterID(), pathForCreate: "testdata/TestResGtmProperty/traffic_target/no_datacenter_id.tf", pathForUpdate: "testdata/TestResGtmProperty/traffic_target/no_datacenter_id_diff_order.tf", nonEmptyPlan: false, @@ -545,7 +579,75 @@ func getRankedFailoverPropertyWithPrecedence() *gtm.Property { DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ + { + DisableNonstandardPortWarning: false, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(10), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "ranked-failover", + } +} + +// getRankedFailoverPropertyResponseWithPrecedence gets the property values taken from `create_ranked_failover_precedence.tf` +func getRankedFailoverPropertyResponseWithPrecedence() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ { DisableNonstandardPortWarning: false, Name: "lt5", @@ -554,7 +656,7 @@ func getRankedFailoverPropertyWithPrecedence() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", @@ -569,19 +671,19 @@ func getRankedFailoverPropertyWithPrecedence() *gtm.Property { TestObject: "/junk", TestObjectPort: 80, PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, + HTTPHeaders: []gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -615,14 +717,14 @@ func getRankedFailoverPropertyNoPrecedence() *gtm.Property { HandoutLimit: 5, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -766,7 +868,7 @@ func getUpdatedProperty() *gtm.Property { DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { Name: "lt5", TestInterval: 50, @@ -774,7 +876,7 @@ func getUpdatedProperty() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", @@ -789,29 +891,155 @@ func getUpdatedProperty() *gtm.Property { TestObject: "/junk", TestObjectPort: 80, PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, + HTTPHeaders: []gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseDiff gets the property values taken from `create_basic.tf` +func getBasicPropertyResponseDiff() gtm.GetPropertyResponse { + return gtm.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, { DatacenterID: 3132, Enabled: true, HandoutCName: "test", Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyCopy gets the property values taken from `create_basic.tf` +func getBasicPropertyDiff() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", "1.2.3.5", }, Weight: 200.0, Precedence: ptr.To(0), }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, }, Type: "weighted-round-robin", } @@ -823,7 +1051,7 @@ func getBasicProperty() *gtm.Property { DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { Name: "lt5", TestInterval: 40, @@ -831,7 +1059,7 @@ func getBasicProperty() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", @@ -846,19 +1074,19 @@ func getBasicProperty() *gtm.Property { TestObject: "/junk", TestObjectPort: 80, PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, + HTTPHeaders: []gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + StaticRRSets: []gtm.StaticRRSet{ { Type: "MX", TTL: 300, Rdata: []string{"100 test_e"}, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, @@ -874,13 +1102,13 @@ func getBasicProperty() *gtm.Property { } } -// getBasicPropertyWithLivenessTests gets the property values taken from `create_basic_additional_liveness_tests.tf` -func getBasicPropertyWithLivenessTests() *gtm.Property { +// getBasicPropertySecondApply gets the property values taken from `create_multiple_traffic_targets.tf` +func getBasicPropertySecondApply() *gtm.Property { return >m.Property{ DynamicTTL: 300, HandoutMode: "normal", HandoutLimit: 5, - LivenessTests: []*gtm.LivenessTest{ + LivenessTests: []gtm.LivenessTest{ { Name: "lt5", TestInterval: 40, @@ -888,117 +1116,593 @@ func getBasicPropertyWithLivenessTests() *gtm.Property { TestObjectPort: 1, TestObjectProtocol: "HTTP", TestTimeout: 30.0, - HTTPHeaders: []*gtm.HTTPHeader{ + HTTPHeaders: []gtm.HTTPHeader{ { Name: "test_name", Value: "test_value", }, }, - HTTPMethod: ptr.To("GET"), - HTTPRequestBody: ptr.To("Body"), - Pre2023SecurityPosture: true, - AlternateCACertificates: []string{"test1"}, - }, - { - Name: "lt2", - TestInterval: 30, - TestObjectProtocol: "HTTP", - TestTimeout: 20, - TestObject: "/junk", - TestObjectPort: 80, - PeerCertificateVerification: true, - HTTPHeaders: []*gtm.HTTPHeader{}, }, }, Name: "tfexample_prop_1", ScoreAggregationType: "median", - StaticRRSets: []*gtm.StaticRRSet{ + TrafficTargets: []gtm.TrafficTarget{ { - Type: "MX", - TTL: 300, - Rdata: []string{"100 test_e"}, + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + }, + Weight: 200, + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200, + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200, + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseSecondApply gets the property values taken from `create_multiple_traffic_targets.tf` +func getBasicPropertyResponseSecondApply() gtm.GetPropertyResponse { + return gtm.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, }, }, - TrafficTargets: []*gtm.TrafficTarget{ + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ { DatacenterID: 3131, Enabled: true, HandoutCName: "test", Servers: []string{ - "1.2.3.9", + "1.2.3.4", }, - Weight: 200.0, - Precedence: ptr.To(0), + Weight: 200, + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200, + }, + { + DatacenterID: 3133, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200, }, }, Type: "weighted-round-robin", } } -// getMocks is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs -func getMocks() *gtm.Mock { - client := new(gtm.Mock) - - // read - getPropertyCall := client.On("GetProperty", mock.Anything, "tfexample_prop_1", gtmTestDomain). - Return(nil, >m.Error{StatusCode: http.StatusNotFound}) - // create - // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock +// getBasicPropertyResponse gets the property values taken from `create_basic.tf` +func getBasicPropertyResponse() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseUpdate gets the property values taken from `update_basic.tf` +func getBasicPropertyResponseUpdate() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 50, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyWithoutDatacenterID gets the property values without DatacenterID +func getBasicPropertyWithoutDatacenterID() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseWithoutDatacenterID gets the property values without DatacenterID +func getBasicPropertyResponseWithoutDatacenterID() gtm.GetPropertyResponse { + return gtm.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + AlternateCACertificates: []string{}, + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.4", + "1.2.3.5", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + DatacenterID: 3132, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.6", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + { + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.7", + "1.2.3.8", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyWithLivenessTests gets the property values taken from `create_basic_additional_liveness_tests.tf` +func getBasicPropertyWithLivenessTests() *gtm.Property { + return >m.Property{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + HTTPMethod: ptr.To("GET"), + HTTPRequestBody: ptr.To("Body"), + Pre2023SecurityPosture: true, + AlternateCACertificates: []string{"test1"}, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getBasicPropertyResponseWithLivenessTests gets the property values taken from `create_basic_additional_liveness_tests.tf` +func getBasicPropertyResponseWithLivenessTests() *gtm.GetPropertyResponse { + return >m.GetPropertyResponse{ + DynamicTTL: 300, + HandoutMode: "normal", + HandoutLimit: 5, + LivenessTests: []gtm.LivenessTest{ + { + Name: "lt5", + TestInterval: 40, + TestObject: "/junk", + TestObjectPort: 1, + TestObjectProtocol: "HTTP", + TestTimeout: 30.0, + HTTPHeaders: []gtm.HTTPHeader{ + { + Name: "test_name", + Value: "test_value", + }, + }, + HTTPMethod: ptr.To("GET"), + HTTPRequestBody: ptr.To("Body"), + Pre2023SecurityPosture: true, + AlternateCACertificates: []string{"test1"}, + }, + { + Name: "lt2", + TestInterval: 30, + TestObjectProtocol: "HTTP", + TestTimeout: 20, + TestObject: "/junk", + TestObjectPort: 80, + PeerCertificateVerification: true, + HTTPHeaders: []gtm.HTTPHeader{}, + }, + }, + Name: "tfexample_prop_1", + ScoreAggregationType: "median", + StaticRRSets: []gtm.StaticRRSet{ + { + Type: "MX", + TTL: 300, + Rdata: []string{"100 test_e"}, + }, + }, + TrafficTargets: []gtm.TrafficTarget{ + { + DatacenterID: 3131, + Enabled: true, + HandoutCName: "test", + Servers: []string{ + "1.2.3.9", + }, + Weight: 200.0, + Precedence: ptr.To(0), + }, + }, + Type: "weighted-round-robin", + } +} + +// getMocks is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocks() *gtm.Mock { + client := new(gtm.Mock) + + // read + getCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}).Once() + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + resp := getBasicPropertyResponseDiff() + client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest")).Return(>m.CreatePropertyResponse{ + Resource: getBasicPropertyDiff(), + Status: &pendingResponseStatus, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} + }) + + // read + client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(&resp, nil).Times(4) + + // delete + client.On("DeleteProperty", + mock.Anything, + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil) + + return client +} + +// getMocksNoDatacenterId is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocksWithoutDatacenterID() *gtm.Mock { + client := new(gtm.Mock) + + // read + getCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}).Once() + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock // each one and for those test it's not important, since we are only checking the diff - client.On("CreateProperty", mock.Anything, mock.AnythingOfType("*gtm.Property"), mock.AnythingOfType("string")).Return(>m.PropertyResponse{ - Resource: getBasicProperty(), + resp := getBasicPropertyResponseWithoutDatacenterID() + client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest")).Return(>m.CreatePropertyResponse{ + Resource: getBasicPropertyWithoutDatacenterID(), Status: &pendingResponseStatus, }, nil).Run(func(args mock.Arguments) { - getPropertyCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Property), nil} + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + + // read + client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(&resp, nil).Times(4) + + // delete + client.On("DeleteProperty", + mock.Anything, + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil) + + return client +} + +// getMocksSecondApply is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocksSecondApply() *gtm.Mock { + client := new(gtm.Mock) + + // read + getCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}).Once() + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + resp := getBasicPropertyResponseSecondApply() + client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest")).Return(>m.CreatePropertyResponse{ + Resource: getBasicPropertySecondApply(), + Status: &pendingResponseStatus, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} + }) + + // read + client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(&resp, nil).Times(4) + // delete client.On("DeleteProperty", mock.Anything, - mock.AnythingOfType("*gtm.Property"), - "gtm_terra_testdomain.akadns.net", - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil) return client } -func mockCreateProperty(client *gtm.Mock, property *gtm.Property, domain string) { - resp := gtm.PropertyResponse{} +func mockCreateProperty(client *gtm.Mock, property *gtm.Property) { + resp := gtm.CreatePropertyResponse{} resp.Resource = property resp.Status = &pendingResponseStatus client.On("CreateProperty", mock.Anything, - property, - domain, + mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(&resp, nil).Once() } -func mockGetProperty(client *gtm.Mock, property *gtm.Property, propertyName, domain string, times int) { +func mockGetProperty(client *gtm.Mock, property *gtm.GetPropertyResponse, times int) { client.On("GetProperty", mock.Anything, - propertyName, - domain, + mock.AnythingOfType("gtm.GetPropertyRequest"), ).Return(property, nil).Times(times) } -func mockUpdateProperty(client *gtm.Mock, property *gtm.Property, domain string) { +func mockUpdateProperty(client *gtm.Mock) { client.On("UpdateProperty", mock.Anything, - property, - domain, - ).Return(&completeResponseStatus, nil).Once() + mock.AnythingOfType("gtm.UpdatePropertyRequest"), + ).Return(updatePropertyResponseStatus, nil).Once() } -func mockGetDomainStatus(client *gtm.Mock, domain string, times int) { +func mockGetDomainStatus(client *gtm.Mock, times int) { client.On("GetDomainStatus", mock.Anything, - domain, - ).Return(&completeResponseStatus, nil).Times(times) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil).Times(times) } -func mockDeleteProperty(client *gtm.Mock, property *gtm.Property, domain string) { +func mockDeleteProperty(client *gtm.Mock) { client.On("DeleteProperty", mock.Anything, - property, - domain, - ).Return(&completeResponseStatus, nil).Once() + mock.AnythingOfType("gtm.DeletePropertyRequest"), + ).Return(deletePropertyResponseStatus, nil).Once() } diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource.go b/pkg/providers/gtm/resource_akamai_gtm_resource.go index cba5470a0..e2200aae9 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource.go @@ -142,7 +142,10 @@ func resourceGTMv1ResourceCreate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } logger.Debugf("Proposed New Resource: [%v]", newRsrc) - cStatus, err := Client(meta).CreateResource(ctx, newRsrc, domain) + cStatus, err := Client(meta).CreateResource(ctx, gtm.CreateResourceRequest{ + Resource: newRsrc, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Create failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -209,7 +212,10 @@ func resourceGTMv1ResourceRead(ctx context.Context, d *schema.ResourceData, m in logger.Errorf("Invalid resource Resource ID") return diag.FromErr(err) } - rsrc, err := Client(meta).GetResource(ctx, resource, domain) + rsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -248,7 +254,10 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } // Get existing property - existRsrc, err := Client(meta).GetResource(ctx, resource, domain) + existRsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -257,12 +266,16 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m Detail: err.Error(), }) } + newRsrc := createResourceStruct(existRsrc) logger.Debugf("Updating Resource BEFORE: %v", existRsrc) - if err := populateResourceObject(d, existRsrc, m); err != nil { + if err := populateResourceObject(d, newRsrc, m); err != nil { return diag.FromErr(err) } logger.Debugf("Updating Resource PROPOSED: %v", existRsrc) - uStat, err := Client(meta).UpdateResource(ctx, existRsrc, domain) + uStat, err := Client(meta).UpdateResource(ctx, gtm.UpdateResourceRequest{ + Resource: newRsrc, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Update failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -272,11 +285,11 @@ func resourceGTMv1ResourceUpdate(ctx context.Context, d *schema.ResourceData, m }) } logger.Debugf("Resource Update status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -323,11 +336,13 @@ func resourceGTMv1ResourceImport(d *schema.ResourceData, m interface{}) ([]*sche if err != nil { return []*schema.ResourceData{d}, err } - rsrc, err := Client(meta).GetResource(ctx, resource, domain) + rsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { return nil, err } - err = d.Set("domain", domain) if err != nil { return nil, err @@ -367,7 +382,10 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m logger.Errorf("Invalid resource ID") return diag.FromErr(err) } - existRsrc, err := Client(meta).GetResource(ctx, resource, domain) + existRsrc, err := Client(meta).GetResource(ctx, gtm.GetResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Delete Read failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -376,8 +394,12 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m Detail: err.Error(), }) } - logger.Debugf("Deleting Resource: %v", existRsrc) - uStat, err := Client(meta).DeleteResource(ctx, existRsrc, domain) + newRsrc := createResourceStruct(existRsrc) + logger.Debugf("Deleting Resource: %v", newRsrc) + uStat, err := Client(meta).DeleteResource(ctx, gtm.DeleteResourceRequest{ + ResourceName: resource, + DomainName: domain, + }) if err != nil { logger.Errorf("Resource Delete failed: %s", err.Error()) return append(diags, diag.Diagnostic{ @@ -387,11 +409,11 @@ func resourceGTMv1ResourceDelete(ctx context.Context, d *schema.ResourceData, m }) } logger.Debugf("Resource Delete status: %v", uStat) - if uStat.PropagationStatus == "DENIED" { - logger.Errorf(uStat.Message) + if uStat.Status.PropagationStatus == "DENIED" { + logger.Errorf(uStat.Status.Message) return append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: uStat.Message, + Summary: uStat.Status.Message, }) } @@ -432,7 +454,7 @@ func populateNewResourceObject(d *schema.ResourceData, m interface{}) (*gtm.Reso } rsrcObj := >m.Resource{ Name: name, - ResourceInstances: make([]*gtm.ResourceInstance, 0), + ResourceInstances: make([]gtm.ResourceInstance, 0), } err = populateResourceObject(d, rsrcObj, m) @@ -543,14 +565,14 @@ func populateResourceObject(d *schema.ResourceData, rsrc *gtm.Resource, m interf if _, ok := d.GetOk("resource_instance"); ok { populateResourceInstancesObject(meta, d, rsrc) } else if d.HasChange("resource_instance") { - rsrc.ResourceInstances = make([]*gtm.ResourceInstance, 0) + rsrc.ResourceInstances = make([]gtm.ResourceInstance, 0) } return nil } // Populate Terraform state from provided Resource object -func populateTerraformResourceState(d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) error { +func populateTerraformResourceState(d *schema.ResourceData, rsrc *gtm.GetResourceResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformResourceState") @@ -586,10 +608,10 @@ func populateResourceInstancesObject(meta meta.Meta, d *schema.ResourceData, rsr // pull apart List rsrcInstances, err := tf.GetListValue("resource_instance", d) if err == nil { - rsrcInstanceObjList := make([]*gtm.ResourceInstance, len(rsrcInstances)) // create new object list + rsrcInstanceObjList := make([]gtm.ResourceInstance, len(rsrcInstances)) // create new object list for i, v := range rsrcInstances { riMap := v.(map[string]interface{}) - rsrcInstance := >m.ResourceInstance{DatacenterID: riMap["datacenter_id"].(int)} + rsrcInstance := gtm.ResourceInstance{DatacenterID: riMap["datacenter_id"].(int)} rsrcInstance.UseDefaultLoadObject = riMap["use_default_load_object"].(bool) if riMap["load_servers"] != nil { loadServers, ok := riMap["load_servers"].(*schema.Set) @@ -611,11 +633,11 @@ func populateResourceInstancesObject(meta meta.Meta, d *schema.ResourceData, rsr } // create and populate Terraform resource_instances schema -func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.Resource, m interface{}) error { +func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.GetResourceResponse, m interface{}) error { meta := meta.Must(m) logger := meta.Log("Akamai GTM", "populateTerraformResourceInstancesState") - riObjectInventory := make(map[int]*gtm.ResourceInstance, len(rsrc.ResourceInstances)) + riObjectInventory := make(map[int]gtm.ResourceInstance, len(rsrc.ResourceInstances)) if len(rsrc.ResourceInstances) > 0 { for _, riObj := range rsrc.ResourceInstances { riObjectInventory[riObj.DatacenterID] = riObj @@ -629,7 +651,7 @@ func populateTerraformResourceInstancesState(d *schema.ResourceData, rsrc *gtm.R ri := riMap.(map[string]interface{}) objIndex := ri["datacenter_id"].(int) riObject := riObjectInventory[objIndex] - if riObject == nil { + if &riObject == nil { logger.Warnf("Resource_instance %d NOT FOUND in returned GTM Object", ri["datacenter_id"]) continue } @@ -715,6 +737,29 @@ func resourceInstanceDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { return true } +// createResourceStruct converts response from GetResourceResponse into Resource +func createResourceStruct(res *gtm.GetResourceResponse) *gtm.Resource { + if res != nil { + return >m.Resource{ + Type: res.Type, + HostHeader: res.HostHeader, + LeastSquaresDecay: res.LeastSquaresDecay, + Description: res.Description, + LeaderString: res.LeaderString, + ConstrainedProperty: res.ConstrainedProperty, + ResourceInstances: res.ResourceInstances, + AggregationType: res.AggregationType, + Links: res.Links, + LoadImbalancePercentage: res.LoadImbalancePercentage, + UpperBound: res.UpperBound, + Name: res.Name, + MaxUMultiplicativeIncrement: res.MaxUMultiplicativeIncrement, + DecayRate: res.DecayRate, + } + } + return nil +} + // loadServersEqual checks whether load_servers are equal func loadServersEqual(oldVal, newVal interface{}) bool { logger := logger.Get("Akamai GTM", "loadServersEqual") diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go index 22490a62d..a92750557 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go @@ -18,41 +18,46 @@ func TestResGTMResource(t *testing.T) { getCall := client.On("GetResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetResourceRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, - }) + }).Once() - resp := gtm.ResourceResponse{} - resp.Resource = &rsrc - resp.Status = &pendingResponseStatus + resp := rsrc client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Resource), nil} + mock.AnythingOfType("gtm.CreateResourceRequest"), + ).Return(>m.CreateResourceResponse{ + Resource: rsrcCreate.Resource, + Status: rsrcCreate.Status, + }, nil).Run(func(args mock.Arguments) { + getCall.ReturnArguments = mock.Arguments{&resp, nil} }) + client.On("GetResource", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetResourceRequest"), + ).Return(&resp, nil).Times(3) + client.On("GetDomainStatus", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.GetDomainStatusRequest"), + ).Return(getDomainStatusResponseStatus, nil) client.On("UpdateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil).Run(func(args mock.Arguments) { - getCall.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Resource), nil} - }) + mock.AnythingOfType("gtm.UpdateResourceRequest"), + ).Return(updateResourceResponseStatus, nil) + + client.On("GetResource", + mock.Anything, // ctx is irrelevant for this test + mock.AnythingOfType("gtm.GetResourceRequest"), + ).Return(&rsrcUpdate, nil).Times(3) client.On("DeleteResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteResourceRequest"), + ).Return(deleteResourceResponseStatus, nil) dataSourceName := "akamai_gtm_resource.tfexample_resource_1" @@ -86,8 +91,7 @@ func TestResGTMResource(t *testing.T) { client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateResourceRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusBadRequest, }) @@ -110,13 +114,12 @@ func TestResGTMResource(t *testing.T) { t.Run("create resource denied", func(t *testing.T) { client := >m.Mock{} - dr := gtm.ResourceResponse{} - dr.Resource = &rsrc + dr := gtm.CreateResourceResponse{} + dr.Resource = rsrcCreate.Resource dr.Status = &deniedResponseStatus client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - gtmTestDomain, + mock.AnythingOfType("gtm.CreateResourceRequest"), ).Return(&dr, nil) useClient(client, func() { @@ -216,39 +219,37 @@ func getGTMResourceMocks() *gtm.Mock { mockGetResource := client.On("GetResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("string"), - mock.AnythingOfType("string"), + mock.AnythingOfType("gtm.GetResourceRequest"), ).Return(nil, >m.Error{ StatusCode: http.StatusNotFound, }) - resp := gtm.ResourceResponse{} - resp.Resource = &resourceForOrderTests - resp.Status = &pendingResponseStatus + resp := resourceForOrderTests client.On("CreateResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&resp, nil).Run(func(args mock.Arguments) { - mockGetResource.ReturnArguments = mock.Arguments{args.Get(1).(*gtm.Resource), nil} + mock.AnythingOfType("gtm.CreateResourceRequest"), + ).Return(>m.CreateResourceResponse{ + Resource: rsrcCreate.Resource, + Status: rsrcCreate.Status, + }, nil).Run(func(args mock.Arguments) { + mockGetResource.ReturnArguments = mock.Arguments{&resp, nil} }) client.On("DeleteResource", mock.Anything, // ctx is irrelevant for this test - mock.AnythingOfType("*gtm.Resource"), - mock.AnythingOfType("string"), - ).Return(&completeResponseStatus, nil) + mock.AnythingOfType("gtm.DeleteResourceRequest"), + ).Return(deleteResourceResponseStatus, nil) return client } var ( // resourceForOrderTests is a gtm.Resource structure used in testing the order of resource_instance - resourceForOrderTests = gtm.Resource{ + resourceForOrderTests = gtm.GetResourceResponse{ Name: "tfexample_resource_1", AggregationType: "latest", Type: "XML load object via HTTP", - ResourceInstances: []*gtm.ResourceInstance{ + ResourceInstances: []gtm.ResourceInstance{ { DatacenterID: 3131, UseDefaultLoadObject: false, @@ -270,11 +271,84 @@ var ( }, } - rsrc = gtm.Resource{ + rsrcCreateForOrder = gtm.CreateResourceResponse{ + Resource: >m.Resource{ + Name: "tfexample_resource_1", + AggregationType: "latest", + Type: "XML load object via HTTP", + ResourceInstances: []gtm.ResourceInstance{ + { + DatacenterID: 3131, + UseDefaultLoadObject: false, + LoadObject: gtm.LoadObject{ + LoadObject: "/test1", + LoadServers: []string{"1.2.3.4", "1.2.3.5", "1.2.3.6"}, + LoadObjectPort: 80, + }, + }, + { + DatacenterID: 3132, + UseDefaultLoadObject: false, + LoadObject: gtm.LoadObject{ + LoadObject: "/test2", + LoadServers: []string{"1.2.3.7", "1.2.3.8", "1.2.3.9", "1.2.3.10"}, + LoadObjectPort: 80, + }, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + rsrcCreate = gtm.CreateResourceResponse{ + Resource: >m.Resource{ + Name: "tfexample_resource_1", + AggregationType: "latest", + Type: "XML load object via HTTP", + ResourceInstances: []gtm.ResourceInstance{ + { + DatacenterID: 3131, + UseDefaultLoadObject: false, + LoadObject: gtm.LoadObject{ + LoadObject: "/test1", + LoadServers: []string{"1.2.3.4"}, + LoadObjectPort: 80, + }, + }, + }, + }, + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + + rsrc = gtm.GetResourceResponse{ Name: "tfexample_resource_1", AggregationType: "latest", Type: "XML load object via HTTP", - ResourceInstances: []*gtm.ResourceInstance{ + ResourceInstances: []gtm.ResourceInstance{ { DatacenterID: 3131, UseDefaultLoadObject: false, @@ -286,4 +360,51 @@ var ( }, }, } + + rsrcUpdate = gtm.GetResourceResponse{ + Name: "tfexample_resource_1", + AggregationType: "latest", + Type: "XML load object via HTTP", + ResourceInstances: []gtm.ResourceInstance{ + { + DatacenterID: 3132, + LoadObject: gtm.LoadObject{ + LoadObject: "/test2", + LoadServers: []string{"1.2.3.5"}, + LoadObjectPort: 80, + }, + }, + }, + } + + updateResourceResponseStatus = >m.UpdateResourceResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } + deleteResourceResponseStatus = >m.DeleteResourceResponse{ + Status: >m.ResponseStatus{ + ChangeID: "40e36abd-bfb2-4635-9fca-62175cf17007", + Links: []gtm.Link{ + { + Href: "https://akab-ymtebc45gco3ypzj-apz4yxpek55y7fyv.luna.akamaiapis.net/config-gtm/v1/domains/gtmdomtest.akadns.net/status/current", + Rel: "self", + }, + }, + Message: "Current configuration has been propagated to all GTM nameservers", + PassingValidation: true, + PropagationStatus: "COMPLETE", + PropagationStatusDate: "2019-04-25T14:54:00.000+00:00", + }, + } ) diff --git a/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf b/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf index a12de3e20..1d697a840 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDatacenter/create_basic.tf @@ -10,6 +10,10 @@ resource "akamai_gtm_datacenter" "tfexample_dc_1" { domain = local.gtmTestDomain nickname = "tfexample_dc_1" wait_on_complete = false + city = "Snæfellsjökull" + country = "IS" + latitude = "64.808" + longitude = "-23.776" default_load_object { load_object = "/test" load_object_port = 80 diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf index c9058f31a..26ce3b3bb 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 } diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf index 778e19a6b..5a6861ce1 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/create_basic_with_sign_and_serve.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 sign_and_serve = true diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf index 4d467beac..4254e7522 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/create.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 email_notification_list = ["email1@nomail.com", "email2@nomail.com", "email3@nomail.com"] diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf index 2382e5b3e..23c3cd36e 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/order/email_notification_list/reorder.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 10.0 email_notification_list = ["email3@nomail.com", "email1@nomail.com", "email2@nomail.com"] diff --git a/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf b/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf index 4f6d71ed9..1c7b29be2 100644 --- a/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmDomain/update_basic.tf @@ -6,7 +6,7 @@ resource "akamai_gtm_domain" "testdomain" { name = "gtm_terra_testdomain.akadns.net" type = "weighted" contract = "1-2ABCDEF" - comment = "Test" + comment = "Edit Property test_property" group = "123ABC" load_imbalance_percentage = 20.0 } diff --git a/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf b/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf index a1dfcdb99..ff828fac7 100644 --- a/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf +++ b/pkg/providers/gtm/testdata/TestResGtmProperty/create_basic.tf @@ -20,7 +20,6 @@ resource "akamai_gtm_property" "tfexample_prop_1" { servers = ["1.2.3.9"] handout_cname = "test" } - liveness_test { name = "lt5" test_interval = 40 From 6eb82a1f94c924426340d6750ac6bd80572a9470 Mon Sep 17 00:00:00 2001 From: Piotr Bartosik Date: Tue, 4 Jun 2024 07:55:29 +0000 Subject: [PATCH 12/54] DXE-3855 Adjustments to DXE-3640 after rebasing to develop --- .../dns/resource_akamai_dns_record.go | 1 + .../dns/resource_akamai_dns_record_test.go | 43 ++++++++----- pkg/providers/gtm/data_akamai_gtm_geomap.go | 8 ++- .../gtm/data_akamai_gtm_geomap_test.go | 23 ++++--- pkg/providers/gtm/data_akamai_gtm_geomaps.go | 4 +- .../gtm/data_akamai_gtm_geomaps_test.go | 26 ++++---- .../gtm/resource_akamai_gtm_property_test.go | 63 +++++++++++-------- 7 files changed, 104 insertions(+), 64 deletions(-) diff --git a/pkg/providers/dns/resource_akamai_dns_record.go b/pkg/providers/dns/resource_akamai_dns_record.go index 5141fd83b..8411708f5 100644 --- a/pkg/providers/dns/resource_akamai_dns_record.go +++ b/pkg/providers/dns/resource_akamai_dns_record.go @@ -644,6 +644,7 @@ func execFunc(ctx context.Context, meta meta.Meta, fn string, rec *dns.RecordBod case "Delete": e = inst.Client(meta).DeleteRecord(ctx, dns.DeleteRecordRequest{ Zone: zone, + Name: rec.Name, RecordType: rec.RecordType, RecLock: rlock, }) diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index b59241f49..12169c6d6 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -673,42 +673,55 @@ func TestMXRecord(t *testing.T) { } dnsClient := dns.Client(session.Must(session.New())) name, zone, mx := "exampleterraform.io", "exampleterraform.io", "MX" + getRecordRequest := dns.GetRecordRequest{ + Zone: zone, + Name: name, + RecordType: mx} mockCreate := func(d *dns.Mock, realClient dns.DNS, createdRecord *dns.RecordBody) { - d.On("GetRecord", mock.Anything, zone, name, mx). + d.On("GetRecord", mock.Anything, getRecordRequest). Return(nil, notFound).Twice() - d.On("CreateRecord", mock.Anything, - createdRecord, zone, []bool{false}). + d.On("CreateRecord", mock.Anything, dns.CreateRecordRequest{ + Record: createdRecord, + Zone: zone, + RecLock: []bool{false}}). Return(nil).Once() } mockRead := func(d *dns.Mock, realClient dns.DNS, createdRecord *dns.RecordBody) { - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(createdRecord, nil).Once() + response := (*dns.GetRecordResponse)(createdRecord) + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ProcessRdata", mock.Anything, createdRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), createdRecord.Target, mx)).Once() - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(createdRecord, nil).Once() + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ParseRData", mock.Anything, mx, createdRecord.Target). Return(realClient.ParseRData(context.Background(), mx, createdRecord.Target)).Once() d.On("ProcessRdata", mock.Anything, createdRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), createdRecord.Target, mx)).Once() } mockUpdate := func(d *dns.Mock, realClient dns.DNS, previousRecord *dns.RecordBody, updatedRecord *dns.RecordBody) { - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(previousRecord, nil).Once() + response := (*dns.GetRecordResponse)(previousRecord) + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ProcessRdata", mock.Anything, previousRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), previousRecord.Target, mx)).Once() - d.On("GetRecord", mock.Anything, zone, name, mx). - Return(previousRecord, nil).Once() + d.On("GetRecord", mock.Anything, getRecordRequest). + Return(response, nil).Once() d.On("ProcessRdata", mock.Anything, previousRecord.Target, mx). Return(realClient.ProcessRdata(context.Background(), previousRecord.Target, mx)).Once() - d.On("UpdateRecord", mock.Anything, - updatedRecord, zone, []bool{false}). + d.On("UpdateRecord", mock.Anything, dns.UpdateRecordRequest{ + Record: updatedRecord, + Zone: zone, + RecLock: []bool{false}}). Return(nil) } mockDelete := func(d *dns.Mock, createdRecord *dns.RecordBody) { - d.On("DeleteRecord", mock.Anything, - createdRecord, zone, []bool{false}). + d.On("DeleteRecord", mock.Anything, dns.DeleteRecordRequest{ + Zone: zone, + Name: createdRecord.Name, + RecordType: createdRecord.RecordType, + RecLock: []bool{false}}). Return(nil) } diff --git a/pkg/providers/gtm/data_akamai_gtm_geomap.go b/pkg/providers/gtm/data_akamai_gtm_geomap.go index 4a3d709e1..b701c12e1 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomap.go @@ -138,7 +138,9 @@ func (d *geoMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, } client := Client(d.meta) - geoMap, err := client.GetGeoMap(ctx, data.Name.ValueString(), data.Domain.ValueString()) + geoMap, err := client.GetGeoMap(ctx, gtm.GetGeoMapRequest{ + MapName: data.Name.ValueString(), + DomainName: data.Domain.ValueString()}) if err != nil { resp.Diagnostics.AddError("fetching GTM Geographic map failed: ", err.Error()) return @@ -153,7 +155,7 @@ func (d *geoMapDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (m *geoMapDataSourceModel) setAttributes(ctx context.Context, geoMap *gtm.GeoMap) diag.Diagnostics { +func (m *geoMapDataSourceModel) setAttributes(ctx context.Context, geoMap *gtm.GetGeoMapResponse) diag.Diagnostics { m.Name = types.StringValue(geoMap.Name) m.DefaultDatacenter = newDefaultDatacenter(*geoMap.DefaultDatacenter) m.Links = getLinks(geoMap.Links) @@ -166,7 +168,7 @@ func (m *geoMapDataSourceModel) setAttributes(ctx context.Context, geoMap *gtm.G return nil } -func (m *geoMapDataSourceModel) setAssignments(ctx context.Context, assignments []*gtm.GeoAssignment) diag.Diagnostics { +func (m *geoMapDataSourceModel) setAssignments(ctx context.Context, assignments []gtm.GeoAssignment) diag.Diagnostics { for _, a := range assignments { countries, diags := types.SetValueFrom(ctx, types.StringType, a.Countries) if diags.HasError() { diff --git a/pkg/providers/gtm/data_akamai_gtm_geomap_test.go b/pkg/providers/gtm/data_akamai_gtm_geomap_test.go index 8040ba238..cfd0fc77a 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomap_test.go @@ -12,6 +12,11 @@ import ( ) func TestDataGTMGeoMap(t *testing.T) { + getGeoMapRequest := gtm.GetGeoMapRequest{ + MapName: "mapTest", + DomainName: "test.geomap.domain.net"} + anyContext := mock.AnythingOfType("*context.valueCtx") + tests := map[string]struct { givenTF string init func(mock *gtm.Mock) @@ -21,14 +26,14 @@ func TestDataGTMGeoMap(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetGeoMap", mock.AnythingOfType("*context.valueCtx"), "mapTest", "test.geomap.domain.net").Return( - >m.GeoMap{ + m.On("GetGeoMap", anyContext, getGeoMapRequest).Return( + >m.GetGeoMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{{ + Assignments: []gtm.GeoAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments", DatacenterID: 2, @@ -38,7 +43,7 @@ func TestDataGTMGeoMap(t *testing.T) { "US", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, @@ -70,7 +75,7 @@ func TestDataGTMGeoMap(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetGeoMap", mock.AnythingOfType("*context.valueCtx"), "mapTest", "test.geomap.domain.net").Return( + m.On("GetGeoMap", anyContext, getGeoMapRequest).Return( nil, fmt.Errorf("API error")) }, expectError: regexp.MustCompile("API error"), @@ -78,15 +83,15 @@ func TestDataGTMGeoMap(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("GetGeoMap", mock.AnythingOfType("*context.valueCtx"), "mapTest", "test.geomap.domain.net").Return( - >m.GeoMap{ + m.On("GetGeoMap", anyContext, getGeoMapRequest).Return( + >m.GetGeoMapResponse{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.GeoAssignment{}, + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, diff --git a/pkg/providers/gtm/data_akamai_gtm_geomaps.go b/pkg/providers/gtm/data_akamai_gtm_geomaps.go index 0dd04067a..450c2a7b7 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomaps.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomaps.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -141,7 +142,8 @@ func (d *geoMapsDataSource) Read(ctx context.Context, req datasource.ReadRequest } client := Client(d.meta) - geoMaps, err := client.ListGeoMaps(ctx, data.Domain.ValueString()) + geoMaps, err := client.ListGeoMaps(ctx, gtm.ListGeoMapsRequest{ + DomainName: data.Domain.ValueString()}) if err != nil { resp.Diagnostics.AddError("fetching GTM Geographic maps failed: ", err.Error()) return diff --git a/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go b/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go index 2f6f36e83..bd836b8e5 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go @@ -12,6 +12,10 @@ import ( ) func TestDataGTMGeoMaps(t *testing.T) { + listGeoMapsRequest := gtm.ListGeoMapsRequest{ + DomainName: "test.geomaps.domain.net"} + anyContext := mock.AnythingOfType("*context.valueCtx") + tests := map[string]struct { givenTF string init func(mock *gtm.Mock) @@ -21,15 +25,15 @@ func TestDataGTMGeoMaps(t *testing.T) { "happy path": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListGeoMaps", mock.AnythingOfType("*context.valueCtx"), "test.geomaps.domain.net").Return( - []*gtm.GeoMap{ + m.On("ListGeoMaps", anyContext, listGeoMapsRequest).Return( + []gtm.GeoMap{ { Name: "TestName1", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname1", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{{ + Assignments: []gtm.GeoAssignment{{ DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments1", DatacenterID: 2, @@ -39,7 +43,7 @@ func TestDataGTMGeoMaps(t *testing.T) { "US", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel1", Href: "TestHref1", }}, @@ -50,7 +54,7 @@ func TestDataGTMGeoMaps(t *testing.T) { Nickname: "TestNickname2", DatacenterID: 3, }, - Assignments: []*gtm.GeoAssignment{ + Assignments: []gtm.GeoAssignment{ { DatacenterBase: gtm.DatacenterBase{ Nickname: "TestNicknameAssignments2", @@ -71,7 +75,7 @@ func TestDataGTMGeoMaps(t *testing.T) { "IT", }, }}, - Links: []*gtm.Link{{ + Links: []gtm.Link{{ Rel: "TestRel2", Href: "TestHref2", }}, @@ -113,7 +117,7 @@ func TestDataGTMGeoMaps(t *testing.T) { "error response from api": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListGeoMaps", mock.AnythingOfType("*context.valueCtx"), "test.geomaps.domain.net").Return( + m.On("ListGeoMaps", anyContext, listGeoMapsRequest).Return( nil, fmt.Errorf("API error")) }, expectError: regexp.MustCompile("API error"), @@ -121,15 +125,15 @@ func TestDataGTMGeoMaps(t *testing.T) { "no assignments": { givenTF: "valid.tf", init: func(m *gtm.Mock) { - m.On("ListGeoMaps", mock.AnythingOfType("*context.valueCtx"), "test.geomaps.domain.net").Return( - []*gtm.GeoMap{{ + m.On("ListGeoMaps", anyContext, listGeoMapsRequest).Return( + []gtm.GeoMap{{ Name: "TestName", DefaultDatacenter: >m.DatacenterBase{ Nickname: "TestNickname", DatacenterID: 1, }, - Assignments: []*gtm.GeoAssignment{}, - Links: []*gtm.Link{{ + Assignments: []gtm.GeoAssignment{}, + Links: []gtm.Link{{ Rel: "TestRel", Href: "TestHref", }}, diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 4e4d05c48..0ed9ef252 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -758,77 +758,77 @@ func TestResourceGTMLivenessTestOrder(t *testing.T) { planOnly bool }{ "second apply - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", nonEmptyPlan: false, planOnly: true, }, "re-ordered liveness test - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_liveness_tests_order.tf", nonEmptyPlan: false, planOnly: true, }, "remove liveness test - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/remove_liveness_test.tf", nonEmptyPlan: true, planOnly: true, }, "add liveness test - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/add_liveness_tests.tf", nonEmptyPlan: true, planOnly: true, }, "re-ordered liveness test and re-ordered http headers - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_lt_and_header_order.tf", nonEmptyPlan: false, planOnly: true, }, "change of 'timeout' field - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/change_timeout.tf", nonEmptyPlan: true, planOnly: true, }, "change of 'timeout' field and reorder of liveness tests - diff_(messy)": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/change_timeout_reorder_lt.tf", nonEmptyPlan: true, planOnly: true, }, "re-ordered liveness test and change http headers - diff_(messy)": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_lt_order_and_header_change.tf", nonEmptyPlan: true, planOnly: true, }, "change http headers - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/change_header.tf", nonEmptyPlan: true, planOnly: true, }, "value added to http header - diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/http_header_without_value.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests.tf", nonEmptyPlan: true, planOnly: true, }, "re-ordered liveness test and alternate ca certificates - no diff": { - client: getMocks(), + client: getMocksForLivenessTest(), pathForCreate: "testdata/TestResGtmProperty/liveness_test/multiple_liveness_tests_with_ca_cert.tf", pathForUpdate: "testdata/TestResGtmProperty/liveness_test/diff_lt_and_ca_certificate_order.tf", nonEmptyPlan: false, @@ -1576,6 +1576,28 @@ func getBasicPropertyResponseWithLivenessTests() *gtm.GetPropertyResponse { } } +// getMocksForLivenessTest is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs +func getMocksForLivenessTest() *gtm.Mock { + client := new(gtm.Mock) + + // read + getPropertyCall := client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). + Return(nil, >m.Error{StatusCode: http.StatusNotFound}) + // create + // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock + // each one and for those test it's not important, since we are only checking the diff + mockCreateProperty(client, getBasicProperty()). + Run(func(args mock.Arguments) { + arg := (*gtm.GetPropertyResponse)(args.Get(1).(gtm.CreatePropertyRequest).Property) + getPropertyCall.ReturnArguments = mock.Arguments{arg, nil} + }) + + // delete + mockDeleteProperty(client) + + return client +} + // getMocks is used for diff tests, where the contents of property not matter as much, as those tests aim to check the diffs func getMocks() *gtm.Mock { client := new(gtm.Mock) @@ -1587,10 +1609,7 @@ func getMocks() *gtm.Mock { // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock // each one and for those test it's not important, since we are only checking the diff resp := getBasicPropertyResponseDiff() - client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest")).Return(>m.CreatePropertyResponse{ - Resource: getBasicPropertyDiff(), - Status: &pendingResponseStatus, - }, nil).Run(func(args mock.Arguments) { + mockCreateProperty(client, getBasicPropertyDiff()).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{&resp, nil} }) @@ -1618,10 +1637,7 @@ func getMocksWithoutDatacenterID() *gtm.Mock { // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock // each one and for those test it's not important, since we are only checking the diff resp := getBasicPropertyResponseWithoutDatacenterID() - client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest")).Return(>m.CreatePropertyResponse{ - Resource: getBasicPropertyWithoutDatacenterID(), - Status: &pendingResponseStatus, - }, nil).Run(func(args mock.Arguments) { + mockCreateProperty(client, getBasicPropertyWithoutDatacenterID()).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{&resp, nil} }) @@ -1649,10 +1665,7 @@ func getMocksSecondApply() *gtm.Mock { // mock.AnythingOfType *gtm.Property is used is those mock calls as there are too many different test cases to mock // each one and for those test it's not important, since we are only checking the diff resp := getBasicPropertyResponseSecondApply() - client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest")).Return(>m.CreatePropertyResponse{ - Resource: getBasicPropertySecondApply(), - Status: &pendingResponseStatus, - }, nil).Run(func(args mock.Arguments) { + mockCreateProperty(client, getBasicPropertySecondApply()).Run(func(args mock.Arguments) { getCall.ReturnArguments = mock.Arguments{&resp, nil} }) @@ -1669,11 +1682,11 @@ func getMocksSecondApply() *gtm.Mock { return client } -func mockCreateProperty(client *gtm.Mock, property *gtm.Property) { +func mockCreateProperty(client *gtm.Mock, property *gtm.Property) *mock.Call { resp := gtm.CreatePropertyResponse{} resp.Resource = property resp.Status = &pendingResponseStatus - client.On("CreateProperty", + return client.On("CreateProperty", mock.Anything, mock.AnythingOfType("gtm.CreatePropertyRequest"), ).Return(&resp, nil).Once() From 0f3a9b632cca67af26bf9b54f94205f702502ded Mon Sep 17 00:00:00 2001 From: Wojciech Zagrajczuk Date: Fri, 6 Sep 2024 11:56:28 +0000 Subject: [PATCH 13/54] DXE-3948 Adjust mocks after bump of testing library, adjust logger after rebase, adjust mocks after change of structs in DNS and PAPI --- pkg/providers/dns/data_dns_record_set_test.go | 4 +- .../dns/resource_akamai_dns_record_test.go | 76 ++++++++----------- .../gtm/resource_akamai_gtm_property_test.go | 6 +- .../data_akamai_property_rules_template.go | 1 + pkg/providers/property/helpers.go | 22 +++--- 5 files changed, 48 insertions(+), 61 deletions(-) diff --git a/pkg/providers/dns/data_dns_record_set_test.go b/pkg/providers/dns/data_dns_record_set_test.go index 6e793afc9..e4dadfae5 100644 --- a/pkg/providers/dns/data_dns_record_set_test.go +++ b/pkg/providers/dns/data_dns_record_set_test.go @@ -55,9 +55,7 @@ func TestDataSourceDNSRecordSet_basic(t *testing.T) { client.On("GetRdata", mock.Anything, // ctx is irrelevant for this test - "exampleterraform.io", - "exampleterraform.io", - "TXT", + dns.GetRdataRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, ).Return(rdata, nil) useClient(client, func() { diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index 12169c6d6..c0540d00c 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -234,30 +234,28 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "exampleterraform.io", - RecordType: "TXT", - TTL: 300, - Active: false, - Target: []string{normalizedTarget1, normalizedTarget2, normalizedTarget3}, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "exampleterraform.io", + RecordType: "TXT", + TTL: 300, + Active: false, + Target: []string{normalizedTarget1, normalizedTarget2, normalizedTarget3}, + }, + Zone: "exampleterraform.io", + RecLock: []bool{false}, }, - "exampleterraform.io", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -281,10 +279,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "TXT", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "TXT", TTL: 300, @@ -294,9 +290,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "TXT", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.txt_record" @@ -544,30 +538,28 @@ func TestResDnsRecord(t *testing.T) { targetReceived := []string{"2001:db8:0:0:0:0:0:68", "::ffff:192.0.2.1"} client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "AAAA", + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "exampleterraform.io", - RecordType: "AAAA", - TTL: 300, - Active: false, - Target: targetSent, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "exampleterraform.io", + RecordType: "AAAA", + TTL: 300, + Active: false, + Target: targetSent, + }, + Zone: "exampleterraform.io", + RecLock: []bool{false}, }, - "exampleterraform.io", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "AAAA", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "AAAA", TTL: 300, @@ -591,10 +583,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "exampleterraform.io", - "exampleterraform.io", - "AAAA", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA"}, + ).Return(&dns.GetRecordResponse{ Name: "exampleterraform.io", RecordType: "AAAA", TTL: 300, @@ -604,9 +594,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "exampleterraform.io", Name: "exampleterraform.io", RecordType: "AAAA", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.aaaa_record" diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 0ed9ef252..90e9b9b6f 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -1615,7 +1615,7 @@ func getMocks() *gtm.Mock { // read client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). - Return(&resp, nil).Times(4) + Return(&resp, nil).Times(3) // delete client.On("DeleteProperty", @@ -1643,7 +1643,7 @@ func getMocksWithoutDatacenterID() *gtm.Mock { // read client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). - Return(&resp, nil).Times(4) + Return(&resp, nil).Times(3) // delete client.On("DeleteProperty", @@ -1671,7 +1671,7 @@ func getMocksSecondApply() *gtm.Mock { // read client.On("GetProperty", mock.Anything, mock.AnythingOfType("gtm.GetPropertyRequest")). - Return(&resp, nil).Times(4) + Return(&resp, nil).Times(3) // delete client.On("DeleteProperty", diff --git a/pkg/providers/property/data_akamai_property_rules_template.go b/pkg/providers/property/data_akamai_property_rules_template.go index c4acdc935..af3712453 100644 --- a/pkg/providers/property/data_akamai_property_rules_template.go +++ b/pkg/providers/property/data_akamai_property_rules_template.go @@ -16,6 +16,7 @@ import ( "strings" "text/template" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/log" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/property/helpers.go b/pkg/providers/property/helpers.go index 07cd34ce1..bfe48edff 100644 --- a/pkg/providers/property/helpers.go +++ b/pkg/providers/property/helpers.go @@ -9,9 +9,9 @@ import ( "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/log" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" - "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -226,14 +226,14 @@ type papiKey struct { contractID string } -func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key papiKey, - destGroupID string) error { +func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key papiKey, destGroupID string) error { - logger := log.FromContext(ctx).WithFields(log.Fields{ + fieldsToLog := log.Fields{ "key": key, "destGroupID": destGroupID, - }) - logger.Debug("updateGroupID") + } + logger := log.FromContext(ctx) + logger.Debug("updateGroupID", fieldsToLog) from, err := str.GetIntID(key.groupID, "grp_") if err != nil { @@ -258,7 +258,7 @@ func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key return err } - logger.Debugf("Changing group id from %d to %d for IAM id %d", from, to, iamID) + logger.Debugf("Changing group id from %d to %d for IAM id %d", from, to, iamID, fieldsToLog) err = iamClient.MoveProperty(ctx, iam.MovePropertyRequest{ PropertyID: int64(iamID), @@ -280,8 +280,8 @@ func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key } func waitForGroupIDChange(ctx context.Context, client papi.PAPI, key papiKey, maxAttempts int) error { - logger := log.FromContext(ctx).WithFields(log.Fields{"key": key}) - logger.Debug("waitForGroupIDChange") + logger := log.FromContext(ctx) + logger.Debug("waitForGroupIDChange", "key", key) req := papi.GetPropertyRequest{ PropertyID: key.propertyID, @@ -294,7 +294,7 @@ func waitForGroupIDChange(ctx context.Context, client papi.PAPI, key papiKey, ma for { _, err := client.GetProperty(ctx, req) if err == nil { - logger.Debug("waitForGroupIDChange: success") + logger.Debug("waitForGroupIDChange: success", "key", key) return nil } if !isHTTP403(err) { @@ -309,7 +309,7 @@ func waitForGroupIDChange(ctx context.Context, client papi.PAPI, key papiKey, ma key.groupID, key.propertyID, key.contractID, maxAttempts) } logger.Debugf("waitForGroupIDChange: new group id still not visible, %d attempts left, "+ - "waiting %s... (original error: %s)", attemptsLeft, wait, err) + "waiting %s... (original error: %s)", attemptsLeft, wait, err, "key", key) select { case <-ctx.Done(): From 1552715000b3bf64b8f2bfa70e69f09bd21e6e5a Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Mon, 30 Sep 2024 15:23:41 +0200 Subject: [PATCH 14/54] DXE-4206 Remove logger changes --- .../gtm/resource_akamai_gtm_property.go | 2 +- .../gtm/resource_akamai_gtm_property_test.go | 6 +++--- .../data_akamai_property_rules_template.go | 1 - pkg/providers/property/helpers.go | 21 +++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 7395c5c48..964ee240a 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -583,7 +583,7 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m } -func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Interface, newProp *gtm.Property, domain string) (*gtm.PropertyResponse, error) { +func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Interface, newProp *gtm.Property, domain string) (*gtm.CreatePropertyResponse, error) { // Initial backoff interval retryInterval := time.Second * 10 // Maximum retry interval diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 90e9b9b6f..864488f55 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -163,9 +163,9 @@ func TestResGTMProperty(t *testing.T) { }).Once() // Simulate successful property creation on the second attempt - mockCreateProperty(m, getBasicProperty(), gtmTestDomain) - mockGetProperty(m, getBasicProperty(), propertyName, gtmTestDomain, 3) - mockDeleteProperty(m, getBasicProperty(), gtmTestDomain) + mockCreateProperty(m, getBasicProperty()) + mockGetProperty(m, getBasicPropertyResponse(), 3) + mockDeleteProperty(m) }, steps: []resource.TestStep{ { diff --git a/pkg/providers/property/data_akamai_property_rules_template.go b/pkg/providers/property/data_akamai_property_rules_template.go index af3712453..c4acdc935 100644 --- a/pkg/providers/property/data_akamai_property_rules_template.go +++ b/pkg/providers/property/data_akamai_property_rules_template.go @@ -16,7 +16,6 @@ import ( "strings" "text/template" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/log" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/property/helpers.go b/pkg/providers/property/helpers.go index bfe48edff..a34ecece7 100644 --- a/pkg/providers/property/helpers.go +++ b/pkg/providers/property/helpers.go @@ -9,9 +9,9 @@ import ( "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/log" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -228,12 +228,11 @@ type papiKey struct { func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key papiKey, destGroupID string) error { - fieldsToLog := log.Fields{ + logger := log.FromContext(ctx).WithFields(log.Fields{ "key": key, "destGroupID": destGroupID, - } - logger := log.FromContext(ctx) - logger.Debug("updateGroupID", fieldsToLog) + }) + logger.Debug("updateGroupID") from, err := str.GetIntID(key.groupID, "grp_") if err != nil { @@ -258,11 +257,11 @@ func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key return err } - logger.Debugf("Changing group id from %d to %d for IAM id %d", from, to, iamID, fieldsToLog) + logger.Debugf("Changing group id from %d to %d for IAM id %d", from, to, iamID) err = iamClient.MoveProperty(ctx, iam.MovePropertyRequest{ PropertyID: int64(iamID), - BodyParams: iam.MovePropertyReqBody{ + Body: iam.MovePropertyRequestBody{ DestinationGroupID: int64(to), SourceGroupID: int64(from), }, @@ -280,8 +279,8 @@ func updateGroupID(ctx context.Context, client papi.PAPI, iamClient iam.IAM, key } func waitForGroupIDChange(ctx context.Context, client papi.PAPI, key papiKey, maxAttempts int) error { - logger := log.FromContext(ctx) - logger.Debug("waitForGroupIDChange", "key", key) + logger := log.FromContext(ctx).WithFields(log.Fields{"key": key}) + logger.Debug("waitForGroupIDChange") req := papi.GetPropertyRequest{ PropertyID: key.propertyID, @@ -294,7 +293,7 @@ func waitForGroupIDChange(ctx context.Context, client papi.PAPI, key papiKey, ma for { _, err := client.GetProperty(ctx, req) if err == nil { - logger.Debug("waitForGroupIDChange: success", "key", key) + logger.Debug("waitForGroupIDChange: success") return nil } if !isHTTP403(err) { @@ -309,7 +308,7 @@ func waitForGroupIDChange(ctx context.Context, client papi.PAPI, key papiKey, ma key.groupID, key.propertyID, key.contractID, maxAttempts) } logger.Debugf("waitForGroupIDChange: new group id still not visible, %d attempts left, "+ - "waiting %s... (original error: %s)", attemptsLeft, wait, err, "key", key) + "waiting %s... (original error: %s)", attemptsLeft, wait, err) select { case <-ctx.Done(): From ed296b8cc5f9d4f9d438487c7d0084e63bf075e7 Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Mon, 9 Sep 2024 13:31:31 +0000 Subject: [PATCH 15/54] DXE-4150 Align TFP after unifying request body naming --- .../resource_akamai_cloudaccess_key.go | 8 ++-- .../resource_akamai_cloudaccess_key_test.go | 8 ++-- .../resource_akamai_cloudlets_policy_test.go | 4 +- .../resource_akamai_cloudlets_policy_v3.go | 2 +- ...akamai_cloudwrapper_configuration_model.go | 4 +- ..._akamai_cloudwrapper_configuration_test.go | 38 +++++++++---------- .../edgeworkers/resource_akamai_edgeworker.go | 6 +-- .../resource_akamai_edgeworker_test.go | 4 +- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go index d4f8ae466..c782ef9fa 100644 --- a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go +++ b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go @@ -963,21 +963,21 @@ func (m *KeyResourceModel) setCredentialsForAccessKeyCreation(useCredA bool) clo } func (m *KeyResourceModel) buildCreateKeyVersionRequest(useCredA bool) cloudaccess.CreateAccessKeyVersionRequest { - var bodyParams cloudaccess.CreateAccessKeyVersionBodyParams + var bodyParams cloudaccess.CreateAccessKeyVersionRequestBody if useCredA { - bodyParams = cloudaccess.CreateAccessKeyVersionBodyParams{ + bodyParams = cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: m.CredentialsA.CloudAccessKeyID.ValueString(), CloudSecretAccessKey: m.CredentialsA.CloudSecretAccessKey.ValueString(), } } else { - bodyParams = cloudaccess.CreateAccessKeyVersionBodyParams{ + bodyParams = cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: m.CredentialsB.CloudAccessKeyID.ValueString(), CloudSecretAccessKey: m.CredentialsB.CloudSecretAccessKey.ValueString(), } } return cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: m.AccessKeyUID.ValueInt64(), - BodyParams: bodyParams, + Body: bodyParams, } } diff --git a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go index 5d8c22934..989016d6e 100644 --- a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go +++ b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go @@ -443,7 +443,7 @@ func TestAccessKeyResource(t *testing.T) { //create new version (no.3) m.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: resourceData.accessKeyData[0].accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: "test_key_id_3", CloudSecretAccessKey: "test_secret_3", }}).Return(&cloudaccess.CreateAccessKeyVersionResponse{RequestID: 321321, RetryAfter: 1000}, nil).Once() @@ -610,7 +610,7 @@ func TestAccessKeyResource(t *testing.T) { //create new version (no.3) m.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: resourceData.accessKeyData[0].accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: "test_key_id_3", CloudSecretAccessKey: "test_secret_3", }}).Return(&cloudaccess.CreateAccessKeyVersionResponse{RequestID: 321321, RetryAfter: 1000}, nil).Once() @@ -1377,7 +1377,7 @@ func TestAccessKeyResource(t *testing.T) { // fail and taint resource m.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: resourceData.accessKeyData[0].accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: resourceData.accessKeyData[0].credentialsB.cloudAccessKeyID, CloudSecretAccessKey: resourceData.accessKeyData[0].credentialsB.cloudSecretAccessKey, }}).Return(nil, cloudaccess.ErrCreateAccessKeyVersion).Once() @@ -1770,7 +1770,7 @@ func mockGetAccessKeyVersionStatus(client *cloudaccess.Mock, testData commonData func mockCreateAccessKeyVersion(client *cloudaccess.Mock, testData commonDataForAccessKey) *mock.Call { return client.On("CreateAccessKeyVersion", mock.Anything, cloudaccess.CreateAccessKeyVersionRequest{ AccessKeyUID: testData.accessKeyUID, - BodyParams: cloudaccess.CreateAccessKeyVersionBodyParams{ + Body: cloudaccess.CreateAccessKeyVersionRequestBody{ CloudAccessKeyID: testData.credentialsB.cloudAccessKeyID, CloudSecretAccessKey: testData.credentialsB.cloudSecretAccessKey, }}).Return(&cloudaccess.CreateAccessKeyVersionResponse{RequestID: 124, RetryAfter: 1000}, nil) diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go index 85f37ef1e..33c1ed4ff 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go @@ -1551,7 +1551,7 @@ func TestResourcePolicyV3(t *testing.T) { require.NoError(t, err) policyUpdate.GroupID = updatedGroup client.On("UpdatePolicy", mock.Anything, v3.UpdatePolicyRequest{ - BodyParams: v3.UpdatePolicyBodyParams{ + Body: v3.UpdatePolicyRequestBody{ GroupID: updatedGroup, }, PolicyID: policyUpdate.ID, @@ -2706,7 +2706,7 @@ func TestResourcePolicyV3(t *testing.T) { policy, version := expectCreatePolicy(t, client, 2, 123, matchRules, "test policy description") expectReadPolicy(t, client, policy, version, 3) client.On("UpdatePolicy", mock.Anything, v3.UpdatePolicyRequest{ - BodyParams: v3.UpdatePolicyBodyParams{ + Body: v3.UpdatePolicyRequestBody{ GroupID: 321, }, PolicyID: policy.ID, diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go index 6abcf9802..1f3332d67 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go @@ -77,7 +77,7 @@ func (strategy v3PolicyStrategy) updatePolicyVersion(ctx context.Context, d *sch func (strategy v3PolicyStrategy) updatePolicy(ctx context.Context, policyID, groupID int64, _ string) error { updatePolicyReq := v3.UpdatePolicyRequest{ PolicyID: policyID, - BodyParams: v3.UpdatePolicyBodyParams{ + Body: v3.UpdatePolicyRequestBody{ GroupID: groupID, }, } diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go index a20f080de..9bd6b0b8b 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go @@ -67,7 +67,7 @@ func (m *ConfigurationResourceModel) hasUnknown() bool { func (m *ConfigurationResourceModel) buildCreateRequest(ctx context.Context) cloudwrapper.CreateConfigurationRequest { return cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ CapacityAlertsThreshold: m.getCapacityAlertsThreshold(), Comments: m.Comments.ValueString(), ContractID: m.ContractID.ValueString(), @@ -84,7 +84,7 @@ func (m *ConfigurationResourceModel) buildCreateRequest(ctx context.Context) clo func (m *ConfigurationResourceModel) buildUpdateRequest(ctx context.Context) cloudwrapper.UpdateConfigurationRequest { return cloudwrapper.UpdateConfigurationRequest{ ConfigID: m.ID.ValueInt64(), - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ CapacityAlertsThreshold: m.getCapacityAlertsThreshold(), Comments: m.Comments.ValueString(), Locations: m.getLocationsReq(), diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go index 92e61f0a8..d2f50445b 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go @@ -19,7 +19,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -78,7 +78,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -127,7 +127,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -176,7 +176,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -204,7 +204,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectDelete() configUpdate := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -259,7 +259,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -289,7 +289,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectDelete() configUpdate := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_234", Locations: []cloudwrapper.ConfigLocationReq{ @@ -346,7 +346,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -376,7 +376,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectDelete() configUpdate := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_234", Locations: []cloudwrapper.ConfigLocationReq{ @@ -433,7 +433,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -491,7 +491,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -521,7 +521,7 @@ func TestConfigurationResource(t *testing.T) { configUpdate := cloudwrapper.UpdateConfigurationRequest{ ConfigID: expecter.config.ConfigID, - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ CapacityAlertsThreshold: &capacityAlertsThreshold, Comments: "test", Locations: []cloudwrapper.ConfigLocationReq{ @@ -547,7 +547,7 @@ func TestConfigurationResource(t *testing.T) { configUpdate2 := cloudwrapper.UpdateConfigurationRequest{ ConfigID: expecter.config.ConfigID, - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ Comments: "test", Locations: []cloudwrapper.ConfigLocationReq{ { @@ -610,7 +610,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -674,7 +674,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -734,7 +734,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -782,7 +782,7 @@ func TestConfigurationResource(t *testing.T) { expecter.ExpectUpdate(cloudwrapper.UpdateConfigurationRequest{ ConfigID: 123, Activate: false, - Body: cloudwrapper.UpdateConfigurationBody{ + Body: cloudwrapper.UpdateConfigurationRequestBody{ Comments: "test", Locations: []cloudwrapper.ConfigLocationReq{ { @@ -833,7 +833,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ @@ -912,7 +912,7 @@ func TestConfigurationResource(t *testing.T) { client := &cloudwrapper.Mock{} configuration := cloudwrapper.CreateConfigurationRequest{ - Body: cloudwrapper.CreateConfigurationBody{ + Body: cloudwrapper.CreateConfigurationRequestBody{ Comments: "test", ContractID: "ctr_123", Locations: []cloudwrapper.ConfigLocationReq{ diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go index fabf16cf7..1fe2334b1 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go @@ -318,14 +318,14 @@ func resourceEdgeWorkerUpdate(ctx context.Context, d *schema.ResourceData, m int if err != nil { return diag.FromErr(err) } - edgeWorkerIDBodyReq := edgeworkers.EdgeWorkerIDBodyRequest{ + edgeWorkerIDBodyReq := edgeworkers.EdgeWorkerIDRequestBody{ Name: name, GroupID: groupIDNum, ResourceTierID: resourceTierID, } _, err = client.UpdateEdgeWorkerID(ctx, edgeworkers.UpdateEdgeWorkerIDRequest{ - EdgeWorkerIDBodyRequest: edgeWorkerIDBodyReq, - EdgeWorkerID: edgeWorkerIDReq, + Body: edgeWorkerIDBodyReq, + EdgeWorkerID: edgeWorkerIDReq, }) if err != nil { return diag.FromErr(err) diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go index bdecb17bb..dfbd801b2 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go @@ -172,7 +172,7 @@ func TestResourceEdgeWorkersEdgeWorker(t *testing.T) { EdgeWorkerID: edgeWorkerID, } updateEdgeWorkerID := edgeworkers.UpdateEdgeWorkerIDRequest{ - EdgeWorkerIDBodyRequest: edgeworkers.EdgeWorkerIDBodyRequest{ + Body: edgeworkers.EdgeWorkerIDRequestBody{ Name: name, GroupID: groupID, ResourceTierID: resourceTierID, @@ -209,7 +209,7 @@ func TestResourceEdgeWorkersEdgeWorker(t *testing.T) { EdgeWorkerID: edgeWorkerID, } updateEdgeWorkerID := edgeworkers.UpdateEdgeWorkerIDRequest{ - EdgeWorkerIDBodyRequest: edgeworkers.EdgeWorkerIDBodyRequest{ + Body: edgeworkers.EdgeWorkerIDRequestBody{ Name: name, GroupID: groupID, ResourceTierID: resourceTierID, From 206216af2247284c62ae98e17c5423492a2097ea Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Wed, 24 Jul 2024 07:32:48 +0000 Subject: [PATCH 16/54] DXE-4061 Align iam_user resource to changes in edgegrid --- pkg/providers/iam/resource_akamai_iam_user.go | 2 +- pkg/providers/iam/resource_akamai_iam_user_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 20ac511e3..21c4dfb53 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -229,7 +229,7 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf UserBasicInfo: basicUser, AuthGrants: authGrants, SendEmail: true, - Notifications: iam.UserNotifications{ + Notifications: &iam.UserNotifications{ Options: iam.UserNotificationOptions{ Proactive: []string{}, Upgrade: []string{}, diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index a42cb6c8c..2b8bb9473 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -190,19 +190,19 @@ func TestResourceUser(t *testing.T) { userCreateRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userCreateExtPhoneRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfoExtPhone, AuthGrants: authGrantsCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userSubgroupCreateRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsSubgroupCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userCreateLocked := iam.User{ @@ -220,7 +220,7 @@ func TestResourceUser(t *testing.T) { userCreateLockedRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsCreateRequest, - Notifications: notifications, + Notifications: ¬ifications, } userUpdateInfo := iam.User{ @@ -252,7 +252,7 @@ func TestResourceUser(t *testing.T) { userUpdateGrantsRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfo, AuthGrants: authGrantsUpdateRequest, - Notifications: notifications, + Notifications: ¬ifications, } authGrantsCreateWithIgnoredFields := []iam.AuthGrantRequest{ { From fa34de268efdbe4029c6c37c824bb0d71f719626 Mon Sep 17 00:00:00 2001 From: Michal Mazur Date: Fri, 2 Aug 2024 12:54:57 +0000 Subject: [PATCH 17/54] DXE-4026 implement iam ip allowlist resource --- CHANGELOG.md | 4 +- pkg/providers/iam/provider.go | 4 +- .../iam/resource_akamai_iam_ip_allowlist.go | 196 +++++++++++++ .../resource_akamai_iam_ip_allowlist_test.go | 263 ++++++++++++++++++ .../testdata/TestResIPAllowlist/disable.tf | 7 + .../iam/testdata/TestResIPAllowlist/enable.tf | 7 + 6 files changed, 479 insertions(+), 2 deletions(-) create mode 100644 pkg/providers/iam/resource_akamai_iam_ip_allowlist.go create mode 100644 pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go create mode 100644 pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf create mode 100644 pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c3a67f6..af148c2ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,9 @@ - +* IAM + * Added new resource: + * `akamai_iam_ip_allowlist` - enable or disable your account's allowlist diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 01141e313..1dce9f906 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -79,7 +79,9 @@ func (p *Subprovider) SDKDataSources() map[string]*schema.Resource { // FrameworkResources returns the IAM resources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkResources() []func() resource.Resource { - return []func() resource.Resource{} + return []func() resource.Resource{ + NewIPAllowlistResource, + } } // FrameworkDataSources returns the IAM data sources implemented using terraform-plugin-framework diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go new file mode 100644 index 000000000..6f9efa058 --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go @@ -0,0 +1,196 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &IPAllowlistResource{} + + _ resource.ResourceWithConfigure = &IPAllowlistResource{} + + _ resource.ResourceWithImportState = &IPAllowlistResource{} +) + +// IPAllowlistResource represents akamai_iam_ip_allowlist resource +type IPAllowlistResource struct { + meta meta.Meta +} + +// NewIPAllowlistResource returns new akamai_iam_ip_allowlist resource +func NewIPAllowlistResource() resource.Resource { + return &IPAllowlistResource{} +} + +// IPAllowlistResourceModel represents model of akamai_iam_ip_allowlist resource +type IPAllowlistResourceModel struct { + Enable types.Bool `tfsdk:"enable"` +} + +// Configure implements resource.ResourceWithConfigure. +func (r *IPAllowlistResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "unexpected resource configure type", + fmt.Sprintf("expected meta.Meta, got: %T. please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + r.meta = meta.Must(req.ProviderData) +} + +// Metadata implements resource.Resource. +func (r IPAllowlistResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_iam_ip_allowlist" +} + +// Schema implements resource.Resource. +func (r IPAllowlistResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "enable": schema.BoolAttribute{ + Required: true, + Description: "Whether to enable or disable the allowlist.", + }, + }, + } +} + +// Create implements resource.Resource. +func (r IPAllowlistResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating IP Allowlist resource") + var plan *IPAllowlistResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if plan.Enable.ValueBool() { + resp.Diagnostics.Append(r.enableIPAllowlist(ctx)...) + } else { + resp.Diagnostics.Append(r.disableIPAllowlist(ctx)...) + } + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r IPAllowlistResource) enableIPAllowlist(ctx context.Context) diag.Diagnostics { + var diags diag.Diagnostics + client := inst.Client(r.meta) + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + diags.AddError("cannot fetch IP Allowlist status", err.Error()) + return diags + } + if !status.Enabled { + err = client.EnableIPAllowlist(ctx) + if err != nil { + diags.AddError("enable ip allowlist fail", err.Error()) + return diags + } + } + return nil +} + +func (r IPAllowlistResource) disableIPAllowlist(ctx context.Context) diag.Diagnostics { + var diags diag.Diagnostics + client := inst.Client(r.meta) + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + diags.AddError("cannot fetch IP Allowlist status", err.Error()) + return diags + } + if status.Enabled != false { + err = client.DisableIPAllowlist(ctx) + if err != nil { + diags.AddError("disable IP allowlist fail", err.Error()) + return diags + } + } + return nil +} + +// Read implements resource.Resource. +func (r IPAllowlistResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading IP Allowlist Resource") + var oldState *IPAllowlistResourceModel + client := inst.Client(r.meta) + resp.Diagnostics.Append(req.State.Get(ctx, &oldState)...) + if resp.Diagnostics.HasError() { + return + } + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + resp.Diagnostics.AddError("cannot fetch IP Allowlist status", err.Error()) + return + } + + oldState.Enable = types.BoolValue(status.Enabled) + resp.Diagnostics.Append(resp.State.Set(ctx, &oldState)...) +} + +// Update implements resource.Resource. +func (r IPAllowlistResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating IP Allowlist Resource") + var diags diag.Diagnostics + var plan *IPAllowlistResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + if plan.Enable.ValueBool() { + diags.Append(r.enableIPAllowlist(ctx)...) + } else { + diags.Append(r.disableIPAllowlist(ctx)...) + } + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +// Delete implements resource.Resource. +func (r IPAllowlistResource) Delete(ctx context.Context, _ resource.DeleteRequest, resp *resource.DeleteResponse) { + // It can be only removed from state + resp.State.RemoveResource(ctx) +} + +// ImportState implements resource.ResourceWithImportState. +func (r IPAllowlistResource) ImportState(ctx context.Context, _ resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing IP Allowlist Resource") + client := inst.Client(r.meta) + status, err := client.GetIPAllowlistStatus(ctx) + if err != nil { + resp.Diagnostics.AddError("cannot fetch IP Allowlist status", err.Error()) + return + } + var state = &IPAllowlistResourceModel{} + state.Enable = types.BoolValue(status.Enabled) + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go new file mode 100644 index 000000000..bd01233e1 --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go @@ -0,0 +1,263 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/mock" +) + +func TestResourceIAMIPAllowlistResource(t *testing.T) { + t.Parallel() + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock) + steps []resource.TestStep + error *regexp.Regexp + }{ + "create - enable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 2 read + mockReadIPAllowlistStatus(m, true) + // step 3 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }, + "create - disable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlist(m) + // step 2 read + mockReadIPAllowlistStatus(m, false) + // step 3 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + }, + }, + "create - already enabled on server": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - ip allowlist already enabled on server + mockReadIPAllowlistStatus(m, true) + // step 2 read + mockReadIPAllowlistStatus(m, true) + // step 3 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }, + "create - already disabled on server": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - ip allowlist already disabled on server + mockReadIPAllowlistStatus(m, false) + // step 2 read + mockReadIPAllowlistStatus(m, false) + // step 3 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + }, + }, + "update - enable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlist(m) + // step 2 refresh + mockReadIPAllowlistStatus(m, false) + mockReadIPAllowlistStatus(m, false) + // step 3 update + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 4 refresh + mockReadIPAllowlistStatus(m, true) + // step 5 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }, + "update - disable": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 2 refresh + mockReadIPAllowlistStatus(m, true) + mockReadIPAllowlistStatus(m, true) + // step 3 update + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlist(m) + // step 4 refresh + mockReadIPAllowlistStatus(m, false) + // step 5 delete - remove resource form state(no mock) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "false")), + }, + }, + }, + "error - enable error ip not on allowlist": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - error + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlistError(m) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + ExpectError: regexp.MustCompile("enable ip allowlist fail"), + }, + }, + }, + "error - disable error IP not on allowlist": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create - error + mockReadIPAllowlistStatus(m, true) + mockDisableIPAllowlistError(m) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/disable.tf"), + ExpectError: regexp.MustCompile("disable IP allowlist fail"), + }, + }, + }, + "import": { + init: func(t *testing.T, m *iam.Mock) { + // step 1 create + mockReadIPAllowlistStatus(m, false) + mockEnableIPAllowlist(m) + // step 2 refresh + mockReadIPAllowlistStatus(m, true) + + // step 3 import + mockReadIPAllowlistStatus(m, true) + // step 4 refresh + mockReadIPAllowlistStatus(m, true) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + { + ImportState: true, + ImportStateVerify: false, + ResourceName: "akamai_iam_ip_allowlist.test", + ImportStateCheck: checkImportEnabledIPAllowlistForSpecificUser(), + }, + }, + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: test.steps, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkImportEnabledIPAllowlistForSpecificUser() resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + if len(s) == 0 { + return errors.New("No Instance found") + } + if len(s) != 1 { + return fmt.Errorf("Expected one Instance: %d", len(s)) + } + + state := s[0].Attributes + + attributes := map[string]string{ + "enable": "true", + } + + invalidValues := []string{} + for field, expectedVal := range attributes { + if state[field] != expectedVal { + invalidValues = append(invalidValues, fmt.Sprintf("field: %s, got: %s, expected: %s ", field, state[field], expectedVal)) + } + } + return nil + } +} + +func mockEnableIPAllowlist(m *iam.Mock) *mock.Call { + return m.On("EnableIPAllowlist", mock.Anything).Return(nil).Once() +} + +func mockEnableIPAllowlistError(m *iam.Mock) *mock.Call { + return m.On("EnableIPAllowlist", mock.Anything).Return(iam.ErrEnableIPAllowlist).Once() +} + +func mockDisableIPAllowlist(m *iam.Mock) *mock.Call { + return m.On("DisableIPAllowlist", mock.Anything).Return(nil).Once() +} +func mockDisableIPAllowlistError(m *iam.Mock) *mock.Call { + return m.On("DisableIPAllowlist", mock.Anything).Return(iam.ErrDisableIPAllowlist).Once() +} + +func mockReadIPAllowlistStatus(m *iam.Mock, enabled bool) *mock.Call { + if enabled { + return m.On("GetIPAllowlistStatus", mock.Anything).Return(&iam.GetIPAllowlistStatusResponse{Enabled: true}, nil).Once() + } + return m.On("GetIPAllowlistStatus", mock.Anything).Return(&iam.GetIPAllowlistStatusResponse{Enabled: false}, nil).Once() +} diff --git a/pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf b/pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf new file mode 100644 index 000000000..1f0c48566 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResIPAllowlist/disable.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_ip_allowlist" "test" { + enable = false +} diff --git a/pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf b/pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf new file mode 100644 index 000000000..fa9ea229e --- /dev/null +++ b/pkg/providers/iam/testdata/TestResIPAllowlist/enable.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_ip_allowlist" "test" { + enable = true +} From ed6a0c9ce70943da629fec7187dd6ff327b128f6 Mon Sep 17 00:00:00 2001 From: Filip Antkowiak Date: Tue, 6 Aug 2024 09:43:49 +0000 Subject: [PATCH 18/54] DXE-4066 Modify dates to use time.Time in IAM --- CHANGELOG.md | 3 ++- pkg/providers/iam/data_akamai_iam_groups.go | 5 ++-- .../iam/data_akamai_iam_groups_test.go | 17 ++++++------ pkg/providers/iam/data_akamai_iam_roles.go | 5 ++-- .../iam/data_akamai_iam_roles_test.go | 5 ++-- pkg/providers/iam/resource_akamai_iam_user.go | 5 ++-- .../iam/resource_akamai_iam_user_test.go | 26 ++++++++++--------- 7 files changed, 37 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af148c2ed..779bc4e3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ - +* IAM + * Improved date handling to use `time.Time` instead of `string` diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index df7dc79e8..ef3896878 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -3,6 +3,7 @@ package iam import ( "context" "strconv" + "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" @@ -115,8 +116,8 @@ func groupToState(g iam.Group) map[string]interface{} { m["name"] = g.GroupName m["group_id"] = strconv.FormatInt(g.GroupID, 10) m["parent_group_id"] = strconv.FormatInt(g.ParentGroupID, 10) - m["time_created"] = g.CreatedDate - m["time_modified"] = g.ModifiedDate + m["time_created"] = g.CreatedDate.Format(time.RFC3339Nano) + m["time_modified"] = g.ModifiedDate.Format(time.RFC3339Nano) m["modified_by"] = g.ModifiedBy m["created_by"] = g.CreatedBy diff --git a/pkg/providers/iam/data_akamai_iam_groups_test.go b/pkg/providers/iam/data_akamai_iam_groups_test.go index 1d788b168..bffc29942 100644 --- a/pkg/providers/iam/data_akamai_iam_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_groups_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -26,11 +27,11 @@ func TestDataGroups(t *testing.T) { { req := iam.ListGroupsRequest{} - group1 := makeGroup("test group 1", 101, 100, nil, nil) - group4 := makeGroup("test group 4", 104, 103, nil, nil) - group5 := makeGroup("test group 5", 105, 102, nil, nil) - group3 := makeGroup("test group 3", 103, 102, []iam.Group{group4}, nil) - group2 := makeGroup("test group 2", 102, 100, []iam.Group{group3, group5}, nil) + group1 := makeGroup(t, "test group 1", 101, 100, nil, nil) + group4 := makeGroup(t, "test group 4", 104, 103, nil, nil) + group5 := makeGroup(t, "test group 5", 105, 102, nil, nil) + group3 := makeGroup(t, "test group 3", 103, 102, []iam.Group{group4}, nil) + group2 := makeGroup(t, "test group 2", 102, 100, []iam.Group{group3, group5}, nil) res := []iam.Group{group1, group2, group3} client.On("ListGroups", mock.Anything, req).Return(res, nil) @@ -117,16 +118,16 @@ func groupsNestingDepth(res *schema.Resource) int { } // Convenience method to make a group -func makeGroup(Name string, GroupID, PGroupID int64, SubGroups []iam.Group, Actions *iam.GroupActions) iam.Group { +func makeGroup(t *testing.T, Name string, GroupID, PGroupID int64, SubGroups []iam.Group, Actions *iam.GroupActions) iam.Group { return iam.Group{ Actions: Actions, GroupName: Name, GroupID: GroupID, ParentGroupID: PGroupID, CreatedBy: "creator@akamai.net", - CreatedDate: "2020-01-01T00:00:00Z", + CreatedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), ModifiedBy: "modifier@akamai.net", - ModifiedDate: "2020-01-01T00:00:00Z", + ModifiedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), SubGroups: SubGroups, } } diff --git a/pkg/providers/iam/data_akamai_iam_roles.go b/pkg/providers/iam/data_akamai_iam_roles.go index a849239a5..b463b1eaa 100644 --- a/pkg/providers/iam/data_akamai_iam_roles.go +++ b/pkg/providers/iam/data_akamai_iam_roles.go @@ -3,6 +3,7 @@ package iam import ( "context" "strconv" + "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" @@ -109,8 +110,8 @@ func roleToState(r iam.Role) map[string]interface{} { m["name"] = r.RoleName m["description"] = r.RoleDescription m["type"] = string(r.RoleType) - m["time_created"] = r.CreatedDate - m["time_modified"] = r.ModifiedDate + m["time_created"] = r.CreatedDate.Format(time.RFC3339Nano) + m["time_modified"] = r.ModifiedDate.Format(time.RFC3339Nano) m["modified_by"] = r.ModifiedBy m["created_by"] = r.CreatedBy diff --git a/pkg/providers/iam/data_akamai_iam_roles_test.go b/pkg/providers/iam/data_akamai_iam_roles_test.go index d181214ca..9f9891012 100644 --- a/pkg/providers/iam/data_akamai_iam_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_roles_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -21,9 +22,9 @@ func TestDataRoles(t *testing.T) { RoleDescription: "role description", RoleType: iam.RoleTypeStandard, CreatedBy: "creator@akamai.net", - CreatedDate: "2020-01-01T00:00:00Z", + CreatedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), ModifiedBy: "modifier@akamai.net", - ModifiedDate: "2020-01-01T00:00:00Z", + ModifiedDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), }} req := iam.ListRolesRequest{} diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 21c4dfb53..8fbef4245 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -8,6 +8,7 @@ import ( "regexp" "sort" "strings" + "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" @@ -308,8 +309,8 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "country": user.Country, "contact_type": user.ContactType, "preferred_language": user.PreferredLanguage, - "last_login": user.LastLoginDate, - "password_expired_after": user.PasswordExpiryDate, + "last_login": user.LastLoginDate.Format(time.RFC3339Nano), + "password_expired_after": user.PasswordExpiryDate.Format(time.RFC3339Nano), "tfa_configured": user.TFAConfigured, "email_update_pending": user.EmailUpdatePending, "session_timeout": *user.SessionTimeOut, diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index 2b8bb9473..4c94234de 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -6,8 +6,10 @@ import ( "regexp" "strings" "testing" + "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -148,8 +150,8 @@ func TestResourceUser(t *testing.T) { resource.TestCheckResourceAttr("akamai_iam_user.test", "state", user.State), resource.TestCheckResourceAttr("akamai_iam_user.test", "zip_code", user.ZipCode), resource.TestCheckResourceAttr("akamai_iam_user.test", "preferred_language", user.PreferredLanguage), - resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", user.LastLoginDate), - resource.TestCheckResourceAttr("akamai_iam_user.test", "password_expired_after", user.PasswordExpiryDate), + resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", user.LastLoginDate.Format(time.RFC3339Nano)), + resource.TestCheckResourceAttr("akamai_iam_user.test", "password_expired_after", user.PasswordExpiryDate.Format(time.RFC3339Nano)), resource.TestCheckResourceAttr("akamai_iam_user.test", "tfa_configured", fmt.Sprintf("%t", user.TFAConfigured)), resource.TestCheckResourceAttr("akamai_iam_user.test", "email_update_pending", fmt.Sprintf("%t", user.EmailUpdatePending)), resource.TestCheckResourceAttr("akamai_iam_user.test", "session_timeout", fmt.Sprintf("%d", *user.SessionTimeOut)), @@ -162,8 +164,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsCreate, @@ -179,8 +181,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsSubgroupCreate, @@ -209,8 +211,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: true, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsCreate, @@ -227,8 +229,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: extendedUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsCreate, @@ -241,8 +243,8 @@ func TestResourceUser(t *testing.T) { UserBasicInfo: basicUserInfo, IdentityID: id, IsLocked: false, - LastLoginDate: "last login", - PasswordExpiryDate: "password expired after", + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), TFAConfigured: true, EmailUpdatePending: true, AuthGrants: authGrantsUpdate, From 50689d7388e663fbd3b713f06367847cba5e2578 Mon Sep 17 00:00:00 2001 From: Filip Antkowiak Date: Wed, 7 Aug 2024 11:45:53 +0000 Subject: [PATCH 19/54] DXE-4035 Implement iam_allowed_apis datasource --- CHANGELOG.md | 4 +- pkg/providers/iam/data_akamai_allowed_apis.go | 186 +++++++++++++++ .../iam/data_akamai_allowed_apis_test.go | 213 ++++++++++++++++++ pkg/providers/iam/iam_errors.go | 8 + pkg/providers/iam/provider.go | 4 +- .../testdata/TestDataAllowedAPIs/default.tf | 9 + .../default_no_optional.tf | 7 + 7 files changed, 429 insertions(+), 2 deletions(-) create mode 100644 pkg/providers/iam/data_akamai_allowed_apis.go create mode 100644 pkg/providers/iam/data_akamai_allowed_apis_test.go create mode 100644 pkg/providers/iam/iam_errors.go create mode 100644 pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf create mode 100644 pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 779bc4e3c..e1c58a6be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,9 @@ #### FEATURES/ENHANCEMENTS: - +* IAM + * Added new data source: + * `akamai_iam_allowed_apis` - read the list of APIs available to the user diff --git a/pkg/providers/iam/data_akamai_allowed_apis.go b/pkg/providers/iam/data_akamai_allowed_apis.go new file mode 100644 index 000000000..8dc8c441c --- /dev/null +++ b/pkg/providers/iam/data_akamai_allowed_apis.go @@ -0,0 +1,186 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &allowedAPIsDataSource{} + _ datasource.DataSourceWithConfigure = &allowedAPIsDataSource{} +) + +type ( + allowedAPIsDataSource struct { + meta meta.Meta + } + + allowedAPIsSourceModel struct { + Username types.String `tfsdk:"username"` + ClientType types.String `tfsdk:"client_type"` + AllowAccountSwitch types.Bool `tfsdk:"allow_account_switch"` + AllowedAPIs []apiModel `tfsdk:"allowed_apis"` + } + + apiModel struct { + AccessLevels []types.String `tfsdk:"access_levels"` + APIID types.Int64 `tfsdk:"api_id"` + APIName types.String `tfsdk:"api_name"` + Description types.String `tfsdk:"description"` + DocumentationURL types.String `tfsdk:"documentation_url"` + Endpoint types.String `tfsdk:"endpoint"` + HasAccess types.Bool `tfsdk:"has_access"` + ServiceProviderID types.Int64 `tfsdk:"service_provider_id"` + } +) + +// NewAllowedAPIsDataSource returns a new iam allowed APIs data source +func NewAllowedAPIsDataSource() datasource.DataSource { + return &allowedAPIsDataSource{} +} + +// Metadata configures data source's meta information +func (d *allowedAPIsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_allowed_apis" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *allowedAPIsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *allowedAPIsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management allowed APIs", + Attributes: map[string]schema.Attribute{ + "username": schema.StringAttribute{ + Required: true, + Description: "Unique username for each user.", + }, + "client_type": schema.StringAttribute{ + Optional: true, + Description: "Filters data by client type, either USER_CLIENT, SERVICE_ACCOUNT, or default CLIENT", + }, + "allow_account_switch": schema.BoolAttribute{ + Optional: true, + Description: "Includes account a user can switch to, false by default.", + }, + "allowed_apis": schema.ListNestedAttribute{ + Description: "List of available APIs for the user", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "access_levels": schema.ListAttribute{ + ElementType: types.StringType, + Computed: true, + Description: "API access levels, possible values are READ-ONLY and READ-WRITE.", + }, + "api_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each API.", + }, + "api_name": schema.StringAttribute{ + Computed: true, + Description: "Name of the API.", + }, + "description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the API.", + }, + "documentation_url": schema.StringAttribute{ + Computed: true, + Description: "Link to more information about the API.", + }, + "endpoint": schema.StringAttribute{ + Computed: true, + Description: "Specifies where the API can access resources.", + }, + "has_access": schema.BoolAttribute{ + Computed: true, + Description: "Confirms access to the API.", + }, + "service_provider_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for the API's service provider.", + }, + }, + }, + }, + }, + } + +} + +// Read is called when the provider must read data source values in order to update state +func (d *allowedAPIsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Allowed APIs DataSource Read") + + var data allowedAPIsSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + apis, err := client.ListAllowedAPIs(ctx, iam.ListAllowedAPIsRequest{ + UserName: data.Username.ValueString(), + ClientType: iam.ClientType(data.ClientType.ValueString()), + AllowAccountSwitch: data.AllowAccountSwitch.ValueBool(), + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMListAllowedAPIs), err.Error()) + return + } + + if resp.Diagnostics.Append(data.read(apis)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + +} + +func (d *allowedAPIsSourceModel) read(allowedAPIs iam.ListAllowedAPIsResponse) diag.Diagnostics { + var apis []apiModel + for _, api := range allowedAPIs { + accessLevels := make([]types.String, 0, len(api.AccessLevels)) + for _, accessLevel := range api.AccessLevels { + accessLevels = append(accessLevels, types.StringValue(accessLevel)) + } + + a := apiModel{ + AccessLevels: accessLevels, + APIID: types.Int64Value(api.APIID), + APIName: types.StringValue(api.APIName), + Description: types.StringValue(api.Description), + DocumentationURL: types.StringValue(api.DocumentationURL), + Endpoint: types.StringValue(api.Endpoint), + HasAccess: types.BoolValue(api.HasAccess), + ServiceProviderID: types.Int64Value(api.ServiceProviderID), + } + apis = append(apis, a) + } + + d.AllowedAPIs = apis + return nil + +} diff --git a/pkg/providers/iam/data_akamai_allowed_apis_test.go b/pkg/providers/iam/data_akamai_allowed_apis_test.go new file mode 100644 index 000000000..8026bf270 --- /dev/null +++ b/pkg/providers/iam/data_akamai_allowed_apis_test.go @@ -0,0 +1,213 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForAllowedAPIs struct { + username string + clientType *string + allowAccountSwitch *bool + allowedAPIs []apiData + } + + apiData struct { + accessLevels []string + apiID int64 + apiName string + description string + documentationURL string + endpoint string + hasAccess bool + serviceProviderID int64 + } +) + +var ( + basicTestDataForAllowedAPIs = testDataForAllowedAPIs{ + username: "test", + clientType: ptr.To("CLIENT"), + allowAccountSwitch: ptr.To(true), + allowedAPIs: []apiData{{ + accessLevels: []string{ + "READ-WRITE"}, + apiID: 146, + apiName: "Property Manager (PAPI)", + description: "Property Manager (PAPI). PAPI requires access to Edge Hostnames. Please edit your authorizations to add HAPI to your API Client.", + documentationURL: "https://developer.akamai.com/api/luna/papi/overview.html", + endpoint: "/papi", + hasAccess: true, + serviceProviderID: 1, + }, { + accessLevels: []string{ + "READ-ONLY", + "READ-WRITE"}, + apiID: 11, + apiName: "Event Center", + description: "Event Center", + documentationURL: "https://developer.akamai.com/api/luna/events/overview.html", + endpoint: "/events", + hasAccess: true, + serviceProviderID: 1, + }}, + } + basicTestDataForAllowedAPIsNoOptional = testDataForAllowedAPIs{ + username: "test", + allowedAPIs: []apiData{{ + accessLevels: []string{ + "READ-WRITE"}, + apiID: 146, + apiName: "Property Manager (PAPI)", + description: "Property Manager (PAPI). PAPI requires access to Edge Hostnames. Please edit your authorizations to add HAPI to your API Client.", + documentationURL: "https://developer.akamai.com/api/luna/papi/overview.html", + endpoint: "/papi", + hasAccess: true, + serviceProviderID: 1, + }, { + accessLevels: []string{ + "READ-ONLY", + "READ-WRITE"}, + apiID: 11, + apiName: "Event Center", + description: "Event Center", + documentationURL: "https://developer.akamai.com/api/luna/events/overview.html", + endpoint: "/events", + hasAccess: true, + serviceProviderID: 1, + }}, + } +) + +func TestDataAllowedAPIs(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForAllowedAPIs) + mockData testDataForAllowedAPIs + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataAllowedAPIs/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { + expectFullListAllowedAPIs(t, m, testData, 5) + }, + mockData: basicTestDataForAllowedAPIs, + }, + "happy path no optional values": { + configPath: "testdata/TestDataAllowedAPIs/default_no_optional.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { + expectFullListAllowedAPIs(t, m, testData, 5) + }, + mockData: basicTestDataForAllowedAPIsNoOptional, + }, + "error - ListAllowedAPIs call failed": { + configPath: "testdata/TestDataAllowedAPIs/default_no_optional.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { + listAllowedAPIsReq := iam.ListAllowedAPIsRequest{UserName: testData.username} + + m.On("ListAllowedAPIs", mock.Anything, listAllowedAPIsReq).Return(nil, errors.New("test error")) + }, + error: regexp.MustCompile("test error"), + mockData: basicTestDataForAllowedAPIsNoOptional, + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.mockData) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkKeysAttrs(test.mockData), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func expectFullListAllowedAPIs(_ *testing.T, client *iam.Mock, data testDataForAllowedAPIs, timesToRun int) { + listAllowedAPIsReq := iam.ListAllowedAPIsRequest{ + UserName: data.username, + } + if data.clientType != nil { + listAllowedAPIsReq.ClientType = iam.ClientType(*data.clientType) + } + if data.allowAccountSwitch != nil { + listAllowedAPIsReq.AllowAccountSwitch = *data.allowAccountSwitch + } + + listAllowedAPIsRes := iam.ListAllowedAPIsResponse{} + + for _, api := range data.allowedAPIs { + + listAllowedAPIsRes = append(listAllowedAPIsRes, iam.AllowedAPI{ + AccessLevels: api.accessLevels, + APIID: api.apiID, + APIName: api.apiName, + Description: api.description, + DocumentationURL: api.documentationURL, + Endpoint: api.endpoint, + HasAccess: api.hasAccess, + ServiceProviderID: api.serviceProviderID, + }) + } + + client.On("ListAllowedAPIs", mock.Anything, listAllowedAPIsReq).Return(listAllowedAPIsRes, nil).Times(timesToRun) + +} + +func checkKeysAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { + name := "data.akamai_iam_allowed_apis.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "username", data.username), + } + + if data.clientType != nil { + resource.TestCheckResourceAttr(name, "client_type", *data.clientType) + } else { + resource.TestCheckNoResourceAttr(name, "client_type") + } + + if data.allowAccountSwitch != nil { + resource.TestCheckResourceAttr(name, "allow_account_switch", strconv.FormatBool(*data.allowAccountSwitch)) + } else { + resource.TestCheckNoResourceAttr(name, "allow_account_switch") + } + + for i, api := range data.allowedAPIs { + for j, accessLevel := range api.accessLevels { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.access_levels.%d", i, j), accessLevel)) + } + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.api_id", i), strconv.FormatInt(api.apiID, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.api_name", i), api.apiName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.description", i), api.description)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.documentation_url", i), api.documentationURL)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.endpoint", i), api.endpoint)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.has_access", i), strconv.FormatBool(api.hasAccess))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.service_provider_id", i), strconv.FormatInt(api.serviceProviderID, 10))) + + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) + +} diff --git a/pkg/providers/iam/iam_errors.go b/pkg/providers/iam/iam_errors.go new file mode 100644 index 000000000..7eb974ac3 --- /dev/null +++ b/pkg/providers/iam/iam_errors.go @@ -0,0 +1,8 @@ +package iam + +import "errors" + +var ( + // ErrIAMListAllowedAPIs is returned when ListAllowedAPIs fails + ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") +) diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 1dce9f906..f66ed1139 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -86,5 +86,7 @@ func (p *Subprovider) FrameworkResources() []func() resource.Resource { // FrameworkDataSources returns the IAM data sources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { - return []func() datasource.DataSource{} + return []func() datasource.DataSource{ + NewAllowedAPIsDataSource, + } } diff --git a/pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf new file mode 100644 index 000000000..0ab5b8581 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_allowed_apis" "test" { + username = "test" + client_type = "CLIENT" + allow_account_switch = true +} diff --git a/pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf new file mode 100644 index 000000000..caeffaaed --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAllowedAPIs/default_no_optional.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_allowed_apis" "test" { + username = "test" +} From ae1576d4c1fd948075dc082dbd6a72257c4497b4 Mon Sep 17 00:00:00 2001 From: Shristi Singh Date: Tue, 13 Aug 2024 13:52:46 +0000 Subject: [PATCH 20/54] DXE-4029 Implement iam_blocked_properties data source Merge in DEVEXP/terraform-provider-akamai from feature/DXE-4029 to feature/sp-iam-extension --- CHANGELOG.md | 4 + .../iam/data_akamai_iam_blocked_properties.go | 144 ++++++++++++++++++ ...data_akamai_iam_blocked_properties_test.go | 113 ++++++++++++++ pkg/providers/iam/provider.go | 13 +- pkg/providers/iam/provider_test.go | 21 ++- .../missing_contract_id.tf | 8 + .../missing_group_id.tf | 8 + .../missing_ui_identity_id.tf | 8 + .../TestDataBlockedProperties/valid.tf | 10 ++ 9 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 pkg/providers/iam/data_akamai_iam_blocked_properties.go create mode 100644 pkg/providers/iam/data_akamai_iam_blocked_properties_test.go create mode 100644 pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index e1c58a6be..08436aa27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ #### FEATURES/ENHANCEMENTS: +* IAM + * Added data sources: + * `akamai_iam_blocked_properties` - reads blocked properties for a certain user in a group + * IAM * Added new data source: diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties.go b/pkg/providers/iam/data_akamai_iam_blocked_properties.go new file mode 100644 index 000000000..7f25abb54 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties.go @@ -0,0 +1,144 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var _ datasource.DataSource = &blockedPropertiesDataSource{} +var _ datasource.DataSourceWithConfigure = &blockedPropertiesDataSource{} + +// NewBlockedPropertiesDataSource returns all the properties that are blocked for a certain user in a group +func NewBlockedPropertiesDataSource() datasource.DataSource { + return &blockedPropertiesDataSource{} +} + +// blockedPropertiesDataSource defines the data source implementation for fetching Blocked Properties information +type blockedPropertiesDataSource struct { + meta meta.Meta +} + +// blockedPropertiesDataSource describes the data source data model for BlockedPropertiesDataSource +type blockedPropertiesDataSourceModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + ContractID types.String `tfsdk:"contract_id"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + BlockedProperties types.List `tfsdk:"blocked_properties"` +} + +// Metadata configures data source's meta information +func (d *blockedPropertiesDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_blocked_properties" +} + +// Schema is used to define data source's terraform schema +func (d *blockedPropertiesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Blocked Properties data source", + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each group.", + }, + "contract_id": schema.StringAttribute{ + Required: true, + Description: "Contract ID for which block properties are retrieved.", + }, + "ui_identity_id": schema.StringAttribute{ + Required: true, + Description: "Unique identifier for each user.", + }, + "blocked_properties": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + Description: "The list of blocked properties.", + }, + }, + } +} + +// Configure configures data source at the beginning of the lifecycle +func (d *blockedPropertiesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + d.meta = meta.Must(req.ProviderData) +} + +// Read is called when the provider must read data source values in order to update state +func (d *blockedPropertiesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "BlockedPropertiesDataSource Read") + + var data blockedPropertiesDataSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + + client := inst.Client(d.meta) + papiClient := inst.PapiClient(d.meta) + + listBlockedPropertiesResp, err := client.ListBlockedProperties(ctx, iam.ListBlockedPropertiesRequest{ + IdentityID: data.UIIdentityID.ValueString(), + GroupID: data.GroupID.ValueInt64(), + }) + if err != nil { + resp.Diagnostics.AddError("fetching iam blocked properties failed", err.Error()) + return + } + + var blockedPropertiesPAPI []string + groupID := str.AddPrefix(data.GroupID.String(), "grp_") + + for _, prop := range listBlockedPropertiesResp { + req := iam.MapPropertyIDToNameRequest{ + GroupID: data.GroupID.ValueInt64(), + PropertyID: prop, + } + papiPropertyName, err := client.MapPropertyIDToName(ctx, req) + if err != nil { + resp.Diagnostics.AddError("fetching PAPI propertyName failed", err.Error()) + return + } + papiPropertyID, err := papiClient.MapPropertyNameToID(ctx, papi.MapPropertyNameToIDRequest{ + GroupID: groupID, + ContractID: data.ContractID.ValueString(), + Name: *papiPropertyName, + }) + if err != nil { + resp.Diagnostics.AddError("fetching PAPI propertyID failed", err.Error()) + return + } + + blockedPropertiesPAPI = append(blockedPropertiesPAPI, *papiPropertyID) + } + + blockedPropertyIDsPAPI, diags := types.ListValueFrom(ctx, types.StringType, blockedPropertiesPAPI) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + + data.BlockedProperties = blockedPropertyIDsPAPI + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go new file mode 100644 index 000000000..399641c9d --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go @@ -0,0 +1,113 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestBlockedPropertiesDataSource(t *testing.T) { + propertyName1 := "example1.com" + propertyName2 := "example2.com" + propertyID1 := "prp_123456" + propertyID2 := "prp_456789" + tests := map[string]struct { + givenTF string + init func(*iam.Mock, *papi.Mock) + expectedAttributes map[string]string + expectedMissingAttributes []string + expectError *regexp.Regexp + }{ + "happy path - blocked properties are returned": { + givenTF: "valid.tf", + init: func(im *iam.Mock, pm *papi.Mock) { + im.On("ListBlockedProperties", mock.Anything, iam.ListBlockedPropertiesRequest{ + IdentityID: "user123", + GroupID: 1, + }).Return([]int64{123, 456}, nil) + im.On("MapPropertyIDToName", mock.Anything, iam.MapPropertyIDToNameRequest{ + GroupID: 1, + PropertyID: 123, + }).Return(&propertyName1, nil) + pm.On("MapPropertyNameToID", mock.Anything, papi.MapPropertyNameToIDRequest{ + GroupID: "grp_1", + ContractID: "ctr_C-123", + Name: propertyName1, + }).Return(&propertyID1, nil) + im.On("MapPropertyIDToName", mock.Anything, iam.MapPropertyIDToNameRequest{ + GroupID: 1, + PropertyID: 456, + }).Return(&propertyName2, nil) + pm.On("MapPropertyNameToID", mock.Anything, papi.MapPropertyNameToIDRequest{ + GroupID: "grp_1", + ContractID: "ctr_C-123", + Name: propertyName2, + }).Return(&propertyID2, nil) + + }, + expectedAttributes: map[string]string{ + "blocked_properties.#": "2", + "blocked_properties.0": "prp_123456", + "blocked_properties.1": "prp_456789", + }, + expectError: nil, + }, + "error response from api": { + givenTF: "valid.tf", + init: func(im *iam.Mock, _ *papi.Mock) { + im.On("ListBlockedProperties", mock.Anything, iam.ListBlockedPropertiesRequest{ + IdentityID: "user123", + GroupID: 1, + }).Return(nil, fmt.Errorf("oops")) + }, + expectError: regexp.MustCompile("oops"), + }, + "missing required argument group_id": { + givenTF: "missing_group_id.tf", + expectError: regexp.MustCompile(`The argument "group_id" is required, but no definition was found`), + }, + "missing required argument contract_id": { + givenTF: "missing_contract_id.tf", + expectError: regexp.MustCompile(`The argument "contract_id" is required, but no definition was found`), + }, + "missing required argument ui_identity_id": { + givenTF: "missing_ui_identity_id.tf", + expectError: regexp.MustCompile(`The argument "ui_identity_id" is required, but no definition was found`), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + papiClient := &papi.Mock{} + + if test.init != nil { + test.init(client, papiClient) + } + var checkFuncs []resource.TestCheckFunc + for k, v := range test.expectedAttributes { + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", k, v)) + } + for _, v := range test.expectedMissingAttributes { + checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("data.akamai_iam_blocked_properties.test", v)) + } + useIAMandPAPIClient(client, papiClient, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataBlockedProperties/%s", test.givenTF)), + Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), + ExpectError: test.expectError, + }}, + }) + }) + client.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index f66ed1139..c25c86e79 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -5,6 +5,7 @@ import ( "sync" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -15,7 +16,8 @@ import ( type ( // Subprovider gathers IAM resources and data sources Subprovider struct { - client iam.IAM + client iam.IAM + papiClient papi.PAPI } option func(p *Subprovider) @@ -52,6 +54,14 @@ func (p *Subprovider) Client(meta meta.Meta) iam.IAM { return iam.Client(meta.Session()) } +// PapiClient returns the PAPI interface +func (p *Subprovider) PapiClient(meta meta.Meta) papi.PAPI { + if p.client != nil { + return p.papiClient + } + return papi.Client(meta.Session()) +} + // SDKResources returns the IAM resources implemented using terraform-plugin-sdk func (p *Subprovider) SDKResources() map[string]*schema.Resource { return map[string]*schema.Resource{ @@ -88,5 +98,6 @@ func (p *Subprovider) FrameworkResources() []func() resource.Resource { func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { return []func() datasource.DataSource{ NewAllowedAPIsDataSource, + NewBlockedPropertiesDataSource, } } diff --git a/pkg/providers/iam/provider_test.go b/pkg/providers/iam/provider_test.go index 9651be230..f5e5e3dba 100644 --- a/pkg/providers/iam/provider_test.go +++ b/pkg/providers/iam/provider_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) @@ -22,7 +23,25 @@ func useClient(client iam.IAM, f func()) { inst.client = client defer func() { - inst.client = orig + client = orig + clientLock.Unlock() + }() + + f() +} + +// useClient swaps out the client on the global instance for the duration of the given func using both IAM and PAPI +func useIAMandPAPIClient(client iam.IAM, papiClient papi.PAPI, f func()) { + clientLock.Lock() + orig := inst.client + inst.client = client + + origPapi := inst.papiClient + inst.papiClient = papiClient + + defer func() { + client = orig + papiClient = origPapi clientLock.Unlock() }() diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf new file mode 100644 index 000000000..4522bddd8 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_contract_id.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_blocked_properties" "test" { + group_id = 1 + ui_identity_id = "user123" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf new file mode 100644 index 000000000..db046023a --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_group_id.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_blocked_properties" "test" { + contract_id = "ctr_C-123" + ui_identity_id = "user123" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf new file mode 100644 index 000000000..5e1ac2018 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/missing_ui_identity_id.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_blocked_properties" "test" { + group_id = 1 + contract_id = "ctr_C-123" +} diff --git a/pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf b/pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf new file mode 100644 index 000000000..7b660cd39 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataBlockedProperties/valid.tf @@ -0,0 +1,10 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + + +data "akamai_iam_blocked_properties" "test" { + group_id = 1 + contract_id = "ctr_C-123" + ui_identity_id = "user123" +} From e1440bb558065a5a176c2635ca8d5380474d2ed3 Mon Sep 17 00:00:00 2001 From: Filip Antkowiak Date: Wed, 14 Aug 2024 12:26:14 +0000 Subject: [PATCH 21/54] DXE-4033 Implement cidr block datasource --- CHANGELOG.md | 5 + .../iam/data_akamai_allowed_apis_test.go | 4 +- pkg/providers/iam/data_akamai_cidr_block.go | 172 ++++++++++++++++++ .../iam/data_akamai_cidr_block_test.go | 148 +++++++++++++++ pkg/providers/iam/iam_errors.go | 2 + pkg/providers/iam/provider.go | 1 + .../iam/testdata/TestDataCIDRBlock/default.tf | 7 + .../missing_cidr_block_id.tf | 6 + 8 files changed, 343 insertions(+), 2 deletions(-) create mode 100644 pkg/providers/iam/data_akamai_cidr_block.go create mode 100644 pkg/providers/iam/data_akamai_cidr_block_test.go create mode 100644 pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf create mode 100644 pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 08436aa27..e2b4da1ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,10 @@ * `akamai_iam_allowed_apis` - read the list of APIs available to the user +* IAM + * Added new data source: + * `akamai_iam_cidr_block` - read the CIDR block details + * IAM @@ -37,6 +41,7 @@ + * IAM * Added new resource: * `akamai_iam_ip_allowlist` - enable or disable your account's allowlist diff --git a/pkg/providers/iam/data_akamai_allowed_apis_test.go b/pkg/providers/iam/data_akamai_allowed_apis_test.go index 8026bf270..eb0de7beb 100644 --- a/pkg/providers/iam/data_akamai_allowed_apis_test.go +++ b/pkg/providers/iam/data_akamai_allowed_apis_test.go @@ -135,7 +135,7 @@ func TestDataAllowedAPIs(t *testing.T) { Steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, test.configPath), - Check: checkKeysAttrs(test.mockData), + Check: checkAllowedAPIsAttrs(test.mockData), ExpectError: test.error, }, }, @@ -177,7 +177,7 @@ func expectFullListAllowedAPIs(_ *testing.T, client *iam.Mock, data testDataForA } -func checkKeysAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { +func checkAllowedAPIsAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { name := "data.akamai_iam_allowed_apis.test" checksFuncs := []resource.TestCheckFunc{ resource.TestCheckResourceAttr(name, "username", data.username), diff --git a/pkg/providers/iam/data_akamai_cidr_block.go b/pkg/providers/iam/data_akamai_cidr_block.go new file mode 100644 index 000000000..fd3595ee0 --- /dev/null +++ b/pkg/providers/iam/data_akamai_cidr_block.go @@ -0,0 +1,172 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &cidrBlockDataSource{} + _ datasource.DataSourceWithConfigure = &cidrBlockDataSource{} +) + +type ( + cidrBlockDataSource struct { + meta meta.Meta + } + + cidrBlockSourceModel struct { + CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` + Actions *actions `tfsdk:"actions"` + CIDRBlock types.String `tfsdk:"cidr_block"` + Comments types.String `tfsdk:"comments"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + Enabled types.Bool `tfsdk:"enabled"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + } + + actions struct { + Delete types.Bool `tfsdk:"delete"` + Edit types.Bool `tfsdk:"edit"` + } +) + +// NewCIDRBlockDataSource returns a new iam CIDR block data source +func NewCIDRBlockDataSource() datasource.DataSource { + return &cidrBlockDataSource{} +} + +// Metadata configures data source's meta information +func (d *cidrBlockDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_block" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *cidrBlockDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *cidrBlockDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management CIDR block", + Attributes: map[string]schema.Attribute{ + "cidr_block_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each CIDR block.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block.", + }, + }, + }, + "cidr_block": schema.StringAttribute{ + Computed: true, + Description: "The value of an IP address or IP address range.", + }, + "comments": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + }, + "enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether the CIDR block is enabled.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + }, + }, + } +} + +// Read is called when the provider must read data source values in order to update state +func (d *cidrBlockDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM CIDR Block DataSource Read") + + var data cidrBlockSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + id := data.CIDRBlockID.ValueInt64() + cidrBlock, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ + CIDRBlockID: id, + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMGetCIDRBlock), err.Error()) + return + } + + if resp.Diagnostics.Append(data.read(cidrBlock)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + +} + +func (d *cidrBlockSourceModel) read(cidrBlock *iam.GetCIDRBlockResponse) diag.Diagnostics { + d.CIDRBlock = types.StringValue(cidrBlock.CIDRBlock) + d.Comments = types.StringValue(cidrBlock.Comments) + d.CreatedBy = types.StringValue(cidrBlock.CreatedBy) + d.CreatedDate = types.StringValue(cidrBlock.CreatedDate.Format(time.RFC3339Nano)) + d.Enabled = types.BoolValue(cidrBlock.Enabled) + d.ModifiedBy = types.StringValue(cidrBlock.ModifiedBy) + d.ModifiedDate = types.StringValue(cidrBlock.ModifiedDate.Format(time.RFC3339Nano)) + + if cidrBlock.Actions != nil { + d.Actions = &actions{ + Delete: types.BoolValue(cidrBlock.Actions.Delete), + Edit: types.BoolValue(cidrBlock.Actions.Edit), + } + } + + return nil + +} diff --git a/pkg/providers/iam/data_akamai_cidr_block_test.go b/pkg/providers/iam/data_akamai_cidr_block_test.go new file mode 100644 index 000000000..e421a57ab --- /dev/null +++ b/pkg/providers/iam/data_akamai_cidr_block_test.go @@ -0,0 +1,148 @@ +package iam + +import ( + "errors" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForCIDRBlock struct { + cidrBlockID int64 + actions *testActions + cidrBlock string + comments string + createdBy string + createdDate string + enabled bool + modifiedBy string + modifiedDate string + } + + testActions struct { + delete bool + edit bool + } +) + +var ( + basicTestDataForCIDRBlock = testDataForCIDRBlock{ + cidrBlockID: 2567, + actions: &testActions{ + delete: true, + edit: false, + }, + cidrBlock: "128.5.6.6/24", + comments: "APAC Region", + createdBy: "alfulani", + createdDate: "2017-07-27T18:11:25Z", + enabled: true, + modifiedBy: "alfulani", + modifiedDate: "2017-07-27T18:11:25Z", + } +) + +func TestDataCIDRBlock(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForCIDRBlock) + mockData testDataForCIDRBlock + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataCIDRBlock/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData testDataForCIDRBlock) { + expectGetCIDRBlock(t, m, mockData, 5) + }, + mockData: basicTestDataForCIDRBlock, + }, + "error - missing cidr_block_id": { + configPath: "testdata/TestDataCIDRBlock/missing_cidr_block_id.tf", + error: regexp.MustCompile("Missing required argument"), + mockData: basicTestDataForCIDRBlock, + }, + "error - GetCIDRBlock call failed ": { + configPath: "testdata/TestDataCIDRBlock/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData testDataForCIDRBlock) { + getCIDRBlockReq := iam.GetCIDRBlockRequest{CIDRBlockID: mockData.cidrBlockID, Actions: true} + m.On("GetCIDRBlock", mock.Anything, getCIDRBlockReq).Return(nil, errors.New("test error")) + }, + mockData: basicTestDataForCIDRBlock, + error: regexp.MustCompile("test error"), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.mockData) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkCIDRBlockAttrs(), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkCIDRBlockAttrs() resource.TestCheckFunc { + name := "data.akamai_iam_cidr_block.test" + + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "cidr_block_id", "2567"), + resource.TestCheckResourceAttr(name, "cidr_block", "128.5.6.6/24"), + resource.TestCheckResourceAttr(name, "comments", "APAC Region"), + resource.TestCheckResourceAttr(name, "created_by", "alfulani"), + resource.TestCheckResourceAttr(name, "created_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "enabled", "true"), + resource.TestCheckResourceAttr(name, "modified_by", "alfulani"), + resource.TestCheckResourceAttr(name, "modified_date", "2017-07-27T18:11:25Z"), + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} + +func expectGetCIDRBlock(t *testing.T, client *iam.Mock, data testDataForCIDRBlock, timesToRun int) { + + getCIDRBlockReq := iam.GetCIDRBlockRequest{ + CIDRBlockID: data.cidrBlockID, + Actions: true, + } + + createdDate := test.NewTimeFromString(t, data.createdDate) + modifiedDate := test.NewTimeFromString(t, data.modifiedDate) + + getCIDRBlockResp := iam.GetCIDRBlockResponse{ + CIDRBlock: data.cidrBlock, + CIDRBlockID: data.cidrBlockID, + Comments: data.comments, + CreatedBy: data.createdBy, + CreatedDate: createdDate, + Enabled: data.enabled, + ModifiedBy: data.modifiedBy, + ModifiedDate: modifiedDate, + } + if data.actions != nil { + getCIDRBlockResp.Actions = &iam.CIDRActions{ + Delete: data.actions.delete, + Edit: data.actions.edit, + } + } + client.On("GetCIDRBlock", mock.Anything, getCIDRBlockReq).Return(&getCIDRBlockResp, nil).Times(timesToRun) + +} diff --git a/pkg/providers/iam/iam_errors.go b/pkg/providers/iam/iam_errors.go index 7eb974ac3..2ce76cc30 100644 --- a/pkg/providers/iam/iam_errors.go +++ b/pkg/providers/iam/iam_errors.go @@ -5,4 +5,6 @@ import "errors" var ( // ErrIAMListAllowedAPIs is returned when ListAllowedAPIs fails ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") + // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails + ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") ) diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index c25c86e79..0b9aeaf5f 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -99,5 +99,6 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { return []func() datasource.DataSource{ NewAllowedAPIsDataSource, NewBlockedPropertiesDataSource, + NewCIDRBlockDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf b/pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf new file mode 100644 index 000000000..8d68a5c28 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataCIDRBlock/default.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_cidr_block" "test" { + cidr_block_id = 2567 +} diff --git a/pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf b/pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf new file mode 100644 index 000000000..5d712d559 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataCIDRBlock/missing_cidr_block_id.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_cidr_block" "test" { +} From c192ac44e7a914519926a876183ef50ac9aa919b Mon Sep 17 00:00:00 2001 From: rbhatved Date: Mon, 5 Aug 2024 16:27:47 +0530 Subject: [PATCH 22/54] DXE-4062 Align iam_user resource to changes in edgegrid. --- CHANGELOG.md | 10 +- pkg/common/tf/util.go | 9 + .../datastream/resource_akamai_datastream.go | 4 +- pkg/providers/datastream/stream.go | 9 - pkg/providers/datastream/stream_test.go | 3 +- pkg/providers/iam/resource_akamai_iam_user.go | 359 +++++++++++++-- .../iam/resource_akamai_iam_user_test.go | 433 +++++++++++++++--- .../TestResourceUserLifecycle/basic_import.tf | 14 + .../TestResourceUserLifecycle/create_basic.tf | 14 +- .../create_basic_authentication_none.tf | 14 + .../create_basic_lock.tf | 15 +- .../create_basic_notification_and_mfa.tf | 28 ++ ...nable_email_notifications_field_missing.tf | 27 ++ ...sic_notification_multiple_options_block.tf | 39 ++ ...asic_notification_options_block_missing.tf | 17 + ...ification_password_expiry_field_missing.tf | 27 ++ .../create_basic_with_password.tf | 15 + .../create_basic_without_password.tf | 14 + .../create_with_invalid_auth_method.tf | 15 + .../update_auth_grants.tf | 13 +- .../TestResourceUserLifecycle/update_email.tf | 14 +- .../update_password.tf | 26 ++ ...ate_password_with_password_empty_string.tf | 25 + .../update_password_without_password.tf | 25 + 24 files changed, 1014 insertions(+), 155 deletions(-) create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b4da1ba..2431e0b52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,11 +24,18 @@ * `akamai_iam_blocked_properties` - reads blocked properties for a certain user in a group +* IAM + * Added below attributes to the `resource_akamai_iam_user` resource. + * Added `user_notifications` attribute to support user notifications. + * Added `enable_mfa` attribute to support authentication of type "MFA". + * Updated `enable_tfa` to an optional field. + * Added `password` attribute to allow users to set password during the creation and update of an user. + * IAM * Added new data source: * `akamai_iam_allowed_apis` - read the list of APIs available to the user - + * IAM * Added new data source: * `akamai_iam_cidr_block` - read the CIDR block details @@ -41,7 +48,6 @@ - * IAM * Added new resource: * `akamai_iam_ip_allowlist` - enable or disable your account's allowlist diff --git a/pkg/common/tf/util.go b/pkg/common/tf/util.go index 5c47e4b50..cc6140a88 100644 --- a/pkg/common/tf/util.go +++ b/pkg/common/tf/util.go @@ -31,3 +31,12 @@ func MaxDuration(x, y time.Duration) time.Duration { } return x } + +// InterfaceSliceToStringSlice converts schema.Set to slice of string +func InterfaceSliceToStringSlice(list []interface{}) []string { + stringList := make([]string, len(list)) + for i, v := range list { + stringList[i] = v.(string) + } + return stringList +} diff --git a/pkg/providers/datastream/resource_akamai_datastream.go b/pkg/providers/datastream/resource_akamai_datastream.go index 92922aa21..41b1b7051 100644 --- a/pkg/providers/datastream/resource_akamai_datastream.go +++ b/pkg/providers/datastream/resource_akamai_datastream.go @@ -888,7 +888,7 @@ func resourceDatastreamCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } } - emailIDs := InterfaceSliceToStringSlice(emailIDsList) + emailIDs := tf.InterfaceSliceToStringSlice(emailIDsList) if len(emailIDs) == 0 { emailIDs = nil @@ -1185,7 +1185,7 @@ func updateStream(ctx context.Context, client datastream.DS, logger log.Interfac return err } } - emailIDs := InterfaceSliceToStringSlice(emailIDsList) + emailIDs := tf.InterfaceSliceToStringSlice(emailIDsList) propertyIDsList, err := tf.GetListValue("properties", d) diff --git a/pkg/providers/datastream/stream.go b/pkg/providers/datastream/stream.go index 63956ff75..f9fa18e71 100644 --- a/pkg/providers/datastream/stream.go +++ b/pkg/providers/datastream/stream.go @@ -105,15 +105,6 @@ func DatasetFieldListToDatasetFields(list []interface{}) []datastream.DatasetFie return datasetFields } -// InterfaceSliceToStringSlice converts schema.Set to slice of string -func InterfaceSliceToStringSlice(list []interface{}) []string { - stringList := make([]string, len(list)) - for i, v := range list { - stringList[i] = v.(string) - } - return stringList -} - // DataSetFieldsToList converts slice of dataSetFields to slice of ints func DataSetFieldsToList(dataSetFields []datastream.DataSetField) []int { diff --git a/pkg/providers/datastream/stream_test.go b/pkg/providers/datastream/stream_test.go index 8f43570dc..0e7ecdf0e 100644 --- a/pkg/providers/datastream/stream_test.go +++ b/pkg/providers/datastream/stream_test.go @@ -7,6 +7,7 @@ import ( "github.com/tj/assert" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -198,7 +199,7 @@ func TestInterfaceSliceToStringSlice(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { - assert.Equal(t, test.expected, InterfaceSliceToStringSlice(test.input)) + assert.Equal(t, test.expected, tf.InterfaceSliceToStringSlice(test.input)) }) } } diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 8fbef4245..441ef59a2 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -18,6 +18,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -31,6 +32,7 @@ func resourceIAMUser() *schema.Resource { ReadContext: resourceIAMUserRead, UpdateContext: resourceIAMUserUpdate, DeleteContext: resourceIAMUserDelete, + CustomizeDiff: customdiff.All(customizePasswordDiff, customizeNotificationDiff), Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -68,9 +70,14 @@ func resourceIAMUser() *schema.Resource { }, "enable_tfa": { Type: schema.TypeBool, - Required: true, + Optional: true, Description: "Indicates whether two-factor authentication is allowed", }, + "enable_mfa": { + Type: schema.TypeBool, + Optional: true, + Description: "Indicates whether multi-factor authentication is allowed", + }, "auth_grants_json": { Type: schema.TypeString, Required: true, @@ -179,6 +186,71 @@ func resourceIAMUser() *schema.Resource { Description: "Flag to block a user account", Default: false, }, + "password": { + Type: schema.TypeString, + Description: "New password for a user", + Optional: true, + Sensitive: true, + }, + "user_notifications": { + Type: schema.TypeList, + Optional: true, + Description: "Specifies email notifications the user receives for products.", + Computed: true, + MaxItems: 1, // Ensure only one notification configuration can be set + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "options": { + Type: schema.TypeList, + Required: true, + Description: "Specifies email notifications settings.", + MaxItems: 1, // Ensure only one options configuration can be set + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "api_client_credential_expiry_notification": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Enables notifications for expiring API client credentials", + }, + "new_user_notification": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Enables notifications for group administrators when the user creates other new users", + }, + "password_expiry": { + Type: schema.TypeBool, + Required: true, + Description: "Enables notifications for expiring passwords", + }, + "proactive": { + Type: schema.TypeList, + Required: true, + Description: "Products for which the user gets notifications for service issues", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "upgrade": { + Type: schema.TypeList, + Required: true, + Description: "Products for which the user receives notifications for upgrades", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + }, + }, + }, + "enable_email_notifications": { + Type: schema.TypeBool, + Required: true, + Description: "Enables email notifications", + }, + }, + }, + }, }, } } @@ -201,24 +273,30 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf } } + authMethod, err := getAuthenticationMethod(d) + if err != nil { + return diag.FromErr(err) + } + basicUser := iam.UserBasicInfo{ - FirstName: d.Get("first_name").(string), - LastName: d.Get("last_name").(string), - UserName: d.Get("user_name").(string), - Email: d.Get("email").(string), - Phone: d.Get("phone").(string), - TimeZone: d.Get("time_zone").(string), - JobTitle: d.Get("job_title").(string), - TFAEnabled: d.Get("enable_tfa").(bool), - SecondaryEmail: d.Get("secondary_email").(string), - MobilePhone: d.Get("mobile_phone").(string), - Address: d.Get("address").(string), - City: d.Get("city").(string), - State: d.Get("state").(string), - ZipCode: d.Get("zip_code").(string), - Country: d.Get("country").(string), - ContactType: d.Get("contact_type").(string), - PreferredLanguage: d.Get("preferred_language").(string), + FirstName: d.Get("first_name").(string), + LastName: d.Get("last_name").(string), + UserName: d.Get("user_name").(string), + Email: d.Get("email").(string), + Phone: d.Get("phone").(string), + TimeZone: d.Get("time_zone").(string), + JobTitle: d.Get("job_title").(string), + TFAEnabled: d.Get("enable_tfa").(bool), + SecondaryEmail: d.Get("secondary_email").(string), + MobilePhone: d.Get("mobile_phone").(string), + Address: d.Get("address").(string), + City: d.Get("city").(string), + State: d.Get("state").(string), + ZipCode: d.Get("zip_code").(string), + Country: d.Get("country").(string), + ContactType: d.Get("contact_type").(string), + PreferredLanguage: d.Get("preferred_language").(string), + AdditionalAuthentication: iam.Authentication(authMethod), } if st, ok := d.GetOk("session_timeout"); ok { @@ -226,17 +304,23 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf basicUser.SessionTimeOut = &sessionTimeout } - user, err := client.CreateUser(ctx, iam.CreateUserRequest{ + userRequest := iam.CreateUserRequest{ UserBasicInfo: basicUser, AuthGrants: authGrants, SendEmail: true, - Notifications: &iam.UserNotifications{ - Options: iam.UserNotificationOptions{ - Proactive: []string{}, - Upgrade: []string{}, - }, - }, - }) + } + + // Get user notifications if provided + userNotifications, err := getUserNotifications(d) + if err != nil { + return diag.FromErr(err) + } + + if userNotifications != nil { + userRequest.Notifications = userNotifications + } + + user, err := client.CreateUser(ctx, userRequest) if err != nil { logger.WithError(err).Errorf("failed to create user") return diag.Errorf("failed to create user: %s\n%s", err, resourceIAMUserErrorAdvice(err)) @@ -254,10 +338,95 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf } } + err = manageUserPassword(ctx, d, client, user.IdentityID) + if err != nil { + logger.WithError(err).Errorf("failed to set user password") + return diag.Errorf("failed to set user password: %s", err) + } + d.SetId(user.IdentityID) return resourceIAMUserRead(ctx, d, m) } +func manageUserPassword(ctx context.Context, d *schema.ResourceData, client iam.IAM, ID string) error { + password, err := tf.GetStringValue("password", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return err + } + + if password != "" { + err = client.SetUserPassword(ctx, iam.SetUserPasswordRequest{ + IdentityID: ID, + NewPassword: password, + }) + if err != nil { + return err + } + } + return nil +} + +func extractUserNotificationsData(notificationsData interface{}) (*iam.UserNotifications, error) { + + notificationsList, ok := notificationsData.([]interface{}) + if !ok { + return nil, errors.New("user notifications data is not a valid list") + } + + item, ok := notificationsList[0].(map[string]interface{}) + if !ok { + return nil, errors.New("user notifications data item is not a valid map") + } + + options, ok := item["options"].([]interface{}) + if !ok { + return nil, errors.New("options field in user notifications data is not a valid list") + } + + var optionsMap map[string]interface{} + if len(options) > 0 { + optionsMap, ok = options[0].(map[string]interface{}) + if !ok { + return nil, errors.New("options field item is not a valid map") + } + } + + return &iam.UserNotifications{ + EnableEmail: item["enable_email_notifications"].(bool), + Options: iam.UserNotificationOptions{ + APIClientCredentialExpiry: optionsMap["api_client_credential_expiry_notification"].(bool), + NewUser: optionsMap["new_user_notification"].(bool), + PasswordExpiry: optionsMap["password_expiry"].(bool), + Proactive: tf.InterfaceSliceToStringSlice(optionsMap["proactive"].([]interface{})), + Upgrade: tf.InterfaceSliceToStringSlice(optionsMap["upgrade"].([]interface{})), + }, + }, nil +} + +func getUserNotifications(d *schema.ResourceData) (*iam.UserNotifications, error) { + notificationsData, err := tf.GetListValue("user_notifications", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return nil, err + } + return extractUserNotificationsData(notificationsData) +} + +func getAuthenticationMethod(d *schema.ResourceData) (string, error) { + enableTFA := d.Get("enable_tfa").(bool) + enableMFA := d.Get("enable_mfa").(bool) + + if enableTFA && enableMFA { + return "", errors.New("only one of 'enable_tfa' or 'enable_mfa' can be set") + } + + if enableTFA { + return "TFA", nil + } else if enableMFA { + return "MFA", nil + } + return "NONE", nil +} + func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { meta := meta.Must(m) logger := meta.Log("IAM", "resourceIAMUserRead") @@ -267,8 +436,9 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac logger.Debug("Reading User") req := iam.GetUserRequest{ - IdentityID: d.Id(), - AuthGrants: true, + IdentityID: d.Id(), + AuthGrants: true, + Notifications: true, } user, err := client.GetUser(ctx, req) @@ -291,6 +461,22 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac } } + userNotifications := []interface{}{map[string]interface{}{ + "enable_email_notifications": user.Notifications.EnableEmail, + "options": []interface{}{ + map[string]interface{}{ + "api_client_credential_expiry_notification": user.Notifications.Options.APIClientCredentialExpiry, + "new_user_notification": user.Notifications.Options.NewUser, + "password_expiry": user.Notifications.Options.PasswordExpiry, + "proactive": user.Notifications.Options.Proactive, + "upgrade": user.Notifications.Options.Upgrade, + }, + }, + }, + } + + enableMFA := user.AdditionalAuthentication == "MFA" + err = tf.SetAttrs(d, map[string]interface{}{ "first_name": user.FirstName, "last_name": user.LastName, @@ -300,6 +486,7 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "time_zone": user.TimeZone, "job_title": user.JobTitle, "enable_tfa": user.TFAEnabled, + "enable_mfa": enableMFA, "secondary_email": user.SecondaryEmail, "mobile_phone": user.MobilePhone, "address": user.Address, @@ -316,6 +503,7 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "session_timeout": *user.SessionTimeOut, "auth_grants_json": stateAuthGrantsJS(string(authGrantsJSON)), "lock": user.IsLocked, + "user_notifications": userNotifications, }) if err != nil { logger.WithError(err).Error("could not save attributes to state") @@ -350,6 +538,7 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf "time_zone", "job_title", "enable_tfa", + "enable_mfa", "secondary_email", "mobile_phone", "address", @@ -361,25 +550,32 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf "preferred_language", "session_timeout", ) + + authMethod, err := getAuthenticationMethod(d) + if err != nil { + return diag.FromErr(err) + } + if updateBasicInfo { basicUser := iam.UserBasicInfo{ - FirstName: d.Get("first_name").(string), - LastName: d.Get("last_name").(string), - UserName: d.Get("user_name").(string), - Email: d.Get("email").(string), - Phone: d.Get("phone").(string), - TimeZone: d.Get("time_zone").(string), - JobTitle: d.Get("job_title").(string), - TFAEnabled: d.Get("enable_tfa").(bool), - SecondaryEmail: d.Get("secondary_email").(string), - MobilePhone: d.Get("mobile_phone").(string), - Address: d.Get("address").(string), - City: d.Get("city").(string), - State: d.Get("state").(string), - ZipCode: d.Get("zip_code").(string), - Country: d.Get("country").(string), - ContactType: d.Get("contact_type").(string), - PreferredLanguage: d.Get("preferred_language").(string), + FirstName: d.Get("first_name").(string), + LastName: d.Get("last_name").(string), + UserName: d.Get("user_name").(string), + Email: d.Get("email").(string), + Phone: d.Get("phone").(string), + TimeZone: d.Get("time_zone").(string), + JobTitle: d.Get("job_title").(string), + TFAEnabled: d.Get("enable_tfa").(bool), + SecondaryEmail: d.Get("secondary_email").(string), + MobilePhone: d.Get("mobile_phone").(string), + Address: d.Get("address").(string), + City: d.Get("city").(string), + State: d.Get("state").(string), + ZipCode: d.Get("zip_code").(string), + Country: d.Get("country").(string), + ContactType: d.Get("contact_type").(string), + PreferredLanguage: d.Get("preferred_language").(string), + AdditionalAuthentication: iam.Authentication(authMethod), } if st, ok := d.GetOk("session_timeout"); ok { @@ -443,6 +639,41 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf } } + // user notifications + if d.HasChange("user_notifications") { + notificationsData, err := tf.GetListValue("user_notifications", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return diag.FromErr(err) + } + + userNotifications, err := extractUserNotificationsData(notificationsData) + if err != nil { + return diag.Errorf("failed to extract user notifications: %s", err) + } + + req := iam.UpdateUserNotificationsRequest{ + IdentityID: d.Id(), + Notifications: userNotifications, + } + + if _, err := client.UpdateUserNotifications(ctx, req); err != nil { + d.Partial(true) + logger.WithError(err).Errorf("failed to update user notifications") + return diag.Errorf("failed to update user notifications: %s", err) + } + needRead = true + } + + // password + if d.HasChange("password") { + err = manageUserPassword(ctx, d, client, d.Id()) + if err != nil { + logger.WithError(err).Errorf("failed to set user password") + return diag.Errorf("failed to set user password: %s", err) + } + needRead = true + } + if needRead { d.Partial(false) return resourceIAMUserRead(ctx, d, m) @@ -621,3 +852,41 @@ func validatePhone(i interface{}, k string) (warnings []string, errors []error) return warnings, errors } + +func customizePasswordDiff(_ context.Context, d *schema.ResourceDiff, _ interface{}) error { + if d.HasChange("password") { + oldVal, newVal := d.GetChange("password") + oldPassword := oldVal.(string) + newPassword := newVal.(string) + if oldPassword != "" && newPassword == "" { + return fmt.Errorf("deleting the password field or setting the password to an empty string is not allowed") + } + } + return nil +} + +func customizeNotificationDiff(_ context.Context, d *schema.ResourceDiff, _ interface{}) error { + newValue := d.GetRawConfig() + if newValue.GetAttr("user_notifications").LengthInt() == 0 { + // Field is omitted, so apply the default configuration + defaultConfig := []interface{}{ + map[string]interface{}{ + "enable_email_notifications": true, + "options": []interface{}{ + map[string]interface{}{ + "api_client_credential_expiry_notification": false, + "new_user_notification": true, + "password_expiry": true, + "proactive": []interface{}{}, + "upgrade": []interface{}{}, + }, + }, + }, + } + if err := d.SetNew("user_notifications", defaultConfig); err != nil { + return fmt.Errorf("failed to set default notification configuration: %s", err) + } + } + + return nil +} diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index 4c94234de..8d28253a2 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -19,31 +19,43 @@ import ( func TestResourceUser(t *testing.T) { basicUserInfo := iam.UserBasicInfo{ - FirstName: "John", - LastName: "Smith", - Email: "jsmith@example.com", - Phone: "(111) 111-1111", - TFAEnabled: false, - Country: "country", + FirstName: "John", + LastName: "Smith", + Email: "jsmith@example.com", + Phone: "(111) 111-1111", + TFAEnabled: false, + Country: "country", + AdditionalAuthentication: "NONE", + } + + basicUserInfoWithMFA := iam.UserBasicInfo{ + FirstName: "John", + LastName: "Smith", + Email: "jsmith@example.com", + Phone: "(111) 111-1111", + TFAEnabled: false, + Country: "country", + AdditionalAuthentication: "MFA", } extendedUserInfo := iam.UserBasicInfo{ - FirstName: "John", - LastName: "Smith", - Email: "jsmith@example.com", - Phone: "(111) 111-1111", - TimeZone: "timezone", - JobTitle: "job title", - TFAEnabled: false, - SecondaryEmail: "secondary.email@example.com", - MobilePhone: "(222) 222-2222", - Address: "123 B Street", - City: "B-Town", - State: "state", - ZipCode: "zip", - Country: "country", - ContactType: "contact type", - PreferredLanguage: "language", - SessionTimeOut: ptr.To(2), + FirstName: "John", + LastName: "Smith", + Email: "jsmith@example.com", + Phone: "(111) 111-1111", + TimeZone: "timezone", + JobTitle: "job title", + TFAEnabled: false, + SecondaryEmail: "secondary.email@example.com", + MobilePhone: "(222) 222-2222", + Address: "123 B Street", + City: "B-Town", + State: "state", + ZipCode: "zip", + Country: "country", + ContactType: "contact type", + PreferredLanguage: "language", + SessionTimeOut: ptr.To(2), + AdditionalAuthentication: "NONE", } authGrantsCreate := []iam.AuthGrant{ @@ -101,14 +113,30 @@ func TestResourceUser(t *testing.T) { } notifications := iam.UserNotifications{ + EnableEmail: true, + Options: iam.UserNotificationOptions{ + NewUser: true, + PasswordExpiry: true, + Proactive: []string{}, + Upgrade: []string{}, + APIClientCredentialExpiry: false, + }, + } + + customNotifications := iam.UserNotifications{ + EnableEmail: true, Options: iam.UserNotificationOptions{ - Proactive: []string{}, - Upgrade: []string{}, + NewUser: true, + PasswordExpiry: true, + Proactive: []string{"EdgeScape"}, + Upgrade: []string{"NetStorage"}, + APIClientCredentialExpiry: true, }, } + id := "test_identity_id" - checkUserAttributes := func(user iam.User) resource.TestCheckFunc { + checkUserAttributes := func(user iam.User, checkPassword bool) resource.TestCheckFunc { if user.SessionTimeOut == nil { user.SessionTimeOut = ptr.To(0) } @@ -131,7 +159,7 @@ func TestResourceUser(t *testing.T) { authGrantsJSON = string(marshalledAuthGrants) } - return resource.ComposeAggregateTestCheckFunc( + checks := []resource.TestCheckFunc{ resource.TestCheckResourceAttr("akamai_iam_user.test", "id", "test_identity_id"), resource.TestCheckResourceAttr("akamai_iam_user.test", "first_name", user.FirstName), resource.TestCheckResourceAttr("akamai_iam_user.test", "last_name", user.LastName), @@ -139,6 +167,7 @@ func TestResourceUser(t *testing.T) { resource.TestCheckResourceAttr("akamai_iam_user.test", "country", user.Country), resource.TestCheckResourceAttr("akamai_iam_user.test", "phone", user.Phone), resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_tfa", fmt.Sprintf("%t", user.TFAEnabled)), + resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_mfa", fmt.Sprintf("%t", user.AdditionalAuthentication == "MFA")), resource.TestCheckResourceAttr("akamai_iam_user.test", "contact_type", user.ContactType), resource.TestCheckResourceAttr("akamai_iam_user.test", "user_name", user.UserName), resource.TestCheckResourceAttr("akamai_iam_user.test", "job_title", user.JobTitle), @@ -157,7 +186,35 @@ func TestResourceUser(t *testing.T) { resource.TestCheckResourceAttr("akamai_iam_user.test", "session_timeout", fmt.Sprintf("%d", *user.SessionTimeOut)), resource.TestCheckResourceAttr("akamai_iam_user.test", "auth_grants_json", authGrantsJSON), resource.TestCheckResourceAttr("akamai_iam_user.test", "lock", fmt.Sprintf("%t", user.IsLocked)), - ) + } + if checkPassword { + checks = append(checks, resource.TestCheckResourceAttrSet("akamai_iam_user.test", "password")) + } else { + checks = append(checks, resource.TestCheckNoResourceAttr("akamai_iam_user.test", "password")) + } + return resource.ComposeAggregateTestCheckFunc(checks...) + } + checkDefaultUserNotificationsAttributes := func(user iam.User) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.new_user_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.password_expiry", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.proactive.#", "0"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.upgrade.#", "0"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.api_client_credential_expiry_notification", "false"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true")) + } + + checkUserNotificationsAttributes := func(user iam.User) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.new_user_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.password_expiry", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.proactive.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.upgrade.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.api_client_credential_expiry_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true")) } userCreate := iam.User{ @@ -171,6 +228,18 @@ func TestResourceUser(t *testing.T) { AuthGrants: authGrantsCreate, Notifications: notifications, } + + userCreateWithNotification := iam.User{ + UserBasicInfo: basicUserInfoWithMFA, + IdentityID: id, + IsLocked: false, + LastLoginDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00.000Z"), + TFAConfigured: true, + EmailUpdatePending: true, + AuthGrants: authGrantsCreate, + Notifications: customNotifications, + } basicUserInfoExtPhone := basicUserInfo basicUserInfoExtPhone.Phone = "(617) 444-3000 x2664" @@ -195,6 +264,12 @@ func TestResourceUser(t *testing.T) { Notifications: ¬ifications, } + userCreateRequestWithNotifications := iam.CreateUserRequest{ + UserBasicInfo: basicUserInfoWithMFA, + AuthGrants: authGrantsCreateRequest, + Notifications: &customNotifications, + } + userCreateExtPhoneRequest := iam.CreateUserRequest{ UserBasicInfo: basicUserInfoExtPhone, AuthGrants: authGrantsCreateRequest, @@ -284,10 +359,10 @@ func TestResourceUser(t *testing.T) { init func(*iam.Mock) steps []resource.TestStep }{ - "basic": { + "basic - default notification": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // delete @@ -296,14 +371,92 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), + }, + }, + }, + "basic - custom notification": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequestWithNotifications, userCreateWithNotification, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreateWithNotification, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreateWithNotification, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateWithNotification, false), checkUserNotificationsAttributes(userCreateWithNotification)), + }, + }, + }, + "basic - custom notification - password_expiry field missing": { + init: func(m *iam.Mock) { + + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf"), + ExpectError: regexp.MustCompile("The argument \"password_expiry\" is required, but no definition was found."), + }, + }, + }, + "basic - custom notification - options block missing": { + init: func(m *iam.Mock) { + + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf"), + ExpectError: regexp.MustCompile("At least 1 \"options\" blocks are required."), + }, + }, + }, + "basic - custom notification - multiple options block": { + init: func(m *iam.Mock) { + + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf"), + ExpectError: regexp.MustCompile("No more than 1 \"options\" blocks are allowed"), + }, + }, + }, + "basic - custom notification - enable_email_notifications missing": { + init: func(m *iam.Mock) { + + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf"), + ExpectError: regexp.MustCompile("The argument \"enable_email_notifications\" is required, but no definition was\nfound."), + }, + }, + }, + "basic - authentication method - NONE": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreate, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_tfa", fmt.Sprintf("%t", false)), + resource.TestCheckResourceAttr("akamai_iam_user.test", "enable_mfa", fmt.Sprintf("%t", false))), }, }, }, "basic with extension phone number": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateExtPhoneRequest, userCreateExtPhone, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateExtPhoneRequest, userCreateExtPhone, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreateExtPhone, nil).Times(2) // delete @@ -312,14 +465,14 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_ext_phone.tf"), - Check: checkUserAttributes(userCreateExtPhone), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateExtPhone, false), checkDefaultUserNotificationsAttributes(userCreateExtPhone)), }, }, }, "basic lock": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateLockedRequest, userCreateLocked, true, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateLockedRequest, userCreateLocked, true, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Times(2) // delete @@ -328,7 +481,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_lock.tf"), - Check: checkUserAttributes(userCreateLocked), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, false), checkDefaultUserNotificationsAttributes(userCreateLocked)), }, }, }, @@ -344,7 +497,7 @@ func TestResourceUser(t *testing.T) { "basic error create": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, fmt.Errorf("error create"), nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, fmt.Errorf("error create"), nil, nil) }, steps: []resource.TestStep{ { @@ -353,10 +506,32 @@ func TestResourceUser(t *testing.T) { }, }, }, + "enable_tfa and enable_mfa set to true - error": { + init: func(m *iam.Mock) { + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf"), + ExpectError: regexp.MustCompile("only one of 'enable_tfa' or 'enable_mfa' can be set"), + }, + }, + }, + "setting password- error": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, fmt.Errorf("error setting user password")) + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + ExpectError: regexp.MustCompile("error setting user password"), + }, + }, + }, "basic no diff no update": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -368,18 +543,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: checkUserAttributes(userCreate, false), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: checkUserAttributes(userCreate, false), }, }, }, "update user info": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -394,18 +569,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_user_info.tf"), - Check: checkUserAttributes(userUpdateInfo), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateInfo, false), checkDefaultUserNotificationsAttributes(userUpdateInfo)), }, }, }, "update user info - lock - unlock": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Once() // plan @@ -424,22 +599,22 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_lock.tf"), - Check: checkUserAttributes(userCreateLocked), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, false), checkDefaultUserNotificationsAttributes(userCreateLocked)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, }, }, "update user info - error": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -453,7 +628,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_user_info.tf"), @@ -464,7 +639,7 @@ func TestResourceUser(t *testing.T) { "update user auth grants": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -479,18 +654,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_auth_grants.tf"), - Check: checkUserAttributes(userUpdateGrants), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateGrants, false), checkDefaultUserNotificationsAttributes(userUpdateGrants)), }, }, }, "update swap user auth grants subgroups": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userSubgroupCreateRequest, userSubgroupCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userSubgroupCreateRequest, userSubgroupCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userSubgroupCreate, nil).Times(2) // plan @@ -502,18 +677,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_grants.tf"), - Check: checkUserAttributes(userSubgroupCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userSubgroupCreate, false), checkDefaultUserNotificationsAttributes(userSubgroupCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_grants_swap.tf"), - Check: checkUserAttributes(userSubgroupCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userSubgroupCreate, false), checkDefaultUserNotificationsAttributes(userSubgroupCreate)), }, }, }, "update user auth grants with redundant fields": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateWithIgnoredFieldsRequest, userCreateWithIgnoredFields, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateWithIgnoredFieldsRequest, userCreateWithIgnoredFields, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreateWithIgnoredFieldsResponse, nil).Once() expectResourceIAMUserReadPhase(m, userCreateWithIgnoredFieldsResponse, nil).Once() @@ -527,18 +702,18 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_auth_grants.tf"), - Check: checkUserAttributes(userCreateWithIgnoredFieldsResponse), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateWithIgnoredFieldsResponse, false), checkDefaultUserNotificationsAttributes(userCreateWithIgnoredFieldsResponse)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_auth_grants.tf"), - Check: checkUserAttributes(userCreateWithIgnoredFieldsResponse), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateWithIgnoredFieldsResponse, false), checkDefaultUserNotificationsAttributes(userCreateWithIgnoredFieldsResponse)), }, }, }, "update user auth grants - an error": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -552,7 +727,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_auth_grants.tf"), @@ -563,7 +738,7 @@ func TestResourceUser(t *testing.T) { "basic import": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // import @@ -574,8 +749,8 @@ func TestResourceUser(t *testing.T) { }, steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/basic_import.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), }, { ImportState: true, @@ -599,7 +774,7 @@ func TestResourceUser(t *testing.T) { "error updating email": { init: func(m *iam.Mock) { // create - expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, nil, nil) + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) // plan @@ -611,7 +786,7 @@ func TestResourceUser(t *testing.T) { steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), - Check: checkUserAttributes(userCreate), + Check: checkUserAttributes(userCreate, false), }, { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_email.tf"), @@ -628,6 +803,104 @@ func TestResourceUser(t *testing.T) { }, }, }, + "create user with password and update user info and set new password": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + // update basic info + expectResourceIAMUserUpdateInfoAndPasswordPhase(m, userUpdateInfo.IdentityID, userUpdateInfo.UserBasicInfo, "NewPassword@123", nil).Once() + expectResourceIAMUserReadPhase(m, userUpdateInfo, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, true), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateInfo, true), checkDefaultUserNotificationsAttributes(userUpdateInfo)), + }, + }, + }, + "create user with password and update user info and remove the password field": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, true), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password_without_password.tf"), + ExpectError: regexp.MustCompile("deleting the password field or setting the password to an empty string is not allowed"), + }, + }, + }, + "create user with password and update user info with the empty password field": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, true), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf"), + ExpectError: regexp.MustCompile("deleting the password field or setting the password to an empty string is not allowed"), + }, + }, + }, + "create without a password, later update user info and set a password": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreate, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreate, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreate, nil).Once() + // update basic info + expectResourceIAMUserUpdateInfoAndPasswordPhase(m, userUpdateInfo.IdentityID, userUpdateInfo.UserBasicInfo, "NewPassword@123", nil).Once() + expectResourceIAMUserReadPhase(m, userUpdateInfo, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userUpdateInfo, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreate, false), checkDefaultUserNotificationsAttributes(userCreate)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userUpdateInfo, true), checkDefaultUserNotificationsAttributes(userUpdateInfo)), + }, + }, + }, } for name, test := range tests { t.Run(name, func(t *testing.T) { @@ -646,7 +919,7 @@ func TestResourceUser(t *testing.T) { } // create -func expectResourceIAMUserCreatePhase(m *iam.Mock, request iam.CreateUserRequest, response iam.User, lock bool, creationError, lockError error) { +func expectResourceIAMUserCreatePhase(m *iam.Mock, request iam.CreateUserRequest, response iam.User, lock bool, setPassword bool, creationError, lockError error, setPasswordError error) { onCreation := m.On("CreateUser", mock.Anything, iam.CreateUserRequest{ UserBasicInfo: request.UserBasicInfo, AuthGrants: request.AuthGrants, @@ -665,6 +938,13 @@ func expectResourceIAMUserCreatePhase(m *iam.Mock, request iam.CreateUserRequest return } } + password := "Password@123" + if setPassword { + expectPassword(m, response.IdentityID, password, setPasswordError).Once() + if setPasswordError != nil { + return + } + } } func expectToggleLock(m *iam.Mock, identityID string, lock bool, err error) *mock.Call { @@ -674,11 +954,16 @@ func expectToggleLock(m *iam.Mock, identityID string, lock bool, err error) *moc return m.On("UnlockUser", mock.Anything, iam.UnlockUserRequest{IdentityID: identityID}).Return(err) } +func expectPassword(m *iam.Mock, identityID string, password string, err error) *mock.Call { + return m.On("SetUserPassword", mock.Anything, iam.SetUserPasswordRequest{IdentityID: identityID, NewPassword: password}).Return(err) +} + // read func expectResourceIAMUserReadPhase(m *iam.Mock, user iam.User, anError error) *mock.Call { on := m.On("GetUser", mock.Anything, iam.GetUserRequest{ - IdentityID: user.IdentityID, - AuthGrants: true, + IdentityID: user.IdentityID, + AuthGrants: true, + Notifications: true, }) if anError != nil { return on.Return(nil, anError).Once() @@ -698,6 +983,20 @@ func expectResourceIAMUserInfoUpdatePhase(m *iam.Mock, id string, basicUserInfo return on.Return(&basicUserInfo, nil) } +func expectResourceIAMUserUpdateInfoAndPasswordPhase(m *iam.Mock, id string, basicUserInfo iam.UserBasicInfo, password string, anError error) *mock.Call { + on := m.On("UpdateUserInfo", mock.Anything, iam.UpdateUserInfoRequest{ + IdentityID: id, + User: basicUserInfo, + }) + + expectPassword(m, id, password, nil).Once() + + if anError != nil { + return on.Return(nil, anError).Once() + } + return on.Return(&basicUserInfo, nil) +} + // update auth grants func expectResourceIAMUserAuthGrantsUpdatePhase(m *iam.Mock, id string, authGrantsReqest []iam.AuthGrantRequest, authGrants []iam.AuthGrant, anError error) *mock.Call { on := m.On("UpdateUserAuthGrants", mock.Anything, iam.UpdateUserAuthGrantsRequest{ diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf new file mode 100644 index 000000000..671007198 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/basic_import.tf @@ -0,0 +1,14 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf index 5f448e0fb..671007198 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic.tf @@ -3,12 +3,12 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf new file mode 100644 index 000000000..671007198 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_authentication_none.tf @@ -0,0 +1,14 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf index 6b10c7d9a..fc156d1b8 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_lock.tf @@ -3,13 +3,12 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - lock = true - + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + lock = true auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf new file mode 100644 index 000000000..c668a1a36 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf @@ -0,0 +1,28 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + options { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + } + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf new file mode 100644 index 000000000..64292b6df --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf @@ -0,0 +1,27 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + options { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + } + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf new file mode 100644 index 000000000..54d9a87cc --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf @@ -0,0 +1,39 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + options { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + } + options { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + } + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf new file mode 100644 index 000000000..835a6828c --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf @@ -0,0 +1,17 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf new file mode 100644 index 000000000..4e595d497 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf @@ -0,0 +1,27 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + options { + api_client_credential_expiry_notification = true + new_user_notification = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + } + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf new file mode 100644 index 000000000..279ec3db8 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + password = "Password@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf new file mode 100644 index 000000000..671007198 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_without_password.tf @@ -0,0 +1,14 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf new file mode 100644 index 000000000..d240d280d --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf @@ -0,0 +1,15 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = true + enable_mfa = true + password = "Password@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf index 43462bdf1..8e84d49b1 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_auth_grants.tf @@ -3,12 +3,11 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false auth_grants_json = "[{\"groupId\":1,\"groupName\":\"other_group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf index e9071846e..2060c5efb 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_email.tf @@ -3,12 +3,12 @@ provider "akamai" { } resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@update.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - + first_name = "John" + last_name = "Smith" + email = "jsmith@update.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + password = "Password@123" auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" } diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf new file mode 100644 index 000000000..03bfd98df --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password.tf @@ -0,0 +1,26 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + enable_tfa = false + + contact_type = "contact type" + job_title = "job title" + time_zone = "timezone" + secondary_email = "secondary.email@example.com" + mobile_phone = "+49 98765 4321" + address = "123 B Street" + city = "B-Town" + state = "state" + zip_code = "zip" + preferred_language = "language" + session_timeout = 2 + password = "NewPassword@123" + + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf new file mode 100644 index 000000000..84337911a --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_with_password_empty_string.tf @@ -0,0 +1,25 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + enable_tfa = false + + contact_type = "contact type" + job_title = "job title" + time_zone = "timezone" + secondary_email = "secondary.email@example.com" + mobile_phone = "+49 98765 4321" + address = "123 B Street" + city = "B-Town" + state = "state" + zip_code = "zip" + preferred_language = "language" + session_timeout = 2 + password = "" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf new file mode 100644 index 000000000..6179f3876 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_without_password.tf @@ -0,0 +1,25 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + enable_tfa = false + + contact_type = "contact type" + job_title = "job title" + time_zone = "timezone" + secondary_email = "secondary.email@example.com" + mobile_phone = "+49 98765 4321" + address = "123 B Street" + city = "B-Town" + state = "state" + zip_code = "zip" + preferred_language = "language" + session_timeout = 2 + + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} From c487ef5415a8d53456dfd1c8e0ac8da3ff225318 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Tue, 20 Aug 2024 12:35:04 +0000 Subject: [PATCH 23/54] DXE-4038 Implement iam_password_policy data source --- CHANGELOG.md | 3 + .../iam/data_akamai_iam_password_policy.go | 135 ++++++++++++++++++ .../data_akamai_iam_password_policy_test.go | 90 ++++++++++++ pkg/providers/iam/provider.go | 1 + .../TestDataPasswordPolicy/default.tf | 5 + 5 files changed, 234 insertions(+) create mode 100644 pkg/providers/iam/data_akamai_iam_password_policy.go create mode 100644 pkg/providers/iam/data_akamai_iam_password_policy_test.go create mode 100644 pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 2431e0b52..d378a06dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,9 @@ +* IAM + * Added new data source: + * `akamai_iam_password_policy` - read the password policy parameters diff --git a/pkg/providers/iam/data_akamai_iam_password_policy.go b/pkg/providers/iam/data_akamai_iam_password_policy.go new file mode 100644 index 000000000..4fc8405df --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_password_policy.go @@ -0,0 +1,135 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &passwordPolicyDataSource{} + _ datasource.DataSourceWithConfigure = &passwordPolicyDataSource{} +) + +type ( + passwordPolicyDataSource struct { + meta meta.Meta + } + + passwordPolicyDataSourceModel struct { + PwClass types.String `tfsdk:"pw_class"` + CaseDif types.Int64 `tfsdk:"case_dif"` + MaxRepeating types.Int64 `tfsdk:"max_repeating"` + MinDigits types.Int64 `tfsdk:"min_digits"` + MinLength types.Int64 `tfsdk:"min_length"` + MinLetters types.Int64 `tfsdk:"min_letters"` + MinNonAlpha types.Int64 `tfsdk:"min_non_alpha"` + MinReuse types.Int64 `tfsdk:"min_reuse"` + RotateFrequency types.Int64 `tfsdk:"rotate_frequency"` + } +) + +// NewPasswordPolicyDataSource returns a new password policy data source +func NewPasswordPolicyDataSource() datasource.DataSource { + return &passwordPolicyDataSource{} +} + +// Metadata configures data source's meta information +func (d *passwordPolicyDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_password_policy" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *passwordPolicyDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *passwordPolicyDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management password policy", + Attributes: map[string]schema.Attribute{ + "pw_class": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for a password policy.", + }, + "min_length": schema.Int64Attribute{ + Computed: true, + Description: "The minimum length of a password.", + }, + "min_letters": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of letters in a password.", + }, + "min_digits": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of digits in a password.", + }, + "case_dif": schema.Int64Attribute{ + Computed: true, + Description: "The number of characters that, at minimum, need to be in a different case.", + }, + "min_non_alpha": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of non-alphabetic characters in a password.", + }, + "max_repeating": schema.Int64Attribute{ + Computed: true, + Description: "The maximum allowed number of repeating characters.", + }, + "min_reuse": schema.Int64Attribute{ + Computed: true, + Description: "The minimum number of previous passwords to retain to prevent password reuse.", + }, + "rotate_frequency": schema.Int64Attribute{ + Computed: true, + Description: "The number of days a password is valid.", + }, + }, + } +} + +// Read is called when the provider must read data source values in order to update state +func (d *passwordPolicyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Password Policy DataSource Read") + + var data passwordPolicyDataSourceModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + passwordPolicyResponse, err := client.GetPasswordPolicy(ctx) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Password Policy Failed", err.Error()) + return + } + + data.PwClass = types.StringValue(passwordPolicyResponse.PwClass) + data.CaseDif = types.Int64Value(passwordPolicyResponse.CaseDiff) + data.MaxRepeating = types.Int64Value(passwordPolicyResponse.MaxRepeating) + data.MinDigits = types.Int64Value(passwordPolicyResponse.MinDigits) + data.MinLength = types.Int64Value(passwordPolicyResponse.MinLength) + data.MinLetters = types.Int64Value(passwordPolicyResponse.MinLetters) + data.MinNonAlpha = types.Int64Value(passwordPolicyResponse.MinNonAlpha) + data.MinReuse = types.Int64Value(passwordPolicyResponse.MinReuse) + data.RotateFrequency = types.Int64Value(passwordPolicyResponse.RotateFrequency) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/iam/data_akamai_iam_password_policy_test.go b/pkg/providers/iam/data_akamai_iam_password_policy_test.go new file mode 100644 index 000000000..32aead9ab --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_password_policy_test.go @@ -0,0 +1,90 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestPasswordPolicy(t *testing.T) { + expectGetPasswordPolicy := func(client *iam.Mock, timesToRun int) { + passwordPolicyResponse := iam.GetPasswordPolicyResponse{ + CaseDiff: 0, + MaxRepeating: 2, + MinDigits: 1, + MinLength: 8, + MinLetters: 1, + MinNonAlpha: 0, + MinReuse: 4, + PwClass: "aka90", + RotateFrequency: 90, + } + client.On("GetPasswordPolicy", mock.Anything).Return(&passwordPolicyResponse, nil).Times(timesToRun) + } + + expectGetPasswordPolicyWithError := func(client *iam.Mock, timesToRun int) { + client.On("GetPasswordPolicy", mock.Anything).Return(nil, fmt.Errorf("get password policy failed")).Times(timesToRun) + } + + tests := map[string]struct { + init func(*iam.Mock) + error *regexp.Regexp + }{ + "happy path": { + init: func(m *iam.Mock) { + expectGetPasswordPolicy(m, 5) + }, + }, + "error listing password policy": { + init: func(m *iam.Mock) { + expectGetPasswordPolicyWithError(m, 1) + }, + error: regexp.MustCompile("get password policy failed"), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(client) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestDataPasswordPolicy/default.tf"), + Check: checkPasswordPolicyAttrs(), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkPasswordPolicyAttrs() resource.TestCheckFunc { + var checkFuncs []resource.TestCheckFunc + + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "pw_class", "aka90")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "case_dif", "0")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "max_repeating", "2")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_digits", "1")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_length", "8")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_letters", "1")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_non_alpha", "0")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "min_reuse", "4")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_password_policy.test", "rotate_frequency", "90")) + + return resource.ComposeAggregateTestCheckFunc(checkFuncs...) +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 0b9aeaf5f..193e72334 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -100,5 +100,6 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewAllowedAPIsDataSource, NewBlockedPropertiesDataSource, NewCIDRBlockDataSource, + NewPasswordPolicyDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf b/pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf new file mode 100644 index 000000000..281287419 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPasswordPolicy/default.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_password_policy" "test" {} \ No newline at end of file From 6a322e3d7d2b9871b90a6a079c1b6670080962b3 Mon Sep 17 00:00:00 2001 From: Cyryl Kulinski Date: Wed, 21 Aug 2024 09:46:55 +0000 Subject: [PATCH 24/54] DXE-4006 changed type of accessLevels Merge in DEVEXP/terraform-provider-akamai from bugfix/DXE-4006-fix-access-levels-type to feature/sp-iam-extension --- pkg/providers/iam/data_akamai_allowed_apis.go | 2 +- .../iam/data_akamai_allowed_apis_test.go | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/providers/iam/data_akamai_allowed_apis.go b/pkg/providers/iam/data_akamai_allowed_apis.go index 8dc8c441c..ff8f52511 100644 --- a/pkg/providers/iam/data_akamai_allowed_apis.go +++ b/pkg/providers/iam/data_akamai_allowed_apis.go @@ -164,7 +164,7 @@ func (d *allowedAPIsSourceModel) read(allowedAPIs iam.ListAllowedAPIsResponse) d for _, api := range allowedAPIs { accessLevels := make([]types.String, 0, len(api.AccessLevels)) for _, accessLevel := range api.AccessLevels { - accessLevels = append(accessLevels, types.StringValue(accessLevel)) + accessLevels = append(accessLevels, types.StringValue(string(accessLevel))) } a := apiModel{ diff --git a/pkg/providers/iam/data_akamai_allowed_apis_test.go b/pkg/providers/iam/data_akamai_allowed_apis_test.go index eb0de7beb..2602c156c 100644 --- a/pkg/providers/iam/data_akamai_allowed_apis_test.go +++ b/pkg/providers/iam/data_akamai_allowed_apis_test.go @@ -23,7 +23,7 @@ type ( } apiData struct { - accessLevels []string + accessLevels []iam.AccessLevel apiID int64 apiName string description string @@ -40,8 +40,8 @@ var ( clientType: ptr.To("CLIENT"), allowAccountSwitch: ptr.To(true), allowedAPIs: []apiData{{ - accessLevels: []string{ - "READ-WRITE"}, + accessLevels: []iam.AccessLevel{ + iam.ReadWriteLevel}, apiID: 146, apiName: "Property Manager (PAPI)", description: "Property Manager (PAPI). PAPI requires access to Edge Hostnames. Please edit your authorizations to add HAPI to your API Client.", @@ -50,9 +50,9 @@ var ( hasAccess: true, serviceProviderID: 1, }, { - accessLevels: []string{ - "READ-ONLY", - "READ-WRITE"}, + accessLevels: []iam.AccessLevel{ + iam.ReadOnlyLevel, + iam.ReadWriteLevel}, apiID: 11, apiName: "Event Center", description: "Event Center", @@ -65,8 +65,8 @@ var ( basicTestDataForAllowedAPIsNoOptional = testDataForAllowedAPIs{ username: "test", allowedAPIs: []apiData{{ - accessLevels: []string{ - "READ-WRITE"}, + accessLevels: []iam.AccessLevel{ + iam.ReadWriteLevel}, apiID: 146, apiName: "Property Manager (PAPI)", description: "Property Manager (PAPI). PAPI requires access to Edge Hostnames. Please edit your authorizations to add HAPI to your API Client.", @@ -75,9 +75,9 @@ var ( hasAccess: true, serviceProviderID: 1, }, { - accessLevels: []string{ - "READ-ONLY", - "READ-WRITE"}, + accessLevels: []iam.AccessLevel{ + iam.ReadOnlyLevel, + iam.ReadWriteLevel}, apiID: 11, apiName: "Event Center", description: "Event Center", @@ -197,7 +197,7 @@ func checkAllowedAPIsAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { for i, api := range data.allowedAPIs { for j, accessLevel := range api.accessLevels { - checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.access_levels.%d", i, j), accessLevel)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.access_levels.%d", i, j), string(accessLevel))) } checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.api_id", i), strconv.FormatInt(api.apiID, 10))) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.api_name", i), api.apiName)) From dfeaabfecd79b84799eb922ebc7986b80339911c Mon Sep 17 00:00:00 2001 From: rbhatved Date: Fri, 16 Aug 2024 18:13:53 +0530 Subject: [PATCH 25/54] DXE-4034 Implement iam_authorized_users --- CHANGELOG.md | 4 + .../iam/data_akamai_iam_authorized_users.go | 138 ++++++++++++++++++ .../data_akamai_iam_authorized_users_test.go | 131 +++++++++++++++++ pkg/providers/iam/provider.go | 1 + .../testdata/TestAuthorizedUsers/default.tf | 5 + 5 files changed, 279 insertions(+) create mode 100644 pkg/providers/iam/data_akamai_iam_authorized_users.go create mode 100644 pkg/providers/iam/data_akamai_iam_authorized_users_test.go create mode 100644 pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index d378a06dc..8fe91a753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ #### FEATURES/ENHANCEMENTS: +* IAM + * Added data source: + * `akamai_iam_authorized_users` - read the list of authorized API client users + * IAM * Added data sources: * `akamai_iam_blocked_properties` - reads blocked properties for a certain user in a group diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users.go b/pkg/providers/iam/data_akamai_iam_authorized_users.go new file mode 100644 index 000000000..19b85940f --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_authorized_users.go @@ -0,0 +1,138 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &authorizedUsersDataSource{} + _ datasource.DataSourceWithConfigure = &authorizedUsersDataSource{} +) + +type ( + authorizedUsersDataSource struct { + meta meta.Meta + } + + authorizedUsersDataSourceModel struct { + AuthorizedUsers []userModel `tfsdk:"authorized_users"` + } + + userModel struct { + Email types.String `tfsdk:"email"` + Username types.String `tfsdk:"username"` + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + } +) + +// NewAuthorizedUsersDataSource returns the list of authorized API client users. +func NewAuthorizedUsersDataSource() datasource.DataSource { + return &authorizedUsersDataSource{} +} + +// Metadata configures data source's meta information +func (a *authorizedUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, response *datasource.MetadataResponse) { + response.TypeName = "akamai_iam_authorized_users" +} + +// Configure configures data source at the beginning of the lifecycle +func (a *authorizedUsersDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + if request.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + response.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + request.ProviderData)) + } + }() + a.meta = meta.Must(request.ProviderData) +} + +func (a *authorizedUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, response *datasource.SchemaResponse) { + response.Schema = schema.Schema{ + Description: "List of authorized API client users", + Attributes: map[string]schema.Attribute{ + "authorized_users": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + "username": schema.StringAttribute{ + Computed: true, + Description: "The user's Control Center sign-in name.", + }, + }, + }, + }, + }, + } +} + +func (a *authorizedUsersDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Authorized Users DataSource Read") + + var data authorizedUsersDataSourceModel + if response.Diagnostics.Append(request.Config.Get(ctx, &data)...); response.Diagnostics.HasError() { + return + } + client := inst.Client(a.meta) + + users, err := client.ListAuthorizedUsers(ctx) + if err != nil { + response.Diagnostics.AddError("Failed to fetch authorized users:", err.Error()) + return + } + + if response.Diagnostics.Append(data.read(users)...); response.Diagnostics.HasError() { + return + } + + response.Diagnostics.Append(response.State.Set(ctx, &data)...) +} + +func (d *authorizedUsersDataSourceModel) read(authorisedUsers iam.ListAuthorizedUsersResponse) diag.Diagnostics { + var users []userModel + for _, user := range authorisedUsers { + authorizedUser := userModel{ + Email: types.StringValue(user.Email), + Username: types.StringValue(user.Username), + FirstName: types.StringValue(user.FirstName), + LastName: types.StringValue(user.LastName), + UIIdentityID: types.StringValue(user.UIIdentityID), + } + + users = append(users, authorizedUser) + } + + d.AuthorizedUsers = users + return nil +} diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go new file mode 100644 index 000000000..1482c8a2e --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go @@ -0,0 +1,131 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForAuthorizedUsers struct { + authorizedUsers []userData + } + + userData struct { + Email string + Username string + FirstName string + LastName string + UIIdentityID string + } +) + +var ( + basicTestDataForAuthorizedUsers = testDataForAuthorizedUsers{ + authorizedUsers: []userData{ + { + Email: "user1@example.com", + Username: "user1", + FirstName: "John", + LastName: "Doe", + UIIdentityID: "U-I-DYS45", + }, + { + Email: "user2@example.com", + Username: "user2", + FirstName: "Jane", + LastName: "Smith", + UIIdentityID: "B-P-2XYC01", + }, + }, + } +) + +func TestAuthorizedUsers(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForAuthorizedUsers) + mockData testDataForAuthorizedUsers + error *regexp.Regexp + }{ + "success path": { + configPath: "testdata/TestAuthorizedUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAuthorizedUsers) { + expectFullListAuthorizedUsers(t, m, testData, 5) + }, + mockData: basicTestDataForAuthorizedUsers, + }, + "fail path": { + configPath: "testdata/TestAuthorizedUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForAuthorizedUsers) { + m.On("ListAuthorizedUsers", mock.Anything).Return(iam.ListAuthorizedUsersResponse{}, errors.New("could not get authorized users")) + }, + error: regexp.MustCompile(`could not get authorized users`), + mockData: basicTestDataForAuthorizedUsers, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.mockData) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkAuthorizedUsersAttrs(test.mockData), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func expectFullListAuthorizedUsers(_ *testing.T, client *iam.Mock, data testDataForAuthorizedUsers, timesToRun int) { + listAuthorizedUsersRes := iam.ListAuthorizedUsersResponse{} + + for _, user := range data.authorizedUsers { + listAuthorizedUsersRes = append(listAuthorizedUsersRes, iam.AuthorizedUser{ + Email: user.Email, + Username: user.Username, + FirstName: user.FirstName, + LastName: user.LastName, + UIIdentityID: user.UIIdentityID, + }) + } + + client.On("ListAuthorizedUsers", mock.Anything).Return(listAuthorizedUsersRes, nil).Times(timesToRun) +} + +func checkAuthorizedUsersAttrs(data testDataForAuthorizedUsers) resource.TestCheckFunc { + name := "data.akamai_iam_authorized_users.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "authorized_users.#", strconv.Itoa(len(data.authorizedUsers))), + } + + for i, user := range data.authorizedUsers { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.ui_identity_id", i), user.UIIdentityID)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.email", i), user.Email)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.first_name", i), user.FirstName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.last_name", i), user.LastName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("authorized_users.%d.username", i), user.Username)) + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 193e72334..6776d7633 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -101,5 +101,6 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewBlockedPropertiesDataSource, NewCIDRBlockDataSource, NewPasswordPolicyDataSource, + NewAuthorizedUsersDataSource, } } diff --git a/pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf b/pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf new file mode 100644 index 000000000..8aa70e27c --- /dev/null +++ b/pkg/providers/iam/testdata/TestAuthorizedUsers/default.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_authorized_users" "test" {} From 668aad6138c6826fdd541ec3f35eecb62b9b0558 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Thu, 22 Aug 2024 13:52:18 +0000 Subject: [PATCH 26/54] DXE-4037 Implement iam_account_switch_keys data source --- CHANGELOG.md | 3 + .../data_akamai_iam_account_switch_keys.go | 128 ++++++++++++++++++ ...ata_akamai_iam_account_switch_keys_test.go | 110 +++++++++++++++ pkg/providers/iam/provider.go | 1 + .../TestDataAccountSwitchKeys/default.tf | 5 + .../default_correct_filter.tf | 8 ++ .../incorrect_filter.tf | 7 + 7 files changed, 262 insertions(+) create mode 100644 pkg/providers/iam/data_akamai_iam_account_switch_keys.go create mode 100644 pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go create mode 100644 pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf create mode 100644 pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf create mode 100644 pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fe91a753..0e14e050a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,9 @@ +* IAM + * Added new data source: + * `akamai_iam_account_switch_keys` - read the account switch keys diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go new file mode 100644 index 000000000..ad5cc9364 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go @@ -0,0 +1,128 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &accountSwitchKeysDataSource{} + _ datasource.DataSourceWithConfigure = &accountSwitchKeysDataSource{} +) + +type ( + accountSwitchKeysDataSource struct { + meta meta.Meta + } + + accountSwitchKeysDataSourceModel struct { + ClientID types.String `tfsdk:"client_id"` + Filter types.String `tfsdk:"filter"` + AccountSwitchKeys []accountSwitchKey `tfsdk:"account_switch_keys"` + } + + accountSwitchKey struct { + AccountName types.String `tfsdk:"account_name"` + AccountSwitchKey types.String `tfsdk:"account_switch_key"` + } +) + +// NewAccountSwitchKeysDataSource returns a new account switch keys data source +func NewAccountSwitchKeysDataSource() datasource.DataSource { + return &accountSwitchKeysDataSource{} +} + +// Metadata configures data source's meta information +func (d *accountSwitchKeysDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_account_switch_keys" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *accountSwitchKeysDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *accountSwitchKeysDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management account switch keys", + Attributes: map[string]schema.Attribute{ + "client_id": schema.StringAttribute{ + Optional: true, + Description: "Unique identifier for each API client. If not provided it assumes your client id.", + }, + "filter": schema.StringAttribute{ + Optional: true, + Description: "Filters results by accountId or accountName. Enter at least three characters to filter the results by substring.", + Validators: []validator.String{stringvalidator.LengthAtLeast(3)}, + }, + "account_switch_keys": schema.ListNestedAttribute{ + Description: "List of account switch keys and account names available to the client.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the account.", + }, + "account_switch_key": schema.StringAttribute{ + Computed: true, + Description: "The identifier for an account other than your API client's default.", + }, + }, + }, + }, + }, + } +} + +// Read is called when the provider must read data source values in order to update state +func (d *accountSwitchKeysDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Account Switch Keys DataSource Read") + + var data accountSwitchKeysDataSourceModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + accountSwitchKeysResponse, err := client.ListAccountSwitchKeys(ctx, iam.ListAccountSwitchKeysRequest{ + ClientID: data.ClientID.ValueString(), + Search: data.Filter.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Account Switch Keys Failed", err.Error()) + return + } + + keys := make([]accountSwitchKey, 0, len(accountSwitchKeysResponse)) + for _, key := range accountSwitchKeysResponse { + switchKey := accountSwitchKey{ + AccountName: types.StringValue(key.AccountName), + AccountSwitchKey: types.StringValue(key.AccountSwitchKey), + } + keys = append(keys, switchKey) + } + data.AccountSwitchKeys = keys + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go new file mode 100644 index 000000000..8a7b1befc --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go @@ -0,0 +1,110 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestAccountSwitchKeys(t *testing.T) { + expectListAccountSwitchKeys := func(client *iam.Mock, clientID string, filter string, timesToRun int) { + accountSwitchKeysResponse := iam.ListAccountSwitchKeysResponse{ + { + AccountName: "Internet Company", + AccountSwitchKey: "1-EFGH", + }, + { + AccountName: "Internet Company", + AccountSwitchKey: "1-ABCD:Z-XYZ", + }, + { + AccountName: "Digital Company", + AccountSwitchKey: "1-ABCD:Z-PQR", + }, + } + client.On("ListAccountSwitchKeys", mock.Anything, iam.ListAccountSwitchKeysRequest{ + ClientID: clientID, + Search: filter, + }).Return(accountSwitchKeysResponse, nil).Times(timesToRun) + } + + expectListAccountSwitchKeysWithError := func(client *iam.Mock, timesToRun int) { + client.On("ListAccountSwitchKeys", mock.Anything, iam.ListAccountSwitchKeysRequest{ + ClientID: "", + Search: "", + }).Return(nil, fmt.Errorf("list account switch keys failed")).Times(timesToRun) + } + + tests := map[string]struct { + givenTF string + init func(*iam.Mock) + error *regexp.Regexp + }{ + "happy path": { + givenTF: "default.tf", + init: func(m *iam.Mock) { + expectListAccountSwitchKeys(m, "", "", 5) + }, + }, + "happy path with correct filter": { + givenTF: "default_correct_filter.tf", + init: func(m *iam.Mock) { + expectListAccountSwitchKeys(m, "XYZ", "ABC", 5) + }, + }, + "incorrect filter": { + givenTF: "incorrect_filter.tf", + error: regexp.MustCompile("Attribute filter string length must be at least 3, got: 2"), + }, + "error listing account switch keys": { + givenTF: "default.tf", + init: func(m *iam.Mock) { + expectListAccountSwitchKeysWithError(m, 1) + }, + error: regexp.MustCompile("list account switch keys failed"), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(client) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataAccountSwitchKeys/%s", test.givenTF)), + Check: checkAccountSwitchKeysAttrs(), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkAccountSwitchKeysAttrs() resource.TestCheckFunc { + var checkFuncs []resource.TestCheckFunc + + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.#", "3")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.0.account_name", "Internet Company")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.0.account_switch_key", "1-EFGH")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.1.account_name", "Internet Company")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.1.account_switch_key", "1-ABCD:Z-XYZ")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.2.account_name", "Digital Company")) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_account_switch_keys.test", "account_switch_keys.2.account_switch_key", "1-ABCD:Z-PQR")) + + return resource.ComposeAggregateTestCheckFunc(checkFuncs...) +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 6776d7633..ce398276f 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -97,6 +97,7 @@ func (p *Subprovider) FrameworkResources() []func() resource.Resource { // FrameworkDataSources returns the IAM data sources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { return []func() datasource.DataSource{ + NewAccountSwitchKeysDataSource, NewAllowedAPIsDataSource, NewBlockedPropertiesDataSource, NewCIDRBlockDataSource, diff --git a/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf new file mode 100644 index 000000000..e02444370 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_account_switch_keys" "test" {} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf new file mode 100644 index 000000000..09c30eaae --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/default_correct_filter.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_account_switch_keys" "test" { + client_id = "XYZ" + filter = "ABC" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf new file mode 100644 index 000000000..07e280d0c --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccountSwitchKeys/incorrect_filter.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_account_switch_keys" "test" { + filter = "AB" +} \ No newline at end of file From fb3092df3d0497def00b9fd1b7b6bb90352ad616 Mon Sep 17 00:00:00 2001 From: Piotr Bartosik Date: Tue, 27 Aug 2024 06:45:23 +0000 Subject: [PATCH 27/54] DXE-4028 implement iam_property_users data source --- CHANGELOG.md | 8 +- .../iam/data_akamai_iam_property_users.go | 176 +++++++++++++++ .../data_akamai_iam_property_users_test.go | 203 ++++++++++++++++++ pkg/providers/iam/provider.go | 3 +- .../TestDataPropertyUsers/aid_prefix.tf | 7 + .../bad_prefix_asset_id.tf | 7 + .../TestDataPropertyUsers/bad_user_type.tf | 8 + .../testdata/TestDataPropertyUsers/basic.tf | 7 + .../TestDataPropertyUsers/empty_asset_id.tf | 7 + .../TestDataPropertyUsers/missing_asset_id.tf | 5 + .../TestDataPropertyUsers/nan_asset_id.tf | 7 + .../trailing_text_asset_id.tf | 7 + .../TestDataPropertyUsers/user_type_all.tf | 8 + .../user_type_assigned.tf | 8 + .../user_type_blocked.tf | 8 + .../property/data_akamai_property.go | 6 + .../property/data_akamai_property_include.go | 6 + .../data_akamai_property_include_test.go | 5 + .../property/data_akamai_property_test.go | 27 +-- .../property/resource_akamai_property.go | 6 + .../resource_akamai_property_include.go | 6 + .../resource_akamai_property_include_test.go | 26 +++ 22 files changed, 527 insertions(+), 24 deletions(-) create mode 100644 pkg/providers/iam/data_akamai_iam_property_users.go create mode 100644 pkg/providers/iam/data_akamai_iam_property_users_test.go create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf create mode 100644 pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e14e050a..d8977cfe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,8 +115,12 @@ * `akamai_iam_password_policy` - read the password policy parameters - - +* IAM + * Added data sources: + * `akamai_iam_property_users` - lists users for property or include + * Added schema field `asset_id` (IAM identifier of a property or include) to: + * `akamai_property` resource and data source, + * `akamai_property_include` resource and data source. diff --git a/pkg/providers/iam/data_akamai_iam_property_users.go b/pkg/providers/iam/data_akamai_iam_property_users.go new file mode 100644 index 000000000..835f3d589 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_property_users.go @@ -0,0 +1,176 @@ +package iam + +import ( + "context" + "fmt" + "regexp" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &propertyUsersDataSource{} + _ datasource.DataSourceWithConfigure = &propertyUsersDataSource{} +) + +type ( + propertyUsersDataSource struct { + meta meta.Meta + } + + propertyUsersDataSourceModel struct { + AssetID types.String `tfsdk:"asset_id"` + UserType types.String `tfsdk:"user_type"` + Users []propertyUser `tfsdk:"users"` + } + + propertyUser struct { + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + UIUserName types.String `tfsdk:"ui_user_name"` + } +) + +// NewPropertyUsersDataSource returns a new iam property users data source +func NewPropertyUsersDataSource() datasource.DataSource { + return &propertyUsersDataSource{} +} + +// Metadata configures data source's meta information +func (d *propertyUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_property_users" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *propertyUsersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *propertyUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management property users data source. Lists users for " + + "property or include.", + Attributes: map[string]schema.Attribute{ + "asset_id": schema.StringAttribute{ + Required: true, + Description: "IAM identifier of the property or include. The optional aid_ prefix " + + "is allowed.", + Validators: []validator.String{stringvalidator.RegexMatches( + regexp.MustCompile(`^(aid_)?\d+$`), + `must be a number with the optional "aid_" prefix`)}, + }, + "user_type": schema.StringAttribute{ + Optional: true, + Description: "Filters the list based on users' access to the property.", + Validators: []validator.String{stringvalidator.OneOf( + string(iam.PropertyUserTypeAll), + string(iam.PropertyUserTypeBlocked), + string(iam.PropertyUserTypeAssigned))}, + }, + "users": schema.ListNestedAttribute{ + Computed: true, + Description: "List of users accessing the property.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a property is blocked.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds " + + "to their Control Center profile or client ID. Also known " + + "as a contactId in other APIs.", + }, + "ui_user_name": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + }, + }, + }, + }, + } +} + +// Read is called when the provider must read data source values in order to update state +func (d *propertyUsersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Property Users DataSource Read") + + var data propertyUsersDataSourceModel + + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + id, err := str.GetIntID(data.AssetID.ValueString(), "aid_") + if err != nil { + resp.Diagnostics.AddError( + "Unable to read IAM Property Users DataSource", + fmt.Sprintf("Error occurred while parsing property id: %s. Error: %s", + data.AssetID.ValueString(), err.Error())) + return + } + + client := inst.Client(d.meta) + + users, err := client.ListUsersForProperty(ctx, iam.ListUsersForPropertyRequest{ + PropertyID: int64(id), + UserType: iam.PropertyUserType(data.UserType.ValueString()), + }) + if err != nil { + resp.Diagnostics.AddError( + "Unable to read IAM Property Users DataSource", + fmt.Sprintf( + "Error occurred while listing users for property: %s (user type: %s). Error: %s", + data.AssetID.ValueString(), data.UserType.ValueString(), err.Error())) + return + } + + for _, user := range *users { + data.Users = append(data.Users, newPropertyUser(user)) + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func newPropertyUser(user iam.UsersForProperty) propertyUser { + return propertyUser{ + FirstName: types.StringValue(user.FirstName), + LastName: types.StringValue(user.LastName), + IsBlocked: types.BoolValue(user.IsBlocked), + UIIdentityID: types.StringValue(user.UIIdentityID), + UIUserName: types.StringValue(user.UIUserName), + } +} diff --git a/pkg/providers/iam/data_akamai_iam_property_users_test.go b/pkg/providers/iam/data_akamai_iam_property_users_test.go new file mode 100644 index 000000000..1eab935dd --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_property_users_test.go @@ -0,0 +1,203 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestDataPropertyUsers(t *testing.T) { + userJohn := iam.UsersForProperty{ + FirstName: "John", + LastName: "Smith", + IsBlocked: false, + UIIdentityID: "B-C-IP9IND", + UIUserName: "josmith", + } + + userJane := iam.UsersForProperty{ + FirstName: "Jane", + LastName: "Smith", + IsBlocked: false, + UIIdentityID: "B-C-AB1CDE", + UIUserName: "jasmith", + } + + blockedUserJudy := iam.UsersForProperty{ + FirstName: "Judy", + LastName: "Smith", + IsBlocked: true, + UIIdentityID: "B-C-FG2HIJ", + UIUserName: "jusmith", + } + + mockListUsersForProperty := func(iamMock *iam.Mock, req iam.ListUsersForPropertyRequest, + users ...iam.UsersForProperty) { + iamMock.On("ListUsersForProperty", mock.Anything, req). + Return((*iam.ListUsersForPropertyResponse)(&users), nil) + } + + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock) + check resource.TestCheckFunc + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataPropertyUsers/basic.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + mockListUsersForProperty(iamMock, req, userJohn, userJane, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckNoResourceAttr("data.akamai_iam_property_users.test", "user_type"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "3"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.last_name", "Smith"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.1.is_blocked", "false"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.2.ui_identity_id", "B-C-FG2HIJ"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.2.ui_user_name", "jusmith")), + }, + "handling aid prefix": { + configPath: "testdata/TestDataPropertyUsers/aid_prefix.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + mockListUsersForProperty(iamMock, req, userJohn, userJane, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "aid_12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "3"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John")), + }, + "user filtering - two users assigned": { + configPath: "testdata/TestDataPropertyUsers/user_type_assigned.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + UserType: "assigned", + } + mockListUsersForProperty(iamMock, req, userJohn, userJane) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "user_type", "assigned"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "2"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.is_blocked", "false"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.1.first_name", "Jane"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.1.is_blocked", "false")), + }, + "user filtering - one user blocked": { + configPath: "testdata/TestDataPropertyUsers/user_type_blocked.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + UserType: "blocked", + } + mockListUsersForProperty(iamMock, req, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "user_type", "blocked"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "1"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "Judy"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.is_blocked", "true")), + }, + "user filtering - all users returned for all": { + configPath: "testdata/TestDataPropertyUsers/user_type_all.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + UserType: "all", + } + mockListUsersForProperty(iamMock, req, userJohn, userJane, blockedUserJudy) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "user_type", "all"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "3"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.0.first_name", "John"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.2.first_name", "Judy")), + }, + "no users returned": { + configPath: "testdata/TestDataPropertyUsers/basic.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + mockListUsersForProperty(iamMock, req) + }, + check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "asset_id", "12345"), + resource.TestCheckNoResourceAttr("data.akamai_iam_property_users.test", "user_type"), + resource.TestCheckResourceAttr("data.akamai_iam_property_users.test", "users.#", "0")), + }, + "missing property id": { + configPath: "testdata/TestDataPropertyUsers/missing_asset_id.tf", + error: regexp.MustCompile(`The argument "asset_id" is required, but no definition was found`), + }, + "empty property id": { + configPath: "testdata/TestDataPropertyUsers/empty_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "property id is not a number": { + configPath: "testdata/TestDataPropertyUsers/nan_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "property id has invalid prefix": { + configPath: "testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "property id has trailing text": { + configPath: "testdata/TestDataPropertyUsers/trailing_text_asset_id.tf", + error: regexp.MustCompile(`Attribute asset_id must be a number with the optional "aid_" prefix`), + }, + "bad user type": { + configPath: "testdata/TestDataPropertyUsers/bad_user_type.tf", + error: regexp.MustCompile(`Attribute user_type value must be one of.+all.+blocked.+assigned`), + }, + "edgegrid error": { + configPath: "testdata/TestDataPropertyUsers/basic.tf", + init: func(t *testing.T, iamMock *iam.Mock) { + req := iam.ListUsersForPropertyRequest{ + PropertyID: 12345, + } + iamMock.On("ListUsersForProperty", mock.Anything, req). + Return(nil, fmt.Errorf("list users failed")) + }, + error: regexp.MustCompile("list users failed"), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + iamMock := iam.Mock{} + if test.init != nil { + test.init(t, &iamMock) + } + + useClient(&iamMock, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: test.check, + ExpectError: test.error, + }, + }, + }) + }) + iamMock.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index ce398276f..663f23715 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -99,9 +99,10 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { return []func() datasource.DataSource{ NewAccountSwitchKeysDataSource, NewAllowedAPIsDataSource, + NewAuthorizedUsersDataSource, NewBlockedPropertiesDataSource, NewCIDRBlockDataSource, NewPasswordPolicyDataSource, - NewAuthorizedUsersDataSource, + NewPropertyUsersDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf new file mode 100644 index 000000000..65f162a27 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/aid_prefix.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "aid_12345" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf new file mode 100644 index 000000000..fff0350f9 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_prefix_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "raid_321" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf new file mode 100644 index 000000000..6139d8c9a --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/bad_user_type.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "foo" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf new file mode 100644 index 000000000..d434c50cf --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/basic.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf new file mode 100644 index 000000000..9bbece598 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/empty_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf new file mode 100644 index 000000000..a4f60d6b7 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/missing_asset_id.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf new file mode 100644 index 000000000..308d8d81c --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/nan_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "foobar" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf new file mode 100644 index 000000000..154bd5fa0 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/trailing_text_asset_id.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "123foo" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf new file mode 100644 index 000000000..77e128ac3 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_all.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "all" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf new file mode 100644 index 000000000..5c60c1e27 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_assigned.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "assigned" +} diff --git a/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf new file mode 100644 index 000000000..92fdd17c6 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataPropertyUsers/user_type_blocked.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_property_users" "test" { + asset_id = "12345" + user_type = "blocked" +} diff --git a/pkg/providers/property/data_akamai_property.go b/pkg/providers/property/data_akamai_property.go index 7dd03f897..31a22ca30 100644 --- a/pkg/providers/property/data_akamai_property.go +++ b/pkg/providers/property/data_akamai_property.go @@ -78,6 +78,11 @@ func dataSourceProperty() *schema.Resource { Computed: true, Description: "Property's version currently activated in staging (zero when not active in staging).", }, + "asset_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the property in the Identity and Access Management API.", + }, }, } } @@ -164,6 +169,7 @@ func getRulesForProperty(ctx context.Context, property *papi.Property, meta meta func getPropertyAttributes(propertyResponse *papi.Property, propertyVersionResponse *papi.GetPropertyVersionsResponse) map[string]interface{} { propertyVersion := propertyVersionResponse.Version property := map[string]interface{}{ + "asset_id": propertyResponse.AssetID, "contract_id": propertyResponse.ContractID, "group_id": propertyResponse.GroupID, "latest_version": propertyResponse.LatestVersion, diff --git a/pkg/providers/property/data_akamai_property_include.go b/pkg/providers/property/data_akamai_property_include.go index 6eb26424f..4d1ff562e 100644 --- a/pkg/providers/property/data_akamai_property_include.go +++ b/pkg/providers/property/data_akamai_property_include.go @@ -28,6 +28,7 @@ type includeDataSource struct { // includeDataSourceModel describes the data source data model for PropertyIncludeDataSource. type includeDataSourceModel struct { + AssetID types.String `tfsdk:"asset_id"` ContractID types.String `tfsdk:"contract_id"` GroupID types.String `tfsdk:"group_id"` IncludeID types.String `tfsdk:"include_id"` @@ -85,6 +86,10 @@ func (d *includeDataSource) Schema(_ context.Context, _ datasource.SchemaRequest MarkdownDescription: "Identifier of the data source", Computed: true, }, + "asset_id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "ID of the include in the Identity and Access Management API.", + }, }, } } @@ -130,6 +135,7 @@ func (d *includeDataSource) Read(ctx context.Context, req datasource.ReadRequest include := getIncludeResp.Include + data.AssetID = types.StringValue(include.AssetID) data.Name = types.StringValue(include.IncludeName) data.Type = types.StringValue(string(include.IncludeType)) data.LatestVersion = types.Int64Value(int64(include.LatestVersion)) diff --git a/pkg/providers/property/data_akamai_property_include_test.go b/pkg/providers/property/data_akamai_property_include_test.go index fb4428f37..37ed7b37a 100644 --- a/pkg/providers/property/data_akamai_property_include_test.go +++ b/pkg/providers/property/data_akamai_property_include_test.go @@ -31,6 +31,7 @@ func TestDataPropertyInclude(t *testing.T) { Includes: papi.IncludeItems{ Items: []papi.Include{ { + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, @@ -40,6 +41,7 @@ func TestDataPropertyInclude(t *testing.T) { }, }, Include: papi.Include{ + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, @@ -49,6 +51,7 @@ func TestDataPropertyInclude(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "inc_name", "type": "MICROSERVICES", "latest_version": "4", @@ -68,6 +71,7 @@ func TestDataPropertyInclude(t *testing.T) { Includes: papi.IncludeItems{ Items: []papi.Include{ { + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, @@ -77,6 +81,7 @@ func TestDataPropertyInclude(t *testing.T) { }, }, Include: papi.Include{ + AssetID: "aid_555", IncludeName: "inc_name", IncludeType: "MICROSERVICES", LatestVersion: 4, diff --git a/pkg/providers/property/data_akamai_property_test.go b/pkg/providers/property/data_akamai_property_test.go index 146b5af77..0b0157e6d 100644 --- a/pkg/providers/property/data_akamai_property_test.go +++ b/pkg/providers/property/data_akamai_property_test.go @@ -2,7 +2,6 @@ package property import ( "fmt" - "log" "regexp" "testing" @@ -10,7 +9,6 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/mock" ) @@ -45,6 +43,7 @@ func TestDataProperty(t *testing.T) { }).Return(&papi.GetPropertyResponse{ Properties: papi.PropertiesItems{Items: []*papi.Property{ { + AssetID: "aid_555", ContractID: "ctr_1", GroupID: "grp_1", LatestVersion: 1, @@ -90,6 +89,7 @@ func TestDataProperty(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "property_name", "rules": compactJSON(testutils.LoadFixtureBytes(t, "testdata/TestDataProperty/no_version_rules.json")), "contract_id": "ctr_1", @@ -127,6 +127,7 @@ func TestDataProperty(t *testing.T) { }).Return(&papi.GetPropertyResponse{ Properties: papi.PropertiesItems{Items: []*papi.Property{ { + AssetID: "aid_555", ContractID: "ctr_1", GroupID: "grp_1", LatestVersion: 1, @@ -172,6 +173,7 @@ func TestDataProperty(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "property_name", "rules": compactJSON(testutils.LoadFixtureBytes(t, "testdata/TestDataProperty/with_version_rules.json")), "contract_id": "ctr_1", @@ -209,6 +211,7 @@ func TestDataProperty(t *testing.T) { }).Return(&papi.GetPropertyResponse{ Properties: papi.PropertiesItems{Items: []*papi.Property{ { + AssetID: "aid_555", ContractID: "ctr_1", GroupID: "grp_1", LatestVersion: 1, @@ -252,6 +255,7 @@ func TestDataProperty(t *testing.T) { }, nil) }, expectedAttributes: map[string]string{ + "asset_id": "aid_555", "name": "property_name", "rules": compactJSON(testutils.LoadFixtureBytes(t, "testdata/TestDataProperty/no_version_rules.json")), "contract_id": "ctr_1", @@ -448,22 +452,3 @@ func TestDataProperty(t *testing.T) { }) } } - -func testAccDataSourcePropertyBasic() string { - return ` - provider "akamai" { - papi_section = "papi" - } - -data "akamai_property" "test" { - name = "terraform-test-datasource" - version = 1 -} -` -} - -func testAccCheckDataSourcePropertyDestroy(_ *terraform.State) error { - log.Printf("[DEBUG] [Group] Searching for Property Delete skipped ") - - return nil -} diff --git a/pkg/providers/property/resource_akamai_property.go b/pkg/providers/property/resource_akamai_property.go index 8b1b39f2e..7c3b42c5c 100644 --- a/pkg/providers/property/resource_akamai_property.go +++ b/pkg/providers/property/resource_akamai_property.go @@ -207,6 +207,11 @@ func resourceProperty() *schema.Resource { Elem: papiError(), Description: "Rule validation warnings", }, + "asset_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the property in the Identity and Access Management API.", + }, }, } } @@ -634,6 +639,7 @@ func resourcePropertyRead(ctx context.Context, d *schema.ResourceData, m interfa } attrs := map[string]interface{}{ + "asset_id": property.AssetID, "name": property.PropertyName, "group_id": property.GroupID, "contract_id": property.ContractID, diff --git a/pkg/providers/property/resource_akamai_property_include.go b/pkg/providers/property/resource_akamai_property_include.go index af818be12..065fbc951 100644 --- a/pkg/providers/property/resource_akamai_property_include.go +++ b/pkg/providers/property/resource_akamai_property_include.go @@ -110,6 +110,11 @@ func resourcePropertyInclude() *schema.Resource { Computed: true, Description: "The most recent version to be activated to the production network", }, + "asset_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the include in the Identity and Access Management API.", + }, }, } } @@ -289,6 +294,7 @@ func resourcePropertyIncludeRead(ctx context.Context, rd *schema.ResourceData, m } attrs := map[string]interface{}{ + "asset_id": include.AssetID, "rules": string(rulesJSON), "name": include.IncludeName, "type": include.IncludeType, diff --git a/pkg/providers/property/resource_akamai_property_include_test.go b/pkg/providers/property/resource_akamai_property_include_test.go index e4a26136c..de9b8cc10 100644 --- a/pkg/providers/property/resource_akamai_property_include_test.go +++ b/pkg/providers/property/resource_akamai_property_include_test.go @@ -21,6 +21,7 @@ import ( func TestResourcePropertyInclude(t *testing.T) { type testData struct { + assetID string groupID string rulesPath string includeID string @@ -50,6 +51,7 @@ func TestResourcePropertyInclude(t *testing.T) { newGetIncludeResp := func(testData *testData) *papi.GetIncludeResponse { return &papi.GetIncludeResponse{ Include: papi.Include{ + AssetID: testData.assetID, GroupID: testData.groupID, IncludeID: testData.includeID, ContractID: testData.contractID, @@ -294,6 +296,7 @@ func TestResourcePropertyInclude(t *testing.T) { }{ "create include - no rules and no warnings": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", productID: "prd_test", includeID: includeID, @@ -311,6 +314,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_no_rules.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -329,6 +333,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - with rules": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -348,6 +353,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -366,6 +372,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - with rules with comment": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules_with_comment.json", productID: "prd_test", @@ -385,6 +392,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_with_comment.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -403,6 +411,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - rules with validation errors": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -423,6 +432,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -440,6 +450,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - rules with validation warnings": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -460,6 +471,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -478,6 +490,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - rules with validation errors and warnings": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -498,6 +511,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -516,6 +530,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - server returns no warnings on second apply": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -541,6 +556,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -558,6 +574,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -576,6 +593,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "create include - server returns no errors on second apply": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", rulesPath: "simple_rules.json", productID: "prd_test", @@ -601,6 +619,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -618,6 +637,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -636,6 +656,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "update include - editable version": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", productID: "prd_test", includeID: includeID, @@ -663,6 +684,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_no_rules.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -680,6 +702,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -698,6 +721,7 @@ func TestResourcePropertyInclude(t *testing.T) { }, "update include - create new version": { testData: testData{ + assetID: "aid_555", groupID: "grp_123", productID: "prd_test", includeID: includeID, @@ -730,6 +754,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include_no_rules.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), @@ -747,6 +772,7 @@ func TestResourcePropertyInclude(t *testing.T) { { Config: testutils.LoadFixtureString(t, "%s/property_include.tf", workdir), Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_property_include.test", "asset_id", "aid_555"), resource.TestCheckResourceAttr("akamai_property_include.test", "group_id", "grp_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "contract_id", "ctr_123"), resource.TestCheckResourceAttr("akamai_property_include.test", "product_id", "prd_test"), From a17587cc25b3b6af67edbf2aa8828fe5d18756f5 Mon Sep 17 00:00:00 2001 From: Shristi Singh Date: Tue, 27 Aug 2024 10:19:58 +0000 Subject: [PATCH 28/54] DXE-4039 Implement iam_role data source Merge in DEVEXP/terraform-provider-akamai from feature/DXE-4039 to feature/sp-iam-extension --- CHANGELOG.md | 4 + pkg/providers/iam/data_akamai_iam_role.go | 263 ++++++++++++++++++ .../iam/data_akamai_iam_role_test.go | 108 +++++++ pkg/providers/iam/provider.go | 1 + .../testdata/TestDataRole/missing_role_id.tf | 6 + .../iam/testdata/TestDataRole/valid.tf | 8 + 6 files changed, 390 insertions(+) create mode 100644 pkg/providers/iam/data_akamai_iam_role.go create mode 100644 pkg/providers/iam/data_akamai_iam_role_test.go create mode 100644 pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataRole/valid.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index d8977cfe9..d37d1b18a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ #### FEATURES/ENHANCEMENTS: +* IAM + * Added data source: + * `akamai_iam_role` - read the details for a role + * IAM * Added data source: * `akamai_iam_authorized_users` - read the list of authorized API client users diff --git a/pkg/providers/iam/data_akamai_iam_role.go b/pkg/providers/iam/data_akamai_iam_role.go new file mode 100644 index 000000000..c86a4e9eb --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_role.go @@ -0,0 +1,263 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var _ datasource.DataSource = &roleDataSource{} +var _ datasource.DataSourceWithConfigure = &roleDataSource{} + +// NewRoleDataSource returns all the details for a role. +func NewRoleDataSource() datasource.DataSource { + return &roleDataSource{} +} + +type ( + + // roleDataSource defines the data source implementation for fetching details for a role. + roleDataSource struct { + meta meta.Meta + } + + // roleDataSourceModel describes the data source data model for roleDataSource. + roleDataSourceModel struct { + RoleID types.Int64 `tfsdk:"role_id"` + Actions *actions `tfsdk:"actions"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + RoleDescription types.String `tfsdk:"role_description"` + RoleName types.String `tfsdk:"role_name"` + Type types.String `tfsdk:"type"` + GrantedRoles []GrantedRole `tfsdk:"granted_roles"` + Users []User `tfsdk:"users"` + } + + // GrantedRole contains details about Granted roles for the account. + GrantedRole struct { + GrantedRoleID types.Int64 `tfsdk:"granted_role_id"` + GrantedRoleName types.String `tfsdk:"granted_role_name"` + GrantedRoleDescription types.String `tfsdk:"granted_role_description"` + } + + // User is one of the Users on the account who share the same role. + User struct { + AccountID types.String `tfsdk:"account_id"` + Email types.String `tfsdk:"email"` + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + LastLoginDate types.String `tfsdk:"last_login_date"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + } +) + +// Schema is used to define data source's terraform schema +func (d *roleDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Role data source", + Attributes: map[string]schema.Attribute{ + "role_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each role.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the granted role.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the granted role was originally created.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the granted role.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the granted role was last updated.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "type": schema.StringAttribute{ + Computed: true, + Description: "Whether it's a standard role defined by Akamai or a custom role created by a user of your account. You can't modify or delete a standard role.", + Validators: []validator.String{ + stringvalidator.OneOf("standard", "custom"), + }, + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the role.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can remove the role.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can modify the role.", + }, + }, + }, + "granted_roles": schema.ListNestedAttribute{ + Computed: true, + Description: "Granted roles for the account.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "granted_role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "granted_role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each granted role.", + }, + "granted_role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the granted role.", + }, + }, + }, + }, + "users": schema.ListNestedAttribute{ + Computed: true, + Description: "Users on the account who share the same role.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each account.", + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + }, + }, + }, + }, + } +} + +// Metadata configures data source's meta information +func (d *roleDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_role" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *roleDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + d.meta = meta.Must(req.ProviderData) +} + +// Read is called when the provider must read data source values in order to update state +func (d *roleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Role DataSource Read") + + var data roleDataSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + + client := inst.Client(d.meta) + + getRoleResp, err := client.GetRole(ctx, iam.GetRoleRequest{ + ID: data.RoleID.ValueInt64(), + Actions: true, + GrantedRoles: true, + Users: true, + }) + if err != nil { + resp.Diagnostics.AddError("fetching iam role failed", err.Error()) + return + } + + data.setAttributes(getRoleResp) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (m *roleDataSourceModel) setAttributes(role *iam.Role) { + + m.CreatedBy = types.StringValue(role.CreatedBy) + m.CreatedDate = types.StringValue(role.CreatedDate.Format(time.RFC3339Nano)) + m.ModifiedBy = types.StringValue(role.ModifiedBy) + m.ModifiedDate = types.StringValue(role.ModifiedDate.Format(time.RFC3339Nano)) + m.RoleName = types.StringValue(role.RoleName) + m.RoleDescription = types.StringValue(role.RoleDescription) + m.Type = types.StringValue(string(role.RoleType)) + + if role.Actions != nil { + m.Actions = &actions{ + Delete: types.BoolValue(role.Actions.Delete), + Edit: types.BoolValue(role.Actions.Edit), + } + } + + for _, grantedRole := range role.GrantedRoles { + grantedRoleObject := GrantedRole{ + GrantedRoleID: types.Int64Value(grantedRole.RoleID), + GrantedRoleName: types.StringValue(grantedRole.RoleName), + GrantedRoleDescription: types.StringValue(grantedRole.Description), + } + m.GrantedRoles = append(m.GrantedRoles, grantedRoleObject) + } + for _, user := range role.Users { + userObject := User{ + AccountID: types.StringValue(user.AccountID), + Email: types.StringValue(user.Email), + FirstName: types.StringValue(user.FirstName), + LastName: types.StringValue(user.LastName), + LastLoginDate: types.StringValue(user.LastLoginDate.String()), + UIIdentityID: types.StringValue(user.UIIdentityID), + } + + m.Users = append(m.Users, userObject) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_role_test.go b/pkg/providers/iam/data_akamai_iam_role_test.go new file mode 100644 index 000000000..9e629743b --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_role_test.go @@ -0,0 +1,108 @@ +package iam + +import ( + "fmt" + "regexp" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestRoleDataSource(t *testing.T) { + createdDate := time.Date(2017, time.July, 27, 18, 11, 25, 0, time.UTC) + modifiedDate := time.Date(2017, time.August, 27, 18, 11, 25, 0, time.UTC) + + tests := map[string]struct { + givenTF string + init func(*iam.Mock) + expectedAttributes map[string]string + expectedMissingAttributes []string + expectError *regexp.Regexp + }{ + "happy path - role is returned": { + givenTF: "valid.tf", + init: func(m *iam.Mock) { + m.On("GetRole", mock.Anything, iam.GetRoleRequest{ + ID: 12345, + Actions: true, + GrantedRoles: true, + Users: true, + }).Return(&iam.Role{ + RoleID: int64(12345), + RoleName: "example-role", + RoleDescription: "This is an example role.", + CreatedBy: "user@example.com", + CreatedDate: createdDate, + ModifiedBy: "admin@example.com", + ModifiedDate: modifiedDate, + RoleType: "custom", + Actions: &iam.RoleAction{ + Delete: true, + Edit: true, + }, + }, nil) + }, + expectedAttributes: map[string]string{ + "role_id": "12345", + "role_name": "example-role", + "role_description": "This is an example role.", + "created_by": "user@example.com", + "created_date": "2017-07-27T18:11:25Z", + "modified_by": "admin@example.com", + "modified_date": "2017-08-27T18:11:25Z", + "type": "custom", + "actions.delete": "true", + "actions.edit": "true", + }, + expectError: nil, + }, + "error response from API": { + givenTF: "valid.tf", + init: func(m *iam.Mock) { + m.On("GetRole", mock.Anything, iam.GetRoleRequest{ + ID: 12345, + Actions: true, + GrantedRoles: true, + Users: true, + }).Return(nil, fmt.Errorf("API error")) + }, + expectError: regexp.MustCompile("API error"), + }, + "missing required argument role_id": { + givenTF: "missing_role_id.tf", + expectError: regexp.MustCompile(`The argument "role_id" is required, but no definition was found`), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + + if test.init != nil { + test.init(client) + } + var checkFuncs []resource.TestCheckFunc + for k, v := range test.expectedAttributes { + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_role.test", k, v)) + } + for _, v := range test.expectedMissingAttributes { + checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("data.akamai_iam_role.test", v)) + } + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataRole/%s", test.givenTF)), + Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), + ExpectError: test.expectError, + }}, + }) + }) + client.AssertExpectations(t) + }) + } +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 663f23715..a4aee7516 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -104,5 +104,6 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewCIDRBlockDataSource, NewPasswordPolicyDataSource, NewPropertyUsersDataSource, + NewRoleDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf b/pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf new file mode 100644 index 000000000..eb4168a15 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataRole/missing_role_id.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + + +data "akamai_iam_role" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataRole/valid.tf b/pkg/providers/iam/testdata/TestDataRole/valid.tf new file mode 100644 index 000000000..8887458f2 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataRole/valid.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + + +data "akamai_iam_role" "test" { + role_id = 12345 +} From 641716fe85fcb27c2b448bea318e0820a2191aa9 Mon Sep 17 00:00:00 2001 From: Shristi Singh Date: Fri, 30 Aug 2024 06:49:07 +0000 Subject: [PATCH 29/54] DXE-4040 Implement akamai_iam_group data source Merge in DEVEXP/terraform-provider-akamai from feature/DXE-4040 to feature/sp-iam-extension --- CHANGELOG.md | 4 + pkg/providers/iam/data_akamai_iam_group.go | 206 ++++++++++++++++++ .../iam/data_akamai_iam_group_test.go | 162 ++++++++++++++ pkg/providers/iam/provider.go | 1 + .../TestDataGroup/missing_group_id.tf | 5 + .../iam/testdata/TestDataGroup/valid.tf | 7 + 6 files changed, 385 insertions(+) create mode 100644 pkg/providers/iam/data_akamai_iam_group.go create mode 100644 pkg/providers/iam/data_akamai_iam_group_test.go create mode 100644 pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf create mode 100644 pkg/providers/iam/testdata/TestDataGroup/valid.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index d37d1b18a..ec69d6b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ #### FEATURES/ENHANCEMENTS: +* IAM + * Added data source: + * `akamai_iam_group` - read the details for a group + * IAM * Added data source: * `akamai_iam_role` - read the details for a role diff --git a/pkg/providers/iam/data_akamai_iam_group.go b/pkg/providers/iam/data_akamai_iam_group.go new file mode 100644 index 000000000..93250d38f --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_group.go @@ -0,0 +1,206 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &groupDataSource{} + _ datasource.DataSourceWithConfigure = &groupDataSource{} +) + +const schemaMaxGroupDepth = 50 + +// NewGroupDataSource returns all the details for a group +func NewGroupDataSource() datasource.DataSource { + return &groupDataSource{} +} + +type ( + + // groupDataSource defines the data source implementation for fetching Group information + groupDataSource struct { + meta meta.Meta + } + + // groupDataSourceModel describes the data source data model for groupDataSource + groupDataSourceModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + Actions *actions `tfsdk:"actions"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + ParentGroupID types.Int64 `tfsdk:"parent_group_id"` + SubGroups []groupDataSourceModel `tfsdk:"sub_groups"` + } +) + +// groupSchemaAttributes returns the schema attributes for a group, with optional nesting for subgroups +func (d *groupDataSource) groupSchemaAttributes(remainingNesting int) map[string]schema.Attribute { + groupAttributes := map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the group.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the group was created.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the group.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the group was last updated.", + }, + "parent_group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for the parent group within the subgroup tree.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the group.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can remove the group from the account. You can't remove a group that contains resources or subgroups, or if users have roles on that group.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can modify the group.", + }, + }, + }, + } + + if remainingNesting > 0 { + groupAttributes["sub_groups"] = schema.ListNestedAttribute{ + Computed: true, + Description: fmt.Sprintf("Children of the parent group. Maximal depth of subgroups is %d.", schemaMaxGroupDepth), + NestedObject: schema.NestedAttributeObject{ + Attributes: d.groupSchemaAttributes(remainingNesting - 1), + }, + } + } + + return groupAttributes +} + +// Schema is used to define data source's terraform schema +func (d *groupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "IAM Group data source", + Attributes: d.groupSchemaAttributes(schemaMaxGroupDepth + 1), + } +} + +// Metadata configures data source's meta information +func (d *groupDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_group" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *groupDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + d.meta = meta.Must(req.ProviderData) +} + +// Read is called when the provider must read data source values in order to update state +func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Group DataSource Read") + + var data groupDataSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + + client := inst.Client(d.meta) + + getGroupResp, err := client.GetGroup(ctx, iam.GetGroupRequest{ + GroupID: data.GroupID.ValueInt64(), + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError("Fetching IAM group failed", err.Error()) + return + } + + groupData, diags := d.convertGroupData(getGroupResp, data, schemaMaxGroupDepth) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &groupData)...) +} + +// convertGroupData converts the response from the IAM client into the groupDataSourceModel structure +func (d *groupDataSource) convertGroupData(group *iam.Group, data groupDataSourceModel, remainingNesting int) (groupDataSourceModel, diag.Diagnostics) { + data.GroupName = types.StringValue(group.GroupName) + data.CreatedBy = types.StringValue(group.CreatedBy) + data.CreatedDate = types.StringValue(group.CreatedDate.Format(time.RFC3339Nano)) + data.ModifiedBy = types.StringValue(group.ModifiedBy) + data.ModifiedDate = types.StringValue(group.ModifiedDate.Format(time.RFC3339Nano)) + data.ParentGroupID = types.Int64Value(group.ParentGroupID) + data.GroupID = types.Int64Value(group.GroupID) + + if group.Actions != nil { + data.Actions = &actions{ + Delete: types.BoolValue(group.Actions.Delete), + Edit: types.BoolValue(group.Actions.Edit), + } + } + + var subGroups []groupDataSourceModel + if remainingNesting > 1 { + for _, subGroup := range group.SubGroups { + subGroupData, diags := d.convertGroupData(&subGroup, groupDataSourceModel{}, remainingNesting-1) + if diags.HasError() { + return groupDataSourceModel{}, diags + } + subGroups = append(subGroups, subGroupData) + } + data.SubGroups = subGroups + } else if remainingNesting <= 1 && len(group.SubGroups) > 0 { + return groupDataSourceModel{}, diag.Diagnostics{diag.NewErrorDiagnostic( + "unsupported subgroup depth", + fmt.Sprintf("Subgroup %d contains more subgroups and exceeds the total supported limit of nesting %d.", group.GroupID, schemaMaxGroupDepth), + )} + } + + return data, nil +} diff --git a/pkg/providers/iam/data_akamai_iam_group_test.go b/pkg/providers/iam/data_akamai_iam_group_test.go new file mode 100644 index 000000000..387dac793 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_group_test.go @@ -0,0 +1,162 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestGroupDataSource(t *testing.T) { + mockGetGroup := func(client *iam.Mock, group *iam.Group) *mock.Call { + return client.On("GetGroup", mock.Anything, iam.GetGroupRequest{ + GroupID: 123, + Actions: true, + }).Return(group, nil) + } + + tests := map[string]struct { + init func(mock *iam.Mock) + expectedError *regexp.Regexp + expectedChecks resource.TestCheckFunc + givenTF string + }{ + "normal case - all fields": { + init: func(client *iam.Mock) { + group := &iam.Group{ + GroupID: 123, + GroupName: "parent_group", + CreatedBy: "DevUser", + CreatedDate: test.NewTimeFromString(t, "2024-05-28T06:58:26Z"), + ModifiedBy: "TestUser", + ModifiedDate: test.NewTimeFromString(t, "2024-05-28T06:58:27Z"), + ParentGroupID: 0, + Actions: &iam.GroupActions{ + Delete: true, + Edit: true, + }, + SubGroups: []iam.Group{}, + } + mockGetGroup(client, group) + }, + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_id", "123"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_name", "parent_group"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "created_by", "DevUser"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "modified_by", "TestUser"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "parent_group_id", "0"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "actions.edit", "true"), + ), + givenTF: "valid.tf", + }, + "normal case - nested subgroups": { + init: func(client *iam.Mock) { + group := &iam.Group{ + GroupID: 123, + GroupName: "parent_group", + CreatedBy: "DevUser", + CreatedDate: test.NewTimeFromString(t, "2024-05-28T06:58:26Z"), + ModifiedBy: "TestUser", + ModifiedDate: test.NewTimeFromString(t, "2024-05-28T06:58:27Z"), + ParentGroupID: 0, + SubGroups: []iam.Group{ + { + GroupID: 456, + GroupName: "child_group", + CreatedBy: "creator_child", + ModifiedBy: "modifier_child", + ParentGroupID: 123, + }, + }, + } + mockGetGroup(client, group) + }, + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_id", "123"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_name", "parent_group"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.group_id", "456"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.group_name", "child_group"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.created_by", "creator_child"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.modified_by", "modifier_child"), + resource.TestCheckResourceAttr("data.akamai_iam_group.test", "sub_groups.0.parent_group_id", "123"), + ), + givenTF: "valid.tf", + }, + "error - too deep nesting": { + init: func(client *iam.Mock) { + group := &iam.Group{ + GroupID: 123, + GroupName: "root_group", + CreatedBy: "DevUser", + ModifiedBy: "TestUser", + ParentGroupID: 0, + SubGroups: generateDeepSubGroups(51), + } + mockGetGroup(client, group) + }, + expectedError: regexp.MustCompile("unsupported subgroup depth"), + givenTF: "valid.tf", + }, + "api failed": { + init: func(client *iam.Mock) { + client.On("GetGroup", mock.Anything, iam.GetGroupRequest{ + GroupID: 123, + Actions: true, + }).Return(nil, errors.New("api failed")) + }, + expectedError: regexp.MustCompile("api failed"), + givenTF: "valid.tf", + }, + "missing group_id": { + init: func(client *iam.Mock) {}, + expectedError: regexp.MustCompile("The argument \"group_id\" is required, but no definition was found."), + givenTF: "missing_group_id.tf", + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(client) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestDataGroup/%s", test.givenTF), + Check: test.expectedChecks, + ExpectError: test.expectedError, + }, + }, + }) + }) + }) + } + +} + +func generateDeepSubGroups(depth int64) []iam.Group { + if depth == 0 { + return nil + } + + return []iam.Group{ + { + GroupID: depth, + GroupName: fmt.Sprintf("group%d", depth), + CreatedBy: "DevUser", + ModifiedBy: "TestUser", + ParentGroupID: depth - 1, + SubGroups: generateDeepSubGroups(depth - 1), + }, + } +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index a4aee7516..8c6740d08 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -102,6 +102,7 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewAuthorizedUsersDataSource, NewBlockedPropertiesDataSource, NewCIDRBlockDataSource, + NewGroupDataSource, NewPasswordPolicyDataSource, NewPropertyUsersDataSource, NewRoleDataSource, diff --git a/pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf b/pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf new file mode 100644 index 000000000..1a14120bb --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataGroup/missing_group_id.tf @@ -0,0 +1,5 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_group" "test" {} diff --git a/pkg/providers/iam/testdata/TestDataGroup/valid.tf b/pkg/providers/iam/testdata/TestDataGroup/valid.tf new file mode 100644 index 000000000..950ded310 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataGroup/valid.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_group" "test" { + group_id = 123 +} From 071cf0b719a10f828e93c7453f817ced379acd94 Mon Sep 17 00:00:00 2001 From: rbhatved Date: Thu, 29 Aug 2024 13:36:48 +0530 Subject: [PATCH 30/54] DXE-4152 lock field not changed --- pkg/providers/iam/resource_akamai_iam_user.go | 46 +++++++++---------- .../iam/resource_akamai_iam_user_test.go | 26 +++++++++++ ...c_with_password_and_user_profile_locked.tf | 16 +++++++ ...update_password_for_user_profile_locked.tf | 16 +++++++ 4 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 441ef59a2..49911e1fb 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -326,6 +326,12 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf return diag.Errorf("failed to create user: %s\n%s", err, resourceIAMUserErrorAdvice(err)) } + err = manageUserPassword(ctx, d, client, user.IdentityID) + if err != nil { + logger.WithError(err).Errorf("failed to set user password") + return diag.Errorf("failed to set user password: %s", err) + } + // lock the user's account lock, err := tf.GetBoolValue("lock", d) if err != nil && !errors.Is(err, tf.ErrNotFound) { @@ -338,12 +344,6 @@ func resourceIAMUserCreate(ctx context.Context, d *schema.ResourceData, m interf } } - err = manageUserPassword(ctx, d, client, user.IdentityID) - if err != nil { - logger.WithError(err).Errorf("failed to set user password") - return diag.Errorf("failed to set user password: %s", err) - } - d.SetId(user.IdentityID) return resourceIAMUserRead(ctx, d, m) } @@ -622,23 +622,6 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf needRead = true } - // lock the user - if d.HasChange("lock") { - lock, err := tf.GetBoolValue("lock", d) - if err != nil && !errors.Is(err, tf.ErrNotFound) { - return diag.FromErr(err) - } - - if lock { - err = client.LockUser(ctx, iam.LockUserRequest{IdentityID: d.Id()}) - } else { - err = client.UnlockUser(ctx, iam.UnlockUserRequest{IdentityID: d.Id()}) - } - if err != nil { - return diag.FromErr(err) - } - } - // user notifications if d.HasChange("user_notifications") { notificationsData, err := tf.GetListValue("user_notifications", d) @@ -674,6 +657,23 @@ func resourceIAMUserUpdate(ctx context.Context, d *schema.ResourceData, m interf needRead = true } + // lock the user + if d.HasChange("lock") { + lock, err := tf.GetBoolValue("lock", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return diag.FromErr(err) + } + + if lock { + err = client.LockUser(ctx, iam.LockUserRequest{IdentityID: d.Id()}) + } else { + err = client.UnlockUser(ctx, iam.UnlockUserRequest{IdentityID: d.Id()}) + } + if err != nil { + return diag.FromErr(err) + } + } + if needRead { d.Partial(false) return resourceIAMUserRead(ctx, d, m) diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index 8d28253a2..071b732f1 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -829,6 +829,32 @@ func TestResourceUser(t *testing.T) { }, }, }, + "create user with password, set lock field as true and set new password": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateLockedRequest, userCreateLocked, true, true, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Times(2) + + // plan + expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Once() + // update only the user password + expectPassword(m, userCreateLocked.IdentityID, "NewPassword@123", nil).Once() + expectResourceIAMUserReadPhase(m, userCreateLocked, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreateLocked, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, true), checkDefaultUserNotificationsAttributes(userCreateLocked)), + }, + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateLocked, true), checkDefaultUserNotificationsAttributes(userCreateLocked)), + }, + }, + }, "create user with password and update user info and remove the password field": { init: func(m *iam.Mock) { // create diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf new file mode 100644 index 000000000..ce5381aed --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_with_password_and_user_profile_locked.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + lock = true + password = "Password@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf new file mode 100644 index 000000000..e3536775d --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/update_password_for_user_profile_locked.tf @@ -0,0 +1,16 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = false + lock = true + password = "NewPassword@123" + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" +} From a3e102cf9e11318b68403d5d5fb3244b7f7ef516 Mon Sep 17 00:00:00 2001 From: Wojciech Zagrajczuk Date: Tue, 3 Sep 2024 07:14:06 +0000 Subject: [PATCH 31/54] DXE-4036 Added akamai_iam_accessible_groups datasource --- CHANGELOG.md | 21 ++ .../iam/data_akamai_iam_accessible_groups.go | 224 ++++++++++++++++++ .../data_akamai_iam_accessible_groups_test.go | 214 +++++++++++++++++ pkg/providers/iam/data_akamai_iam_group.go | 10 +- pkg/providers/iam/data_akamai_iam_groups.go | 2 +- pkg/providers/iam/provider.go | 1 + .../TestDataAccessibleGroups/basic.tf | 7 + .../TestDataAccessibleGroups/no-username.tf | 6 + 8 files changed, 479 insertions(+), 6 deletions(-) create mode 100644 pkg/providers/iam/data_akamai_iam_accessible_groups.go create mode 100644 pkg/providers/iam/data_akamai_iam_accessible_groups_test.go create mode 100644 pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf create mode 100644 pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index ec69d6b32..b2237a445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,6 +112,27 @@ * Added new data source: * `akamai_iam_account_switch_keys` - read the account switch keys +* IAM: + * Added new datasource: + * `akamai_iam_accessible_groups` - read the groups and subgroups accessible for provided user + + + + + + + + + + + + + + + + + + diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups.go b/pkg/providers/iam/data_akamai_iam_accessible_groups.go new file mode 100644 index 000000000..4c755deaf --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups.go @@ -0,0 +1,224 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &accessibleGroups{} + _ datasource.DataSourceWithConfigure = &accessibleGroups{} +) + +type ( + accessibleGroups struct { + meta meta.Meta + } + + accessibleGroupsModel struct { + Username types.String `tfsdk:"username"` + AccessibleGroups []accessibleGroupModel `tfsdk:"accessible_groups"` + } + + accessibleGroupModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + RoleDescription types.String `tfsdk:"role_description"` + RoleID types.Int64 `tfsdk:"role_id"` + RoleName types.String `tfsdk:"role_name"` + SubGroups []accessibleSubgroupModel `tfsdk:"sub_groups"` + } + + accessibleSubgroupModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + ParentGroupID types.Int64 `tfsdk:"parent_group_id"` + SubGroups []accessibleSubgroupModel `tfsdk:"sub_groups"` + } +) + +// NewAccessibleGroupsDataSource returns new accessible groups data source +func NewAccessibleGroupsDataSource() datasource.DataSource { + return &accessibleGroups{} +} + +func (a *accessibleGroups) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_accessible_groups" +} + +func (a *accessibleGroups) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + a.meta = meta.Must(req.ProviderData) +} + +func (a *accessibleGroups) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "username": schema.StringAttribute{ + Required: true, + Description: "User's username for which the accessible groups will be listed.", + }, + "accessible_groups": schema.ListNestedAttribute{ + Description: "List of accessible groups for the user", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "sub_groups": schema.ListNestedAttribute{ + Computed: true, + Description: "Children of the parent group", + // Schema effectively must be +1 size nested, to support correctly marshalling of last level (null of type []accessibleSubgroupModel onto `sub_groups`) + NestedObject: a.subgroupsSchema(maxSupportedGroupNesting + 1), + }, + }, + }, + }, + }, + } +} + +func (a *accessibleGroups) subgroupsSchema(remainingNesting int) schema.NestedAttributeObject { + subgroupSchema := schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "parent_group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for the parent group.", + }, + }, + } + + var subgroupsAttribute schema.Attribute + if remainingNesting > 0 { + subgroupsAttribute = schema.ListNestedAttribute{ + Computed: true, + Description: fmt.Sprintf("Children of the parent group. Current maximal depth of subgroups is %d.", maxSupportedGroupNesting), + NestedObject: a.subgroupsSchema(remainingNesting - 1), + } + subgroupSchema.Attributes["sub_groups"] = subgroupsAttribute + } + + return subgroupSchema +} + +func (a *accessibleGroups) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Accessible Groups Datasource Read") + + var data accessibleGroupsModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + client := inst.Client(a.meta) + groups, err := client.ListAccessibleGroups(ctx, iam.ListAccessibleGroupsRequest{UserName: data.Username.ValueString()}) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Accessible Groups failed", err.Error()) + return + } + + newData, diags := a.convertAccessibleGroups(groups, data) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + resp.Diagnostics.Append(resp.State.Set(ctx, newData)...) +} + +func (a *accessibleGroups) convertAccessibleGroups(groups iam.ListAccessibleGroupsResponse, data accessibleGroupsModel) (*accessibleGroupsModel, diag.Diagnostics) { + data.AccessibleGroups = []accessibleGroupModel{} + for _, group := range groups { + newGroup := accessibleGroupModel{ + GroupID: types.Int64Value(group.GroupID), + GroupName: types.StringValue(group.GroupName), + IsBlocked: types.BoolValue(group.IsBlocked), + RoleDescription: types.StringValue(group.RoleDescription), + RoleID: types.Int64Value(group.RoleID), + RoleName: types.StringValue(group.RoleName), + } + + subgroups, diags := a.convertAccessibleSubgroups(group.SubGroups, maxSupportedGroupNesting) + if diags.HasError() { + return nil, diags + } + newGroup.SubGroups = subgroups + + data.AccessibleGroups = append(data.AccessibleGroups, newGroup) + + } + return &data, nil +} + +func (a *accessibleGroups) convertAccessibleSubgroups(subgroups []iam.AccessibleSubGroup, remainingNesting int) ([]accessibleSubgroupModel, diag.Diagnostics) { + groups := []accessibleSubgroupModel{} + + for _, subgroup := range subgroups { + newSubgroup := accessibleSubgroupModel{ + GroupID: types.Int64Value(subgroup.GroupID), + GroupName: types.StringValue(subgroup.GroupName), + ParentGroupID: types.Int64Value(subgroup.ParentGroupID), + } + if remainingNesting > 1 { + newSubgroups, diags := a.convertAccessibleSubgroups(subgroup.SubGroups, remainingNesting-1) + if diags.HasError() { + return nil, diags + } + newSubgroup.SubGroups = newSubgroups + } else if subgroup.SubGroups != nil && len(subgroup.SubGroups) > 0 { // We already processed the last level (remainingNesting = 1). If it still has subgroups, we cannot handle it + return nil, diag.Diagnostics{diag.NewErrorDiagnostic("unsupported subgroup depth", + fmt.Sprintf("Subgroup %d contains more subgroups and exceed total supported limit of nesting %d.", subgroup.GroupID, maxSupportedGroupNesting))} + } + groups = append(groups, newSubgroup) + } + + return groups, nil +} diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go new file mode 100644 index 000000000..d1d2fbf22 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go @@ -0,0 +1,214 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestAccessibleGroups(t *testing.T) { + mockPositiveCase := func(client *iam.Mock, returnedGroups iam.ListAccessibleGroupsResponse) *mock.Call { + return client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(returnedGroups, nil).Times(5) + } + + generateCheckForGroup := func(path, groupID, groupName, isBlocked, roleDescription, roleID, roleName, subGroupsNumber string) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_id", path), groupID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_name", path), groupName), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.is_blocked", path), isBlocked), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.role_description", path), roleDescription), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.role_id", path), roleID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.role_name", path), roleName), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.sub_groups.#", path), subGroupsNumber), + ) + } + + generateCheckForSubGroup := func(path, groupID, groupName, parentGroupID, subGroupsNumber string) resource.TestCheckFunc { + return resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_id", path), groupID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.group_name", path), groupName), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.parent_group_id", path), parentGroupID), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", fmt.Sprintf("%s.sub_groups.#", path), subGroupsNumber), + ) + } + + generateSubGroups := func(maxDepth, parentGroupID int64) []iam.AccessibleSubGroup { + var childSubgroups []iam.AccessibleSubGroup + + for groupID := maxDepth; groupID > 1; groupID-- { + currentSubgroups := iam.AccessibleSubGroup{ + GroupID: groupID, + GroupName: fmt.Sprintf("group%d", groupID), + ParentGroupID: groupID - 1, + SubGroups: childSubgroups, + } + childSubgroups = []iam.AccessibleSubGroup{currentSubgroups} + } + return []iam.AccessibleSubGroup{ + { + GroupID: 1, + GroupName: "group1", + ParentGroupID: parentGroupID, + SubGroups: childSubgroups, + }, + } + } + + generateIntermediateChecksForGeneratedSubGroup := func(min, max int) resource.TestCheckFunc { + var testCases []resource.TestCheckFunc + + for i := min; i < max; i++ { + testCases = append(testCases, generateCheckForSubGroup(fmt.Sprintf("accessible_groups.0%s", strings.Repeat(".sub_groups.0", i)), strconv.Itoa(i), fmt.Sprintf("group%d", i), strconv.Itoa(i-1), "1")) + } + + return resource.ComposeAggregateTestCheckFunc(testCases...) + } + + tests := map[string]struct { + init func(mock *iam.Mock) + config string + expectedError *regexp.Regexp + expectedChecks resource.TestCheckFunc + }{ + "normal case - all fields": { + init: func(client *iam.Mock) { + returnedGroups := []iam.AccessibleGroup{ + { + GroupID: 123, + GroupName: "first_group", + RoleID: 456, + RoleName: "admin", + RoleDescription: "admin description", + IsBlocked: true, + }, + { + GroupID: 321, + GroupName: "second_group", + RoleID: 654, + RoleName: "group1", + RoleDescription: "group1 description", + IsBlocked: false, + SubGroups: []iam.AccessibleSubGroup{ + { + GroupID: 234, + GroupName: "name2", + ParentGroupID: 321, + SubGroups: []iam.AccessibleSubGroup{ + { + GroupID: 345, + GroupName: "name3", + ParentGroupID: 234, + SubGroups: []iam.AccessibleSubGroup{}, + }, + }, + }, + }, + }, + } + mockPositiveCase(client, returnedGroups) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "username", "user1"), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "accessible_groups.#", "2"), + generateCheckForGroup("accessible_groups.0", "123", "first_group", "true", "admin description", "456", "admin", "0"), + generateCheckForGroup("accessible_groups.1", "321", "second_group", "false", "group1 description", "654", "group1", "1"), + generateCheckForSubGroup("accessible_groups.1.sub_groups.0", "234", "name2", "321", "1"), + generateCheckForSubGroup("accessible_groups.1.sub_groups.0.sub_groups.0", "345", "name3", "234", "0"), + ), + }, + "normal case - max depth": { + init: func(client *iam.Mock) { + returnedGroups := []iam.AccessibleGroup{ + { + GroupID: 123, + GroupName: "root group", + RoleID: 321, + RoleName: "role321", + RoleDescription: "role321 description", + IsBlocked: false, + SubGroups: generateSubGroups(50, 123), + }, + } + mockPositiveCase(client, returnedGroups) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "username", "user1"), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "accessible_groups.#", "1"), + generateCheckForSubGroup(fmt.Sprintf("accessible_groups.0%s", strings.Repeat(".sub_groups.0", 1)), "1", "group1", "123", "1"), + generateIntermediateChecksForGeneratedSubGroup(2, 50), + generateCheckForSubGroup(fmt.Sprintf("accessible_groups.0%s", strings.Repeat(".sub_groups.0", 50)), "50", "group50", "49", "0"), + ), + }, + "normal case - empty response": { + init: func(client *iam.Mock) { + mockPositiveCase(client, []iam.AccessibleGroup{}) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "username", "user1"), + resource.TestCheckResourceAttr("data.akamai_iam_accessible_groups.groups", "accessible_groups.#", "0"), + ), + }, + "error - too deep nesting": { + init: func(client *iam.Mock) { + returnedGroups := []iam.AccessibleGroup{ + { + GroupID: 123, + GroupName: "root group", + RoleID: 321, + RoleName: "role321", + RoleDescription: "role321 description", + IsBlocked: false, + SubGroups: generateSubGroups(51, 123), + }, + } + mockPositiveCase(client, returnedGroups) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedError: regexp.MustCompile("unsupported subgroup depth"), + }, + "error - api failed": { + init: func(client *iam.Mock) { + client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(nil, errors.New("api failed")).Times(5) + }, + config: "testdata/TestDataAccessibleGroups/basic.tf", + expectedError: regexp.MustCompile("api failed"), + }, + "error - missing username": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataAccessibleGroups/no-username.tf", + expectedError: regexp.MustCompile("Missing required argument"), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(client) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.config), + Check: test.expectedChecks, + ExpectError: test.expectedError, + }, + }, + }) + }) + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_group.go b/pkg/providers/iam/data_akamai_iam_group.go index 93250d38f..b4ab70c31 100644 --- a/pkg/providers/iam/data_akamai_iam_group.go +++ b/pkg/providers/iam/data_akamai_iam_group.go @@ -19,7 +19,7 @@ var ( _ datasource.DataSourceWithConfigure = &groupDataSource{} ) -const schemaMaxGroupDepth = 50 +const maxSupportedGroupNesting = 50 // NewGroupDataSource returns all the details for a group func NewGroupDataSource() datasource.DataSource { @@ -97,7 +97,7 @@ func (d *groupDataSource) groupSchemaAttributes(remainingNesting int) map[string if remainingNesting > 0 { groupAttributes["sub_groups"] = schema.ListNestedAttribute{ Computed: true, - Description: fmt.Sprintf("Children of the parent group. Maximal depth of subgroups is %d.", schemaMaxGroupDepth), + Description: fmt.Sprintf("Children of the parent group. Maximal depth of subgroups is %d.", maxSupportedGroupNesting), NestedObject: schema.NestedAttributeObject{ Attributes: d.groupSchemaAttributes(remainingNesting - 1), }, @@ -111,7 +111,7 @@ func (d *groupDataSource) groupSchemaAttributes(remainingNesting int) map[string func (d *groupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ MarkdownDescription: "IAM Group data source", - Attributes: d.groupSchemaAttributes(schemaMaxGroupDepth + 1), + Attributes: d.groupSchemaAttributes(maxSupportedGroupNesting + 1), } } @@ -159,7 +159,7 @@ func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - groupData, diags := d.convertGroupData(getGroupResp, data, schemaMaxGroupDepth) + groupData, diags := d.convertGroupData(getGroupResp, data, maxSupportedGroupNesting) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return @@ -198,7 +198,7 @@ func (d *groupDataSource) convertGroupData(group *iam.Group, data groupDataSourc } else if remainingNesting <= 1 && len(group.SubGroups) > 0 { return groupDataSourceModel{}, diag.Diagnostics{diag.NewErrorDiagnostic( "unsupported subgroup depth", - fmt.Sprintf("Subgroup %d contains more subgroups and exceeds the total supported limit of nesting %d.", group.GroupID, schemaMaxGroupDepth), + fmt.Sprintf("Subgroup %d contains more subgroups and exceeds the total supported limit of nesting %d.", group.GroupID, maxSupportedGroupNesting), )} } diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index ef3896878..991d7b4c7 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -18,7 +18,7 @@ func dataSourceIAMGroups() *schema.Resource { Description: `List all groups in which you have a scope of "admin" for the current account and contract`, ReadContext: dataIAMGroupsRead, Schema: map[string]*schema.Schema{ - "groups": nestedGroupsSchema(50), // Can handle groups with nesting up to 50 levels deep + "groups": nestedGroupsSchema(maxSupportedGroupNesting), // Can handle groups with nesting up to 50 levels deep }, } } diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 8c6740d08..892f97ba3 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -97,6 +97,7 @@ func (p *Subprovider) FrameworkResources() []func() resource.Resource { // FrameworkDataSources returns the IAM data sources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { return []func() datasource.DataSource{ + NewAccessibleGroupsDataSource, NewAccountSwitchKeysDataSource, NewAllowedAPIsDataSource, NewAuthorizedUsersDataSource, diff --git a/pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf b/pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf new file mode 100644 index 000000000..e16c8194b --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccessibleGroups/basic.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_accessible_groups" "groups" { + username = "user1" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf b/pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf new file mode 100644 index 000000000..90cb348ba --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataAccessibleGroups/no-username.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_accessible_groups" "groups" { +} \ No newline at end of file From 0f626581a4885b06bf4f72e381d70e7cce69aa8e Mon Sep 17 00:00:00 2001 From: Wojciech Zagrajczuk Date: Wed, 4 Sep 2024 06:01:07 +0000 Subject: [PATCH 32/54] DXE-4041 Users affected by moving group datasource --- CHANGELOG.md | 4 +- ...amai_iam_users_affected_by_moving_group.go | 170 ++++++++++++++++++ ...iam_users_affected_by_moving_group_test.go | 162 +++++++++++++++++ pkg/providers/iam/provider.go | 1 + .../testdata/TestDataUsersAffected/basic.tf | 8 + .../testdata/TestDataUsersAffected/gained.tf | 9 + .../incorrect-usertype.tf | 9 + .../testdata/TestDataUsersAffected/lost.tf | 9 + .../missing-destination.tf | 7 + .../TestDataUsersAffected/missing-source.tf | 7 + 10 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go create mode 100644 pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go create mode 100644 pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf create mode 100644 pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf create mode 100644 pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf create mode 100644 pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf create mode 100644 pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf create mode 100644 pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index b2237a445..b2311e131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -153,7 +153,9 @@ - +* IAM + * Added new data source: + * `akamai_iam_users_affected_by_moving_group` - list the users affected by moving a group diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go new file mode 100644 index 000000000..4ee56caf7 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go @@ -0,0 +1,170 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &usersAffectedByMovingGroup{} + _ datasource.DataSourceWithConfigure = &usersAffectedByMovingGroup{} +) + +type ( + usersAffectedByMovingGroup struct { + meta meta.Meta + } + + usersAffectedByMovingGroupModel struct { + SourceGroupID types.Int64 `tfsdk:"source_group_id"` + DestinationGroupID types.Int64 `tfsdk:"destination_group_id"` + UserType types.String `tfsdk:"user_type"` + Users []userAffectedByMovingGroupModel `tfsdk:"users"` + } + + userAffectedByMovingGroupModel struct { + AccountID types.String `tfsdk:"account_id"` + Email types.String `tfsdk:"email"` + FirstName types.String `tfsdk:"first_name"` + LastLoginDate types.String `tfsdk:"last_login_date"` + LastName types.String `tfsdk:"last_name"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + UIUsername types.String `tfsdk:"ui_username"` + } +) + +// NewUsersAffectedByMovingGroupDataSource returns new users affected by moving group data source +func NewUsersAffectedByMovingGroupDataSource() datasource.DataSource { + return &usersAffectedByMovingGroup{} +} + +func (a *usersAffectedByMovingGroup) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_users_affected_by_moving_group" +} + +func (a *usersAffectedByMovingGroup) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + a.meta = meta.Must(req.ProviderData) +} + +func (a *usersAffectedByMovingGroup) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "source_group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for a group you want to move.", + }, + "destination_group_id": schema.Int64Attribute{ + Required: true, + Description: "Unique identifier for a group you're putting the other group into.", + }, + "user_type": schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("lostAccess", "gainAccess", ""), + }, + Description: "Filters the list by users who have lostAccess or the reverse gainAccess.", + }, + "users": schema.ListNestedAttribute{ + Computed: true, + Description: "The list of affected users", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each account.", + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + "ui_username": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + }, + }, + }, + }, + } +} + +func (a *usersAffectedByMovingGroup) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Users affected by moving group Datasource Read") + + var data usersAffectedByMovingGroupModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + client := inst.Client(a.meta) + users, err := client.ListAffectedUsers(ctx, iam.ListAffectedUsersRequest{ + SourceGroupID: data.SourceGroupID.ValueInt64(), + DestinationGroupID: data.DestinationGroupID.ValueInt64(), + UserType: data.UserType.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError("Reading IAM Users affected by moving group failed", err.Error()) + return + } + + data.Users = convertUsersAffectedByMove(users) + + resp.Diagnostics.Append(resp.State.Set(ctx, data)...) +} + +func convertUsersAffectedByMove(users []iam.GroupUser) []userAffectedByMovingGroupModel { + convertedUsers := []userAffectedByMovingGroupModel{} + for _, user := range users { + convertedUser := userAffectedByMovingGroupModel{ + AccountID: types.StringValue(user.AccountID), + Email: types.StringValue(user.Email), + FirstName: types.StringValue(user.FirstName), + LastName: types.StringValue(user.LastName), + UIIdentityID: types.StringValue(user.IdentityID), + UIUsername: types.StringValue(user.UserName), + } + if !user.LastLoginDate.IsZero() { + convertedUser.LastLoginDate = types.StringValue(user.LastLoginDate.Format(time.RFC3339Nano)) + } + convertedUsers = append(convertedUsers, convertedUser) + } + return convertedUsers +} diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go new file mode 100644 index 000000000..7422a0076 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go @@ -0,0 +1,162 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestUsersAffectedByMovingGroup(t *testing.T) { + + mockListAffectedUsers := func(client *iam.Mock, userType string, users []iam.GroupUser) *mock.Call { + return client.On("ListAffectedUsers", mock.Anything, iam.ListAffectedUsersRequest{SourceGroupID: 123, DestinationGroupID: 321, UserType: userType}). + Return(users, nil) + } + + generateExpectedGroup := func(path, accountID, email, firstName, lastName, userName, identityID string, lastLoginDate *string) resource.TestCheckFunc { + checks := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.account_id", path), accountID), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.email", path), email), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.first_name", path), firstName), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_name", path), lastName), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.ui_username", path), userName), + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.ui_identity_id", path), identityID), + } + + if lastLoginDate != nil { + checks = append(checks, resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path), *lastLoginDate)) + } else { + checks = append(checks, resource.TestCheckNoResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path))) + } + + return resource.ComposeAggregateTestCheckFunc(checks...) + } + + tests := map[string]struct { + init func(mock *iam.Mock) + config string + expectedError *regexp.Regexp + expectedChecks resource.TestCheckFunc + }{ + "normal case - no filter": { + init: func(client *iam.Mock) { + mockListAffectedUsers(client, "", []iam.GroupUser{ + { + AccountID: "1-ABCD", + Email: "ab.cd@test.com", + FirstName: "ab", + LastName: "cd", + UserName: "abcd", + IdentityID: "F-CO-abcd", + }, + { + AccountID: "1-EFGH", + Email: "ef.gh@test.com", + FirstName: "ef", + LastName: "gh", + UserName: "efgh", + IdentityID: "F-CO-efgh", + LastLoginDate: test.NewTimeFromString(t, "2024-02-06T15:00:00.000Z"), + }, + }) + }, + config: "testdata/TestDataUsersAffected/basic.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", "users.#", "2"), + generateExpectedGroup("users.0", "1-ABCD", "ab.cd@test.com", "ab", "cd", "abcd", "F-CO-abcd", nil), + generateExpectedGroup("users.1", "1-EFGH", "ef.gh@test.com", "ef", "gh", "efgh", "F-CO-efgh", ptr.To("2024-02-06T15:00:00Z")), + ), + }, + "normal case - only gained": { + init: func(client *iam.Mock) { + mockListAffectedUsers(client, "gainAccess", []iam.GroupUser{ + { + AccountID: "1-ABCD", + Email: "ab.cd@test.com", + FirstName: "ab", + LastName: "cd", + UserName: "abcd", + IdentityID: "F-CO-abcd", + }, + }) + }, + config: "testdata/TestDataUsersAffected/gained.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", "users.#", "1"), + generateExpectedGroup("users.0", "1-ABCD", "ab.cd@test.com", "ab", "cd", "abcd", "F-CO-abcd", nil), + ), + }, + "normal case - only lost": { + init: func(client *iam.Mock) { + mockListAffectedUsers(client, "lostAccess", []iam.GroupUser{ + { + AccountID: "1-EFGH", + Email: "ef.gh@test.com", + FirstName: "ef", + LastName: "gh", + UserName: "efgh", + IdentityID: "F-CO-efgh", + LastLoginDate: test.NewTimeFromString(t, "2024-02-06T15:00:00.000Z"), + }, + }) + }, + config: "testdata/TestDataUsersAffected/lost.tf", + expectedChecks: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", "users.#", "1"), + generateExpectedGroup("users.0", "1-EFGH", "ef.gh@test.com", "ef", "gh", "efgh", "F-CO-efgh", ptr.To("2024-02-06T15:00:00Z")), + ), + }, + "validation - missing source": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataUsersAffected/missing-source.tf", + expectedError: regexp.MustCompile("Missing required argument(.|\n)*The argument \"source_group_id\" is required, but no definition was found."), + }, + "validation - missing destination": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataUsersAffected/missing-destination.tf", + expectedError: regexp.MustCompile("Missing required argument(.|\n)*The argument \"destination_group_id\" is required, but no definition was found."), + }, + "validation - incorrect user_type": { + init: func(client *iam.Mock) {}, + config: "testdata/TestDataUsersAffected/incorrect-usertype.tf", + expectedError: regexp.MustCompile("Invalid Attribute Value Match(.|\n)*Attribute user_type value must be one of: \\[\"lostAccess\" \"gainAccess\" \"\"]"), + }, + "api failed": { + init: func(client *iam.Mock) { + client.On("ListAffectedUsers", mock.Anything, iam.ListAffectedUsersRequest{SourceGroupID: 123, DestinationGroupID: 321, UserType: ""}). + Return(nil, errors.New("api failed")) + }, + config: "testdata/TestDataUsersAffected/basic.tf", + expectedError: regexp.MustCompile("api failed"), + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(client) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.config), + Check: test.expectedChecks, + ExpectError: test.expectedError, + }, + }, + }) + }) + }) + } +} diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 892f97ba3..5556409cd 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -107,5 +107,6 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewPasswordPolicyDataSource, NewPropertyUsersDataSource, NewRoleDataSource, + NewUsersAffectedByMovingGroupDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf new file mode 100644 index 000000000..acdae832a --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/basic.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf new file mode 100644 index 000000000..38217c5a9 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/gained.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 + user_type = "gainAccess" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf new file mode 100644 index 000000000..8e3798d00 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/incorrect-usertype.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 + user_type = "incorrect" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf new file mode 100644 index 000000000..23ae9931f --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/lost.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 + destination_group_id = 321 + user_type = "lostAccess" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf new file mode 100644 index 000000000..a70315e20 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-destination.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + source_group_id = 123 +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf new file mode 100644 index 000000000..f13f24a02 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsersAffected/missing-source.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users_affected_by_moving_group" "test" { + destination_group_id = 321 +} \ No newline at end of file From 0aa8ccb3853015a22d3f18c041fc7720bbfe2eb8 Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Wed, 4 Sep 2024 13:13:53 +0000 Subject: [PATCH 33/54] DXE-4063 Remove unnecessary options field from notifications --- pkg/providers/iam/resource_akamai_iam_user.go | 127 +++++++----------- .../iam/resource_akamai_iam_user_test.go | 55 +++----- .../create_basic_notification_and_mfa.tf | 20 ++- ...nable_email_notifications_field_missing.tf | 20 ++- ...tification_multiple_notification_blocks.tf | 38 ++++++ ...sic_notification_multiple_options_block.tf | 39 ------ ...asic_notification_options_block_missing.tf | 17 --- ...ification_password_expiry_field_missing.tf | 18 ++- 8 files changed, 130 insertions(+), 204 deletions(-) create mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf delete mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf delete mode 100644 pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 49911e1fb..742564835 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -200,47 +200,37 @@ func resourceIAMUser() *schema.Resource { MaxItems: 1, // Ensure only one notification configuration can be set Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "options": { + "api_client_credential_expiry_notification": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Enables notifications for expiring API client credentials", + }, + "new_user_notification": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Enables notifications for group administrators when the user creates other new users", + }, + "password_expiry": { + Type: schema.TypeBool, + Required: true, + Description: "Enables notifications for expiring passwords", + }, + "proactive": { + Type: schema.TypeList, + Required: true, + Description: "Products for which the user gets notifications for service issues", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "upgrade": { Type: schema.TypeList, Required: true, - Description: "Specifies email notifications settings.", - MaxItems: 1, // Ensure only one options configuration can be set - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "api_client_credential_expiry_notification": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: "Enables notifications for expiring API client credentials", - }, - "new_user_notification": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "Enables notifications for group administrators when the user creates other new users", - }, - "password_expiry": { - Type: schema.TypeBool, - Required: true, - Description: "Enables notifications for expiring passwords", - }, - "proactive": { - Type: schema.TypeList, - Required: true, - Description: "Products for which the user gets notifications for service issues", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "upgrade": { - Type: schema.TypeList, - Required: true, - Description: "Products for which the user receives notifications for upgrades", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, + Description: "Products for which the user receives notifications for upgrades", + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, "enable_email_notifications": { @@ -373,32 +363,19 @@ func extractUserNotificationsData(notificationsData interface{}) (*iam.UserNotif return nil, errors.New("user notifications data is not a valid list") } - item, ok := notificationsList[0].(map[string]interface{}) + itemMap, ok := notificationsList[0].(map[string]interface{}) if !ok { return nil, errors.New("user notifications data item is not a valid map") } - options, ok := item["options"].([]interface{}) - if !ok { - return nil, errors.New("options field in user notifications data is not a valid list") - } - - var optionsMap map[string]interface{} - if len(options) > 0 { - optionsMap, ok = options[0].(map[string]interface{}) - if !ok { - return nil, errors.New("options field item is not a valid map") - } - } - return &iam.UserNotifications{ - EnableEmail: item["enable_email_notifications"].(bool), + EnableEmail: itemMap["enable_email_notifications"].(bool), Options: iam.UserNotificationOptions{ - APIClientCredentialExpiry: optionsMap["api_client_credential_expiry_notification"].(bool), - NewUser: optionsMap["new_user_notification"].(bool), - PasswordExpiry: optionsMap["password_expiry"].(bool), - Proactive: tf.InterfaceSliceToStringSlice(optionsMap["proactive"].([]interface{})), - Upgrade: tf.InterfaceSliceToStringSlice(optionsMap["upgrade"].([]interface{})), + APIClientCredentialExpiry: itemMap["api_client_credential_expiry_notification"].(bool), + NewUser: itemMap["new_user_notification"].(bool), + PasswordExpiry: itemMap["password_expiry"].(bool), + Proactive: tf.InterfaceSliceToStringSlice(itemMap["proactive"].([]interface{})), + Upgrade: tf.InterfaceSliceToStringSlice(itemMap["upgrade"].([]interface{})), }, }, nil } @@ -462,16 +439,12 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac } userNotifications := []interface{}{map[string]interface{}{ - "enable_email_notifications": user.Notifications.EnableEmail, - "options": []interface{}{ - map[string]interface{}{ - "api_client_credential_expiry_notification": user.Notifications.Options.APIClientCredentialExpiry, - "new_user_notification": user.Notifications.Options.NewUser, - "password_expiry": user.Notifications.Options.PasswordExpiry, - "proactive": user.Notifications.Options.Proactive, - "upgrade": user.Notifications.Options.Upgrade, - }, - }, + "enable_email_notifications": user.Notifications.EnableEmail, + "api_client_credential_expiry_notification": user.Notifications.Options.APIClientCredentialExpiry, + "new_user_notification": user.Notifications.Options.NewUser, + "password_expiry": user.Notifications.Options.PasswordExpiry, + "proactive": user.Notifications.Options.Proactive, + "upgrade": user.Notifications.Options.Upgrade, }, } @@ -871,16 +844,12 @@ func customizeNotificationDiff(_ context.Context, d *schema.ResourceDiff, _ inte // Field is omitted, so apply the default configuration defaultConfig := []interface{}{ map[string]interface{}{ - "enable_email_notifications": true, - "options": []interface{}{ - map[string]interface{}{ - "api_client_credential_expiry_notification": false, - "new_user_notification": true, - "password_expiry": true, - "proactive": []interface{}{}, - "upgrade": []interface{}{}, - }, - }, + "enable_email_notifications": true, + "api_client_credential_expiry_notification": false, + "new_user_notification": true, + "password_expiry": true, + "proactive": []interface{}{}, + "upgrade": []interface{}{}, }, } if err := d.SetNew("user_notifications", defaultConfig); err != nil { diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index 071b732f1..65d32fc84 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -197,11 +197,11 @@ func TestResourceUser(t *testing.T) { checkDefaultUserNotificationsAttributes := func(user iam.User) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.#", "1"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.new_user_notification", "true"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.password_expiry", "true"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.proactive.#", "0"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.upgrade.#", "0"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.api_client_credential_expiry_notification", "false"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.new_user_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.password_expiry", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.proactive.#", "0"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.upgrade.#", "0"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.api_client_credential_expiry_notification", "false"), resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true")) } @@ -209,11 +209,11 @@ func TestResourceUser(t *testing.T) { return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.#", "1"), resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.new_user_notification", "true"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.password_expiry", "true"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.proactive.#", "1"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.upgrade.#", "1"), - resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.options.0.api_client_credential_expiry_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.new_user_notification", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.password_expiry", "true"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.proactive.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.upgrade.#", "1"), + resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.api_client_credential_expiry_notification", "true"), resource.TestCheckResourceAttr("akamai_iam_user.test", "user_notifications.0.enable_email_notifications", "true")) } @@ -392,9 +392,7 @@ func TestResourceUser(t *testing.T) { }, }, "basic - custom notification - password_expiry field missing": { - init: func(m *iam.Mock) { - - }, + init: func(m *iam.Mock) {}, steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf"), @@ -402,32 +400,17 @@ func TestResourceUser(t *testing.T) { }, }, }, - "basic - custom notification - options block missing": { - init: func(m *iam.Mock) { - - }, - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf"), - ExpectError: regexp.MustCompile("At least 1 \"options\" blocks are required."), - }, - }, - }, - "basic - custom notification - multiple options block": { - init: func(m *iam.Mock) { - - }, + "basic - custom notification - multiple user_notification blocks": { + init: func(m *iam.Mock) {}, steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf"), - ExpectError: regexp.MustCompile("No more than 1 \"options\" blocks are allowed"), + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf"), + ExpectError: regexp.MustCompile("No more than 1 \"user_notifications\" blocks are allowed"), }, }, }, "basic - custom notification - enable_email_notifications missing": { - init: func(m *iam.Mock) { - - }, + init: func(m *iam.Mock) {}, steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf"), @@ -507,8 +490,7 @@ func TestResourceUser(t *testing.T) { }, }, "enable_tfa and enable_mfa set to true - error": { - init: func(m *iam.Mock) { - }, + init: func(m *iam.Mock) {}, steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_with_invalid_auth_method.tf"), @@ -761,8 +743,7 @@ func TestResourceUser(t *testing.T) { }, }, "auth_grants_json should not panic when supplied interpolated string with unknown value": { - init: func(m *iam.Mock) { - }, + init: func(m *iam.Mock) {}, steps: []resource.TestStep{ { Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/auth_grants_interpolated.tf"), diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf index c668a1a36..e913c9799 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_and_mfa.tf @@ -12,17 +12,15 @@ resource "akamai_iam_user" "test" { enable_mfa = true auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" user_notifications { - options { - api_client_credential_expiry_notification = true - new_user_notification = true - password_expiry = true - proactive = [ - "EdgeScape", - ] - upgrade = [ - "NetStorage", - ] - } + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] enable_email_notifications = true } } \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf index 64292b6df..035416472 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_enable_email_notifications_field_missing.tf @@ -12,16 +12,14 @@ resource "akamai_iam_user" "test" { enable_mfa = true auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" user_notifications { - options { - api_client_credential_expiry_notification = true - new_user_notification = true - password_expiry = true - proactive = [ - "EdgeScape", - ] - upgrade = [ - "NetStorage", - ] - } + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] } } \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf new file mode 100644 index 000000000..088be9bbb --- /dev/null +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_notification_blocks.tf @@ -0,0 +1,38 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_user" "test" { + first_name = "John" + last_name = "Smith" + email = "jsmith@example.com" + country = "country" + phone = "(111) 111-1111" + enable_tfa = false + enable_mfa = true + auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" + user_notifications { + api_client_credential_expiry_notification = true + new_user_notification = true + password_expiry = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + enable_email_notifications = true + } + user_notifications { + api_client_credential_expiry_notification = false + new_user_notification = true + password_expiry = false + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] + enable_email_notifications = true + } +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf deleted file mode 100644 index 54d9a87cc..000000000 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_multiple_options_block.tf +++ /dev/null @@ -1,39 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - enable_mfa = true - auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" - user_notifications { - options { - api_client_credential_expiry_notification = true - new_user_notification = true - password_expiry = true - proactive = [ - "EdgeScape", - ] - upgrade = [ - "NetStorage", - ] - } - options { - api_client_credential_expiry_notification = true - new_user_notification = true - password_expiry = true - proactive = [ - "EdgeScape", - ] - upgrade = [ - "NetStorage", - ] - } - enable_email_notifications = true - } -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf deleted file mode 100644 index 835a6828c..000000000 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_options_block_missing.tf +++ /dev/null @@ -1,17 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_user" "test" { - first_name = "John" - last_name = "Smith" - email = "jsmith@example.com" - country = "country" - phone = "(111) 111-1111" - enable_tfa = false - enable_mfa = true - auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" - user_notifications { - enable_email_notifications = true - } -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf index 4e595d497..ad4c96db8 100644 --- a/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf +++ b/pkg/providers/iam/testdata/TestResourceUserLifecycle/create_basic_notification_password_expiry_field_missing.tf @@ -12,16 +12,14 @@ resource "akamai_iam_user" "test" { enable_mfa = true auth_grants_json = "[{\"groupId\":0,\"groupName\":\"group\",\"roleDescription\":\"\",\"roleName\":\"\"}]" user_notifications { - options { - api_client_credential_expiry_notification = true - new_user_notification = true - proactive = [ - "EdgeScape", - ] - upgrade = [ - "NetStorage", - ] - } + api_client_credential_expiry_notification = true + new_user_notification = true + proactive = [ + "EdgeScape", + ] + upgrade = [ + "NetStorage", + ] enable_email_notifications = true } } \ No newline at end of file From 8f0e0d0fb87f87df06a3f0879fb585edad308bfe Mon Sep 17 00:00:00 2001 From: Filip Antkowiak Date: Wed, 4 Sep 2024 17:18:07 +0000 Subject: [PATCH 34/54] DXE-4032 Implement iam_cidr_blocks data source --- CHANGELOG.md | 3 + ...pis.go => data_akamai_iam_allowed_apis.go} | 0 ...o => data_akamai_iam_allowed_apis_test.go} | 0 ...block.go => data_akamai_iam_cidr_block.go} | 0 ....go => data_akamai_iam_cidr_block_test.go} | 0 .../iam/data_akamai_iam_cidr_blocks.go | 171 ++++++++++++++++++ .../iam/data_akamai_iam_cidr_blocks_test.go | 113 ++++++++++++ pkg/providers/iam/iam_errors.go | 2 + pkg/providers/iam/provider.go | 1 + .../testdata/TestDataCIDRBlocks/default.tf | 6 + 10 files changed, 296 insertions(+) rename pkg/providers/iam/{data_akamai_allowed_apis.go => data_akamai_iam_allowed_apis.go} (100%) rename pkg/providers/iam/{data_akamai_allowed_apis_test.go => data_akamai_iam_allowed_apis_test.go} (100%) rename pkg/providers/iam/{data_akamai_cidr_block.go => data_akamai_iam_cidr_block.go} (100%) rename pkg/providers/iam/{data_akamai_cidr_block_test.go => data_akamai_iam_cidr_block_test.go} (100%) create mode 100644 pkg/providers/iam/data_akamai_iam_cidr_blocks.go create mode 100644 pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go create mode 100644 pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index b2311e131..9418327e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,9 @@ +* IAM + * Added new data source: + * `akamai_iam_cidr_blocks` - read the CIDR blocks details diff --git a/pkg/providers/iam/data_akamai_allowed_apis.go b/pkg/providers/iam/data_akamai_iam_allowed_apis.go similarity index 100% rename from pkg/providers/iam/data_akamai_allowed_apis.go rename to pkg/providers/iam/data_akamai_iam_allowed_apis.go diff --git a/pkg/providers/iam/data_akamai_allowed_apis_test.go b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go similarity index 100% rename from pkg/providers/iam/data_akamai_allowed_apis_test.go rename to pkg/providers/iam/data_akamai_iam_allowed_apis_test.go diff --git a/pkg/providers/iam/data_akamai_cidr_block.go b/pkg/providers/iam/data_akamai_iam_cidr_block.go similarity index 100% rename from pkg/providers/iam/data_akamai_cidr_block.go rename to pkg/providers/iam/data_akamai_iam_cidr_block.go diff --git a/pkg/providers/iam/data_akamai_cidr_block_test.go b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go similarity index 100% rename from pkg/providers/iam/data_akamai_cidr_block_test.go rename to pkg/providers/iam/data_akamai_iam_cidr_block_test.go diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go new file mode 100644 index 000000000..485b1c5e4 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go @@ -0,0 +1,171 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &cidrBlocksDataSource{} + _ datasource.DataSourceWithConfigure = &cidrBlocksDataSource{} +) + +type ( + cidrBlocksDataSource struct { + meta meta.Meta + } + + cidrBlocksSourceModel struct { + CIDRBlocks []cidrBlockSourceModel `tfsdk:"cidr_blocks"` + } +) + +// NewCIDRBlocksDataSource returns a new iam CIDR block data source +func NewCIDRBlocksDataSource() datasource.DataSource { + return &cidrBlocksDataSource{} +} + +// Metadata configures data source's meta information +func (d *cidrBlocksDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_blocks" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *cidrBlocksDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *cidrBlocksDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management CIDR block", + Attributes: map[string]schema.Attribute{ + "cidr_blocks": schema.ListNestedAttribute{ + Description: "List of CIDR blocks on account's allowlist", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block.", + }, + }, + }, + "cidr_block": schema.StringAttribute{ + Computed: true, + Description: "The value of an IP address or IP address range.", + }, + "cidr_block_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each CIDR block.", + }, + "comments": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + }, + "enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether the CIDR block is enabled.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + }, + }, + }, + }, + }, + } +} + +// Read is called when the provider must read data source values in order to update state +func (d *cidrBlocksDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM CIDR Blocks DataSource Read") + + var data cidrBlocksSourceModel + + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + cidrBlocks, err := client.ListCIDRBlocks(ctx, iam.ListCIDRBlocksRequest{ + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMListCIDRBlocks), err.Error()) + return + } + + if resp.Diagnostics.Append(data.read(cidrBlocks)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + +} + +func (d *cidrBlocksSourceModel) read(cidrBlocks *iam.ListCIDRBlocksResponse) diag.Diagnostics { + for _, cidrBlock := range *cidrBlocks { + block := cidrBlockSourceModel{ + CIDRBlock: types.StringValue(cidrBlock.CIDRBlock), + Enabled: types.BoolValue(cidrBlock.Enabled), + Comments: types.StringValue(cidrBlock.Comments), + CIDRBlockID: types.Int64Value(cidrBlock.CIDRBlockID), + CreatedBy: types.StringValue(cidrBlock.CreatedBy), + CreatedDate: types.StringValue(cidrBlock.CreatedDate.Format(time.RFC3339Nano)), + ModifiedBy: types.StringValue(cidrBlock.ModifiedBy), + ModifiedDate: types.StringValue(cidrBlock.ModifiedDate.Format(time.RFC3339Nano)), + } + if cidrBlock.Actions != nil { + block.Actions = &actions{ + Delete: types.BoolValue(cidrBlock.Actions.Delete), + Edit: types.BoolValue(cidrBlock.Actions.Edit), + } + } + + d.CIDRBlocks = append(d.CIDRBlocks, block) + } + + return nil +} diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go new file mode 100644 index 000000000..6d940e6b8 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go @@ -0,0 +1,113 @@ +package iam + +import ( + "errors" + "regexp" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +func TestDataCIDRBlocks(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*iam.Mock) + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataCIDRBlocks/default.tf", + init: func(m *iam.Mock) { + listCIDRBlocksReq := iam.ListCIDRBlocksRequest{Actions: true} + listCIDRBlocksResp := iam.ListCIDRBlocksResponse{ + { + Actions: &iam.CIDRActions{ + Delete: true, + Edit: false, + }, + CIDRBlock: "128.5.6.6/24", + CIDRBlockID: 2567, + Comments: "APAC Region", + CreatedBy: "user1", + CreatedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + Enabled: true, + ModifiedBy: "user1", + ModifiedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + }, + { + Actions: &iam.CIDRActions{ + Delete: true, + Edit: false, + }, + CIDRBlock: "128.5.6.6/24", + CIDRBlockID: 6042, + Comments: "East Coast Office", + CreatedBy: "user2", + CreatedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + Enabled: true, + ModifiedBy: "user3", + ModifiedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), + }, + } + m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(&listCIDRBlocksResp, nil).Times(5) + }, + }, + "error - ListCIDRBlocks call failed ": { + configPath: "testdata/TestDataCIDRBlocks/default.tf", + init: func(m *iam.Mock) { + listCIDRBlocksReq := iam.ListCIDRBlocksRequest{Actions: true} + m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(nil, errors.New("test error")) + }, + error: regexp.MustCompile("test error"), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(client) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkCIDRBlocksAttrs(), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkCIDRBlocksAttrs() resource.TestCheckFunc { + name := "data.akamai_iam_cidr_blocks.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "cidr_blocks.#", "2"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.cidr_block_id", "2567"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.cidr_block", "128.5.6.6/24"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.comments", "APAC Region"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.created_by", "user1"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.created_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.enabled", "true"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.modified_by", "user1"), + resource.TestCheckResourceAttr(name, "cidr_blocks.0.modified_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.cidr_block_id", "6042"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.cidr_block", "128.5.6.6/24"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.comments", "East Coast Office"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.created_by", "user2"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.created_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.enabled", "true"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.modified_by", "user3"), + resource.TestCheckResourceAttr(name, "cidr_blocks.1.modified_date", "2017-07-27T18:11:25Z"), + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} diff --git a/pkg/providers/iam/iam_errors.go b/pkg/providers/iam/iam_errors.go index 2ce76cc30..2c3b587bf 100644 --- a/pkg/providers/iam/iam_errors.go +++ b/pkg/providers/iam/iam_errors.go @@ -7,4 +7,6 @@ var ( ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") + // ErrIAMListCIDRBlocks is returned when ListCIDRBlocks fails + ErrIAMListCIDRBlocks = errors.New("IAM list CIDR blocks failed") ) diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 5556409cd..b562e83f0 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -103,6 +103,7 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewAuthorizedUsersDataSource, NewBlockedPropertiesDataSource, NewCIDRBlockDataSource, + NewCIDRBlocksDataSource, NewGroupDataSource, NewPasswordPolicyDataSource, NewPropertyUsersDataSource, diff --git a/pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf b/pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf new file mode 100644 index 000000000..084f79804 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataCIDRBlocks/default.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_cidr_blocks" "test" { +} From 140d60a2beae392b54762226b48850834fc588b9 Mon Sep 17 00:00:00 2001 From: Wojciech Zagrajczuk Date: Fri, 6 Sep 2024 08:09:52 +0000 Subject: [PATCH 35/54] DXE-3948 Adjust mocks after bump of testing library, enhance mocks --- .../iam/data_akamai_iam_accessible_groups_test.go | 15 ++++++++------- .../data_akamai_iam_account_switch_keys_test.go | 4 ++-- .../iam/data_akamai_iam_allowed_apis_test.go | 4 ++-- .../iam/data_akamai_iam_authorized_users_test.go | 2 +- .../iam/data_akamai_iam_cidr_block_test.go | 2 +- .../iam/data_akamai_iam_cidr_blocks_test.go | 2 +- pkg/providers/iam/data_akamai_iam_group_test.go | 13 +++++++------ .../iam/data_akamai_iam_password_policy_test.go | 2 +- .../iam/data_akamai_iam_property_users_test.go | 2 +- pkg/providers/iam/data_akamai_iam_role_test.go | 4 ++-- ...mai_iam_users_affected_by_moving_group_test.go | 5 +++-- 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go index d1d2fbf22..58d07a554 100644 --- a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go @@ -15,8 +15,8 @@ import ( ) func TestAccessibleGroups(t *testing.T) { - mockPositiveCase := func(client *iam.Mock, returnedGroups iam.ListAccessibleGroupsResponse) *mock.Call { - return client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(returnedGroups, nil).Times(5) + mockPositiveCase := func(client *iam.Mock, returnedGroups iam.ListAccessibleGroupsResponse, times int) *mock.Call { + return client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(returnedGroups, nil).Times(times) } generateCheckForGroup := func(path, groupID, groupName, isBlocked, roleDescription, roleID, roleName, subGroupsNumber string) resource.TestCheckFunc { @@ -113,7 +113,7 @@ func TestAccessibleGroups(t *testing.T) { }, }, } - mockPositiveCase(client, returnedGroups) + mockPositiveCase(client, returnedGroups, 3) }, config: "testdata/TestDataAccessibleGroups/basic.tf", expectedChecks: resource.ComposeAggregateTestCheckFunc( @@ -138,7 +138,7 @@ func TestAccessibleGroups(t *testing.T) { SubGroups: generateSubGroups(50, 123), }, } - mockPositiveCase(client, returnedGroups) + mockPositiveCase(client, returnedGroups, 3) }, config: "testdata/TestDataAccessibleGroups/basic.tf", expectedChecks: resource.ComposeAggregateTestCheckFunc( @@ -151,7 +151,7 @@ func TestAccessibleGroups(t *testing.T) { }, "normal case - empty response": { init: func(client *iam.Mock) { - mockPositiveCase(client, []iam.AccessibleGroup{}) + mockPositiveCase(client, []iam.AccessibleGroup{}, 3) }, config: "testdata/TestDataAccessibleGroups/basic.tf", expectedChecks: resource.ComposeAggregateTestCheckFunc( @@ -172,14 +172,14 @@ func TestAccessibleGroups(t *testing.T) { SubGroups: generateSubGroups(51, 123), }, } - mockPositiveCase(client, returnedGroups) + mockPositiveCase(client, returnedGroups, 1) }, config: "testdata/TestDataAccessibleGroups/basic.tf", expectedError: regexp.MustCompile("unsupported subgroup depth"), }, "error - api failed": { init: func(client *iam.Mock) { - client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(nil, errors.New("api failed")).Times(5) + client.On("ListAccessibleGroups", mock.Anything, iam.ListAccessibleGroupsRequest{UserName: "user1"}).Return(nil, errors.New("api failed")).Times(1) }, config: "testdata/TestDataAccessibleGroups/basic.tf", expectedError: regexp.MustCompile("api failed"), @@ -209,6 +209,7 @@ func TestAccessibleGroups(t *testing.T) { }, }) }) + client.AssertExpectations(t) }) } } diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go index 8a7b1befc..eeb347164 100644 --- a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go @@ -48,13 +48,13 @@ func TestAccountSwitchKeys(t *testing.T) { "happy path": { givenTF: "default.tf", init: func(m *iam.Mock) { - expectListAccountSwitchKeys(m, "", "", 5) + expectListAccountSwitchKeys(m, "", "", 3) }, }, "happy path with correct filter": { givenTF: "default_correct_filter.tf", init: func(m *iam.Mock) { - expectListAccountSwitchKeys(m, "XYZ", "ABC", 5) + expectListAccountSwitchKeys(m, "XYZ", "ABC", 3) }, }, "incorrect filter": { diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go index 2602c156c..01aa05e0a 100644 --- a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go @@ -99,14 +99,14 @@ func TestDataAllowedAPIs(t *testing.T) { "happy path": { configPath: "testdata/TestDataAllowedAPIs/default.tf", init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { - expectFullListAllowedAPIs(t, m, testData, 5) + expectFullListAllowedAPIs(t, m, testData, 3) }, mockData: basicTestDataForAllowedAPIs, }, "happy path no optional values": { configPath: "testdata/TestDataAllowedAPIs/default_no_optional.tf", init: func(t *testing.T, m *iam.Mock, testData testDataForAllowedAPIs) { - expectFullListAllowedAPIs(t, m, testData, 5) + expectFullListAllowedAPIs(t, m, testData, 3) }, mockData: basicTestDataForAllowedAPIsNoOptional, }, diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go index 1482c8a2e..f4cc10a1e 100644 --- a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go @@ -58,7 +58,7 @@ func TestAuthorizedUsers(t *testing.T) { "success path": { configPath: "testdata/TestAuthorizedUsers/default.tf", init: func(t *testing.T, m *iam.Mock, testData testDataForAuthorizedUsers) { - expectFullListAuthorizedUsers(t, m, testData, 5) + expectFullListAuthorizedUsers(t, m, testData, 3) }, mockData: basicTestDataForAuthorizedUsers, }, diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go index e421a57ab..8f02341ad 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go @@ -58,7 +58,7 @@ func TestDataCIDRBlock(t *testing.T) { "happy path": { configPath: "testdata/TestDataCIDRBlock/default.tf", init: func(t *testing.T, m *iam.Mock, mockData testDataForCIDRBlock) { - expectGetCIDRBlock(t, m, mockData, 5) + expectGetCIDRBlock(t, m, mockData, 3) }, mockData: basicTestDataForCIDRBlock, }, diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go index 6d940e6b8..f4fc09a5c 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go @@ -52,7 +52,7 @@ func TestDataCIDRBlocks(t *testing.T) { ModifiedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), }, } - m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(&listCIDRBlocksResp, nil).Times(5) + m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(&listCIDRBlocksResp, nil).Times(3) }, }, "error - ListCIDRBlocks call failed ": { diff --git a/pkg/providers/iam/data_akamai_iam_group_test.go b/pkg/providers/iam/data_akamai_iam_group_test.go index 387dac793..9a6b50dbb 100644 --- a/pkg/providers/iam/data_akamai_iam_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_group_test.go @@ -14,11 +14,11 @@ import ( ) func TestGroupDataSource(t *testing.T) { - mockGetGroup := func(client *iam.Mock, group *iam.Group) *mock.Call { + mockGetGroup := func(client *iam.Mock, group *iam.Group, times int) *mock.Call { return client.On("GetGroup", mock.Anything, iam.GetGroupRequest{ GroupID: 123, Actions: true, - }).Return(group, nil) + }).Return(group, nil).Times(times) } tests := map[string]struct { @@ -43,7 +43,7 @@ func TestGroupDataSource(t *testing.T) { }, SubGroups: []iam.Group{}, } - mockGetGroup(client, group) + mockGetGroup(client, group, 3) }, expectedChecks: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_id", "123"), @@ -76,7 +76,7 @@ func TestGroupDataSource(t *testing.T) { }, }, } - mockGetGroup(client, group) + mockGetGroup(client, group, 3) }, expectedChecks: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.akamai_iam_group.test", "group_id", "123"), @@ -99,7 +99,7 @@ func TestGroupDataSource(t *testing.T) { ParentGroupID: 0, SubGroups: generateDeepSubGroups(51), } - mockGetGroup(client, group) + mockGetGroup(client, group, 1) }, expectedError: regexp.MustCompile("unsupported subgroup depth"), givenTF: "valid.tf", @@ -109,7 +109,7 @@ func TestGroupDataSource(t *testing.T) { client.On("GetGroup", mock.Anything, iam.GetGroupRequest{ GroupID: 123, Actions: true, - }).Return(nil, errors.New("api failed")) + }).Return(nil, errors.New("api failed")).Once() }, expectedError: regexp.MustCompile("api failed"), givenTF: "valid.tf", @@ -139,6 +139,7 @@ func TestGroupDataSource(t *testing.T) { }, }) }) + client.AssertExpectations(t) }) } diff --git a/pkg/providers/iam/data_akamai_iam_password_policy_test.go b/pkg/providers/iam/data_akamai_iam_password_policy_test.go index 32aead9ab..1819a44da 100644 --- a/pkg/providers/iam/data_akamai_iam_password_policy_test.go +++ b/pkg/providers/iam/data_akamai_iam_password_policy_test.go @@ -37,7 +37,7 @@ func TestPasswordPolicy(t *testing.T) { }{ "happy path": { init: func(m *iam.Mock) { - expectGetPasswordPolicy(m, 5) + expectGetPasswordPolicy(m, 3) }, }, "error listing password policy": { diff --git a/pkg/providers/iam/data_akamai_iam_property_users_test.go b/pkg/providers/iam/data_akamai_iam_property_users_test.go index 1eab935dd..096e1cb76 100644 --- a/pkg/providers/iam/data_akamai_iam_property_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_property_users_test.go @@ -39,7 +39,7 @@ func TestDataPropertyUsers(t *testing.T) { mockListUsersForProperty := func(iamMock *iam.Mock, req iam.ListUsersForPropertyRequest, users ...iam.UsersForProperty) { iamMock.On("ListUsersForProperty", mock.Anything, req). - Return((*iam.ListUsersForPropertyResponse)(&users), nil) + Return((*iam.ListUsersForPropertyResponse)(&users), nil).Times(3) } tests := map[string]struct { diff --git a/pkg/providers/iam/data_akamai_iam_role_test.go b/pkg/providers/iam/data_akamai_iam_role_test.go index 9e629743b..172c953bb 100644 --- a/pkg/providers/iam/data_akamai_iam_role_test.go +++ b/pkg/providers/iam/data_akamai_iam_role_test.go @@ -44,7 +44,7 @@ func TestRoleDataSource(t *testing.T) { Delete: true, Edit: true, }, - }, nil) + }, nil).Times(3) }, expectedAttributes: map[string]string{ "role_id": "12345", @@ -68,7 +68,7 @@ func TestRoleDataSource(t *testing.T) { Actions: true, GrantedRoles: true, Users: true, - }).Return(nil, fmt.Errorf("API error")) + }).Return(nil, fmt.Errorf("API error")).Once() }, expectError: regexp.MustCompile("API error"), }, diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go index 7422a0076..5beab1664 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go @@ -18,7 +18,7 @@ func TestUsersAffectedByMovingGroup(t *testing.T) { mockListAffectedUsers := func(client *iam.Mock, userType string, users []iam.GroupUser) *mock.Call { return client.On("ListAffectedUsers", mock.Anything, iam.ListAffectedUsersRequest{SourceGroupID: 123, DestinationGroupID: 321, UserType: userType}). - Return(users, nil) + Return(users, nil).Times(3) } generateExpectedGroup := func(path, accountID, email, firstName, lastName, userName, identityID string, lastLoginDate *string) resource.TestCheckFunc { @@ -132,7 +132,7 @@ func TestUsersAffectedByMovingGroup(t *testing.T) { "api failed": { init: func(client *iam.Mock) { client.On("ListAffectedUsers", mock.Anything, iam.ListAffectedUsersRequest{SourceGroupID: 123, DestinationGroupID: 321, UserType: ""}). - Return(nil, errors.New("api failed")) + Return(nil, errors.New("api failed")).Once() }, config: "testdata/TestDataUsersAffected/basic.tf", expectedError: regexp.MustCompile("api failed"), @@ -157,6 +157,7 @@ func TestUsersAffectedByMovingGroup(t *testing.T) { }, }) }) + client.AssertExpectations(t) }) } } From 73485093cb7fef3b94e8ba37e31c0dd238eacc4f Mon Sep 17 00:00:00 2001 From: Wojciech Zagrajczuk Date: Wed, 11 Sep 2024 09:41:17 +0000 Subject: [PATCH 36/54] DXE-4170 Enhance data_akamai_iam_blocked_properties to return both IDs --- .../iam/data_akamai_iam_blocked_properties.go | 40 +++++++++++------- ...data_akamai_iam_blocked_properties_test.go | 42 +++++++++++-------- 2 files changed, 50 insertions(+), 32 deletions(-) diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties.go b/pkg/providers/iam/data_akamai_iam_blocked_properties.go index 7f25abb54..8494cf37d 100644 --- a/pkg/providers/iam/data_akamai_iam_blocked_properties.go +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties.go @@ -29,10 +29,15 @@ type blockedPropertiesDataSource struct { // blockedPropertiesDataSource describes the data source data model for BlockedPropertiesDataSource type blockedPropertiesDataSourceModel struct { - GroupID types.Int64 `tfsdk:"group_id"` - ContractID types.String `tfsdk:"contract_id"` - UIIdentityID types.String `tfsdk:"ui_identity_id"` - BlockedProperties types.List `tfsdk:"blocked_properties"` + GroupID types.Int64 `tfsdk:"group_id"` + ContractID types.String `tfsdk:"contract_id"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + BlockedProperties []blockedPropertyIDsModel `tfsdk:"blocked_properties"` +} + +type blockedPropertyIDsModel struct { + PropertyID types.String `tfsdk:"property_id"` + AssetID types.Int64 `tfsdk:"asset_id"` } // Metadata configures data source's meta information @@ -57,10 +62,21 @@ func (d *blockedPropertiesDataSource) Schema(_ context.Context, _ datasource.Sch Required: true, Description: "Unique identifier for each user.", }, - "blocked_properties": schema.ListAttribute{ + "blocked_properties": schema.ListNestedAttribute{ Computed: true, - ElementType: types.StringType, Description: "The list of blocked properties.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "property_id": schema.StringAttribute{ + Computed: true, + Description: "PAPI's blocked property ID", + }, + "asset_id": schema.Int64Attribute{ + Computed: true, + Description: "IAM's blocked property ID", + }, + }, + }, }, }, } @@ -106,7 +122,7 @@ func (d *blockedPropertiesDataSource) Read(ctx context.Context, req datasource.R return } - var blockedPropertiesPAPI []string + var blockedProperties []blockedPropertyIDsModel groupID := str.AddPrefix(data.GroupID.String(), "grp_") for _, prop := range listBlockedPropertiesResp { @@ -129,16 +145,10 @@ func (d *blockedPropertiesDataSource) Read(ctx context.Context, req datasource.R return } - blockedPropertiesPAPI = append(blockedPropertiesPAPI, *papiPropertyID) - } - - blockedPropertyIDsPAPI, diags := types.ListValueFrom(ctx, types.StringType, blockedPropertiesPAPI) - if diags.HasError() { - resp.Diagnostics.Append(diags...) - return + blockedProperties = append(blockedProperties, blockedPropertyIDsModel{PropertyID: types.StringValue(*papiPropertyID), AssetID: types.Int64Value(prop)}) } - data.BlockedProperties = blockedPropertyIDsPAPI + data.BlockedProperties = blockedProperties resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go index 399641c9d..089b6d2fc 100644 --- a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go @@ -17,12 +17,12 @@ func TestBlockedPropertiesDataSource(t *testing.T) { propertyName2 := "example2.com" propertyID1 := "prp_123456" propertyID2 := "prp_456789" + tests := map[string]struct { - givenTF string - init func(*iam.Mock, *papi.Mock) - expectedAttributes map[string]string - expectedMissingAttributes []string - expectError *regexp.Regexp + givenTF string + init func(*iam.Mock, *papi.Mock) + expectedCheck resource.TestCheckFunc + expectError *regexp.Regexp }{ "happy path - blocked properties are returned": { givenTF: "valid.tf", @@ -51,11 +51,26 @@ func TestBlockedPropertiesDataSource(t *testing.T) { }).Return(&propertyID2, nil) }, - expectedAttributes: map[string]string{ - "blocked_properties.#": "2", - "blocked_properties.0": "prp_123456", - "blocked_properties.1": "prp_456789", + expectedCheck: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.#", "2"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.0.property_id", "prp_123456"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.0.asset_id", "123"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.1.property_id", "prp_456789"), + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.1.asset_id", "456"), + ), + expectError: nil, + }, + "happy path - no blocked properties are returned": { + givenTF: "valid.tf", + init: func(im *iam.Mock, pm *papi.Mock) { + im.On("ListBlockedProperties", mock.Anything, iam.ListBlockedPropertiesRequest{ + IdentityID: "user123", + GroupID: 1, + }).Return([]int64{}, nil) }, + expectedCheck: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", "blocked_properties.#", "0"), + ), expectError: nil, }, "error response from api": { @@ -89,20 +104,13 @@ func TestBlockedPropertiesDataSource(t *testing.T) { if test.init != nil { test.init(client, papiClient) } - var checkFuncs []resource.TestCheckFunc - for k, v := range test.expectedAttributes { - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_blocked_properties.test", k, v)) - } - for _, v := range test.expectedMissingAttributes { - checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("data.akamai_iam_blocked_properties.test", v)) - } useIAMandPAPIClient(client, papiClient, func() { resource.Test(t, resource.TestCase{ IsUnitTest: true, ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{{ Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataBlockedProperties/%s", test.givenTF)), - Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), + Check: test.expectedCheck, ExpectError: test.expectError, }}, }) From b3bde4b060a00af0a005012a79a8700f3a8399eb Mon Sep 17 00:00:00 2001 From: Michal Mazur Date: Wed, 11 Sep 2024 13:01:12 +0000 Subject: [PATCH 37/54] DXE-4031 implement iam user data source --- CHANGELOG.md | 3 + pkg/providers/iam/data_akamai_iam_user.go | 497 ++++++++++++++++ .../iam/data_akamai_iam_user_test.go | 532 ++++++++++++++++++ pkg/providers/iam/iam_errors.go | 2 + pkg/providers/iam/provider.go | 1 + .../iam/testdata/TestDataUser/default.tf | 7 + .../TestDataUser/missing_ui_identity.tf | 6 + 7 files changed, 1048 insertions(+) create mode 100644 pkg/providers/iam/data_akamai_iam_user.go create mode 100644 pkg/providers/iam/data_akamai_iam_user_test.go create mode 100644 pkg/providers/iam/testdata/TestDataUser/default.tf create mode 100644 pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 9418327e1..6c1b0d4ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,9 @@ +* IAM + * Added new data source + * `akamai_iam_user` - read details about a specific user account diff --git a/pkg/providers/iam/data_akamai_iam_user.go b/pkg/providers/iam/data_akamai_iam_user.go new file mode 100644 index 000000000..076788062 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_user.go @@ -0,0 +1,497 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &userDataSource{} + _ datasource.DataSourceWithConfigure = &userDataSource{} +) + +type ( + //userDataSource defines iam user datasource + userDataSource struct { + meta meta.Meta + } + //userDataSourceModel defines structure of datasource attributes + userDataSourceModel struct { + UIIdentityID types.String `tfsdk:"ui_identity_id"` + AccountID types.String `tfsdk:"account_id"` + Actions *actionsModel `tfsdk:"actions"` + AdditionalAuthentication types.String `tfsdk:"additional_authentication"` + AdditionalAuthenticationConfigured types.Bool `tfsdk:"additional_authentication_configured"` + Address types.String `tfsdk:"address"` + AuthGrants []*authGrantsModel `tfsdk:"auth_grants"` + City types.String `tfsdk:"city"` + ContactType types.String `tfsdk:"contact_type"` + Country types.String `tfsdk:"country"` + Email types.String `tfsdk:"email"` + EmailUpdatePending types.Bool `tfsdk:"email_update_pending"` + FirstName types.String `tfsdk:"first_name"` + IsLocked types.Bool `tfsdk:"is_locked"` + JobTitle types.String `tfsdk:"job_title"` + LastLoginDate types.String `tfsdk:"last_login_date"` + LastName types.String `tfsdk:"last_name"` + MobilePhone types.String `tfsdk:"mobile_phone"` + Notifications *notificationsModel `tfsdk:"notifications"` + PasswordExpiryDate types.String `tfsdk:"password_expiry_date"` + Phone types.String `tfsdk:"phone"` + PreferredLanguage types.String `tfsdk:"preferred_language"` + SecondaryEmail types.String `tfsdk:"secondary_email"` + SessionTimeout types.Int64 `tfsdk:"session_timeout"` + State types.String `tfsdk:"state"` + TFAConfigured types.Bool `tfsdk:"tfa_configured"` + TFAEnabled types.Bool `tfsdk:"tfa_enabled"` + TimeZone types.String `tfsdk:"time_zone"` + UIUserName types.String `tfsdk:"ui_user_name"` + ZIPCode types.String `tfsdk:"zip_code"` + } + + actionsModel struct { + Delete types.Bool `tfsdk:"delete"` + APIClient types.Bool `tfsdk:"api_client"` + Edit types.Bool `tfsdk:"edit"` + IsCloneable types.Bool `tfsdk:"is_cloneable"` + ResetPassword types.Bool `tfsdk:"reset_password"` + ThirdPartyAccess types.Bool `tfsdk:"third_party_access"` + } + authGrantsModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + RoleDescription types.String `tfsdk:"role_description"` + RoleID types.Int64 `tfsdk:"role_id"` + RoleName types.String `tfsdk:"role_name"` + SubGroups []*authGrantsModel `tfsdk:"sub_groups"` + } + notificationsModel struct { + Options optionsModel `tfsdk:"options"` + EnableEmailNotifications types.Bool `tfsdk:"enable_email_notifications"` + } + + optionsModel struct { + APIClientCredentialExpiryNotification types.Bool `tfsdk:"api_client_credential_expiry_notification"` + NewUserNotification types.Bool `tfsdk:"new_user_notification"` + PasswordExpiry types.Bool `tfsdk:"password_expiry"` + Proactive []types.String `tfsdk:"proactive"` + Upgrade []types.String `tfsdk:"upgrade"` + } +) + +// NewUserDataSource returns a new iam allowed APIs data source +func NewUserDataSource() datasource.DataSource { + return &userDataSource{} +} + +// Metadata configures data source's meta information +func (d *userDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_user" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *userDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "IAM User Data Source", + Attributes: map[string]schema.Attribute{ + "ui_identity_id": schema.StringAttribute{ + Required: true, + Description: "Unique identifier for each user.", + }, + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each account.", + }, + "actions": schema.SingleNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is deletable.", + }, + "api_client": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to create an API client.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is editable.", + }, + "is_cloneable": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to create a new user with permissions cloned from this user.", + }, + "reset_password": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to send a user a password by email or see a one-time token.", + }, + "third_party_access": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to manage extended access.", + }, + }, + }, + "additional_authentication": schema.StringAttribute{ + Computed: true, + Description: "Specifies the user's multi-factor authentication method, confirming their identity.", + }, + "additional_authentication_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user has multi-factor authentication configured.", + }, + "address": schema.StringAttribute{ + Computed: true, + Description: "The user's street address.", + }, + "auth_grants": schema.ListNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "sub_groups": nestedAuthGrant(maxSupportedGroupNesting), + }, + }, + }, + "city": schema.StringAttribute{ + Computed: true, + Description: "The user's city.", + }, + "contact_type": schema.StringAttribute{ + Computed: true, + Description: "User's contact type.", + }, + "country": schema.StringAttribute{ + Computed: true, + Description: "User's country.", + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "email_update_pending": schema.BoolAttribute{ + Computed: true, + Description: "Whether there are any pending changes to the email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "is_locked": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user's account is locked.", + }, + "job_title": schema.StringAttribute{ + Computed: true, + Description: "The user's position at the company.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "mobile_phone": schema.StringAttribute{ + Computed: true, + Description: "The user's mobile phone number, represented as a ten-digit integer within a string.", + }, + "notifications": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies email notifications the user receives for products.", + Attributes: map[string]schema.Attribute{ + "options": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "api_client_credential_expiry_notification": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user gets notifications for expiring API client credentials.", + }, + "new_user_notification": schema.BoolAttribute{ + Computed: true, + Description: "Whether group administrators get notifications when the user creates other new users.", + }, + "password_expiry": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user gets notifications for password expiration.", + }, + "proactive": schema.ListAttribute{ + Computed: true, + Description: "Products for which the user gets notifications for service issues.", + ElementType: types.StringType, + }, + "upgrade": schema.ListAttribute{ + Computed: true, + Description: "Products for which the user receives notifications for upgrades.", + ElementType: types.StringType, + }, + }, + }, + "enable_email_notifications": schema.BoolAttribute{ + Computed: true, + Description: "Enables email notifications.", + }, + }, + }, + "password_expiry_date": schema.StringAttribute{ + Computed: true, + Description: "The date a user's password expires.", + }, + "phone": schema.StringAttribute{ + Computed: true, + Description: "The user's main phone number.", + }, + "preferred_language": schema.StringAttribute{ + Computed: true, + Description: "The user's language.", + }, + "secondary_email": schema.StringAttribute{ + Computed: true, + Description: "The user's alternate email address.", + }, + "session_timeout": schema.Int64Attribute{ + Computed: true, + Description: "The number of seconds it takes for the user's Control Center session to time out after no activity.", + }, + "state": schema.StringAttribute{ + Computed: true, + Description: "The user's state or province if user's country is USA or Canada.", + }, + "tfa_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is configured.", + }, + "tfa_enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is enabled.", + }, + "time_zone": schema.StringAttribute{ + Computed: true, + Description: "The user's time zone.", + }, + "ui_user_name": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + "zip_code": schema.StringAttribute{ + Computed: true, + Description: "The user's postal code, represented as a string.", + }, + }, + } +} + +func nestedAuthGrant(depth int) *schema.ListNestedAttribute { + authGrant := schema.ListNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + }, + }, + } + if depth > 1 { + authGrant.NestedObject.Attributes["sub_groups"] = nestedAuthGrant(depth - 1) + } + return &authGrant +} + +// Read is called when the provider must read data source values in order to update state +func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Allowed APIs DataSource Read") + + var data userDataSourceModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + user, err := client.GetUser(ctx, iam.GetUserRequest{ + IdentityID: data.UIIdentityID.ValueString(), + Actions: true, + AuthGrants: true, + Notifications: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMGetUser), err.Error()) + return + } + + if resp.Diagnostics.Append(data.setAttributes(user)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + +} + +func (d *userDataSourceModel) setAttributes(user *iam.User) diag.Diagnostics { + d.UIIdentityID = types.StringValue(user.IdentityID) + d.AccountID = types.StringValue(user.AccountID) + d.AdditionalAuthentication = types.StringValue(string(user.AdditionalAuthentication)) + d.AdditionalAuthenticationConfigured = types.BoolValue(user.AdditionalAuthenticationConfigured) + d.Address = types.StringValue(user.Address) + d.City = types.StringValue(user.City) + d.ContactType = types.StringValue(user.ContactType) + d.Country = types.StringValue(user.Country) + d.Email = types.StringValue(user.Email) + d.State = types.StringValue(user.State) + d.EmailUpdatePending = types.BoolValue(user.EmailUpdatePending) + d.FirstName = types.StringValue(user.FirstName) + d.IsLocked = types.BoolValue(user.IsLocked) + d.JobTitle = types.StringValue(user.JobTitle) + if !user.LastLoginDate.IsZero() { + d.LastLoginDate = types.StringValue(user.LastLoginDate.Format(time.RFC3339Nano)) + } + d.LastName = types.StringValue(user.LastName) + d.MobilePhone = types.StringValue(user.MobilePhone) + if !user.PasswordExpiryDate.IsZero() { + d.PasswordExpiryDate = types.StringValue(user.PasswordExpiryDate.Format(time.RFC3339Nano)) + } + d.Phone = types.StringValue(user.Phone) + d.PreferredLanguage = types.StringValue(user.PreferredLanguage) + d.SecondaryEmail = types.StringValue(user.SecondaryEmail) + if user.SessionTimeOut != nil { + d.SessionTimeout = types.Int64Value(int64(*user.SessionTimeOut)) + } + d.TFAEnabled = types.BoolValue(user.TFAEnabled) + d.TFAConfigured = types.BoolValue(user.TFAConfigured) + d.TimeZone = types.StringValue(user.TimeZone) + d.UIUserName = types.StringValue(user.UserName) + d.ZIPCode = types.StringValue(user.ZipCode) + d.Notifications = ¬ificationsModel{ + Options: optionsModel{ + APIClientCredentialExpiryNotification: types.BoolValue(user.Notifications.Options.APIClientCredentialExpiry), + NewUserNotification: types.BoolValue(user.Notifications.Options.NewUser), + PasswordExpiry: types.BoolValue(user.Notifications.Options.PasswordExpiry), + }, + EnableEmailNotifications: types.BoolValue(user.Notifications.EnableEmail), + } + proactiveList := make([]types.String, 0, len(user.Notifications.Options.Proactive)) + for _, proactive := range user.Notifications.Options.Proactive { + proactiveList = append(proactiveList, types.StringValue(proactive)) + } + upgradeList := make([]types.String, 0, len(user.Notifications.Options.Upgrade)) + for _, upgrade := range user.Notifications.Options.Upgrade { + upgradeList = append(upgradeList, types.StringValue(upgrade)) + } + d.Notifications.Options.Proactive = proactiveList + d.Notifications.Options.Upgrade = upgradeList + d.Actions = &actionsModel{ + Delete: types.BoolValue(user.Actions.Delete), + APIClient: types.BoolValue(user.Actions.APIClient), + Edit: types.BoolValue(user.Actions.Edit), + IsCloneable: types.BoolValue(user.Actions.IsCloneable), + ResetPassword: types.BoolValue(user.Actions.ResetPassword), + ThirdPartyAccess: types.BoolValue(user.Actions.ThirdPartyAccess), + } + subGroups, diags := readAuthGrantSubGroups(user.AuthGrants, maxSupportedGroupNesting) + if diags.HasError() { + return diags + } + d.AuthGrants = subGroups + return nil +} + +func readAuthGrantSubGroups(authGrants []iam.AuthGrant, depth int) ([]*authGrantsModel, diag.Diagnostics) { + authGrantModelList := make([]*authGrantsModel, 0, len(authGrants)) + for _, authGrant := range authGrants { + grantModel := authGrantsModel{ + GroupID: types.Int64Value(authGrant.GroupID), + GroupName: types.StringValue(authGrant.GroupName), + IsBlocked: types.BoolValue(authGrant.IsBlocked), + RoleDescription: types.StringValue(authGrant.RoleDescription), + RoleName: types.StringValue(authGrant.RoleName), + } + if authGrant.RoleID != nil { + grantModel.RoleID = types.Int64Value(int64(*authGrant.RoleID)) + } + if depth > 1 { + grants, diags := readAuthGrantSubGroups(authGrant.Subgroups, depth-1) + if diags.HasError() { + return nil, diags + } + grantModel.SubGroups = grants + } else if depth == 1 && authGrant.Subgroups != nil && len(authGrant.Subgroups) > 0 { + return nil, diag.Diagnostics{diag.NewErrorDiagnostic("unsupported subgroup depth", + fmt.Sprintf("AuthGrant %d contains more subgroups and exceed total supported limit of nesting %d.", authGrant.GroupID, maxSupportedGroupNesting))} + } + authGrantModelList = append(authGrantModelList, &grantModel) + } + return authGrantModelList, nil +} diff --git a/pkg/providers/iam/data_akamai_iam_user_test.go b/pkg/providers/iam/data_akamai_iam_user_test.go new file mode 100644 index 000000000..ea6f13d94 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_user_test.go @@ -0,0 +1,532 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +type ( + testDataForUser struct { + uiIdentityID string + accountID string + additionalAuthentication string + additionalAuthenticationConfigured bool + address string + city string + contactType string + country string + email string + emailUpdatePending bool + firstName string + isLocked bool + jobTitle string + lastLoginDate time.Time + lastName string + mobilePhone string + passwordExpiryDate time.Time + phone string + preferredLanguage string + secondaryEmail string + sessionTimeout int64 + state string + tfaConfigured bool + tfaEnabled bool + timeZone string + uiUserName string + zipCode string + actions actionsData + authGrants []authGrantData + notifications notificationData + } + + actionsData struct { + delete bool + apiClient bool + edit bool + isCloneable bool + resetPassword bool + thirdPartyAccess bool + } + + authGrantData struct { + groupID int64 + groupName string + isBlocked bool + roleDescription string + roleID int64 + roleName string + subgroup []*authGrantData + } + notificationData struct { + options optionsData + enableEmailNotifications bool + } + + optionsData struct { + apiClientCredentialExpiryNotification bool + newUserNotification bool + passwordExpiry bool + proactive []string + upgrade []string + } +) + +var ( + basicUserTestData = testDataForUser{ + uiIdentityID: "asd-12345", + uiUserName: "JoeDoeOh", + accountID: "acc-12345", + additionalAuthentication: "NONE", + additionalAuthenticationConfigured: true, + address: "test address 12", + city: "test city", + contactType: "test contact type", + country: "test country", + email: "email@test.com", + emailUpdatePending: true, + firstName: "Joe", + isLocked: true, + jobTitle: "Phd", + lastLoginDate: time.Date(2021, 1, 11, 7, 45, 18, 000, time.UTC), + lastName: "Doe", + mobilePhone: "123-456-789", + passwordExpiryDate: time.Date(2025, 1, 11, 7, 45, 18, 000, time.UTC), + phone: "987-654-321", + preferredLanguage: "English", + secondaryEmail: "seccondEmail@test.com", + sessionTimeout: 1000, + state: "CN", + tfaEnabled: true, + tfaConfigured: true, + timeZone: "UTC", + zipCode: "12-345", + actions: basicActionTestData, + notifications: basicNotificationTesData, + authGrants: append([]authGrantData{}, basicAuthGrantData), + } + basicUserTestDataMaxGroups = testDataForUser{ + uiIdentityID: "asd-12345", + uiUserName: "JoeDoeOh", + accountID: "acc-12345", + additionalAuthentication: "NONE", + additionalAuthenticationConfigured: true, + address: "test address 12", + city: "test city", + contactType: "test contact type", + country: "test country", + email: "email@test.com", + emailUpdatePending: true, + firstName: "Joe", + isLocked: true, + jobTitle: "Phd", + lastLoginDate: time.Date(2021, 1, 11, 7, 45, 18, 000, time.UTC), + lastName: "Doe", + mobilePhone: "123-456-789", + passwordExpiryDate: time.Date(2025, 1, 11, 7, 45, 18, 000, time.UTC), + phone: "987-654-321", + preferredLanguage: "English", + secondaryEmail: "seccondEmail@test.com", + sessionTimeout: 1000, + state: "CN", + tfaEnabled: true, + tfaConfigured: true, + timeZone: "UTC", + zipCode: "12-345", + actions: basicActionTestData, + notifications: basicNotificationTesData, + authGrants: append([]authGrantData{}, basicAuthGrantDataMaxSubgroup), + } + + basicActionTestData = actionsData{ + delete: true, + apiClient: true, + edit: true, + isCloneable: true, + resetPassword: true, + thirdPartyAccess: true, + } + + basicNotificationTesData = notificationData{ + enableEmailNotifications: true, + options: basicOptionsTestData, + } + + basicOptionsTestData = optionsData{ + apiClientCredentialExpiryNotification: true, + newUserNotification: true, + passwordExpiry: true, + proactive: []string{"EdgeScape"}, + upgrade: []string{"NetStorage"}, + } + + basicAuthGrantData = authGrantData{ + roleDescription: "testDesc", + roleName: "admin", + isBlocked: false, + roleID: 1234, + groupID: 1234, + groupName: "TestName", + } + basicAuthGrantDataMaxSubgroup = authGrantData{ + roleDescription: "testDesc", + roleName: "admin", + isBlocked: false, + roleID: 1234, + groupID: 1234, + groupName: "TestName", + subgroup: generateMaxDepthSubGroupsAuthGrantData(maxSupportedGroupNesting), + } +) + +func TestDataUser(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, testDataForUser) + mockData testDataForUser + error *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForUser) { + expectGetUser(t, m, testData, 3) + }, + mockData: basicUserTestData, + }, + "happy path - max amount of sub groups": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForUser) { + expectGetUserMaxAuthGranSubGroups(t, m, testData, 3, maxSupportedGroupNesting) + }, + mockData: basicUserTestDataMaxGroups, + }, + "error - max amount of sub groups + 1": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, testData testDataForUser) { + expectGetUserMaxAuthGranSubGroups(t, m, testData, 1, maxSupportedGroupNesting+1) + }, + error: regexp.MustCompile("unsupported subgroup depth"), + mockData: basicUserTestDataMaxGroups, + }, + "error - missing cidr_block_id": { + configPath: "testdata/TestDataUser/missing_ui_identity.tf", + error: regexp.MustCompile("Missing required argument"), + mockData: basicUserTestData, + }, + "error - GetUser call failed": { + configPath: "testdata/TestDataUser/default.tf", + init: func(t *testing.T, m *iam.Mock, user testDataForUser) { + getUserReq := iam.GetUserRequest{IdentityID: user.uiIdentityID, Actions: true, AuthGrants: true, Notifications: true} + m.On("GetUser", mock.Anything, getUserReq).Return(nil, errors.New("test error")) + }, + error: regexp.MustCompile("test error"), + mockData: basicUserTestData, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.mockData) + } + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkUserAttrs(test.mockData), + ExpectError: test.error, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func expectGetUser(_ *testing.T, client *iam.Mock, data testDataForUser, times int) { + getUserReq := iam.GetUserRequest{ + IdentityID: data.uiIdentityID, + Actions: true, + AuthGrants: true, + Notifications: true, + } + + user := iam.User{ + IdentityID: data.uiIdentityID, + IsLocked: data.isLocked, + LastLoginDate: data.lastLoginDate, + PasswordExpiryDate: data.passwordExpiryDate, + TFAConfigured: data.tfaConfigured, + EmailUpdatePending: data.emailUpdatePending, + AccountID: data.accountID, + AdditionalAuthenticationConfigured: data.additionalAuthenticationConfigured, + UserBasicInfo: iam.UserBasicInfo{ + FirstName: data.firstName, + LastName: data.lastName, + UserName: data.uiUserName, + Email: data.email, + Phone: data.phone, + TimeZone: data.timeZone, + JobTitle: data.jobTitle, + TFAEnabled: data.tfaEnabled, + SecondaryEmail: data.secondaryEmail, + MobilePhone: data.mobilePhone, + Address: data.address, + City: data.city, + State: data.state, + ZipCode: data.zipCode, + Country: data.country, + ContactType: data.contactType, + PreferredLanguage: data.preferredLanguage, + SessionTimeOut: ptr.To(int(data.sessionTimeout)), + AdditionalAuthentication: iam.Authentication(data.additionalAuthentication), + }, + Actions: &iam.UserActions{ + APIClient: data.actions.apiClient, + Delete: data.actions.delete, + Edit: data.actions.edit, + IsCloneable: data.actions.isCloneable, + ResetPassword: data.actions.resetPassword, + ThirdPartyAccess: data.actions.thirdPartyAccess, + }, + Notifications: iam.UserNotifications{ + Options: iam.UserNotificationOptions{ + NewUser: data.notifications.options.newUserNotification, + PasswordExpiry: data.notifications.options.passwordExpiry, + Proactive: data.notifications.options.proactive, + Upgrade: data.notifications.options.upgrade, + APIClientCredentialExpiry: data.notifications.options.apiClientCredentialExpiryNotification, + }, + EnableEmail: data.notifications.enableEmailNotifications, + }, + } + userAuthGrantList := make([]iam.AuthGrant, 0, len(data.authGrants)) + for _, authGrant := range data.authGrants { + userAuthGrant := iam.AuthGrant{ + GroupID: authGrant.groupID, + GroupName: authGrant.groupName, + IsBlocked: authGrant.isBlocked, + RoleDescription: authGrant.roleDescription, + RoleID: ptr.To(int(authGrant.roleID)), + RoleName: authGrant.roleName, + } + userAuthGrantList = append(userAuthGrantList, userAuthGrant) + } + user.AuthGrants = userAuthGrantList + + client.On("GetUser", mock.Anything, getUserReq).Return(&user, nil).Times(times) +} +func expectGetUserMaxAuthGranSubGroups(_ *testing.T, client *iam.Mock, data testDataForUser, times, subGroupsDepth int) { + getUserReq := iam.GetUserRequest{ + IdentityID: data.uiIdentityID, + Actions: true, + AuthGrants: true, + Notifications: true, + } + + user := iam.User{ + IdentityID: data.uiIdentityID, + IsLocked: data.isLocked, + LastLoginDate: data.lastLoginDate, + PasswordExpiryDate: data.passwordExpiryDate, + TFAConfigured: data.tfaConfigured, + EmailUpdatePending: data.emailUpdatePending, + AccountID: data.accountID, + AdditionalAuthenticationConfigured: data.additionalAuthenticationConfigured, + UserBasicInfo: iam.UserBasicInfo{ + FirstName: data.firstName, + LastName: data.lastName, + UserName: data.uiUserName, + Email: data.email, + Phone: data.phone, + TimeZone: data.timeZone, + JobTitle: data.jobTitle, + TFAEnabled: data.tfaEnabled, + SecondaryEmail: data.secondaryEmail, + MobilePhone: data.mobilePhone, + Address: data.address, + City: data.city, + State: data.state, + ZipCode: data.zipCode, + Country: data.country, + ContactType: data.contactType, + PreferredLanguage: data.preferredLanguage, + SessionTimeOut: ptr.To(int(data.sessionTimeout)), + AdditionalAuthentication: iam.Authentication(data.additionalAuthentication), + }, + Actions: &iam.UserActions{ + APIClient: data.actions.apiClient, + Delete: data.actions.delete, + Edit: data.actions.edit, + IsCloneable: data.actions.isCloneable, + ResetPassword: data.actions.resetPassword, + ThirdPartyAccess: data.actions.thirdPartyAccess, + }, + Notifications: iam.UserNotifications{ + Options: iam.UserNotificationOptions{ + NewUser: data.notifications.options.newUserNotification, + PasswordExpiry: data.notifications.options.passwordExpiry, + Proactive: data.notifications.options.proactive, + Upgrade: data.notifications.options.upgrade, + APIClientCredentialExpiry: data.notifications.options.apiClientCredentialExpiryNotification, + }, + EnableEmail: data.notifications.enableEmailNotifications, + }, + } + userAuthGrantList := make([]iam.AuthGrant, 0, len(data.authGrants)) + for _, authGrant := range data.authGrants { + userAuthGrant := iam.AuthGrant{ + GroupID: authGrant.groupID, + GroupName: authGrant.groupName, + IsBlocked: authGrant.isBlocked, + RoleDescription: authGrant.roleDescription, + RoleID: ptr.To(int(authGrant.roleID)), + RoleName: authGrant.roleName, + Subgroups: generateMaxDepthSubGroupsAPIResponse(subGroupsDepth), + } + userAuthGrantList = append(userAuthGrantList, userAuthGrant) + } + user.AuthGrants = userAuthGrantList + + client.On("GetUser", mock.Anything, getUserReq).Return(&user, nil).Times(times) +} + +func checkUserAttrs(data testDataForUser) resource.TestCheckFunc { + name := "data.akamai_iam_user.test" + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "ui_identity_id", data.uiIdentityID), + } + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "account_id", data.accountID)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "additional_authentication", data.additionalAuthentication)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "additional_authentication_configured", strconv.FormatBool(data.additionalAuthenticationConfigured))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "address", data.address)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "city", data.city)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "contact_type", data.contactType)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "state", data.state)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "country", data.country)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "email", data.email)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "email_update_pending", strconv.FormatBool(data.emailUpdatePending))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "first_name", data.firstName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "is_locked", strconv.FormatBool(data.isLocked))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "job_title", data.jobTitle)) + lastLoginDateString, err := date.ToString(data.lastLoginDate) + if err != nil { + panic(err) + } + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_login_date", lastLoginDateString)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_name", data.lastName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "mobile_phone", data.mobilePhone)) + passwordExpiryDateString, err := date.ToString(data.passwordExpiryDate) + if err != nil { + panic(err) + } + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "password_expiry_date", passwordExpiryDateString)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "phone", data.phone)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "preferred_language", data.preferredLanguage)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "secondary_email", data.secondaryEmail)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "session_timeout", strconv.FormatInt(data.sessionTimeout, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "tfa_configured", strconv.FormatBool(data.tfaConfigured))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "tfa_enabled", strconv.FormatBool(data.tfaEnabled))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "time_zone", data.timeZone)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "ui_user_name", data.uiUserName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "zip_code", data.zipCode)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.delete", strconv.FormatBool(data.actions.delete))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.api_client", strconv.FormatBool(data.actions.apiClient))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.edit", strconv.FormatBool(data.actions.edit))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.is_cloneable", strconv.FormatBool(data.actions.isCloneable))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.reset_password", strconv.FormatBool(data.actions.resetPassword))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "actions.third_party_access", strconv.FormatBool(data.actions.thirdPartyAccess))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "auth_grants.#", strconv.Itoa(1))) + for i, authGrant := range data.authGrants { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.group_id", i), strconv.FormatInt(authGrant.groupID, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.group_name", i), authGrant.groupName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.is_blocked", i), strconv.FormatBool(authGrant.isBlocked))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.role_id", i), strconv.FormatInt(authGrant.roleID, 10))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.role_name", i), authGrant.roleName)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("auth_grants.%d.role_description", i), authGrant.roleDescription)) + if authGrant.subgroup != nil && len(authGrant.subgroup) > 0 { + checksFuncs = append(checksFuncs, generateAggregateTestCheckFuncsForMaxAuthGrantSubGroups(i, 2, maxSupportedGroupNesting)) + } + } + + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.enable_email_notifications", strconv.FormatBool(data.notifications.enableEmailNotifications))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.options.api_client_credential_expiry_notification", strconv.FormatBool(data.notifications.options.apiClientCredentialExpiryNotification))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.options.new_user_notification", strconv.FormatBool(data.notifications.options.newUserNotification))) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "notifications.options.password_expiry", strconv.FormatBool(data.notifications.options.passwordExpiry))) + for i, proactiveElement := range data.notifications.options.proactive { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("notifications.options.proactive.%d", i), proactiveElement)) + } + for i, upgradeElement := range data.notifications.options.upgrade { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("notifications.options.upgrade.%d", i), upgradeElement)) + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} + +func generateMaxDepthSubGroupsAuthGrantData(depth int) []*authGrantData { + var subgroups []*authGrantData + for groupID := depth; groupID > 1; groupID-- { + + authGrant := authGrantData{ + groupID: int64(groupID), + groupName: fmt.Sprintf("group%d", groupID), + isBlocked: false, + roleID: int64(groupID), + roleName: fmt.Sprintf("role%d", groupID), + roleDescription: fmt.Sprintf("roleDesc%d", groupID), + subgroup: subgroups, + } + subgroups = append([]*authGrantData{}, &authGrant) + } + return subgroups +} + +func generateMaxDepthSubGroupsAPIResponse(depth int) []iam.AuthGrant { + var subgroups []iam.AuthGrant + for groupID := depth; groupID > 1; groupID-- { + + authGrant := iam.AuthGrant{ + GroupID: int64(groupID), + GroupName: fmt.Sprintf("group%d", groupID), + IsBlocked: false, + RoleID: ptr.To(groupID), + RoleName: fmt.Sprintf("role%d", groupID), + RoleDescription: fmt.Sprintf("roleDesc%d", groupID), + Subgroups: subgroups, + } + subgroups = []iam.AuthGrant{authGrant} + } + return subgroups +} + +func generateAggregateTestCheckFuncsForMaxAuthGrantSubGroups(authGrantElement, min, max int) resource.TestCheckFunc { + var testCases []resource.TestCheckFunc + path := "sub_groups.0" + for i := min; i < max; i++ { + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.group_id", authGrantElement, path), strconv.Itoa(i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.group_name", authGrantElement, path), fmt.Sprintf("group%d", i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.role_id", authGrantElement, path), strconv.Itoa(i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.role_name", authGrantElement, path), fmt.Sprintf("role%d", i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.role_description", authGrantElement, path), fmt.Sprintf("roleDesc%d", i))) + testCases = append(testCases, resource.TestCheckResourceAttr("data.akamai_iam_user.test", fmt.Sprintf("auth_grants.%d.%s.is_blocked", authGrantElement, path), "false")) + path = path + ".sub_groups.0" + } + + return resource.ComposeAggregateTestCheckFunc(testCases...) +} diff --git a/pkg/providers/iam/iam_errors.go b/pkg/providers/iam/iam_errors.go index 2c3b587bf..d9fb79007 100644 --- a/pkg/providers/iam/iam_errors.go +++ b/pkg/providers/iam/iam_errors.go @@ -7,6 +7,8 @@ var ( ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") + // ErrIAMGetUser is returned when GetUser fails + ErrIAMGetUser = errors.New("IAM get user failed") // ErrIAMListCIDRBlocks is returned when ListCIDRBlocks fails ErrIAMListCIDRBlocks = errors.New("IAM list CIDR blocks failed") ) diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index b562e83f0..78eabebb0 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -108,6 +108,7 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewPasswordPolicyDataSource, NewPropertyUsersDataSource, NewRoleDataSource, + NewUserDataSource, NewUsersAffectedByMovingGroupDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataUser/default.tf b/pkg/providers/iam/testdata/TestDataUser/default.tf new file mode 100644 index 000000000..a74248ff4 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUser/default.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_user" "test" { + ui_identity_id = "asd-12345" +} diff --git a/pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf b/pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf new file mode 100644 index 000000000..059b812cc --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUser/missing_ui_identity.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_user" "test" { +} From 637b033a816d4073426a05cbef7e1c098fb4f804 Mon Sep 17 00:00:00 2001 From: Filip Antkowiak Date: Mon, 16 Sep 2024 12:34:19 +0000 Subject: [PATCH 38/54] DXE-4185 Improve time unmarshaling in IAM --- pkg/common/date/parse.go | 9 ++++ pkg/common/date/parse_test.go | 24 +++++++++++ .../iam/data_akamai_iam_cidr_block.go | 6 +-- .../iam/data_akamai_iam_cidr_blocks.go | 6 +-- pkg/providers/iam/data_akamai_iam_group.go | 6 +-- pkg/providers/iam/data_akamai_iam_groups.go | 6 +-- pkg/providers/iam/data_akamai_iam_role.go | 6 +-- .../iam/data_akamai_iam_role_test.go | 35 +++++++++++++++ pkg/providers/iam/data_akamai_iam_roles.go | 6 +-- .../iam/data_akamai_iam_roles_test.go | 43 +++++++++++++++++++ pkg/providers/iam/data_akamai_iam_user.go | 10 ++--- .../iam/data_akamai_iam_user_test.go | 12 +----- ...amai_iam_users_affected_by_moving_group.go | 18 ++++---- ...iam_users_affected_by_moving_group_test.go | 2 +- pkg/providers/iam/resource_akamai_iam_user.go | 6 +-- .../iam/resource_akamai_iam_user_test.go | 33 +++++++++++++- 16 files changed, 178 insertions(+), 50 deletions(-) diff --git a/pkg/common/date/parse.go b/pkg/common/date/parse.go index 93c9fd518..3ca7ffc9d 100644 --- a/pkg/common/date/parse.go +++ b/pkg/common/date/parse.go @@ -37,6 +37,15 @@ func FormatRFC3339(t time.Time) string { return t.Format(time.RFC3339) } +// FormatRFC3339Nano returns a textual representation of time formatted according to the RFC3339Nano standard. +// It returns an empty string if the provided time is equal to zero +func FormatRFC3339Nano(t time.Time) string { + if t.IsZero() { + return "" + } + return t.Format(time.RFC3339Nano) +} + // ToString returns given date in the string format func ToString(value time.Time) (string, error) { bytes, err := value.MarshalText() diff --git a/pkg/common/date/parse_test.go b/pkg/common/date/parse_test.go index 314263f59..b7c170baf 100644 --- a/pkg/common/date/parse_test.go +++ b/pkg/common/date/parse_test.go @@ -3,6 +3,7 @@ package date import ( "errors" "testing" + "time" "github.com/stretchr/testify/assert" ) @@ -34,3 +35,26 @@ func TestParse(t *testing.T) { }) } } + +func TestFormatRFC3339Nano(t *testing.T) { + tests := map[string]struct { + date time.Time + want string + }{ + "non zero time": { + date: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + want: "2000-01-01T00:00:00Z", + }, + "zero time": { + date: time.Time{}, + want: "", + }, + } + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + if got := FormatRFC3339Nano(tt.date); got != tt.want { + t.Errorf("FormatRFC3339Nano() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block.go b/pkg/providers/iam/data_akamai_iam_cidr_block.go index fd3595ee0..5a1d936f6 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block.go @@ -3,9 +3,9 @@ package iam import ( "context" "fmt" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -155,10 +155,10 @@ func (d *cidrBlockSourceModel) read(cidrBlock *iam.GetCIDRBlockResponse) diag.Di d.CIDRBlock = types.StringValue(cidrBlock.CIDRBlock) d.Comments = types.StringValue(cidrBlock.Comments) d.CreatedBy = types.StringValue(cidrBlock.CreatedBy) - d.CreatedDate = types.StringValue(cidrBlock.CreatedDate.Format(time.RFC3339Nano)) + d.CreatedDate = types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)) d.Enabled = types.BoolValue(cidrBlock.Enabled) d.ModifiedBy = types.StringValue(cidrBlock.ModifiedBy) - d.ModifiedDate = types.StringValue(cidrBlock.ModifiedDate.Format(time.RFC3339Nano)) + d.ModifiedDate = types.StringValue(date.FormatRFC3339Nano(cidrBlock.ModifiedDate)) if cidrBlock.Actions != nil { d.Actions = &actions{ diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go index 485b1c5e4..52e4d58b0 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go @@ -3,9 +3,9 @@ package iam import ( "context" "fmt" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -153,9 +153,9 @@ func (d *cidrBlocksSourceModel) read(cidrBlocks *iam.ListCIDRBlocksResponse) dia Comments: types.StringValue(cidrBlock.Comments), CIDRBlockID: types.Int64Value(cidrBlock.CIDRBlockID), CreatedBy: types.StringValue(cidrBlock.CreatedBy), - CreatedDate: types.StringValue(cidrBlock.CreatedDate.Format(time.RFC3339Nano)), + CreatedDate: types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)), ModifiedBy: types.StringValue(cidrBlock.ModifiedBy), - ModifiedDate: types.StringValue(cidrBlock.ModifiedDate.Format(time.RFC3339Nano)), + ModifiedDate: types.StringValue(date.FormatRFC3339Nano(cidrBlock.ModifiedDate)), } if cidrBlock.Actions != nil { block.Actions = &actions{ diff --git a/pkg/providers/iam/data_akamai_iam_group.go b/pkg/providers/iam/data_akamai_iam_group.go index b4ab70c31..9c8dd0ffe 100644 --- a/pkg/providers/iam/data_akamai_iam_group.go +++ b/pkg/providers/iam/data_akamai_iam_group.go @@ -3,9 +3,9 @@ package iam import ( "context" "fmt" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -172,9 +172,9 @@ func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest, func (d *groupDataSource) convertGroupData(group *iam.Group, data groupDataSourceModel, remainingNesting int) (groupDataSourceModel, diag.Diagnostics) { data.GroupName = types.StringValue(group.GroupName) data.CreatedBy = types.StringValue(group.CreatedBy) - data.CreatedDate = types.StringValue(group.CreatedDate.Format(time.RFC3339Nano)) + data.CreatedDate = types.StringValue(date.FormatRFC3339Nano(group.CreatedDate)) data.ModifiedBy = types.StringValue(group.ModifiedBy) - data.ModifiedDate = types.StringValue(group.ModifiedDate.Format(time.RFC3339Nano)) + data.ModifiedDate = types.StringValue(date.FormatRFC3339Nano(group.ModifiedDate)) data.ParentGroupID = types.Int64Value(group.ParentGroupID) data.GroupID = types.Int64Value(group.GroupID) diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index 991d7b4c7..f3bc1e2d6 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -3,10 +3,10 @@ package iam import ( "context" "strconv" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -116,8 +116,8 @@ func groupToState(g iam.Group) map[string]interface{} { m["name"] = g.GroupName m["group_id"] = strconv.FormatInt(g.GroupID, 10) m["parent_group_id"] = strconv.FormatInt(g.ParentGroupID, 10) - m["time_created"] = g.CreatedDate.Format(time.RFC3339Nano) - m["time_modified"] = g.ModifiedDate.Format(time.RFC3339Nano) + m["time_created"] = date.FormatRFC3339Nano(g.CreatedDate) + m["time_modified"] = date.FormatRFC3339Nano(g.ModifiedDate) m["modified_by"] = g.ModifiedBy m["created_by"] = g.CreatedBy diff --git a/pkg/providers/iam/data_akamai_iam_role.go b/pkg/providers/iam/data_akamai_iam_role.go index c86a4e9eb..5ae3b4b9f 100644 --- a/pkg/providers/iam/data_akamai_iam_role.go +++ b/pkg/providers/iam/data_akamai_iam_role.go @@ -3,9 +3,9 @@ package iam import ( "context" "fmt" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -226,9 +226,9 @@ func (d *roleDataSource) Read(ctx context.Context, req datasource.ReadRequest, r func (m *roleDataSourceModel) setAttributes(role *iam.Role) { m.CreatedBy = types.StringValue(role.CreatedBy) - m.CreatedDate = types.StringValue(role.CreatedDate.Format(time.RFC3339Nano)) + m.CreatedDate = types.StringValue(date.FormatRFC3339Nano(role.CreatedDate)) m.ModifiedBy = types.StringValue(role.ModifiedBy) - m.ModifiedDate = types.StringValue(role.ModifiedDate.Format(time.RFC3339Nano)) + m.ModifiedDate = types.StringValue(date.FormatRFC3339Nano(role.ModifiedDate)) m.RoleName = types.StringValue(role.RoleName) m.RoleDescription = types.StringValue(role.RoleDescription) m.Type = types.StringValue(string(role.RoleType)) diff --git a/pkg/providers/iam/data_akamai_iam_role_test.go b/pkg/providers/iam/data_akamai_iam_role_test.go index 172c953bb..1270e6b5d 100644 --- a/pkg/providers/iam/data_akamai_iam_role_test.go +++ b/pkg/providers/iam/data_akamai_iam_role_test.go @@ -60,6 +60,41 @@ func TestRoleDataSource(t *testing.T) { }, expectError: nil, }, + "happy path - role is returned, without dates": { + givenTF: "valid.tf", + init: func(m *iam.Mock) { + m.On("GetRole", mock.Anything, iam.GetRoleRequest{ + ID: 12345, + Actions: true, + GrantedRoles: true, + Users: true, + }).Return(&iam.Role{ + RoleID: int64(12345), + RoleName: "example-role", + RoleDescription: "This is an example role.", + CreatedBy: "user@example.com", + ModifiedBy: "admin@example.com", + RoleType: "custom", + Actions: &iam.RoleAction{ + Delete: true, + Edit: true, + }, + }, nil).Times(3) + }, + expectedAttributes: map[string]string{ + "role_id": "12345", + "role_name": "example-role", + "role_description": "This is an example role.", + "created_by": "user@example.com", + "created_date": "", + "modified_by": "admin@example.com", + "modified_date": "", + "type": "custom", + "actions.delete": "true", + "actions.edit": "true", + }, + expectError: nil, + }, "error response from API": { givenTF: "valid.tf", init: func(m *iam.Mock) { diff --git a/pkg/providers/iam/data_akamai_iam_roles.go b/pkg/providers/iam/data_akamai_iam_roles.go index b463b1eaa..f70c06898 100644 --- a/pkg/providers/iam/data_akamai_iam_roles.go +++ b/pkg/providers/iam/data_akamai_iam_roles.go @@ -3,10 +3,10 @@ package iam import ( "context" "strconv" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -110,8 +110,8 @@ func roleToState(r iam.Role) map[string]interface{} { m["name"] = r.RoleName m["description"] = r.RoleDescription m["type"] = string(r.RoleType) - m["time_created"] = r.CreatedDate.Format(time.RFC3339Nano) - m["time_modified"] = r.ModifiedDate.Format(time.RFC3339Nano) + m["time_created"] = date.FormatRFC3339Nano(r.CreatedDate) + m["time_modified"] = date.FormatRFC3339Nano(r.ModifiedDate) m["modified_by"] = r.ModifiedBy m["created_by"] = r.CreatedBy diff --git a/pkg/providers/iam/data_akamai_iam_roles_test.go b/pkg/providers/iam/data_akamai_iam_roles_test.go index 9f9891012..ad8c6d9b8 100644 --- a/pkg/providers/iam/data_akamai_iam_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_roles_test.go @@ -58,6 +58,49 @@ func TestDataRoles(t *testing.T) { client.AssertExpectations(t) }) + t.Run("happy path/no dates", func(t *testing.T) { + client := &iam.Mock{} + + roles := []iam.Role{{ + RoleName: "test role name", + RoleID: 100, + RoleDescription: "role description", + RoleType: iam.RoleTypeStandard, + CreatedBy: "creator@akamai.net", + ModifiedBy: "modifier@akamai.net", + }} + + req := iam.ListRolesRequest{} + + client.Test(testutils.TattleT{T: t}) + client.On("ListRoles", mock.Anything, req).Return(roles, nil) + + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestDataRoles/happy_path/no_args.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttrSet("data.akamai_iam_roles.test", "id"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.name", "test role name"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.role_id", "100"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.description", "role description"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.type", string(iam.RoleTypeStandard)), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.time_created", ""), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.time_modified", ""), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.created_by", "creator@akamai.net"), + resource.TestCheckResourceAttr("data.akamai_iam_roles.test", "roles.0.modified_by", "modifier@akamai.net"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + t.Run("fail path", func(t *testing.T) { req := iam.ListRolesRequest{} diff --git a/pkg/providers/iam/data_akamai_iam_user.go b/pkg/providers/iam/data_akamai_iam_user.go index 076788062..1bcd57b93 100644 --- a/pkg/providers/iam/data_akamai_iam_user.go +++ b/pkg/providers/iam/data_akamai_iam_user.go @@ -3,9 +3,9 @@ package iam import ( "context" "fmt" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -415,14 +415,10 @@ func (d *userDataSourceModel) setAttributes(user *iam.User) diag.Diagnostics { d.FirstName = types.StringValue(user.FirstName) d.IsLocked = types.BoolValue(user.IsLocked) d.JobTitle = types.StringValue(user.JobTitle) - if !user.LastLoginDate.IsZero() { - d.LastLoginDate = types.StringValue(user.LastLoginDate.Format(time.RFC3339Nano)) - } + d.LastLoginDate = types.StringValue(date.FormatRFC3339Nano(user.LastLoginDate)) d.LastName = types.StringValue(user.LastName) d.MobilePhone = types.StringValue(user.MobilePhone) - if !user.PasswordExpiryDate.IsZero() { - d.PasswordExpiryDate = types.StringValue(user.PasswordExpiryDate.Format(time.RFC3339Nano)) - } + d.PasswordExpiryDate = types.StringValue(date.FormatRFC3339Nano(user.PasswordExpiryDate)) d.Phone = types.StringValue(user.Phone) d.PreferredLanguage = types.StringValue(user.PreferredLanguage) d.SecondaryEmail = types.StringValue(user.SecondaryEmail) diff --git a/pkg/providers/iam/data_akamai_iam_user_test.go b/pkg/providers/iam/data_akamai_iam_user_test.go index ea6f13d94..51c493492 100644 --- a/pkg/providers/iam/data_akamai_iam_user_test.go +++ b/pkg/providers/iam/data_akamai_iam_user_test.go @@ -425,18 +425,10 @@ func checkUserAttrs(data testDataForUser) resource.TestCheckFunc { checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "first_name", data.firstName)) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "is_locked", strconv.FormatBool(data.isLocked))) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "job_title", data.jobTitle)) - lastLoginDateString, err := date.ToString(data.lastLoginDate) - if err != nil { - panic(err) - } - checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_login_date", lastLoginDateString)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_login_date", date.FormatRFC3339Nano(data.lastLoginDate))) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "last_name", data.lastName)) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "mobile_phone", data.mobilePhone)) - passwordExpiryDateString, err := date.ToString(data.passwordExpiryDate) - if err != nil { - panic(err) - } - checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "password_expiry_date", passwordExpiryDateString)) + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "password_expiry_date", date.FormatRFC3339Nano(data.passwordExpiryDate))) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "phone", data.phone)) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "preferred_language", data.preferredLanguage)) checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "secondary_email", data.secondaryEmail)) diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go index 4ee56caf7..dfbef470b 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go @@ -3,9 +3,9 @@ package iam import ( "context" "fmt" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -154,15 +154,13 @@ func convertUsersAffectedByMove(users []iam.GroupUser) []userAffectedByMovingGro convertedUsers := []userAffectedByMovingGroupModel{} for _, user := range users { convertedUser := userAffectedByMovingGroupModel{ - AccountID: types.StringValue(user.AccountID), - Email: types.StringValue(user.Email), - FirstName: types.StringValue(user.FirstName), - LastName: types.StringValue(user.LastName), - UIIdentityID: types.StringValue(user.IdentityID), - UIUsername: types.StringValue(user.UserName), - } - if !user.LastLoginDate.IsZero() { - convertedUser.LastLoginDate = types.StringValue(user.LastLoginDate.Format(time.RFC3339Nano)) + AccountID: types.StringValue(user.AccountID), + Email: types.StringValue(user.Email), + FirstName: types.StringValue(user.FirstName), + LastName: types.StringValue(user.LastName), + UIIdentityID: types.StringValue(user.IdentityID), + UIUsername: types.StringValue(user.UserName), + LastLoginDate: types.StringValue(date.FormatRFC3339Nano(user.LastLoginDate)), } convertedUsers = append(convertedUsers, convertedUser) } diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go index 5beab1664..bf25c70f0 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go @@ -34,7 +34,7 @@ func TestUsersAffectedByMovingGroup(t *testing.T) { if lastLoginDate != nil { checks = append(checks, resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path), *lastLoginDate)) } else { - checks = append(checks, resource.TestCheckNoResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path))) + checks = append(checks, resource.TestCheckResourceAttr("data.akamai_iam_users_affected_by_moving_group.test", fmt.Sprintf("%s.last_login_date", path), "")) } return resource.ComposeAggregateTestCheckFunc(checks...) diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index 742564835..cfa566f4e 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -8,10 +8,10 @@ import ( "regexp" "sort" "strings" - "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/google/go-cmp/cmp" @@ -469,8 +469,8 @@ func resourceIAMUserRead(ctx context.Context, d *schema.ResourceData, m interfac "country": user.Country, "contact_type": user.ContactType, "preferred_language": user.PreferredLanguage, - "last_login": user.LastLoginDate.Format(time.RFC3339Nano), - "password_expired_after": user.PasswordExpiryDate.Format(time.RFC3339Nano), + "last_login": date.FormatRFC3339Nano(user.LastLoginDate), + "password_expired_after": date.FormatRFC3339Nano(user.PasswordExpiryDate), "tfa_configured": user.TFAConfigured, "email_update_pending": user.EmailUpdatePending, "session_timeout": *user.SessionTimeOut, diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index 65d32fc84..bfe8fb906 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -179,7 +179,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", "last_login", user.LastLoginDate.Format(time.RFC3339Nano)), resource.TestCheckResourceAttr("akamai_iam_user.test", "password_expired_after", user.PasswordExpiryDate.Format(time.RFC3339Nano)), resource.TestCheckResourceAttr("akamai_iam_user.test", "tfa_configured", fmt.Sprintf("%t", user.TFAConfigured)), resource.TestCheckResourceAttr("akamai_iam_user.test", "email_update_pending", fmt.Sprintf("%t", user.EmailUpdatePending)), @@ -187,6 +186,11 @@ func TestResourceUser(t *testing.T) { resource.TestCheckResourceAttr("akamai_iam_user.test", "auth_grants_json", authGrantsJSON), resource.TestCheckResourceAttr("akamai_iam_user.test", "lock", fmt.Sprintf("%t", user.IsLocked)), } + if user.LastLoginDate.IsZero() { + checks = append(checks, resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", "")) + } else { + checks = append(checks, resource.TestCheckResourceAttr("akamai_iam_user.test", "last_login", user.LastLoginDate.Format(time.RFC3339Nano))) + } if checkPassword { checks = append(checks, resource.TestCheckResourceAttrSet("akamai_iam_user.test", "password")) } else { @@ -229,6 +233,17 @@ func TestResourceUser(t *testing.T) { Notifications: notifications, } + userCreateNoLastLoginDate := iam.User{ + UserBasicInfo: basicUserInfo, + IdentityID: id, + IsLocked: false, + PasswordExpiryDate: test.NewTimeFromString(t, "2020-01-01T00:00:00Z"), + TFAConfigured: true, + EmailUpdatePending: true, + AuthGrants: authGrantsCreate, + Notifications: notifications, + } + userCreateWithNotification := iam.User{ UserBasicInfo: basicUserInfoWithMFA, IdentityID: id, @@ -375,6 +390,22 @@ func TestResourceUser(t *testing.T) { }, }, }, + "basic - default notification, no last login date": { + init: func(m *iam.Mock) { + // create + expectResourceIAMUserCreatePhase(m, userCreateRequest, userCreateNoLastLoginDate, false, false, nil, nil, nil) + expectResourceIAMUserReadPhase(m, userCreateNoLastLoginDate, nil).Times(2) + + // delete + expectResourceIAMUserDeletePhase(m, userCreateNoLastLoginDate, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestResourceUserLifecycle/create_basic.tf"), + Check: resource.ComposeTestCheckFunc(checkUserAttributes(userCreateNoLastLoginDate, false), checkDefaultUserNotificationsAttributes(userCreateNoLastLoginDate)), + }, + }, + }, "basic - custom notification": { init: func(m *iam.Mock) { // create From ae493a5cb57631965c8eb79b81f41772350b05e7 Mon Sep 17 00:00:00 2001 From: Jakub Bilski Date: Wed, 18 Sep 2024 07:34:35 +0000 Subject: [PATCH 39/54] DXE-4027 Implement iam_cidr_blocks resource Merge in DEVEXP/terraform-provider-akamai from feature/DXE-4027 to feature/sp-iam-extension --- CHANGELOG.md | 18 + .../iam/data_akamai_iam_cidr_block.go | 8 +- .../iam/data_akamai_iam_cidr_block_test.go | 2 +- .../iam/data_akamai_iam_cidr_blocks.go | 12 +- .../iam/data_akamai_iam_cidr_blocks_test.go | 7 +- pkg/providers/iam/provider.go | 1 + .../iam/resource_akamai_iam_cidr_blocks.go | 408 ++++++++++ .../resource_akamai_iam_cidr_blocks_test.go | 764 ++++++++++++++++++ .../iam/resource_akamai_iam_ip_allowlist.go | 18 +- .../resource_akamai_iam_ip_allowlist_test.go | 80 +- .../iam/testdata/TestResCIDRBlocks/create.tf | 13 + .../TestResCIDRBlocks/create_multiple.tf | 31 + .../TestResCIDRBlocks/empty_config.tf | 3 + .../testdata/TestResCIDRBlocks/importable.tf | 13 + .../TestResCIDRBlocks/missing_cidr_block.tf | 12 + .../TestResCIDRBlocks/missing_enabled.tf | 12 + .../testdata/TestResCIDRBlocks/update_five.tf | 30 + .../TestResCIDRBlocks/update_single.tf | 12 + .../update_three_out_of_five.tf | 30 + .../update_three_remove_two.tf | 21 + 20 files changed, 1456 insertions(+), 39 deletions(-) create mode 100644 pkg/providers/iam/resource_akamai_iam_cidr_blocks.go create mode 100644 pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1b0d4ad..93d6f2e25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,24 @@ + + + + + + + + + + +* IAM + * Added new resource: + * `akamai_iam_cidr_blocks` - manage CIDR blocks assigned to the allowlist + + + + + * IAM * Added new resource: * `akamai_iam_ip_allowlist` - enable or disable your account's allowlist diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block.go b/pkg/providers/iam/data_akamai_iam_cidr_block.go index 5a1d936f6..18352aa55 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block.go @@ -153,7 +153,6 @@ func (d *cidrBlockDataSource) Read(ctx context.Context, req datasource.ReadReque func (d *cidrBlockSourceModel) read(cidrBlock *iam.GetCIDRBlockResponse) diag.Diagnostics { d.CIDRBlock = types.StringValue(cidrBlock.CIDRBlock) - d.Comments = types.StringValue(cidrBlock.Comments) d.CreatedBy = types.StringValue(cidrBlock.CreatedBy) d.CreatedDate = types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)) d.Enabled = types.BoolValue(cidrBlock.Enabled) @@ -167,6 +166,13 @@ func (d *cidrBlockSourceModel) read(cidrBlock *iam.GetCIDRBlockResponse) diag.Di } } + if cidrBlock.Comments != nil { + d.Comments = types.StringValue(*cidrBlock.Comments) + } else { + d.Comments = types.StringNull() + + } + return nil } diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go index 8f02341ad..edb1d79b5 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go @@ -130,7 +130,7 @@ func expectGetCIDRBlock(t *testing.T, client *iam.Mock, data testDataForCIDRBloc getCIDRBlockResp := iam.GetCIDRBlockResponse{ CIDRBlock: data.cidrBlock, CIDRBlockID: data.cidrBlockID, - Comments: data.comments, + Comments: &data.comments, CreatedBy: data.createdBy, CreatedDate: createdDate, Enabled: data.enabled, diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go index 52e4d58b0..4c0683a76 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go @@ -145,12 +145,11 @@ func (d *cidrBlocksDataSource) Read(ctx context.Context, req datasource.ReadRequ } -func (d *cidrBlocksSourceModel) read(cidrBlocks *iam.ListCIDRBlocksResponse) diag.Diagnostics { - for _, cidrBlock := range *cidrBlocks { +func (d *cidrBlocksSourceModel) read(cidrBlocks iam.ListCIDRBlocksResponse) diag.Diagnostics { + for _, cidrBlock := range cidrBlocks { block := cidrBlockSourceModel{ CIDRBlock: types.StringValue(cidrBlock.CIDRBlock), Enabled: types.BoolValue(cidrBlock.Enabled), - Comments: types.StringValue(cidrBlock.Comments), CIDRBlockID: types.Int64Value(cidrBlock.CIDRBlockID), CreatedBy: types.StringValue(cidrBlock.CreatedBy), CreatedDate: types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)), @@ -164,6 +163,13 @@ func (d *cidrBlocksSourceModel) read(cidrBlocks *iam.ListCIDRBlocksResponse) dia } } + if cidrBlock.Comments != nil { + block.Comments = types.StringValue(*cidrBlock.Comments) + } else { + block.Comments = types.StringNull() + + } + d.CIDRBlocks = append(d.CIDRBlocks, block) } diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go index f4fc09a5c..2f3464587 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" @@ -30,7 +31,7 @@ func TestDataCIDRBlocks(t *testing.T) { }, CIDRBlock: "128.5.6.6/24", CIDRBlockID: 2567, - Comments: "APAC Region", + Comments: ptr.To("APAC Region"), CreatedBy: "user1", CreatedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), Enabled: true, @@ -44,7 +45,7 @@ func TestDataCIDRBlocks(t *testing.T) { }, CIDRBlock: "128.5.6.6/24", CIDRBlockID: 6042, - Comments: "East Coast Office", + Comments: ptr.To("East Coast Office"), CreatedBy: "user2", CreatedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), Enabled: true, @@ -52,7 +53,7 @@ func TestDataCIDRBlocks(t *testing.T) { ModifiedDate: time.Date(2017, 7, 27, 18, 11, 25, 0, time.UTC), }, } - m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(&listCIDRBlocksResp, nil).Times(3) + m.On("ListCIDRBlocks", mock.Anything, listCIDRBlocksReq).Return(listCIDRBlocksResp, nil).Times(3) }, }, "error - ListCIDRBlocks call failed ": { diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 78eabebb0..758fd9984 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -91,6 +91,7 @@ func (p *Subprovider) SDKDataSources() map[string]*schema.Resource { func (p *Subprovider) FrameworkResources() []func() resource.Resource { return []func() resource.Resource{ NewIPAllowlistResource, + NewCIDRBlocksResource, } } diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_blocks.go b/pkg/providers/iam/resource_akamai_iam_cidr_blocks.go new file mode 100644 index 000000000..51d765ff5 --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_cidr_blocks.go @@ -0,0 +1,408 @@ +package iam + +import ( + "context" + "fmt" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &CIDRBlocksResource{} + _ resource.ResourceWithImportState = &CIDRBlocksResource{} +) + +// CIDRBlocksResource represents akamai_iam_cidr_blocks resource +type CIDRBlocksResource struct { + meta meta.Meta +} + +// NewCIDRBlocksResource returns new akamai_iam_cidr_blocks resource +func NewCIDRBlocksResource() resource.Resource { return &CIDRBlocksResource{} } + +// CIDRBlocksResourceModel represents model of akamai_iam_cidr_blocks resource +type CIDRBlocksResourceModel struct { + CIDRBlocks []CIDRBlock `tfsdk:"cidr_blocks"` +} + +// CIDRBlock represents a single cidr block +type CIDRBlock struct { + CIDR types.String `tfsdk:"cidr_block"` + Enabled types.Bool `tfsdk:"enabled"` + Comments types.String `tfsdk:"comments"` + Actions types.Object `tfsdk:"actions"` + CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` +} + +// Metadata implements resource.Resource. +func (r *CIDRBlocksResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_blocks" +} + +// Schema implements resource.Resource. +func (r *CIDRBlocksResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "cidr_blocks": schema.ListNestedAttribute{ + Optional: true, + Description: "List of CIDR blocks.", + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "cidr_block": schema.StringAttribute{ + Required: true, + Description: "The value of an IP address or IP address range.", + }, + "enabled": schema.BoolAttribute{ + Required: true, + Description: "Enables the IP allowlist on the account.", + }, + "comments": schema.StringAttribute{ + Optional: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block. You can't delete a CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block. You can't edit CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", + }, + }, + }, + "cidr_block_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each CIDR block.", + PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}, + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + }, + }, + }, + }, + }, + } +} + +// Configure implements resource.ResourceWithConfigure. +func (r *CIDRBlocksResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + r.meta = meta.Must(req.ProviderData) +} + +// Create implements resource.Resource. +func (r *CIDRBlocksResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating CIDR Blocks resource") + var plan *CIDRBlocksResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.create(ctx, plan); err != nil { + resp.Diagnostics.AddError("create cidr block failed", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *CIDRBlocksResource) create(ctx context.Context, plan *CIDRBlocksResourceModel) error { + client := inst.Client(r.meta) + + for i, c := range plan.CIDRBlocks { + cidr, err := client.CreateCIDRBlock(ctx, c.buildCreateCIDRBlockRequest()) + if err != nil { + return err + } + plan.setFromCreateCIDRBlock(cidr, i) + } + + return nil +} + +// Read implements resource.Resource. +func (r *CIDRBlocksResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading CIDR Blocks Resource") + var state *CIDRBlocksResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.read(ctx, state); err != nil { + resp.Diagnostics.AddError("read cidr blocks error", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *CIDRBlocksResource) read(ctx context.Context, data *CIDRBlocksResourceModel) error { + client := inst.Client(r.meta) + + res, err := client.ListCIDRBlocks(ctx, iam.ListCIDRBlocksRequest{ + Actions: true, + }) + if err != nil { + return err + } + data.setFromListCIDRBlocks(res) + + return nil +} + +// Update implements resource.Resource. +func (r *CIDRBlocksResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating CIDR Blocks Resource") + var data *CIDRBlocksResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.update(ctx, data); err != nil { + resp.Diagnostics.AddError("update cidr block failed", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *CIDRBlocksResource) update(ctx context.Context, data *CIDRBlocksResourceModel) error { + client := inst.Client(r.meta) + + for i, cidr := range data.CIDRBlocks { + resp, err := client.UpdateCIDRBlock(ctx, cidr.buildUpdateRequest()) + if err != nil { + return err + } + data.setFromUpdateCIDRBlock(resp, i) + } + + return nil +} + +// Delete implements resource.Resource. +func (r *CIDRBlocksResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Deleting CIDR Blocks Resource") + var state *CIDRBlocksResourceModel + client := inst.Client(r.meta) + + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + for _, cidr := range state.CIDRBlocks { + if err := client.DeleteCIDRBlock(ctx, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: cidr.CIDRBlockID.ValueInt64(), + }); err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("delete cidr block %d failed", cidr.CIDRBlockID), err.Error()) + return + } + } + resp.State.RemoveResource(ctx) +} + +// ImportState implements resource.ResourceWithImportState. +func (r *CIDRBlocksResource) ImportState(ctx context.Context, _ resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing CIDR Blocks Resource") + + data := &CIDRBlocksResourceModel{} + client := inst.Client(r.meta) + + res, err := client.ListCIDRBlocks(ctx, iam.ListCIDRBlocksRequest{ + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError("import cidr blocks error", err.Error()) + return + } + + data.setFromImportCIDRBlocks(res) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (m CIDRBlock) buildCreateCIDRBlockRequest() iam.CreateCIDRBlockRequest { + return iam.CreateCIDRBlockRequest{ + CIDRBlock: m.CIDR.ValueString(), + Comments: m.Comments.ValueStringPointer(), + Enabled: m.Enabled.ValueBool(), + } +} + +func (m CIDRBlock) buildUpdateRequest() iam.UpdateCIDRBlockRequest { + return iam.UpdateCIDRBlockRequest{ + CIDRBlockID: m.CIDRBlockID.ValueInt64(), + Body: iam.UpdateCIDRBlockRequestBody{ + CIDRBlock: m.CIDR.ValueString(), + Comments: m.Comments.ValueStringPointer(), + Enabled: m.Enabled.ValueBool(), + }, + } +} + +func (c *CIDRBlocksResourceModel) setFromCreateCIDRBlock(cidr *iam.CreateCIDRBlockResponse, i int) { + if cidr.Actions != nil { + c.CIDRBlocks[i].Actions = getActionFor(cidr.Actions.Edit, cidr.Actions.Delete) + } else { + c.CIDRBlocks[i].Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + } + c.CIDRBlocks[i].CIDR = types.StringValue(cidr.CIDRBlock) + if cidr.Comments != nil { + c.CIDRBlocks[i].Comments = types.StringValue(*cidr.Comments) + } else { + c.CIDRBlocks[i].Comments = types.StringNull() + } + c.CIDRBlocks[i].CIDRBlockID = types.Int64Value(cidr.CIDRBlockID) + c.CIDRBlocks[i].ModifiedBy = types.StringValue(cidr.ModifiedBy) + c.CIDRBlocks[i].ModifiedDate = types.StringValue(cidr.ModifiedDate.Format(time.RFC3339Nano)) + c.CIDRBlocks[i].CreatedBy = types.StringValue(cidr.CreatedBy) + c.CIDRBlocks[i].CreatedDate = types.StringValue(cidr.CreatedDate.Format(time.RFC3339Nano)) +} + +func (c *CIDRBlocksResourceModel) setFromListCIDRBlocks(resp iam.ListCIDRBlocksResponse) { + for _, cidr := range c.CIDRBlocks { + for _, r := range resp { + if cidr.CIDRBlockID.ValueInt64() == r.CIDRBlockID { + cidr.CIDR = types.StringValue(r.CIDRBlock) + if r.Actions != nil { + cidr.Actions = getActionFor(r.Actions.Edit, r.Actions.Delete) + } else { + cidr.Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + } + if r.Comments != nil { + cidr.Comments = types.StringValue(*r.Comments) + } else { + cidr.Comments = types.StringNull() + } + cidr.Enabled = types.BoolValue(r.Enabled) + cidr.ModifiedBy = types.StringValue(r.ModifiedBy) + cidr.ModifiedDate = types.StringValue(r.ModifiedDate.Format(time.RFC3339Nano)) + cidr.CreatedBy = types.StringValue(r.CreatedBy) + cidr.CreatedDate = types.StringValue(r.CreatedDate.Format(time.RFC3339Nano)) + break + } + } + } +} + +func (c *CIDRBlocksResourceModel) setFromUpdateCIDRBlock(resp *iam.UpdateCIDRBlockResponse, i int) { + if resp.Actions != nil { + c.CIDRBlocks[i].Actions = getActionFor(resp.Actions.Edit, resp.Actions.Delete) + } else { + c.CIDRBlocks[i].Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + } + if resp.Comments != nil { + c.CIDRBlocks[i].Comments = types.StringValue(*resp.Comments) + } else { + c.CIDRBlocks[i].Comments = types.StringNull() + } + c.CIDRBlocks[i].CIDR = types.StringValue(resp.CIDRBlock) + c.CIDRBlocks[i].CIDRBlockID = types.Int64Value(resp.CIDRBlockID) + c.CIDRBlocks[i].Enabled = types.BoolValue(resp.Enabled) + c.CIDRBlocks[i].CreatedBy = types.StringValue(resp.CreatedBy) + c.CIDRBlocks[i].CreatedDate = types.StringValue(resp.CreatedDate.Format(time.RFC3339Nano)) + c.CIDRBlocks[i].ModifiedBy = types.StringValue(resp.ModifiedBy) + c.CIDRBlocks[i].ModifiedDate = types.StringValue(resp.ModifiedDate.Format(time.RFC3339Nano)) +} + +func (c *CIDRBlocksResourceModel) setFromImportCIDRBlocks(resp iam.ListCIDRBlocksResponse) { + var action types.Object + + for _, cidr := range resp { + if cidr.Actions != nil { + action = getActionFor(cidr.Actions.Edit, cidr.Actions.Delete) + } else { + action = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + } + block := CIDRBlock{ + CIDR: types.StringValue(cidr.CIDRBlock), + Enabled: types.BoolValue(cidr.Enabled), + Comments: types.StringPointerValue(cidr.Comments), + Actions: action, + CIDRBlockID: types.Int64Value(cidr.CIDRBlockID), + CreatedBy: types.StringValue(cidr.CreatedBy), + CreatedDate: types.StringValue(cidr.CreatedDate.Format(time.RFC3339Nano)), + ModifiedBy: types.StringValue(cidr.ModifiedBy), + ModifiedDate: types.StringValue(cidr.ModifiedDate.Format(time.RFC3339Nano)), + } + c.CIDRBlocks = append(c.CIDRBlocks, block) + } +} + +func getActionFor(editActions, deleteActions bool) basetypes.ObjectValue { + return types.ObjectValueMust( + map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }, + map[string]attr.Value{ + "edit": basetypes.NewBoolValue(editActions), + "delete": basetypes.NewBoolValue(deleteActions), + }, + ) +} diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go new file mode 100644 index 000000000..fbe037fff --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go @@ -0,0 +1,764 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/mock" +) + +type ( + commonDataForResource struct { + cidrBlock string + comments *string + enabled bool + actions *action + cidrBlockID int64 + createdBy string + createdDate string + modifiedBy string + modifiedDate string + } + + action struct { + deleteAction bool + editAction bool + } +) + +var ( + createdCidrBlocks = []commonDataForResource{ + { + cidrBlock: "128.5.6.5/24", + enabled: true, + comments: ptr.To("test"), + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.5.6.6/24", + enabled: false, + comments: nil, + actions: &action{ + deleteAction: true, + editAction: false, + }, + cidrBlockID: 2222, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.5.6.7/24", + comments: ptr.To("test1234"), + enabled: true, + actions: &action{ + deleteAction: false, + editAction: true, + }, + cidrBlockID: 3333, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.5.6.8/24", + comments: ptr.To("abcd12345"), + enabled: false, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 4444, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.5.6.9/24", + enabled: true, + comments: nil, + actions: &action{ + deleteAction: false, + editAction: false, + }, + cidrBlockID: 5555, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + } + + updatedCidrBlocks = []commonDataForResource{ + { + cidrBlock: "128.1.2.5/24", + enabled: false, + comments: nil, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.1.2.6/24", + enabled: false, + comments: nil, + actions: &action{ + deleteAction: true, + editAction: false, + }, + cidrBlockID: 2222, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.1.2.7/24", + comments: ptr.To("test1234"), + enabled: true, + actions: &action{ + deleteAction: false, + editAction: true, + }, + cidrBlockID: 3333, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.1.2.8/24", + comments: ptr.To("up12345"), + enabled: true, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 4444, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.1.2.9/24", + enabled: false, + comments: nil, + actions: &action{ + deleteAction: false, + editAction: false, + }, + cidrBlockID: 5555, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + } + + threeOutOffiveUpdatedCidrBlocks = []commonDataForResource{ + { + cidrBlock: "128.2.2.5/28", + enabled: false, + comments: nil, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.2.2.6/28", + enabled: true, + comments: nil, + actions: &action{ + deleteAction: true, + editAction: false, + }, + cidrBlockID: 2222, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.2.2.7/28", + comments: ptr.To("test12345"), + enabled: false, + actions: &action{ + deleteAction: false, + editAction: true, + }, + cidrBlockID: 3333, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.5.6.8/24", + comments: ptr.To("abcd12345"), + enabled: false, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 4444, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + { + cidrBlock: "128.5.6.9/24", + enabled: true, + comments: nil, + actions: &action{ + deleteAction: false, + editAction: false, + }, + cidrBlockID: 5555, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + }, + } +) + +func TestResourceIAMCIDRBlocksResource(t *testing.T) { + t.Parallel() + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, []commonDataForResource, []commonDataForResource) + createData []commonDataForResource + updatedData []commonDataForResource + steps []resource.TestStep + error *regexp.Regexp + }{ + "create - single cidr Block": { + init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource, _ []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, resourceData) + + // Read + mockListCIDRBlock(t, m, resourceData) + + // Delete + mockDeleteCIDRBlocks(m, resourceData) + }, + createData: generateCIDRBlocks(createdCidrBlocks[:1]), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), + Check: checkAttrs(generateCIDRBlocks(createdCidrBlocks[:1])), + }, + }, + }, + "create - multiple cidr Blocks": { + init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource, _ []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, resourceData) + + // Read + mockListCIDRBlock(t, m, resourceData) + + // Delete + mockDeleteCIDRBlocks(m, resourceData) + }, + createData: generateCIDRBlocks(createdCidrBlocks), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), + Check: checkAttrs(generateCIDRBlocks(createdCidrBlocks)), + }, + }, + }, + "update - single cidr block": { + init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, createData) + + // Read + mockListCIDRBlock(t, m, createData) + + // Refresh read + mockListCIDRBlock(t, m, createData) + + // Update + mockUpdateCIDRBlocks(t, m, updateData) + + // Read + mockListCIDRBlock(t, m, updateData) + + // Delete + mockDeleteCIDRBlocks(m, updateData) + }, + createData: generateCIDRBlocks(createdCidrBlocks[:1]), + updatedData: generateCIDRBlocks(updatedCidrBlocks[:1]), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), + Check: checkAttrs(generateCIDRBlocks(createdCidrBlocks[:1])), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_single.tf"), + Check: checkAttrs(generateCIDRBlocks(updatedCidrBlocks[:1])), + }, + }, + }, + "update - all cidr blocks": { + init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, createData) + + // Read + mockListCIDRBlock(t, m, createData) + + // Refresh read + mockListCIDRBlock(t, m, createData) + + // Update + mockUpdateCIDRBlocks(t, m, updateData) + + // Read + mockListCIDRBlock(t, m, updateData) + + // Delete + mockDeleteCIDRBlocks(m, updateData) + }, + createData: generateCIDRBlocks(createdCidrBlocks), + updatedData: generateCIDRBlocks(updatedCidrBlocks), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), + Check: checkAttrs(createdCidrBlocks), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_five.tf"), + Check: checkAttrs(updatedCidrBlocks), + }, + }, + }, + "update - 3 cidr blocks from 5 created": { + init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, createData) + + // Read + mockListCIDRBlock(t, m, createData) + + // Refresh read + mockListCIDRBlock(t, m, createData) + + // Update + mockUpdateCIDRBlocks(t, m, updateData) + + // Read + mockListCIDRBlock(t, m, updateData) + + // Delete + mockDeleteCIDRBlocks(m, updateData) + }, + createData: generateCIDRBlocks(createdCidrBlocks), + updatedData: generateCIDRBlocks(threeOutOffiveUpdatedCidrBlocks), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), + Check: checkAttrs(createdCidrBlocks), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_three_out_of_five.tf"), + Check: checkAttrs(threeOutOffiveUpdatedCidrBlocks), + }, + }, + }, + "update - 3 cidr blocks and 2 remove": { + init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, createData) + + // Read + mockListCIDRBlock(t, m, createData) + + // Refresh read + mockListCIDRBlock(t, m, createData) + + // Update + mockUpdateCIDRBlocks(t, m, updateData) + + // Read + mockListCIDRBlock(t, m, updateData) + + // Delete + mockDeleteCIDRBlocks(m, updateData) + }, + createData: generateCIDRBlocks(createdCidrBlocks), + updatedData: generateCIDRBlocks(updatedCidrBlocks[:3]), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), + Check: checkAttrs(createdCidrBlocks), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_three_remove_two.tf"), + Check: checkAttrs(generateCIDRBlocks(updatedCidrBlocks[:3])), + }, + }, + }, + "missing cidr block": { + steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/missing_cidr_block.tf"), + ExpectError: regexp.MustCompile("\\s*Inappropriate value for attribute \"cidr_blocks\": element 0: attribute\\s*\"cidr_block\" is required."), + }}, + }, + "missing enabled": { + steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/missing_enabled.tf"), + ExpectError: regexp.MustCompile("\\s*Inappropriate value for attribute \"cidr_blocks\": element 0: attribute\\s*\"enabled\" is required."), + }}, + }, + "error - create": { + init: func(t *testing.T, m *iam.Mock, resourceData, _ []commonDataForResource) { + m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ + CIDRBlock: resourceData[0].cidrBlock, + Comments: resourceData[0].comments, + Enabled: resourceData[0].enabled, + }).Return(nil, iam.ErrCreateCIDRBlock).Once() + }, + createData: generateCIDRBlocks(createdCidrBlocks[:1]), + steps: []resource.TestStep{{ + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), + ExpectError: regexp.MustCompile("create cidr block failed"), + }}, + }, + "error - delete": { + init: func(t *testing.T, m *iam.Mock, resourceData, _ []commonDataForResource) { + // Create + mockCreateCIDRBlocks(t, m, resourceData) + + // Read + mockListCIDRBlock(t, m, resourceData) + + // Read + mockListCIDRBlock(t, m, resourceData) + + // Delete - error + m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: resourceData[0].cidrBlockID, + }).Return(iam.ErrDeleteCIDRBlock).Once() + + // Delete - destroy + mockDeleteCIDRBlocks(m, resourceData) + }, + createData: generateCIDRBlocks(createdCidrBlocks[:1]), + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/empty_config.tf"), + ExpectError: regexp.MustCompile(`Error: delete cidr block {2 1111} failed`), + }, + }, + }, + } + for name, test := range tests { + test := test + t.Run(name, func(t *testing.T) { + t.Parallel() + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.createData, test.updatedData) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: test.steps, + }) + }) + client.AssertExpectations(t) + }) + } + +} + +func TestImportIAMCIDRBlocksResource(t *testing.T) { + tests := map[string]struct { + importID string + configPath string + init func(*testing.T, *iam.Mock, []commonDataForResource) + mockData []commonDataForResource + }{ + "import - single cidr block": { + importID: " ", + mockData: generateCIDRBlocks(createdCidrBlocks[:1]), + init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource) { + // Import + mockListCIDRBlock(t, m, resourceData) + + // Read + mockListCIDRBlock(t, m, resourceData) + }, + }, + "import - five cidr blocks": { + importID: " ", + mockData: generateCIDRBlocks(createdCidrBlocks), + init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource) { + // Import + mockListCIDRBlock(t, m, resourceData) + + // Read + mockListCIDRBlock(t, m, resourceData) + }, + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(t, client, test.mockData) + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + ImportStateCheck: checkImportCIDRBlocks(test.mockData), + ImportStateId: test.importID, + ImportState: true, + ResourceName: "akamai_iam_cidr_blocks.test", + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/importable.tf"), + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkImportCIDRBlocks(data []commonDataForResource) resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + attr := make(map[string]string) + + if len(s) == 0 { + return errors.New("No Instance found") + } + if len(s) != 1 { + return fmt.Errorf("Expected one Instance: %d", len(s)) + } + + for i, cidr := range data { + if cidr.actions != nil { + attr[fmt.Sprintf("cidr_blocks.%d.actions.delete", i)] = strconv.FormatBool(cidr.actions.deleteAction) + attr[fmt.Sprintf("cidr_blocks.%d.actions.edit", i)] = strconv.FormatBool(cidr.actions.editAction) + } + if cidr.comments != nil { + attr[fmt.Sprintf("cidr_blocks.%d.comments", i)] = *cidr.comments + } else { + attr[fmt.Sprintf("cidr_blocks.%d.comments", i)] = "" + } + attr[fmt.Sprintf("cidr_blocks.%d.cidr_block", i)] = cidr.cidrBlock + attr[fmt.Sprintf("cidr_blocks.%d.enabled", i)] = strconv.FormatBool(cidr.enabled) + attr[fmt.Sprintf("cidr_blocks.%d.cidr_block_id", i)] = strconv.FormatInt(cidr.cidrBlockID, 10) + attr[fmt.Sprintf("cidr_blocks.%d.created_by", i)] = cidr.createdBy + attr[fmt.Sprintf("cidr_blocks.%d.created_date", i)] = cidr.createdDate + attr[fmt.Sprintf("cidr_blocks.%d.modified_by", i)] = cidr.modifiedBy + attr[fmt.Sprintf("cidr_blocks.%d.modified_date", i)] = cidr.modifiedDate + } + + state := s[0].Attributes + + attributes := attr + + invalidValues := []string{} + for field, expectedVal := range attributes { + if state[field] != expectedVal { + invalidValues = append(invalidValues, fmt.Sprintf("field: %s, got: %s, expected: %s ", field, state[field], expectedVal)) + } + } + + if len(invalidValues) != 0 { + return fmt.Errorf(strings.Join(invalidValues, "\n")) + } + return nil + } +} + +func mockCreateCIDRBlocks(t *testing.T, m *iam.Mock, testData []commonDataForResource) []*mock.Call { + var mocks []*mock.Call + var act *iam.CIDRActions + + for _, d := range testData { + if d.actions != nil { + act = &iam.CIDRActions{ + Delete: d.actions.deleteAction, + Edit: d.actions.editAction, + } + } + mocks = append(mocks, m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ + CIDRBlock: d.cidrBlock, + Comments: d.comments, + Enabled: d.enabled, + }).Return(&iam.CreateCIDRBlockResponse{ + Actions: act, + CIDRBlock: d.cidrBlock, + CIDRBlockID: d.cidrBlockID, + Comments: d.comments, + CreatedBy: d.createdBy, + CreatedDate: test.NewTimeFromString(t, d.createdDate), + Enabled: d.enabled, + ModifiedBy: d.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, d.modifiedDate), + }, nil).Once()) + } + + return mocks +} + +func mockListCIDRBlock(t *testing.T, m *iam.Mock, testData []commonDataForResource) *mock.Call { + var cidrBlock iam.ListCIDRBlocksResponse + var act *iam.CIDRActions + + for _, cidr := range testData { + if cidr.actions != nil { + act = &iam.CIDRActions{ + Delete: cidr.actions.deleteAction, + Edit: cidr.actions.editAction, + } + } + cidrBlock = append(cidrBlock, iam.CIDRBlock{ + Actions: act, + CIDRBlock: cidr.cidrBlock, + CIDRBlockID: cidr.cidrBlockID, + Comments: cidr.comments, + CreatedBy: cidr.createdBy, + CreatedDate: test.NewTimeFromString(t, cidr.createdDate), + Enabled: cidr.enabled, + ModifiedBy: cidr.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, cidr.modifiedDate), + }) + } + + return m.On("ListCIDRBlocks", mock.Anything, iam.ListCIDRBlocksRequest{ + Actions: true, + }).Return(cidrBlock, nil).Once() +} + +func mockDeleteCIDRBlocks(m *iam.Mock, testData []commonDataForResource) []*mock.Call { + var mocks []*mock.Call + + for _, d := range testData { + mocks = append(mocks, m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: d.cidrBlockID, + }).Return(nil).Once()) + } + + return mocks +} + +func mockUpdateCIDRBlocks(t *testing.T, m *iam.Mock, data []commonDataForResource) []*mock.Call { + var mocks []*mock.Call + + for _, d := range data { + mocks = append(mocks, m.On("UpdateCIDRBlock", mock.Anything, iam.UpdateCIDRBlockRequest{ + CIDRBlockID: d.cidrBlockID, + Body: iam.UpdateCIDRBlockRequestBody{ + CIDRBlock: d.cidrBlock, + Comments: d.comments, + Enabled: d.enabled, + }, + }).Return(&iam.UpdateCIDRBlockResponse{ + Actions: &iam.CIDRActions{ + Delete: d.actions.deleteAction, + Edit: d.actions.editAction, + }, + CIDRBlock: d.cidrBlock, + CIDRBlockID: d.cidrBlockID, + Comments: d.comments, + CreatedBy: d.createdBy, + CreatedDate: test.NewTimeFromString(t, d.createdDate), + Enabled: d.enabled, + ModifiedBy: d.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, d.modifiedDate), + }, nil).Once()) + } + + return mocks +} + +func checkAttrs(data []commonDataForResource) resource.TestCheckFunc { + var checkFuncs []resource.TestCheckFunc + + for i, cidr := range data { + if cidr.actions != nil { + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.actions.delete", i), strconv.FormatBool(cidr.actions.deleteAction))) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.actions.edit", i), strconv.FormatBool(cidr.actions.editAction))) + } + if cidr.comments != nil { + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttrPtr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.comments", i), cidr.comments)) + } else { + checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.comments", i))) + } + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.cidr_block", i), cidr.cidrBlock)) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.enabled", i), strconv.FormatBool(cidr.enabled))) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.cidr_block_id", i), strconv.FormatInt(cidr.cidrBlockID, 10))) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.created_by", i), cidr.createdBy)) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.created_date", i), cidr.createdDate)) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.modified_by", i), cidr.modifiedBy)) + checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.modified_date", i), cidr.modifiedDate)) + } + return resource.ComposeAggregateTestCheckFunc( + checkFuncs..., + ) +} + +func generateCIDRBlocks(data []commonDataForResource) []commonDataForResource { + var cidrBlocks []commonDataForResource + + for _, cidr := range data { + cidrBlocks = append(cidrBlocks, commonDataForResource{ + cidrBlock: cidr.cidrBlock, + comments: cidr.comments, + enabled: cidr.enabled, + actions: cidr.actions, + cidrBlockID: cidr.cidrBlockID, + createdBy: cidr.createdBy, + createdDate: cidr.createdDate, + modifiedBy: cidr.modifiedBy, + modifiedDate: cidr.modifiedDate, + }) + } + + return cidrBlocks +} diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go index 6f9efa058..ba457c2e6 100644 --- a/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go @@ -176,7 +176,23 @@ func (r IPAllowlistResource) Update(ctx context.Context, req resource.UpdateRequ } // Delete implements resource.Resource. -func (r IPAllowlistResource) Delete(ctx context.Context, _ resource.DeleteRequest, resp *resource.DeleteResponse) { +func (r IPAllowlistResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var plan *IPAllowlistResourceModel + + // Read Terraform state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if plan.Enable.ValueBool() { + resp.Diagnostics.Append(r.disableIPAllowlist(ctx)...) + } + + if resp.Diagnostics.HasError() { + return + } + // It can be only removed from state resp.State.RemoveResource(ctx) } diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go index bd01233e1..917fc3323 100644 --- a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go @@ -28,7 +28,8 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { mockEnableIPAllowlist(m) // step 2 read mockReadIPAllowlistStatus(m, true) - // step 3 delete - remove resource form state(no mock) + // step 3 delete - remove resource form state and disable ip allowlist + mockReadIPAllowlistStatus(m, false) }, steps: []resource.TestStep{ { @@ -61,7 +62,8 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { mockReadIPAllowlistStatus(m, true) // step 2 read mockReadIPAllowlistStatus(m, true) - // step 3 delete - remove resource form state(no mock) + // step 3 delete - remove resource form state and disable ip allowlist + mockReadIPAllowlistStatus(m, false) }, steps: []resource.TestStep{ { @@ -100,7 +102,8 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { mockEnableIPAllowlist(m) // step 4 refresh mockReadIPAllowlistStatus(m, true) - // step 5 delete - remove resource form state(no mock) + // step 5 delete - remove resource form state and disable ip allowlist + mockReadIPAllowlistStatus(m, false) }, steps: []resource.TestStep{ { @@ -169,33 +172,6 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { }, }, }, - "import": { - init: func(t *testing.T, m *iam.Mock) { - // step 1 create - mockReadIPAllowlistStatus(m, false) - mockEnableIPAllowlist(m) - // step 2 refresh - mockReadIPAllowlistStatus(m, true) - - // step 3 import - mockReadIPAllowlistStatus(m, true) - // step 4 refresh - mockReadIPAllowlistStatus(m, true) - }, - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), - }, - { - ImportState: true, - ImportStateVerify: false, - ResourceName: "akamai_iam_ip_allowlist.test", - ImportStateCheck: checkImportEnabledIPAllowlistForSpecificUser(), - }, - }, - }, } for name, test := range tests { t.Run(name, func(t *testing.T) { @@ -215,6 +191,50 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { } } +func TestImportIAMIPAllowlistResource(t *testing.T) { + { + tests := map[string]struct { + importID string + configPath string + init func(*testing.T, *iam.Mock) + mockData []commonDataForResource + stateCheck func(s []*terraform.InstanceState) error + }{ + "import": { + importID: " ", + init: func(t *testing.T, m *iam.Mock) { + // Import + mockReadIPAllowlistStatus(m, true).Twice() + }, + stateCheck: checkImportEnabledIPAllowlistForSpecificUser(), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(t, client) + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + ImportStateCheck: test.stateCheck, + ImportStateId: test.importID, + ImportState: true, + ResourceName: "akamai_iam_ip_allowlist.test", + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } + } +} + func checkImportEnabledIPAllowlistForSpecificUser() resource.ImportStateCheckFunc { return func(s []*terraform.InstanceState) error { if len(s) == 0 { diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf new file mode 100644 index 000000000..1ff3afc5f --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf @@ -0,0 +1,13 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.5.6.5/24" + comments = "test" + enabled = true + } + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf new file mode 100644 index 000000000..a3e8c34a5 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf @@ -0,0 +1,31 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.5.6.5/24" + comments = "test" + enabled = true + }, + { + cidr_block = "128.5.6.6/24" + enabled = false + }, + { + cidr_block = "128.5.6.7/24" + enabled = true + comments = "test1234" + }, + { + cidr_block = "128.5.6.8/24" + enabled = false + comments = "abcd12345" + }, + { + cidr_block = "128.5.6.9/24" + enabled = true + }, + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf new file mode 100644 index 000000000..345c8570e --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf @@ -0,0 +1,3 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf new file mode 100644 index 000000000..942dc5694 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf @@ -0,0 +1,13 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.5.6.6/24" + comments = "test" + enabled = true + } + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf new file mode 100644 index 000000000..1dabf7e95 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf @@ -0,0 +1,12 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + comments = "test" + enabled = true + } + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf new file mode 100644 index 000000000..dec299232 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf @@ -0,0 +1,12 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.1.2.5/24" + comments = "test" + } + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf new file mode 100644 index 000000000..fc3fa5768 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf @@ -0,0 +1,30 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.1.2.5/24" + enabled = false + }, + { + cidr_block = "128.1.2.6/24" + enabled = false + }, + { + cidr_block = "128.1.2.7/24" + enabled = true + comments = "test1234" + }, + { + cidr_block = "128.1.2.8/24" + enabled = true + comments = "up12345" + }, + { + cidr_block = "128.1.2.9/24" + enabled = false + }, + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf new file mode 100644 index 000000000..c7317067f --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf @@ -0,0 +1,12 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.1.2.5/24" + enabled = false + } + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf new file mode 100644 index 000000000..9dfd9c624 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf @@ -0,0 +1,30 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.2.2.5/28" + enabled = false + }, + { + cidr_block = "128.2.2.6/28" + enabled = true + }, + { + cidr_block = "128.2.2.7/28" + enabled = false + comments = "test12345" + }, + { + cidr_block = "128.5.6.8/24" + enabled = false + comments = "abcd12345" + }, + { + cidr_block = "128.5.6.9/24" + enabled = true + }, + ] +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf new file mode 100644 index 000000000..d7800c4c7 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf @@ -0,0 +1,21 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_blocks" "test" { + cidr_blocks = [ + { + cidr_block = "128.1.2.5/24" + enabled = false + }, + { + cidr_block = "128.1.2.6/24" + enabled = false + }, + { + cidr_block = "128.1.2.7/24" + enabled = true + comments = "test1234" + }, + ] +} \ No newline at end of file From 563ade867b425ba9efd93b786770ec77a78cee23 Mon Sep 17 00:00:00 2001 From: Filip Antkowiak Date: Fri, 20 Sep 2024 14:59:49 +0000 Subject: [PATCH 40/54] DXE-4030 Implement iam_users data source --- CHANGELOG.md | 3 + pkg/providers/iam/data_akamai_iam_user.go | 28 +- pkg/providers/iam/data_akamai_iam_users.go | 303 ++++++++++++++++++ .../iam/data_akamai_iam_users_test.go | 264 +++++++++++++++ pkg/providers/iam/iam_errors.go | 2 + pkg/providers/iam/provider.go | 1 + .../iam/testdata/TestDataUsers/default.tf | 6 + .../testdata/TestDataUsers/groupIDSearch.tf | 7 + 8 files changed, 600 insertions(+), 14 deletions(-) create mode 100644 pkg/providers/iam/data_akamai_iam_users.go create mode 100644 pkg/providers/iam/data_akamai_iam_users_test.go create mode 100644 pkg/providers/iam/testdata/TestDataUsers/default.tf create mode 100644 pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 93d6f2e25..338a44aed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,9 @@ +* IAM + * Added new data source + * `akamai_iam_users` - read list of users with access to the account * PAPI * Added a new optional param to the import id of the `akamai_edge_hostname` resource. diff --git a/pkg/providers/iam/data_akamai_iam_user.go b/pkg/providers/iam/data_akamai_iam_user.go index 1bcd57b93..f21b2f67c 100644 --- a/pkg/providers/iam/data_akamai_iam_user.go +++ b/pkg/providers/iam/data_akamai_iam_user.go @@ -32,7 +32,7 @@ type ( AdditionalAuthentication types.String `tfsdk:"additional_authentication"` AdditionalAuthenticationConfigured types.Bool `tfsdk:"additional_authentication_configured"` Address types.String `tfsdk:"address"` - AuthGrants []*authGrantsModel `tfsdk:"auth_grants"` + AuthGrants []authGrantsModel `tfsdk:"auth_grants"` City types.String `tfsdk:"city"` ContactType types.String `tfsdk:"contact_type"` Country types.String `tfsdk:"country"` @@ -67,13 +67,13 @@ type ( ThirdPartyAccess types.Bool `tfsdk:"third_party_access"` } authGrantsModel struct { - GroupID types.Int64 `tfsdk:"group_id"` - GroupName types.String `tfsdk:"group_name"` - IsBlocked types.Bool `tfsdk:"is_blocked"` - RoleDescription types.String `tfsdk:"role_description"` - RoleID types.Int64 `tfsdk:"role_id"` - RoleName types.String `tfsdk:"role_name"` - SubGroups []*authGrantsModel `tfsdk:"sub_groups"` + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + IsBlocked types.Bool `tfsdk:"is_blocked"` + RoleDescription types.String `tfsdk:"role_description"` + RoleID types.Int64 `tfsdk:"role_id"` + RoleName types.String `tfsdk:"role_name"` + SubGroups []authGrantsModel `tfsdk:"sub_groups"` } notificationsModel struct { Options optionsModel `tfsdk:"options"` @@ -89,7 +89,7 @@ type ( } ) -// NewUserDataSource returns a new iam allowed APIs data source +// NewUserDataSource returns a new iam user data source func NewUserDataSource() datasource.DataSource { return &userDataSource{} } @@ -373,7 +373,7 @@ func nestedAuthGrant(depth int) *schema.ListNestedAttribute { // Read is called when the provider must read data source values in order to update state func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - tflog.Debug(ctx, "IAM Allowed APIs DataSource Read") + tflog.Debug(ctx, "IAM User DataSource Read") var data userDataSourceModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { @@ -464,8 +464,8 @@ func (d *userDataSourceModel) setAttributes(user *iam.User) diag.Diagnostics { return nil } -func readAuthGrantSubGroups(authGrants []iam.AuthGrant, depth int) ([]*authGrantsModel, diag.Diagnostics) { - authGrantModelList := make([]*authGrantsModel, 0, len(authGrants)) +func readAuthGrantSubGroups(authGrants []iam.AuthGrant, depth int) ([]authGrantsModel, diag.Diagnostics) { + authGrantModelList := make([]authGrantsModel, 0, len(authGrants)) for _, authGrant := range authGrants { grantModel := authGrantsModel{ GroupID: types.Int64Value(authGrant.GroupID), @@ -483,11 +483,11 @@ func readAuthGrantSubGroups(authGrants []iam.AuthGrant, depth int) ([]*authGrant return nil, diags } grantModel.SubGroups = grants - } else if depth == 1 && authGrant.Subgroups != nil && len(authGrant.Subgroups) > 0 { + } else if depth == 1 && len(authGrant.Subgroups) > 0 { return nil, diag.Diagnostics{diag.NewErrorDiagnostic("unsupported subgroup depth", fmt.Sprintf("AuthGrant %d contains more subgroups and exceed total supported limit of nesting %d.", authGrant.GroupID, maxSupportedGroupNesting))} } - authGrantModelList = append(authGrantModelList, &grantModel) + authGrantModelList = append(authGrantModelList, grantModel) } return authGrantModelList, nil } diff --git a/pkg/providers/iam/data_akamai_iam_users.go b/pkg/providers/iam/data_akamai_iam_users.go new file mode 100644 index 000000000..67f8529d5 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users.go @@ -0,0 +1,303 @@ +package iam + +import ( + "context" + "fmt" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ datasource.DataSource = &usersDataSource{} + _ datasource.DataSourceWithConfigure = &usersDataSource{} +) + +type ( + usersDataSource struct { + meta meta.Meta + } + + usersModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + Users []userItem `tfsdk:"users"` + } + + userItem struct { + AccountID types.String `tfsdk:"account_id"` + Actions *userActions `tfsdk:"actions"` + AdditionalAuthentication types.String `tfsdk:"additional_authentication"` + AdditionalAuthenticationConfigured types.Bool `tfsdk:"additional_authentication_configured"` + AuthGrants []authGrantsModel `tfsdk:"auth_grants"` + Email types.String `tfsdk:"email"` + FirstName types.String `tfsdk:"first_name"` + LastName types.String `tfsdk:"last_name"` + IsLocked types.Bool `tfsdk:"is_locked"` + LastLoginDate types.String `tfsdk:"last_login_date"` + TFAConfigured types.Bool `tfsdk:"tfa_configured"` + TFAEnabled types.Bool `tfsdk:"tfa_enabled"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + UIUserName types.String `tfsdk:"ui_user_name"` + } + + userActions struct { + Delete types.Bool `tfsdk:"delete"` + APIClient types.Bool `tfsdk:"api_client"` + CanEditMFA types.Bool `tfsdk:"can_edit_mfa"` + CanEditNone types.Bool `tfsdk:"can_edit_none"` + CanEditTFA types.Bool `tfsdk:"can_edit_tfa"` + Edit types.Bool `tfsdk:"edit"` + EditProfile types.Bool `tfsdk:"edit_profile"` + IsCloneable types.Bool `tfsdk:"is_cloneable"` + ResetPassword types.Bool `tfsdk:"reset_password"` + ThirdPartyAccess types.Bool `tfsdk:"third_party_access"` + } +) + +// NewUsersDataSource returns a new iam users data source +func NewUsersDataSource() datasource.DataSource { + return &usersDataSource{} +} + +// Metadata configures data source's meta information +func (d *usersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_users" +} + +// Configure configures data source at the beginning of the lifecycle +func (d *usersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", + req.ProviderData)) + } + }() + d.meta = meta.Must(req.ProviderData) +} + +// Schema is used to define data source's terraform schema +func (d *usersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Identity and Access Management users", + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Optional: true, + Description: "Filters users for a specific group.", + }, + "users": schema.ListNestedAttribute{ + Description: "List of users in the account", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "account_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier of the account.", + }, + "actions": schema.SingleNestedAttribute{ + Description: "Specifies permissions available to the user for this group.", + Computed: true, + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is deletable.", + }, + "api_client": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to create an API client.", + }, + "can_edit_mfa": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can turn their MFA setting on or off.", + }, + "can_edit_none": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can turn their None setting on or off.", + }, + "can_edit_tfa": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can turn their TFA setting on or off.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user is editable.", + }, + "edit_profile": schema.BoolAttribute{ + Computed: true, + Description: "With a true value, the user can edit their user profile.", + }, + "is_cloneable": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to create a new user with permissions cloned from this user.", + }, + "reset_password": schema.BoolAttribute{ + Computed: true, + Description: "Enables an administrator to send a user a password by email or see a one-time token.", + }, + "third_party_access": schema.BoolAttribute{ + Computed: true, + Description: "Enables the administrator to manage extended access.", + }, + }, + }, + "additional_authentication": schema.StringAttribute{ + Computed: true, + Description: "Specifies the user's multi-factor authentication method, confirming their identity.", + }, + "additional_authentication_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user has multi-factor authentication configured.", + }, + "auth_grants": schema.ListNestedAttribute{ + Description: "A user's role assignments, per group.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "group_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each group.", + }, + "group_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the group.", + }, + "is_blocked": schema.BoolAttribute{ + Computed: true, + Description: "Whether a user's access to a group is blocked.", + }, + "role_description": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role to convey its use.", + }, + "role_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each role.", + }, + "role_name": schema.StringAttribute{ + Computed: true, + Description: "Descriptive label for the role.", + }, + "sub_groups": nestedAuthGrant(50), + }}, + }, + "email": schema.StringAttribute{ + Computed: true, + Description: "The user's email address.", + }, + "first_name": schema.StringAttribute{ + Computed: true, + Description: "The user's first name.", + }, + "is_locked": schema.BoolAttribute{ + Computed: true, + Description: "Whether the user's account is locked.", + }, + "last_login_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the user last logged in.", + }, + "last_name": schema.StringAttribute{ + Computed: true, + Description: "The user's surname.", + }, + "tfa_configured": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is configured.", + }, + "tfa_enabled": schema.BoolAttribute{ + Computed: true, + Description: "Whether TFA is enabled.", + }, + "ui_identity_id": schema.StringAttribute{ + Computed: true, + Description: "Unique identifier for each user, which corresponds to their Control Center profile or client ID. Also known as a contactId in other APIs.", + }, + "ui_user_name": schema.StringAttribute{ + Computed: true, + Description: "The user's username in Control Center.", + }, + }, + }, + }}} +} + +// Read is called when the provider must read data source values in order to update state +func (d *usersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "IAM Users DataSource Read") + + var data usersModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { + return + } + client := inst.Client(d.meta) + + groupID := data.GroupID.ValueInt64Pointer() + + users, err := client.ListUsers(ctx, iam.ListUsersRequest{ + GroupID: groupID, + AuthGrants: true, + Actions: true, + }) + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMListUsers), err.Error()) + return + } + + if resp.Diagnostics.Append(data.read(users)...); resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + +} + +func (d *usersModel) read(users []iam.UserListItem) diag.Diagnostics { + for _, user := range users { + authGrants, diags := readAuthGrantSubGroups(user.AuthGrants, maxSupportedGroupNesting) + if diags.HasError() { + return diags + } + userItem := userItem{ + AccountID: types.StringValue(user.AccountID), + AdditionalAuthentication: types.StringValue(string(user.AdditionalAuthentication)), + AdditionalAuthenticationConfigured: types.BoolValue(user.AdditionalAuthenticationConfigured), + AuthGrants: authGrants, + Email: types.StringValue(user.Email), + FirstName: types.StringValue(user.FirstName), + IsLocked: types.BoolValue(user.IsLocked), + LastName: types.StringValue(user.LastName), + LastLoginDate: types.StringValue(date.FormatRFC3339Nano(user.LastLoginDate)), + TFAConfigured: types.BoolValue(user.TFAConfigured), + TFAEnabled: types.BoolValue(user.TFAEnabled), + UIIdentityID: types.StringValue(user.IdentityID), + UIUserName: types.StringValue(user.UserName), + } + + if user.Actions != nil { + userItem.Actions = &userActions{ + Delete: types.BoolValue(user.Actions.Delete), + APIClient: types.BoolValue(user.Actions.APIClient), + CanEditMFA: types.BoolValue(user.Actions.CanEditMFA), + CanEditNone: types.BoolValue(user.Actions.CanEditNone), + CanEditTFA: types.BoolValue(user.Actions.CanEditTFA), + Edit: types.BoolValue(user.Actions.Edit), + EditProfile: types.BoolValue(user.Actions.EditProfile), + IsCloneable: types.BoolValue(user.Actions.IsCloneable), + ResetPassword: types.BoolValue(user.Actions.ResetPassword), + ThirdPartyAccess: types.BoolValue(user.Actions.ThirdPartyAccess), + } + } + d.Users = append(d.Users, userItem) + } + return nil +} diff --git a/pkg/providers/iam/data_akamai_iam_users_test.go b/pkg/providers/iam/data_akamai_iam_users_test.go new file mode 100644 index 000000000..049c0f2e6 --- /dev/null +++ b/pkg/providers/iam/data_akamai_iam_users_test.go @@ -0,0 +1,264 @@ +package iam + +import ( + "errors" + "regexp" + "testing" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/mock" +) + +var ( + basicTestDataForUsers = []iam.UserListItem{{ + FirstName: "firstName1", + LastName: "lastName1", + UserName: "user1", + Email: "user1@example.com", + TFAEnabled: false, + IdentityID: "A-B-123456", + IsLocked: false, + LastLoginDate: time.Date(2017, time.July, 27, 18, 11, 25, 0, time.UTC), + TFAConfigured: false, + AccountID: "A-CCT3456", + Actions: &iam.UserActions{ + APIClient: true, + Delete: true, + Edit: true, + IsCloneable: true, + ResetPassword: true, + ThirdPartyAccess: true, + CanEditTFA: false, + CanEditMFA: false, + CanEditNone: false, + EditProfile: true, + }, + AuthGrants: []iam.AuthGrant{ + { + GroupID: 12345, + GroupName: "Internet Company", + IsBlocked: false, + RoleDescription: "Role giving admin access.", + RoleID: ptr.To(12), + RoleName: "admin", + Subgroups: []iam.AuthGrant{{ + GroupID: 1000, + GroupName: "sub group", + RoleID: ptr.To(1000), + RoleName: "sub group role", + }}, + }, + { + RoleID: ptr.To(100002), + RoleName: "Admin for Account Roles", + }, + }, + AdditionalAuthentication: "TFA", + AdditionalAuthenticationConfigured: false, + }, + { + FirstName: "firstName2", + LastName: "lastName2", + UserName: "user2", + Email: "user2@example.com", + TFAEnabled: false, + IdentityID: "B-B-123456", + IsLocked: false, + LastLoginDate: time.Time{}, + TFAConfigured: false, + AccountID: "B-CCT3456", + Actions: &iam.UserActions{ + APIClient: true, + Delete: true, + Edit: true, + IsCloneable: true, + ResetPassword: true, + ThirdPartyAccess: true, + CanEditTFA: false, + CanEditMFA: false, + CanEditNone: false, + EditProfile: true, + }, + AuthGrants: []iam.AuthGrant{ + { + RoleID: ptr.To(100002), + RoleName: "Admin for Account Roles", + }, + }, + AdditionalAuthentication: "TFA", + AdditionalAuthenticationConfigured: false, + }} +) + +func TestDataUsers(t *testing.T) { + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, []iam.UserListItem, *int64) + mockData []iam.UserListItem + groupID *int64 + expectedError *regexp.Regexp + }{ + "happy path": { + configPath: "testdata/TestDataUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + expectListUsers(m, mockData, groupID, 3) + }, + mockData: basicTestDataForUsers, + }, + "happy path - no users": { + configPath: "testdata/TestDataUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + expectListUsers(m, mockData, groupID, 3) + }, + mockData: []iam.UserListItem{}, + }, + "happy path - groupID search": { + groupID: ptr.To(int64(12345)), + configPath: "testdata/TestDataUsers/groupIDSearch.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + expectListUsers(m, mockData, groupID, 3) + }, + mockData: basicTestDataForUsers, + }, + "error - list user fails": { + configPath: "testdata/TestDataUsers/default.tf", + init: func(t *testing.T, m *iam.Mock, mockData []iam.UserListItem, groupID *int64) { + listUsersReq := iam.ListUsersRequest{GroupID: groupID, AuthGrants: true, Actions: true} + m.On("ListUsers", mock.Anything, listUsersReq).Return(nil, errors.New("test error")) + }, + expectedError: regexp.MustCompile("test error"), + mockData: basicTestDataForUsers, + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + if test.init != nil { + test.init(t, client, test.mockData, test.groupID) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + IsUnitTest: true, + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, test.configPath), + Check: checkUsersAttrs(test.groupID, len(test.mockData) == 0), + ExpectError: test.expectedError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkUsersAttrs(groupID *int64, emptyReturn bool) resource.TestCheckFunc { + name := "data.akamai_iam_users.test" + + if emptyReturn { + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "users.#", "0"), + } + if groupID != nil { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "group_id", "12345")) + } else { + checksFuncs = append(checksFuncs, resource.TestCheckNoResourceAttr(name, "group_id")) + } + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) + } + + checksFuncs := []resource.TestCheckFunc{ + resource.TestCheckResourceAttr(name, "users.#", "2"), + resource.TestCheckResourceAttr(name, "users.0.account_id", "A-CCT3456"), + resource.TestCheckResourceAttr(name, "users.0.additional_authentication", "TFA"), + resource.TestCheckResourceAttr(name, "users.0.additional_authentication_configured", "false"), + resource.TestCheckResourceAttr(name, "users.0.email", "user1@example.com"), + resource.TestCheckResourceAttr(name, "users.0.first_name", "firstName1"), + resource.TestCheckResourceAttr(name, "users.0.is_locked", "false"), + resource.TestCheckResourceAttr(name, "users.0.last_login_date", "2017-07-27T18:11:25Z"), + resource.TestCheckResourceAttr(name, "users.0.last_name", "lastName1"), + resource.TestCheckResourceAttr(name, "users.0.tfa_configured", "false"), + resource.TestCheckResourceAttr(name, "users.0.tfa_enabled", "false"), + resource.TestCheckResourceAttr(name, "users.0.ui_identity_id", "A-B-123456"), + resource.TestCheckResourceAttr(name, "users.0.ui_user_name", "user1"), + resource.TestCheckResourceAttr(name, "users.0.actions.delete", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.api_client", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.can_edit_mfa", "false"), + resource.TestCheckResourceAttr(name, "users.0.actions.can_edit_none", "false"), + resource.TestCheckResourceAttr(name, "users.0.actions.can_edit_tfa", "false"), + resource.TestCheckResourceAttr(name, "users.0.actions.edit", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.edit_profile", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.is_cloneable", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.reset_password", "true"), + resource.TestCheckResourceAttr(name, "users.0.actions.third_party_access", "true"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.#", "2"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.group_id", "12345"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.group_name", "Internet Company"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.is_blocked", "false"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.role_description", "Role giving admin access."), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.role_id", "12"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.role_name", "admin"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.0.sub_groups.#", "1"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.group_id", "0"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.group_name", ""), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.is_blocked", "false"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.role_description", ""), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.role_id", "100002"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.role_name", "Admin for Account Roles"), + resource.TestCheckResourceAttr(name, "users.0.auth_grants.1.sub_groups.#", "0"), + + resource.TestCheckResourceAttr(name, "users.1.account_id", "B-CCT3456"), + resource.TestCheckResourceAttr(name, "users.1.additional_authentication", "TFA"), + resource.TestCheckResourceAttr(name, "users.1.additional_authentication_configured", "false"), + resource.TestCheckResourceAttr(name, "users.1.email", "user2@example.com"), + resource.TestCheckResourceAttr(name, "users.1.first_name", "firstName2"), + resource.TestCheckResourceAttr(name, "users.1.is_locked", "false"), + resource.TestCheckResourceAttr(name, "users.1.last_login_date", ""), + resource.TestCheckResourceAttr(name, "users.1.last_name", "lastName2"), + resource.TestCheckResourceAttr(name, "users.1.tfa_configured", "false"), + resource.TestCheckResourceAttr(name, "users.1.tfa_enabled", "false"), + resource.TestCheckResourceAttr(name, "users.1.ui_identity_id", "B-B-123456"), + resource.TestCheckResourceAttr(name, "users.1.ui_user_name", "user2"), + resource.TestCheckResourceAttr(name, "users.1.actions.delete", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.api_client", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.can_edit_mfa", "false"), + resource.TestCheckResourceAttr(name, "users.1.actions.can_edit_none", "false"), + resource.TestCheckResourceAttr(name, "users.1.actions.can_edit_tfa", "false"), + resource.TestCheckResourceAttr(name, "users.1.actions.edit", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.edit_profile", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.is_cloneable", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.reset_password", "true"), + resource.TestCheckResourceAttr(name, "users.1.actions.third_party_access", "true"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.#", "1"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.group_id", "0"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.group_name", ""), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.is_blocked", "false"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.role_description", ""), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.role_id", "100002"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.role_name", "Admin for Account Roles"), + resource.TestCheckResourceAttr(name, "users.1.auth_grants.0.sub_groups.#", "0"), + } + if groupID != nil { + checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, "group_id", "12345")) + } else { + checksFuncs = append(checksFuncs, resource.TestCheckNoResourceAttr(name, "group_id")) + } + + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) +} + +func expectListUsers(client *iam.Mock, mockData []iam.UserListItem, groupID *int64, timesToRun int) { + listUsersReq := iam.ListUsersRequest{ + GroupID: groupID, + AuthGrants: true, + Actions: true, + } + + client.On("ListUsers", mock.Anything, listUsersReq).Return(mockData, nil).Times(timesToRun) +} diff --git a/pkg/providers/iam/iam_errors.go b/pkg/providers/iam/iam_errors.go index d9fb79007..8f5f7843f 100644 --- a/pkg/providers/iam/iam_errors.go +++ b/pkg/providers/iam/iam_errors.go @@ -7,6 +7,8 @@ var ( ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") + // ErrIAMListUsers is returned when ListUsers fails + ErrIAMListUsers = errors.New("IAM list users failed") // ErrIAMGetUser is returned when GetUser fails ErrIAMGetUser = errors.New("IAM get user failed") // ErrIAMListCIDRBlocks is returned when ListCIDRBlocks fails diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 758fd9984..421ceff40 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -111,5 +111,6 @@ func (p *Subprovider) FrameworkDataSources() []func() datasource.DataSource { NewRoleDataSource, NewUserDataSource, NewUsersAffectedByMovingGroupDataSource, + NewUsersDataSource, } } diff --git a/pkg/providers/iam/testdata/TestDataUsers/default.tf b/pkg/providers/iam/testdata/TestDataUsers/default.tf new file mode 100644 index 000000000..849e34e67 --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsers/default.tf @@ -0,0 +1,6 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users" "test" { +} diff --git a/pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf b/pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf new file mode 100644 index 000000000..bd7a462bd --- /dev/null +++ b/pkg/providers/iam/testdata/TestDataUsers/groupIDSearch.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +data "akamai_iam_users" "test" { + group_id = 12345 +} From a60da51e194c7bb02253b4fb8ea685276aac81f0 Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Thu, 26 Sep 2024 12:01:43 +0000 Subject: [PATCH 41/54] DXE-4262 Change cidr_blocks resource to cidr_block --- CHANGELOG.md | 2 +- pkg/providers/iam/provider.go | 2 +- .../iam/resource_akamai_iam_cidr_block.go | 335 ++++++++ .../resource_akamai_iam_cidr_block_test.go | 489 +++++++++++ .../iam/resource_akamai_iam_cidr_blocks.go | 408 ---------- .../resource_akamai_iam_cidr_blocks_test.go | 764 ------------------ .../iam/testdata/TestResCIDRBlock/create.tf | 9 + .../create_without_comments.tf | 8 + .../empty_config.tf | 2 +- .../testdata/TestResCIDRBlock/importable.tf | 9 + .../importable_without_comments.tf | 8 + .../TestResCIDRBlock/missing_cidr_block.tf | 7 + .../TestResCIDRBlock/missing_enabled.tf | 7 + .../iam/testdata/TestResCIDRBlock/update.tf | 9 + .../iam/testdata/TestResCIDRBlocks/create.tf | 13 - .../TestResCIDRBlocks/create_multiple.tf | 31 - .../testdata/TestResCIDRBlocks/importable.tf | 13 - .../TestResCIDRBlocks/missing_cidr_block.tf | 12 - .../TestResCIDRBlocks/missing_enabled.tf | 12 - .../testdata/TestResCIDRBlocks/update_five.tf | 30 - .../TestResCIDRBlocks/update_single.tf | 12 - .../update_three_out_of_five.tf | 30 - .../update_three_remove_two.tf | 21 - 23 files changed, 884 insertions(+), 1349 deletions(-) create mode 100644 pkg/providers/iam/resource_akamai_iam_cidr_block.go create mode 100644 pkg/providers/iam/resource_akamai_iam_cidr_block_test.go delete mode 100644 pkg/providers/iam/resource_akamai_iam_cidr_blocks.go delete mode 100644 pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/create.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf rename pkg/providers/iam/testdata/{TestResCIDRBlocks => TestResCIDRBlock}/empty_config.tf (96%) create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf create mode 100644 pkg/providers/iam/testdata/TestResCIDRBlock/update.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf delete mode 100644 pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 338a44aed..bd723e5f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,7 +72,7 @@ * IAM * Added new resource: - * `akamai_iam_cidr_blocks` - manage CIDR blocks assigned to the allowlist + * `akamai_iam_cidr_block` - manage CIDR block assigned to the allowlist diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 421ceff40..14e854e6a 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -90,8 +90,8 @@ func (p *Subprovider) SDKDataSources() map[string]*schema.Resource { // FrameworkResources returns the IAM resources implemented using terraform-plugin-framework func (p *Subprovider) FrameworkResources() []func() resource.Resource { return []func() resource.Resource{ + NewCIDRBlockResource, NewIPAllowlistResource, - NewCIDRBlocksResource, } } diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block.go b/pkg/providers/iam/resource_akamai_iam_cidr_block.go new file mode 100644 index 000000000..a6f9196ab --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block.go @@ -0,0 +1,335 @@ +package iam + +import ( + "context" + "fmt" + "strconv" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +var ( + _ resource.Resource = &CIDRBlockResource{} + _ resource.ResourceWithImportState = &CIDRBlockResource{} +) + +// CIDRBlockResource represents akamai_iam_cidr_block resource +type CIDRBlockResource struct { + meta meta.Meta +} + +// NewCIDRBlockResource returns new akamai_iam_cidr_block resource +func NewCIDRBlockResource() resource.Resource { return &CIDRBlockResource{} } + +// CIDRBlockResourceModel represents model of akamai_iam_cidr_block resource +type CIDRBlockResourceModel struct { + CIDR types.String `tfsdk:"cidr_block"` + Enabled types.Bool `tfsdk:"enabled"` + Comments types.String `tfsdk:"comments"` + Actions types.Object `tfsdk:"actions"` + CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` +} + +// Metadata implements resource.Resource. +func (r *CIDRBlockResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = "akamai_iam_cidr_block" +} + +// Schema implements resource.Resource. +func (r *CIDRBlockResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "cidr_block": schema.StringAttribute{ + Required: true, + Description: "The value of an IP address or IP address range.", + }, + "enabled": schema.BoolAttribute{ + Required: true, + Description: "Enables the CIDR block on the account.", + }, + "comments": schema.StringAttribute{ + Optional: true, + Description: "Descriptive label you provide for the CIDR block.", + }, + "actions": schema.SingleNestedAttribute{ + Computed: true, + Description: "Specifies activities available for the CIDR block.", + PlanModifiers: []planmodifier.Object{ + objectplanmodifier.UseStateForUnknown(), + }, + Attributes: map[string]schema.Attribute{ + "delete": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can delete this CIDR block. You can't delete a CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", + }, + "edit": schema.BoolAttribute{ + Computed: true, + Description: "Whether you can edit this CIDR block. You can't edit CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", + }, + }, + }, + "cidr_block_id": schema.Int64Attribute{ + Computed: true, + Description: "Unique identifier for each CIDR block.", + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.UseStateForUnknown(), + }, + }, + "created_by": schema.StringAttribute{ + Computed: true, + Description: "The user who created the CIDR block.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "created_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was created.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "modified_by": schema.StringAttribute{ + Computed: true, + Description: "The user who last edited the CIDR block.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "modified_date": schema.StringAttribute{ + Computed: true, + Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + }, + } +} + +// Configure implements resource.ResourceWithConfigure. +func (r *CIDRBlockResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider + return + } + + defer func() { + if r := recover(); r != nil { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + } + }() + + r.meta = meta.Must(req.ProviderData) +} + +// Create implements resource.Resource. +func (r *CIDRBlockResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Creating CIDR Block resource") + var plan CIDRBlockResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.create(ctx, &plan); err != nil { + resp.Diagnostics.AddError("create cidr block failed", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *CIDRBlockResource) create(ctx context.Context, plan *CIDRBlockResourceModel) error { + client := inst.Client(r.meta) + + resp, err := client.CreateCIDRBlock(ctx, iam.CreateCIDRBlockRequest{ + CIDRBlock: plan.CIDR.ValueString(), + Comments: plan.Comments.ValueStringPointer(), + Enabled: plan.Enabled.ValueBool(), + }) + if err != nil { + return err + } + + // Use GetCIDRBlock to fetch current actions, as they are not present in the response from CreateCIDRBlock + cidr, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ + CIDRBlockID: resp.CIDRBlockID, + Actions: true, + }) + if err != nil { + return err + } + + plan.setData(cidr) + + return nil +} + +// Read implements resource.Resource. +func (r *CIDRBlockResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Reading CIDR Block Resource") + var state CIDRBlockResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.read(ctx, &state); err != nil { + resp.Diagnostics.AddError("read cidr block error", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *CIDRBlockResource) read(ctx context.Context, data *CIDRBlockResourceModel) error { + client := inst.Client(r.meta) + + cidr, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ + CIDRBlockID: data.CIDRBlockID.ValueInt64(), + Actions: true, + }) + if err != nil { + return err + } + + data.setData(cidr) + + return nil +} + +// Update implements resource.Resource. +func (r *CIDRBlockResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Updating CIDR Block Resource") + var plan CIDRBlockResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + if err := r.update(ctx, &plan); err != nil { + resp.Diagnostics.AddError("update cidr block failed", err.Error()) + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *CIDRBlockResource) update(ctx context.Context, plan *CIDRBlockResourceModel) error { + client := inst.Client(r.meta) + + _, err := client.UpdateCIDRBlock(ctx, iam.UpdateCIDRBlockRequest{ + CIDRBlockID: plan.CIDRBlockID.ValueInt64(), + Body: iam.UpdateCIDRBlockRequestBody{ + CIDRBlock: plan.CIDR.ValueString(), + Comments: plan.Comments.ValueStringPointer(), + Enabled: plan.Enabled.ValueBool(), + }, + }) + if err != nil { + return err + } + + return nil +} + +// Delete implements resource.Resource. +func (r *CIDRBlockResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Deleting CIDR Block Resource") + + var state *CIDRBlockResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + client := inst.Client(r.meta) + + if err := client.DeleteCIDRBlock(ctx, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: state.CIDRBlockID.ValueInt64(), + }); err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("delete cidr block %d failed", state.CIDRBlockID), err.Error()) + return + } + + resp.State.RemoveResource(ctx) +} + +// ImportState implements resource.ResourceWithImportState. +func (r *CIDRBlockResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Importing CIDR Block Resource") + + cidrBlockID, err := strconv.ParseInt(req.ID, 10, 64) + if err != nil { + resp.Diagnostics.AddError("could not convert import ID to int", err.Error()) + return + } + + data := &CIDRBlockResourceModel{} + + // in import, we only need to set cidr block ID to allow read function to fill other attributes + data.CIDRBlockID = types.Int64Value(cidrBlockID) + // we also need to satisfy framework with a correct value for actions object + data.Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (m *CIDRBlockResourceModel) setData(resp *iam.GetCIDRBlockResponse) { + if resp.Actions != nil { + m.Actions = getActionFor(resp.Actions.Edit, resp.Actions.Delete) + } else { + m.Actions = types.ObjectNull(map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }) + } + m.CIDRBlockID = types.Int64Value(resp.CIDRBlockID) + m.ModifiedBy = types.StringValue(resp.ModifiedBy) + m.ModifiedDate = types.StringValue(resp.ModifiedDate.Format(time.RFC3339Nano)) + m.CreatedBy = types.StringValue(resp.CreatedBy) + m.CreatedDate = types.StringValue(resp.CreatedDate.Format(time.RFC3339Nano)) + m.CIDR = types.StringValue(resp.CIDRBlock) + m.Comments = types.StringPointerValue(resp.Comments) + m.Enabled = types.BoolValue(resp.Enabled) +} + +func getActionFor(editAction, deleteAction bool) basetypes.ObjectValue { + return types.ObjectValueMust( + map[string]attr.Type{ + "edit": types.BoolType, + "delete": types.BoolType, + }, + map[string]attr.Value{ + "edit": basetypes.NewBoolValue(editAction), + "delete": basetypes.NewBoolValue(deleteAction), + }, + ) +} diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go b/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go new file mode 100644 index 000000000..c76c9ebd6 --- /dev/null +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go @@ -0,0 +1,489 @@ +package iam + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/terraform-provider-akamai/v6/internal/test" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" + "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/stretchr/testify/mock" +) + +type ( + commonDataForResource struct { + cidrBlock string + comments *string + enabled bool + actions *action + cidrBlockID int64 + createdBy string + createdDate string + modifiedBy string + modifiedDate string + } + + action struct { + deleteAction bool + editAction bool + } +) + +var ( + testCIDR = commonDataForResource{ + cidrBlock: "128.5.6.5/24", + enabled: true, + comments: ptr.To("test"), + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + } + + testCIDRNoComments = commonDataForResource{ + cidrBlock: "128.5.6.5/24", + enabled: false, + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + } + + updatedCIDR = commonDataForResource{ + cidrBlock: "128.5.6.99/24", + enabled: false, + comments: ptr.To("test-updated"), + actions: &action{ + deleteAction: true, + editAction: true, + }, + cidrBlockID: 1111, + createdBy: "jdoe", + createdDate: "2006-01-02T15:04:05.999999999Z", + modifiedBy: "jkowalski", + modifiedDate: "2006-01-02T15:04:05.999999999Z", + } +) + +func TestCIDRBlockResource(t *testing.T) { + t.Parallel() + tests := map[string]struct { + configPath string + init func(*testing.T, *iam.Mock, commonDataForResource, commonDataForResource) + createData commonDataForResource + updateData commonDataForResource + steps []resource.TestStep + error *regexp.Regexp + }{ + "happy path - create with comment": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Twice() + // Delete + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + }, + }, + "happy path - create without comment": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Times(2) + // Delete + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDRNoComments, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create_without_comments.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckNoResourceAttr("akamai_iam_cidr_block.test", "comments"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "false"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + }, + }, + "happy path - update all fields": { + init: func(t *testing.T, m *iam.Mock, createData, updateData commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + mockGetCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Twice() + // Update + mockUpdateCIDRBlock(t, m, updateData) + // Read + mockGetCIDRBlock(t, m, updateData) + // Delete + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDR, + updateData: updatedCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/update.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test-updated"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.99/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "false"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + }, + }, + "validation error - missing cidr block": { + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/missing_cidr_block.tf"), + ExpectError: regexp.MustCompile(`The argument "cidr_block" is required, but no definition was found`), + }, + }, + }, + "validation error - missing enabled": { + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/missing_enabled.tf"), + ExpectError: regexp.MustCompile(`The argument "enabled" is required, but no definition was found`), + }, + }, + }, + "expect error - create": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ + CIDRBlock: createData.cidrBlock, + Comments: createData.comments, + Enabled: createData.enabled, + }).Return(nil, fmt.Errorf("create failed")).Once() + }, + createData: testCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + ExpectError: regexp.MustCompile(`create failed`), + }, + }, + }, + "expect error - delete": { + init: func(t *testing.T, m *iam.Mock, createData, _ commonDataForResource) { + // Create + mockCreateCIDRBlock(t, m, createData) + // Read + mockGetCIDRBlock(t, m, createData).Twice() + mockGetCIDRBlock(t, m, createData) + // Delete - error + m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: createData.cidrBlockID, + }).Return(iam.ErrDeleteCIDRBlock).Once() + // Delete - destroy + mockDeleteCIDRBlock(m, createData) + }, + createData: testCIDR, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/create.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.delete", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "actions.edit", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "comments", "test"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block", "128.5.6.5/24"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "enabled", "true"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "cidr_block_id", "1111"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_by", "jdoe"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "created_date", "2006-01-02T15:04:05.999999999Z"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_by", "jkowalski"), + resource.TestCheckResourceAttr("akamai_iam_cidr_block.test", "modified_date", "2006-01-02T15:04:05.999999999Z"), + ), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/empty_config.tf"), + ExpectError: regexp.MustCompile(`Error: delete cidr block {2 1111} failed`), + }, + }, + }, + } + + for name, tc := range tests { + tc := tc + t.Run(name, func(t *testing.T) { + t.Parallel() + client := &iam.Mock{} + if tc.init != nil { + tc.init(t, client, tc.createData, tc.updateData) + } + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: tc.steps, + }) + }) + client.AssertExpectations(t) + }) + } + +} + +func TestImportCIDRBlockResource(t *testing.T) { + tests := map[string]struct { + importID string + init func(*testing.T, *iam.Mock, commonDataForResource) + mockData commonDataForResource + expectError *regexp.Regexp + }{ + "happy path - import with comments": { + importID: "1111", + mockData: testCIDR, + init: func(t *testing.T, m *iam.Mock, data commonDataForResource) { + // Read + mockGetCIDRBlock(t, m, data) + }, + }, + "happy path - import without comments": { + importID: "1111", + mockData: testCIDRNoComments, + init: func(t *testing.T, m *iam.Mock, data commonDataForResource) { + // Read + mockGetCIDRBlock(t, m, data) + }, + }, + "expect error - wrong import ID": { + importID: "wrong format", + init: func(_ *testing.T, _ *iam.Mock, _ commonDataForResource) {}, + expectError: regexp.MustCompile(`Error: could not convert import ID to int`), + }, + "expect error - read": { + importID: "1111", + init: func(t *testing.T, m *iam.Mock, data commonDataForResource) { + m.On("GetCIDRBlock", mock.Anything, iam.GetCIDRBlockRequest{ + CIDRBlockID: data.cidrBlockID, + Actions: true, + }).Return(nil, fmt.Errorf("get failed")).Once() + }, + mockData: testCIDR, + expectError: regexp.MustCompile(`get failed`), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + tc.init(t, client, tc.mockData) + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + ImportStateCheck: checkImportCIDRBlock(tc.mockData), + ImportStateId: tc.importID, + ImportState: true, + ResourceName: "akamai_iam_cidr_block.test", + Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlock/importable.tf"), + ExpectError: tc.expectError, + }, + }, + }) + }) + client.AssertExpectations(t) + }) + } +} + +func checkImportCIDRBlock(data commonDataForResource) resource.ImportStateCheckFunc { + return func(s []*terraform.InstanceState) error { + attr := make(map[string]string) + + if len(s) == 0 { + return errors.New("no instance found") + } + if len(s) != 1 { + return fmt.Errorf("expected one instance: %d", len(s)) + } + + if data.actions != nil { + attr["actions.delete"] = strconv.FormatBool(data.actions.deleteAction) + attr["actions.edit"] = strconv.FormatBool(data.actions.editAction) + } + if data.comments != nil { + attr["comments"] = *data.comments + } else { + attr["comments"] = "" + } + attr["cidr_block"] = data.cidrBlock + attr["enabled"] = strconv.FormatBool(data.enabled) + attr["cidr_block_id"] = strconv.FormatInt(data.cidrBlockID, 10) + attr["created_by"] = data.createdBy + attr["created_date"] = data.createdDate + attr["modified_by"] = data.modifiedBy + attr["modified_date"] = data.modifiedDate + + state := s[0].Attributes + + attributes := attr + + var invalidValues []string + for field, expectedVal := range attributes { + if state[field] != expectedVal { + invalidValues = append(invalidValues, fmt.Sprintf("field: %s, got: %s, expected: %s ", field, state[field], expectedVal)) + } + } + + if len(invalidValues) != 0 { + return fmt.Errorf(strings.Join(invalidValues, "\n")) + } + return nil + } +} + +func mockCreateCIDRBlock(t *testing.T, m *iam.Mock, testData commonDataForResource) *mock.Call { + var act *iam.CIDRActions + + if testData.actions != nil { + act = &iam.CIDRActions{ + Delete: testData.actions.deleteAction, + Edit: testData.actions.editAction, + } + } + + return m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ + CIDRBlock: testData.cidrBlock, + Comments: testData.comments, + Enabled: testData.enabled, + }).Return(&iam.CreateCIDRBlockResponse{ + Actions: act, + CIDRBlock: testData.cidrBlock, + CIDRBlockID: testData.cidrBlockID, + Comments: testData.comments, + CreatedBy: testData.createdBy, + CreatedDate: test.NewTimeFromString(t, testData.createdDate), + Enabled: testData.enabled, + ModifiedBy: testData.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, testData.modifiedDate), + }, nil).Once() +} + +func mockGetCIDRBlock(t *testing.T, m *iam.Mock, testData commonDataForResource) *mock.Call { + var act *iam.CIDRActions + + if testData.actions != nil { + act = &iam.CIDRActions{ + Delete: testData.actions.deleteAction, + Edit: testData.actions.editAction, + } + } + + return m.On("GetCIDRBlock", mock.Anything, iam.GetCIDRBlockRequest{ + CIDRBlockID: testData.cidrBlockID, + Actions: true, + }).Return(&iam.GetCIDRBlockResponse{ + Actions: act, + CIDRBlock: testData.cidrBlock, + CIDRBlockID: testData.cidrBlockID, + Comments: testData.comments, + CreatedBy: testData.createdBy, + CreatedDate: test.NewTimeFromString(t, testData.createdDate), + Enabled: testData.enabled, + ModifiedBy: testData.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, testData.modifiedDate), + }, nil).Once() +} + +func mockDeleteCIDRBlock(m *iam.Mock, testData commonDataForResource) *mock.Call { + return m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ + CIDRBlockID: testData.cidrBlockID, + }).Return(nil).Once() +} + +func mockUpdateCIDRBlock(t *testing.T, m *iam.Mock, testData commonDataForResource) *mock.Call { + var act *iam.CIDRActions + + if testData.actions != nil { + act = &iam.CIDRActions{ + Delete: testData.actions.deleteAction, + Edit: testData.actions.editAction, + } + } + + return m.On("UpdateCIDRBlock", mock.Anything, iam.UpdateCIDRBlockRequest{ + CIDRBlockID: testData.cidrBlockID, + Body: iam.UpdateCIDRBlockRequestBody{ + CIDRBlock: testData.cidrBlock, + Comments: testData.comments, + Enabled: testData.enabled, + }, + }).Return(&iam.UpdateCIDRBlockResponse{ + Actions: act, + CIDRBlock: testData.cidrBlock, + CIDRBlockID: testData.cidrBlockID, + Comments: testData.comments, + CreatedBy: testData.createdBy, + CreatedDate: test.NewTimeFromString(t, testData.createdDate), + Enabled: testData.enabled, + ModifiedBy: testData.modifiedBy, + ModifiedDate: test.NewTimeFromString(t, testData.modifiedDate), + }, nil).Once() +} diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_blocks.go b/pkg/providers/iam/resource_akamai_iam_cidr_blocks.go deleted file mode 100644 index 51d765ff5..000000000 --- a/pkg/providers/iam/resource_akamai_iam_cidr_blocks.go +++ /dev/null @@ -1,408 +0,0 @@ -package iam - -import ( - "context" - "fmt" - "time" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-plugin-log/tflog" -) - -var ( - _ resource.Resource = &CIDRBlocksResource{} - _ resource.ResourceWithImportState = &CIDRBlocksResource{} -) - -// CIDRBlocksResource represents akamai_iam_cidr_blocks resource -type CIDRBlocksResource struct { - meta meta.Meta -} - -// NewCIDRBlocksResource returns new akamai_iam_cidr_blocks resource -func NewCIDRBlocksResource() resource.Resource { return &CIDRBlocksResource{} } - -// CIDRBlocksResourceModel represents model of akamai_iam_cidr_blocks resource -type CIDRBlocksResourceModel struct { - CIDRBlocks []CIDRBlock `tfsdk:"cidr_blocks"` -} - -// CIDRBlock represents a single cidr block -type CIDRBlock struct { - CIDR types.String `tfsdk:"cidr_block"` - Enabled types.Bool `tfsdk:"enabled"` - Comments types.String `tfsdk:"comments"` - Actions types.Object `tfsdk:"actions"` - CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` - CreatedBy types.String `tfsdk:"created_by"` - CreatedDate types.String `tfsdk:"created_date"` - ModifiedBy types.String `tfsdk:"modified_by"` - ModifiedDate types.String `tfsdk:"modified_date"` -} - -// Metadata implements resource.Resource. -func (r *CIDRBlocksResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = "akamai_iam_cidr_blocks" -} - -// Schema implements resource.Resource. -func (r *CIDRBlocksResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - Attributes: map[string]schema.Attribute{ - "cidr_blocks": schema.ListNestedAttribute{ - Optional: true, - Description: "List of CIDR blocks.", - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "cidr_block": schema.StringAttribute{ - Required: true, - Description: "The value of an IP address or IP address range.", - }, - "enabled": schema.BoolAttribute{ - Required: true, - Description: "Enables the IP allowlist on the account.", - }, - "comments": schema.StringAttribute{ - Optional: true, - Description: "Descriptive label you provide for the CIDR block.", - }, - "actions": schema.SingleNestedAttribute{ - Computed: true, - Description: "Specifies activities available for the CIDR block.", - Attributes: map[string]schema.Attribute{ - "delete": schema.BoolAttribute{ - Computed: true, - Description: "Whether you can delete this CIDR block. You can't delete a CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", - }, - "edit": schema.BoolAttribute{ - Computed: true, - Description: "Whether you can edit this CIDR block. You can't edit CIDR block from an IP address not on the allowlist, or if the CIDR block is the only one on the allowlist.", - }, - }, - }, - "cidr_block_id": schema.Int64Attribute{ - Computed: true, - Description: "Unique identifier for each CIDR block.", - PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}, - }, - "created_by": schema.StringAttribute{ - Computed: true, - Description: "The user who created the CIDR block.", - }, - "created_date": schema.StringAttribute{ - Computed: true, - Description: "ISO 8601 timestamp indicating when the CIDR block was created.", - }, - "modified_by": schema.StringAttribute{ - Computed: true, - Description: "The user who last edited the CIDR block.", - }, - "modified_date": schema.StringAttribute{ - Computed: true, - Description: "ISO 8601 timestamp indicating when the CIDR block was last modified.", - }, - }, - }, - }, - }, - } -} - -// Configure implements resource.ResourceWithConfigure. -func (r *CIDRBlocksResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - if req.ProviderData == nil { - // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider - return - } - - defer func() { - if r := recover(); r != nil { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - } - }() - - r.meta = meta.Must(req.ProviderData) -} - -// Create implements resource.Resource. -func (r *CIDRBlocksResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - tflog.Debug(ctx, "Creating CIDR Blocks resource") - var plan *CIDRBlocksResourceModel - - // Read Terraform plan data into the model - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.create(ctx, plan); err != nil { - resp.Diagnostics.AddError("create cidr block failed", err.Error()) - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -func (r *CIDRBlocksResource) create(ctx context.Context, plan *CIDRBlocksResourceModel) error { - client := inst.Client(r.meta) - - for i, c := range plan.CIDRBlocks { - cidr, err := client.CreateCIDRBlock(ctx, c.buildCreateCIDRBlockRequest()) - if err != nil { - return err - } - plan.setFromCreateCIDRBlock(cidr, i) - } - - return nil -} - -// Read implements resource.Resource. -func (r *CIDRBlocksResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - tflog.Debug(ctx, "Reading CIDR Blocks Resource") - var state *CIDRBlocksResourceModel - - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.read(ctx, state); err != nil { - resp.Diagnostics.AddError("read cidr blocks error", err.Error()) - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) -} - -func (r *CIDRBlocksResource) read(ctx context.Context, data *CIDRBlocksResourceModel) error { - client := inst.Client(r.meta) - - res, err := client.ListCIDRBlocks(ctx, iam.ListCIDRBlocksRequest{ - Actions: true, - }) - if err != nil { - return err - } - data.setFromListCIDRBlocks(res) - - return nil -} - -// Update implements resource.Resource. -func (r *CIDRBlocksResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - tflog.Debug(ctx, "Updating CIDR Blocks Resource") - var data *CIDRBlocksResourceModel - - resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.update(ctx, data); err != nil { - resp.Diagnostics.AddError("update cidr block failed", err.Error()) - return - } - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *CIDRBlocksResource) update(ctx context.Context, data *CIDRBlocksResourceModel) error { - client := inst.Client(r.meta) - - for i, cidr := range data.CIDRBlocks { - resp, err := client.UpdateCIDRBlock(ctx, cidr.buildUpdateRequest()) - if err != nil { - return err - } - data.setFromUpdateCIDRBlock(resp, i) - } - - return nil -} - -// Delete implements resource.Resource. -func (r *CIDRBlocksResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - tflog.Debug(ctx, "Deleting CIDR Blocks Resource") - var state *CIDRBlocksResourceModel - client := inst.Client(r.meta) - - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - for _, cidr := range state.CIDRBlocks { - if err := client.DeleteCIDRBlock(ctx, iam.DeleteCIDRBlockRequest{ - CIDRBlockID: cidr.CIDRBlockID.ValueInt64(), - }); err != nil { - resp.Diagnostics.AddError(fmt.Sprintf("delete cidr block %d failed", cidr.CIDRBlockID), err.Error()) - return - } - } - resp.State.RemoveResource(ctx) -} - -// ImportState implements resource.ResourceWithImportState. -func (r *CIDRBlocksResource) ImportState(ctx context.Context, _ resource.ImportStateRequest, resp *resource.ImportStateResponse) { - tflog.Debug(ctx, "Importing CIDR Blocks Resource") - - data := &CIDRBlocksResourceModel{} - client := inst.Client(r.meta) - - res, err := client.ListCIDRBlocks(ctx, iam.ListCIDRBlocksRequest{ - Actions: true, - }) - if err != nil { - resp.Diagnostics.AddError("import cidr blocks error", err.Error()) - return - } - - data.setFromImportCIDRBlocks(res) - - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (m CIDRBlock) buildCreateCIDRBlockRequest() iam.CreateCIDRBlockRequest { - return iam.CreateCIDRBlockRequest{ - CIDRBlock: m.CIDR.ValueString(), - Comments: m.Comments.ValueStringPointer(), - Enabled: m.Enabled.ValueBool(), - } -} - -func (m CIDRBlock) buildUpdateRequest() iam.UpdateCIDRBlockRequest { - return iam.UpdateCIDRBlockRequest{ - CIDRBlockID: m.CIDRBlockID.ValueInt64(), - Body: iam.UpdateCIDRBlockRequestBody{ - CIDRBlock: m.CIDR.ValueString(), - Comments: m.Comments.ValueStringPointer(), - Enabled: m.Enabled.ValueBool(), - }, - } -} - -func (c *CIDRBlocksResourceModel) setFromCreateCIDRBlock(cidr *iam.CreateCIDRBlockResponse, i int) { - if cidr.Actions != nil { - c.CIDRBlocks[i].Actions = getActionFor(cidr.Actions.Edit, cidr.Actions.Delete) - } else { - c.CIDRBlocks[i].Actions = types.ObjectNull(map[string]attr.Type{ - "edit": types.BoolType, - "delete": types.BoolType, - }) - } - c.CIDRBlocks[i].CIDR = types.StringValue(cidr.CIDRBlock) - if cidr.Comments != nil { - c.CIDRBlocks[i].Comments = types.StringValue(*cidr.Comments) - } else { - c.CIDRBlocks[i].Comments = types.StringNull() - } - c.CIDRBlocks[i].CIDRBlockID = types.Int64Value(cidr.CIDRBlockID) - c.CIDRBlocks[i].ModifiedBy = types.StringValue(cidr.ModifiedBy) - c.CIDRBlocks[i].ModifiedDate = types.StringValue(cidr.ModifiedDate.Format(time.RFC3339Nano)) - c.CIDRBlocks[i].CreatedBy = types.StringValue(cidr.CreatedBy) - c.CIDRBlocks[i].CreatedDate = types.StringValue(cidr.CreatedDate.Format(time.RFC3339Nano)) -} - -func (c *CIDRBlocksResourceModel) setFromListCIDRBlocks(resp iam.ListCIDRBlocksResponse) { - for _, cidr := range c.CIDRBlocks { - for _, r := range resp { - if cidr.CIDRBlockID.ValueInt64() == r.CIDRBlockID { - cidr.CIDR = types.StringValue(r.CIDRBlock) - if r.Actions != nil { - cidr.Actions = getActionFor(r.Actions.Edit, r.Actions.Delete) - } else { - cidr.Actions = types.ObjectNull(map[string]attr.Type{ - "edit": types.BoolType, - "delete": types.BoolType, - }) - } - if r.Comments != nil { - cidr.Comments = types.StringValue(*r.Comments) - } else { - cidr.Comments = types.StringNull() - } - cidr.Enabled = types.BoolValue(r.Enabled) - cidr.ModifiedBy = types.StringValue(r.ModifiedBy) - cidr.ModifiedDate = types.StringValue(r.ModifiedDate.Format(time.RFC3339Nano)) - cidr.CreatedBy = types.StringValue(r.CreatedBy) - cidr.CreatedDate = types.StringValue(r.CreatedDate.Format(time.RFC3339Nano)) - break - } - } - } -} - -func (c *CIDRBlocksResourceModel) setFromUpdateCIDRBlock(resp *iam.UpdateCIDRBlockResponse, i int) { - if resp.Actions != nil { - c.CIDRBlocks[i].Actions = getActionFor(resp.Actions.Edit, resp.Actions.Delete) - } else { - c.CIDRBlocks[i].Actions = types.ObjectNull(map[string]attr.Type{ - "edit": types.BoolType, - "delete": types.BoolType, - }) - } - if resp.Comments != nil { - c.CIDRBlocks[i].Comments = types.StringValue(*resp.Comments) - } else { - c.CIDRBlocks[i].Comments = types.StringNull() - } - c.CIDRBlocks[i].CIDR = types.StringValue(resp.CIDRBlock) - c.CIDRBlocks[i].CIDRBlockID = types.Int64Value(resp.CIDRBlockID) - c.CIDRBlocks[i].Enabled = types.BoolValue(resp.Enabled) - c.CIDRBlocks[i].CreatedBy = types.StringValue(resp.CreatedBy) - c.CIDRBlocks[i].CreatedDate = types.StringValue(resp.CreatedDate.Format(time.RFC3339Nano)) - c.CIDRBlocks[i].ModifiedBy = types.StringValue(resp.ModifiedBy) - c.CIDRBlocks[i].ModifiedDate = types.StringValue(resp.ModifiedDate.Format(time.RFC3339Nano)) -} - -func (c *CIDRBlocksResourceModel) setFromImportCIDRBlocks(resp iam.ListCIDRBlocksResponse) { - var action types.Object - - for _, cidr := range resp { - if cidr.Actions != nil { - action = getActionFor(cidr.Actions.Edit, cidr.Actions.Delete) - } else { - action = types.ObjectNull(map[string]attr.Type{ - "edit": types.BoolType, - "delete": types.BoolType, - }) - } - block := CIDRBlock{ - CIDR: types.StringValue(cidr.CIDRBlock), - Enabled: types.BoolValue(cidr.Enabled), - Comments: types.StringPointerValue(cidr.Comments), - Actions: action, - CIDRBlockID: types.Int64Value(cidr.CIDRBlockID), - CreatedBy: types.StringValue(cidr.CreatedBy), - CreatedDate: types.StringValue(cidr.CreatedDate.Format(time.RFC3339Nano)), - ModifiedBy: types.StringValue(cidr.ModifiedBy), - ModifiedDate: types.StringValue(cidr.ModifiedDate.Format(time.RFC3339Nano)), - } - c.CIDRBlocks = append(c.CIDRBlocks, block) - } -} - -func getActionFor(editActions, deleteActions bool) basetypes.ObjectValue { - return types.ObjectValueMust( - map[string]attr.Type{ - "edit": types.BoolType, - "delete": types.BoolType, - }, - map[string]attr.Value{ - "edit": basetypes.NewBoolValue(editActions), - "delete": basetypes.NewBoolValue(deleteActions), - }, - ) -} diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go deleted file mode 100644 index fbe037fff..000000000 --- a/pkg/providers/iam/resource_akamai_iam_cidr_blocks_test.go +++ /dev/null @@ -1,764 +0,0 @@ -package iam - -import ( - "errors" - "fmt" - "regexp" - "strconv" - "strings" - "testing" - - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/terraform-provider-akamai/v6/internal/test" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" - "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/stretchr/testify/mock" -) - -type ( - commonDataForResource struct { - cidrBlock string - comments *string - enabled bool - actions *action - cidrBlockID int64 - createdBy string - createdDate string - modifiedBy string - modifiedDate string - } - - action struct { - deleteAction bool - editAction bool - } -) - -var ( - createdCidrBlocks = []commonDataForResource{ - { - cidrBlock: "128.5.6.5/24", - enabled: true, - comments: ptr.To("test"), - actions: &action{ - deleteAction: true, - editAction: true, - }, - cidrBlockID: 1111, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.5.6.6/24", - enabled: false, - comments: nil, - actions: &action{ - deleteAction: true, - editAction: false, - }, - cidrBlockID: 2222, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.5.6.7/24", - comments: ptr.To("test1234"), - enabled: true, - actions: &action{ - deleteAction: false, - editAction: true, - }, - cidrBlockID: 3333, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.5.6.8/24", - comments: ptr.To("abcd12345"), - enabled: false, - actions: &action{ - deleteAction: true, - editAction: true, - }, - cidrBlockID: 4444, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.5.6.9/24", - enabled: true, - comments: nil, - actions: &action{ - deleteAction: false, - editAction: false, - }, - cidrBlockID: 5555, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - } - - updatedCidrBlocks = []commonDataForResource{ - { - cidrBlock: "128.1.2.5/24", - enabled: false, - comments: nil, - actions: &action{ - deleteAction: true, - editAction: true, - }, - cidrBlockID: 1111, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.1.2.6/24", - enabled: false, - comments: nil, - actions: &action{ - deleteAction: true, - editAction: false, - }, - cidrBlockID: 2222, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.1.2.7/24", - comments: ptr.To("test1234"), - enabled: true, - actions: &action{ - deleteAction: false, - editAction: true, - }, - cidrBlockID: 3333, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.1.2.8/24", - comments: ptr.To("up12345"), - enabled: true, - actions: &action{ - deleteAction: true, - editAction: true, - }, - cidrBlockID: 4444, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.1.2.9/24", - enabled: false, - comments: nil, - actions: &action{ - deleteAction: false, - editAction: false, - }, - cidrBlockID: 5555, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - } - - threeOutOffiveUpdatedCidrBlocks = []commonDataForResource{ - { - cidrBlock: "128.2.2.5/28", - enabled: false, - comments: nil, - actions: &action{ - deleteAction: true, - editAction: true, - }, - cidrBlockID: 1111, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.2.2.6/28", - enabled: true, - comments: nil, - actions: &action{ - deleteAction: true, - editAction: false, - }, - cidrBlockID: 2222, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.2.2.7/28", - comments: ptr.To("test12345"), - enabled: false, - actions: &action{ - deleteAction: false, - editAction: true, - }, - cidrBlockID: 3333, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.5.6.8/24", - comments: ptr.To("abcd12345"), - enabled: false, - actions: &action{ - deleteAction: true, - editAction: true, - }, - cidrBlockID: 4444, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - { - cidrBlock: "128.5.6.9/24", - enabled: true, - comments: nil, - actions: &action{ - deleteAction: false, - editAction: false, - }, - cidrBlockID: 5555, - createdBy: "jdoe", - createdDate: "2006-01-02T15:04:05.999999999Z", - modifiedBy: "jkowalski", - modifiedDate: "2006-01-02T15:04:05.999999999Z", - }, - } -) - -func TestResourceIAMCIDRBlocksResource(t *testing.T) { - t.Parallel() - tests := map[string]struct { - configPath string - init func(*testing.T, *iam.Mock, []commonDataForResource, []commonDataForResource) - createData []commonDataForResource - updatedData []commonDataForResource - steps []resource.TestStep - error *regexp.Regexp - }{ - "create - single cidr Block": { - init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource, _ []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, resourceData) - - // Read - mockListCIDRBlock(t, m, resourceData) - - // Delete - mockDeleteCIDRBlocks(m, resourceData) - }, - createData: generateCIDRBlocks(createdCidrBlocks[:1]), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), - Check: checkAttrs(generateCIDRBlocks(createdCidrBlocks[:1])), - }, - }, - }, - "create - multiple cidr Blocks": { - init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource, _ []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, resourceData) - - // Read - mockListCIDRBlock(t, m, resourceData) - - // Delete - mockDeleteCIDRBlocks(m, resourceData) - }, - createData: generateCIDRBlocks(createdCidrBlocks), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), - Check: checkAttrs(generateCIDRBlocks(createdCidrBlocks)), - }, - }, - }, - "update - single cidr block": { - init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, createData) - - // Read - mockListCIDRBlock(t, m, createData) - - // Refresh read - mockListCIDRBlock(t, m, createData) - - // Update - mockUpdateCIDRBlocks(t, m, updateData) - - // Read - mockListCIDRBlock(t, m, updateData) - - // Delete - mockDeleteCIDRBlocks(m, updateData) - }, - createData: generateCIDRBlocks(createdCidrBlocks[:1]), - updatedData: generateCIDRBlocks(updatedCidrBlocks[:1]), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), - Check: checkAttrs(generateCIDRBlocks(createdCidrBlocks[:1])), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_single.tf"), - Check: checkAttrs(generateCIDRBlocks(updatedCidrBlocks[:1])), - }, - }, - }, - "update - all cidr blocks": { - init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, createData) - - // Read - mockListCIDRBlock(t, m, createData) - - // Refresh read - mockListCIDRBlock(t, m, createData) - - // Update - mockUpdateCIDRBlocks(t, m, updateData) - - // Read - mockListCIDRBlock(t, m, updateData) - - // Delete - mockDeleteCIDRBlocks(m, updateData) - }, - createData: generateCIDRBlocks(createdCidrBlocks), - updatedData: generateCIDRBlocks(updatedCidrBlocks), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), - Check: checkAttrs(createdCidrBlocks), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_five.tf"), - Check: checkAttrs(updatedCidrBlocks), - }, - }, - }, - "update - 3 cidr blocks from 5 created": { - init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, createData) - - // Read - mockListCIDRBlock(t, m, createData) - - // Refresh read - mockListCIDRBlock(t, m, createData) - - // Update - mockUpdateCIDRBlocks(t, m, updateData) - - // Read - mockListCIDRBlock(t, m, updateData) - - // Delete - mockDeleteCIDRBlocks(m, updateData) - }, - createData: generateCIDRBlocks(createdCidrBlocks), - updatedData: generateCIDRBlocks(threeOutOffiveUpdatedCidrBlocks), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), - Check: checkAttrs(createdCidrBlocks), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_three_out_of_five.tf"), - Check: checkAttrs(threeOutOffiveUpdatedCidrBlocks), - }, - }, - }, - "update - 3 cidr blocks and 2 remove": { - init: func(t *testing.T, m *iam.Mock, createData, updateData []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, createData) - - // Read - mockListCIDRBlock(t, m, createData) - - // Refresh read - mockListCIDRBlock(t, m, createData) - - // Update - mockUpdateCIDRBlocks(t, m, updateData) - - // Read - mockListCIDRBlock(t, m, updateData) - - // Delete - mockDeleteCIDRBlocks(m, updateData) - }, - createData: generateCIDRBlocks(createdCidrBlocks), - updatedData: generateCIDRBlocks(updatedCidrBlocks[:3]), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create_multiple.tf"), - Check: checkAttrs(createdCidrBlocks), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/update_three_remove_two.tf"), - Check: checkAttrs(generateCIDRBlocks(updatedCidrBlocks[:3])), - }, - }, - }, - "missing cidr block": { - steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/missing_cidr_block.tf"), - ExpectError: regexp.MustCompile("\\s*Inappropriate value for attribute \"cidr_blocks\": element 0: attribute\\s*\"cidr_block\" is required."), - }}, - }, - "missing enabled": { - steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/missing_enabled.tf"), - ExpectError: regexp.MustCompile("\\s*Inappropriate value for attribute \"cidr_blocks\": element 0: attribute\\s*\"enabled\" is required."), - }}, - }, - "error - create": { - init: func(t *testing.T, m *iam.Mock, resourceData, _ []commonDataForResource) { - m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ - CIDRBlock: resourceData[0].cidrBlock, - Comments: resourceData[0].comments, - Enabled: resourceData[0].enabled, - }).Return(nil, iam.ErrCreateCIDRBlock).Once() - }, - createData: generateCIDRBlocks(createdCidrBlocks[:1]), - steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), - ExpectError: regexp.MustCompile("create cidr block failed"), - }}, - }, - "error - delete": { - init: func(t *testing.T, m *iam.Mock, resourceData, _ []commonDataForResource) { - // Create - mockCreateCIDRBlocks(t, m, resourceData) - - // Read - mockListCIDRBlock(t, m, resourceData) - - // Read - mockListCIDRBlock(t, m, resourceData) - - // Delete - error - m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ - CIDRBlockID: resourceData[0].cidrBlockID, - }).Return(iam.ErrDeleteCIDRBlock).Once() - - // Delete - destroy - mockDeleteCIDRBlocks(m, resourceData) - }, - createData: generateCIDRBlocks(createdCidrBlocks[:1]), - steps: []resource.TestStep{ - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/create.tf"), - }, - { - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/empty_config.tf"), - ExpectError: regexp.MustCompile(`Error: delete cidr block {2 1111} failed`), - }, - }, - }, - } - for name, test := range tests { - test := test - t.Run(name, func(t *testing.T) { - t.Parallel() - client := &iam.Mock{} - if test.init != nil { - test.init(t, client, test.createData, test.updatedData) - } - useClient(client, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: test.steps, - }) - }) - client.AssertExpectations(t) - }) - } - -} - -func TestImportIAMCIDRBlocksResource(t *testing.T) { - tests := map[string]struct { - importID string - configPath string - init func(*testing.T, *iam.Mock, []commonDataForResource) - mockData []commonDataForResource - }{ - "import - single cidr block": { - importID: " ", - mockData: generateCIDRBlocks(createdCidrBlocks[:1]), - init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource) { - // Import - mockListCIDRBlock(t, m, resourceData) - - // Read - mockListCIDRBlock(t, m, resourceData) - }, - }, - "import - five cidr blocks": { - importID: " ", - mockData: generateCIDRBlocks(createdCidrBlocks), - init: func(t *testing.T, m *iam.Mock, resourceData []commonDataForResource) { - // Import - mockListCIDRBlock(t, m, resourceData) - - // Read - mockListCIDRBlock(t, m, resourceData) - }, - }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - client := &iam.Mock{} - test.init(t, client, test.mockData) - useClient(client, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - ImportStateCheck: checkImportCIDRBlocks(test.mockData), - ImportStateId: test.importID, - ImportState: true, - ResourceName: "akamai_iam_cidr_blocks.test", - Config: testutils.LoadFixtureString(t, "testdata/TestResCIDRBlocks/importable.tf"), - }, - }, - }) - }) - client.AssertExpectations(t) - }) - } -} - -func checkImportCIDRBlocks(data []commonDataForResource) resource.ImportStateCheckFunc { - return func(s []*terraform.InstanceState) error { - attr := make(map[string]string) - - if len(s) == 0 { - return errors.New("No Instance found") - } - if len(s) != 1 { - return fmt.Errorf("Expected one Instance: %d", len(s)) - } - - for i, cidr := range data { - if cidr.actions != nil { - attr[fmt.Sprintf("cidr_blocks.%d.actions.delete", i)] = strconv.FormatBool(cidr.actions.deleteAction) - attr[fmt.Sprintf("cidr_blocks.%d.actions.edit", i)] = strconv.FormatBool(cidr.actions.editAction) - } - if cidr.comments != nil { - attr[fmt.Sprintf("cidr_blocks.%d.comments", i)] = *cidr.comments - } else { - attr[fmt.Sprintf("cidr_blocks.%d.comments", i)] = "" - } - attr[fmt.Sprintf("cidr_blocks.%d.cidr_block", i)] = cidr.cidrBlock - attr[fmt.Sprintf("cidr_blocks.%d.enabled", i)] = strconv.FormatBool(cidr.enabled) - attr[fmt.Sprintf("cidr_blocks.%d.cidr_block_id", i)] = strconv.FormatInt(cidr.cidrBlockID, 10) - attr[fmt.Sprintf("cidr_blocks.%d.created_by", i)] = cidr.createdBy - attr[fmt.Sprintf("cidr_blocks.%d.created_date", i)] = cidr.createdDate - attr[fmt.Sprintf("cidr_blocks.%d.modified_by", i)] = cidr.modifiedBy - attr[fmt.Sprintf("cidr_blocks.%d.modified_date", i)] = cidr.modifiedDate - } - - state := s[0].Attributes - - attributes := attr - - invalidValues := []string{} - for field, expectedVal := range attributes { - if state[field] != expectedVal { - invalidValues = append(invalidValues, fmt.Sprintf("field: %s, got: %s, expected: %s ", field, state[field], expectedVal)) - } - } - - if len(invalidValues) != 0 { - return fmt.Errorf(strings.Join(invalidValues, "\n")) - } - return nil - } -} - -func mockCreateCIDRBlocks(t *testing.T, m *iam.Mock, testData []commonDataForResource) []*mock.Call { - var mocks []*mock.Call - var act *iam.CIDRActions - - for _, d := range testData { - if d.actions != nil { - act = &iam.CIDRActions{ - Delete: d.actions.deleteAction, - Edit: d.actions.editAction, - } - } - mocks = append(mocks, m.On("CreateCIDRBlock", mock.Anything, iam.CreateCIDRBlockRequest{ - CIDRBlock: d.cidrBlock, - Comments: d.comments, - Enabled: d.enabled, - }).Return(&iam.CreateCIDRBlockResponse{ - Actions: act, - CIDRBlock: d.cidrBlock, - CIDRBlockID: d.cidrBlockID, - Comments: d.comments, - CreatedBy: d.createdBy, - CreatedDate: test.NewTimeFromString(t, d.createdDate), - Enabled: d.enabled, - ModifiedBy: d.modifiedBy, - ModifiedDate: test.NewTimeFromString(t, d.modifiedDate), - }, nil).Once()) - } - - return mocks -} - -func mockListCIDRBlock(t *testing.T, m *iam.Mock, testData []commonDataForResource) *mock.Call { - var cidrBlock iam.ListCIDRBlocksResponse - var act *iam.CIDRActions - - for _, cidr := range testData { - if cidr.actions != nil { - act = &iam.CIDRActions{ - Delete: cidr.actions.deleteAction, - Edit: cidr.actions.editAction, - } - } - cidrBlock = append(cidrBlock, iam.CIDRBlock{ - Actions: act, - CIDRBlock: cidr.cidrBlock, - CIDRBlockID: cidr.cidrBlockID, - Comments: cidr.comments, - CreatedBy: cidr.createdBy, - CreatedDate: test.NewTimeFromString(t, cidr.createdDate), - Enabled: cidr.enabled, - ModifiedBy: cidr.modifiedBy, - ModifiedDate: test.NewTimeFromString(t, cidr.modifiedDate), - }) - } - - return m.On("ListCIDRBlocks", mock.Anything, iam.ListCIDRBlocksRequest{ - Actions: true, - }).Return(cidrBlock, nil).Once() -} - -func mockDeleteCIDRBlocks(m *iam.Mock, testData []commonDataForResource) []*mock.Call { - var mocks []*mock.Call - - for _, d := range testData { - mocks = append(mocks, m.On("DeleteCIDRBlock", mock.Anything, iam.DeleteCIDRBlockRequest{ - CIDRBlockID: d.cidrBlockID, - }).Return(nil).Once()) - } - - return mocks -} - -func mockUpdateCIDRBlocks(t *testing.T, m *iam.Mock, data []commonDataForResource) []*mock.Call { - var mocks []*mock.Call - - for _, d := range data { - mocks = append(mocks, m.On("UpdateCIDRBlock", mock.Anything, iam.UpdateCIDRBlockRequest{ - CIDRBlockID: d.cidrBlockID, - Body: iam.UpdateCIDRBlockRequestBody{ - CIDRBlock: d.cidrBlock, - Comments: d.comments, - Enabled: d.enabled, - }, - }).Return(&iam.UpdateCIDRBlockResponse{ - Actions: &iam.CIDRActions{ - Delete: d.actions.deleteAction, - Edit: d.actions.editAction, - }, - CIDRBlock: d.cidrBlock, - CIDRBlockID: d.cidrBlockID, - Comments: d.comments, - CreatedBy: d.createdBy, - CreatedDate: test.NewTimeFromString(t, d.createdDate), - Enabled: d.enabled, - ModifiedBy: d.modifiedBy, - ModifiedDate: test.NewTimeFromString(t, d.modifiedDate), - }, nil).Once()) - } - - return mocks -} - -func checkAttrs(data []commonDataForResource) resource.TestCheckFunc { - var checkFuncs []resource.TestCheckFunc - - for i, cidr := range data { - if cidr.actions != nil { - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.actions.delete", i), strconv.FormatBool(cidr.actions.deleteAction))) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.actions.edit", i), strconv.FormatBool(cidr.actions.editAction))) - } - if cidr.comments != nil { - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttrPtr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.comments", i), cidr.comments)) - } else { - checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.comments", i))) - } - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.cidr_block", i), cidr.cidrBlock)) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.enabled", i), strconv.FormatBool(cidr.enabled))) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.cidr_block_id", i), strconv.FormatInt(cidr.cidrBlockID, 10))) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.created_by", i), cidr.createdBy)) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.created_date", i), cidr.createdDate)) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.modified_by", i), cidr.modifiedBy)) - checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("akamai_iam_cidr_blocks.test", fmt.Sprintf("cidr_blocks.%d.modified_date", i), cidr.modifiedDate)) - } - return resource.ComposeAggregateTestCheckFunc( - checkFuncs..., - ) -} - -func generateCIDRBlocks(data []commonDataForResource) []commonDataForResource { - var cidrBlocks []commonDataForResource - - for _, cidr := range data { - cidrBlocks = append(cidrBlocks, commonDataForResource{ - cidrBlock: cidr.cidrBlock, - comments: cidr.comments, - enabled: cidr.enabled, - actions: cidr.actions, - cidrBlockID: cidr.cidrBlockID, - createdBy: cidr.createdBy, - createdDate: cidr.createdDate, - modifiedBy: cidr.modifiedBy, - modifiedDate: cidr.modifiedDate, - }) - } - - return cidrBlocks -} diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/create.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/create.tf new file mode 100644 index 000000000..8c3382fc5 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/create.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.5/24" + comments = "test" + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf new file mode 100644 index 000000000..2d3295ba0 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/create_without_comments.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.5/24" + enabled = false +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/empty_config.tf similarity index 96% rename from pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf rename to pkg/providers/iam/testdata/TestResCIDRBlock/empty_config.tf index 345c8570e..e713fdeb3 100644 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/empty_config.tf +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/empty_config.tf @@ -1,3 +1,3 @@ provider "akamai" { edgerc = "../../common/testutils/edgerc" -} \ No newline at end of file +} diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf new file mode 100644 index 000000000..2571b89ad --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/importable.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.6/24" + comments = "test" + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf new file mode 100644 index 000000000..514145dbf --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/importable_without_comments.tf @@ -0,0 +1,8 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.6/24" + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf new file mode 100644 index 000000000..af966e85f --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_cidr_block.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + enabled = true +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf new file mode 100644 index 000000000..6918c6a82 --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/missing_enabled.tf @@ -0,0 +1,7 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.1.2.5/24" +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlock/update.tf b/pkg/providers/iam/testdata/TestResCIDRBlock/update.tf new file mode 100644 index 000000000..6640171bd --- /dev/null +++ b/pkg/providers/iam/testdata/TestResCIDRBlock/update.tf @@ -0,0 +1,9 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" +} + +resource "akamai_iam_cidr_block" "test" { + cidr_block = "128.5.6.99/24" + comments = "test-updated" + enabled = false +} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf deleted file mode 100644 index 1ff3afc5f..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/create.tf +++ /dev/null @@ -1,13 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.5.6.5/24" - comments = "test" - enabled = true - } - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf deleted file mode 100644 index a3e8c34a5..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/create_multiple.tf +++ /dev/null @@ -1,31 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.5.6.5/24" - comments = "test" - enabled = true - }, - { - cidr_block = "128.5.6.6/24" - enabled = false - }, - { - cidr_block = "128.5.6.7/24" - enabled = true - comments = "test1234" - }, - { - cidr_block = "128.5.6.8/24" - enabled = false - comments = "abcd12345" - }, - { - cidr_block = "128.5.6.9/24" - enabled = true - }, - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf deleted file mode 100644 index 942dc5694..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/importable.tf +++ /dev/null @@ -1,13 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.5.6.6/24" - comments = "test" - enabled = true - } - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf deleted file mode 100644 index 1dabf7e95..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_cidr_block.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - comments = "test" - enabled = true - } - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf deleted file mode 100644 index dec299232..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/missing_enabled.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.1.2.5/24" - comments = "test" - } - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf deleted file mode 100644 index fc3fa5768..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_five.tf +++ /dev/null @@ -1,30 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.1.2.5/24" - enabled = false - }, - { - cidr_block = "128.1.2.6/24" - enabled = false - }, - { - cidr_block = "128.1.2.7/24" - enabled = true - comments = "test1234" - }, - { - cidr_block = "128.1.2.8/24" - enabled = true - comments = "up12345" - }, - { - cidr_block = "128.1.2.9/24" - enabled = false - }, - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf deleted file mode 100644 index c7317067f..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_single.tf +++ /dev/null @@ -1,12 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.1.2.5/24" - enabled = false - } - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf deleted file mode 100644 index 9dfd9c624..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_out_of_five.tf +++ /dev/null @@ -1,30 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.2.2.5/28" - enabled = false - }, - { - cidr_block = "128.2.2.6/28" - enabled = true - }, - { - cidr_block = "128.2.2.7/28" - enabled = false - comments = "test12345" - }, - { - cidr_block = "128.5.6.8/24" - enabled = false - comments = "abcd12345" - }, - { - cidr_block = "128.5.6.9/24" - enabled = true - }, - ] -} \ No newline at end of file diff --git a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf b/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf deleted file mode 100644 index d7800c4c7..000000000 --- a/pkg/providers/iam/testdata/TestResCIDRBlocks/update_three_remove_two.tf +++ /dev/null @@ -1,21 +0,0 @@ -provider "akamai" { - edgerc = "../../common/testutils/edgerc" -} - -resource "akamai_iam_cidr_blocks" "test" { - cidr_blocks = [ - { - cidr_block = "128.1.2.5/24" - enabled = false - }, - { - cidr_block = "128.1.2.6/24" - enabled = false - }, - { - cidr_block = "128.1.2.7/24" - enabled = true - comments = "test1234" - }, - ] -} \ No newline at end of file From 301dec03d2b170ecfa9d0efc901b772c2b64e072 Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Fri, 27 Sep 2024 08:17:08 +0000 Subject: [PATCH 42/54] DXE-4151 Verify TFP IAM subprovider --- .../iam/data_akamai_iam_accessible_groups.go | 28 +++---- .../data_akamai_iam_accessible_groups_test.go | 10 +-- .../data_akamai_iam_account_switch_keys.go | 10 +-- ...ata_akamai_iam_account_switch_keys_test.go | 10 +-- .../iam/data_akamai_iam_allowed_apis.go | 27 +++--- .../iam/data_akamai_iam_allowed_apis_test.go | 15 ++-- .../iam/data_akamai_iam_authorized_users.go | 60 ++++++-------- .../data_akamai_iam_authorized_users_test.go | 12 +-- .../iam/data_akamai_iam_blocked_properties.go | 52 ++++++------ ...data_akamai_iam_blocked_properties_test.go | 13 +-- .../iam/data_akamai_iam_cidr_block.go | 28 +++---- .../iam/data_akamai_iam_cidr_block_test.go | 13 +-- .../iam/data_akamai_iam_cidr_blocks.go | 29 +++---- .../iam/data_akamai_iam_cidr_blocks_test.go | 10 +-- .../iam/data_akamai_iam_contact_types.go | 6 +- .../iam/data_akamai_iam_countries.go | 4 +- .../iam/data_akamai_iam_grantable_roles.go | 10 +-- pkg/providers/iam/data_akamai_iam_group.go | 43 ++++------ .../iam/data_akamai_iam_group_test.go | 10 +-- pkg/providers/iam/data_akamai_iam_groups.go | 23 +++--- .../iam/data_akamai_iam_password_policy.go | 12 +-- .../data_akamai_iam_password_policy_test.go | 8 +- .../iam/data_akamai_iam_property_users.go | 12 +-- .../data_akamai_iam_property_users_test.go | 15 ++-- pkg/providers/iam/data_akamai_iam_role.go | 57 ++++++------- .../iam/data_akamai_iam_role_test.go | 15 ++-- pkg/providers/iam/data_akamai_iam_roles.go | 18 ++-- pkg/providers/iam/data_akamai_iam_states.go | 6 +- .../iam/data_akamai_iam_supported_langs.go | 4 +- .../iam/data_akamai_iam_timeout_policies.go | 4 +- .../iam/data_akamai_iam_timezones.go | 10 +-- pkg/providers/iam/data_akamai_iam_user.go | 27 +++--- .../iam/data_akamai_iam_user_test.go | 15 ++-- pkg/providers/iam/data_akamai_iam_users.go | 69 ++++++++-------- ...amai_iam_users_affected_by_moving_group.go | 40 ++++----- ...iam_users_affected_by_moving_group_test.go | 10 +-- .../iam/data_akamai_iam_users_test.go | 13 +-- pkg/providers/iam/iam_errors.go | 16 ---- pkg/providers/iam/provider.go | 6 -- ...urce_akamai_iam_blocked_user_properties.go | 8 +- ...akamai_iam_blocked_user_properties_test.go | 8 +- .../iam/resource_akamai_iam_cidr_block.go | 56 ++++++------- .../iam/resource_akamai_iam_group.go | 8 +- .../iam/resource_akamai_iam_group_test.go | 6 +- .../iam/resource_akamai_iam_ip_allowlist.go | 56 +++++-------- .../resource_akamai_iam_ip_allowlist_test.go | 82 +++++++++---------- pkg/providers/iam/resource_akamai_iam_role.go | 8 +- pkg/providers/iam/resource_akamai_iam_user.go | 66 +++++++-------- .../iam/resource_akamai_iam_user_test.go | 6 +- 49 files changed, 486 insertions(+), 588 deletions(-) delete mode 100644 pkg/providers/iam/iam_errors.go diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups.go b/pkg/providers/iam/data_akamai_iam_accessible_groups.go index 4c755deaf..8f251e555 100644 --- a/pkg/providers/iam/data_akamai_iam_accessible_groups.go +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups.go @@ -14,12 +14,12 @@ import ( ) var ( - _ datasource.DataSource = &accessibleGroups{} - _ datasource.DataSourceWithConfigure = &accessibleGroups{} + _ datasource.DataSource = &accessibleGroupsDataSource{} + _ datasource.DataSourceWithConfigure = &accessibleGroupsDataSource{} ) type ( - accessibleGroups struct { + accessibleGroupsDataSource struct { meta meta.Meta } @@ -46,16 +46,16 @@ type ( } ) -// NewAccessibleGroupsDataSource returns new accessible groups data source +// NewAccessibleGroupsDataSource returns new accessible groups data source. func NewAccessibleGroupsDataSource() datasource.DataSource { - return &accessibleGroups{} + return &accessibleGroupsDataSource{} } -func (a *accessibleGroups) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { +func (a *accessibleGroupsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_accessible_groups" } -func (a *accessibleGroups) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (a *accessibleGroupsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -70,7 +70,7 @@ func (a *accessibleGroups) Configure(_ context.Context, req datasource.Configure a.meta = meta.Must(req.ProviderData) } -func (a *accessibleGroups) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (a *accessibleGroupsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "username": schema.StringAttribute{ @@ -108,7 +108,7 @@ func (a *accessibleGroups) Schema(_ context.Context, _ datasource.SchemaRequest, }, "sub_groups": schema.ListNestedAttribute{ Computed: true, - Description: "Children of the parent group", + Description: "Children of the parent group.", // Schema effectively must be +1 size nested, to support correctly marshalling of last level (null of type []accessibleSubgroupModel onto `sub_groups`) NestedObject: a.subgroupsSchema(maxSupportedGroupNesting + 1), }, @@ -119,7 +119,7 @@ func (a *accessibleGroups) Schema(_ context.Context, _ datasource.SchemaRequest, } } -func (a *accessibleGroups) subgroupsSchema(remainingNesting int) schema.NestedAttributeObject { +func (a *accessibleGroupsDataSource) subgroupsSchema(remainingNesting int) schema.NestedAttributeObject { subgroupSchema := schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "group_id": schema.Int64Attribute{ @@ -150,7 +150,7 @@ func (a *accessibleGroups) subgroupsSchema(remainingNesting int) schema.NestedAt return subgroupSchema } -func (a *accessibleGroups) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +func (a *accessibleGroupsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Accessible Groups Datasource Read") var data accessibleGroupsModel @@ -174,7 +174,7 @@ func (a *accessibleGroups) Read(ctx context.Context, req datasource.ReadRequest, resp.Diagnostics.Append(resp.State.Set(ctx, newData)...) } -func (a *accessibleGroups) convertAccessibleGroups(groups iam.ListAccessibleGroupsResponse, data accessibleGroupsModel) (*accessibleGroupsModel, diag.Diagnostics) { +func (a *accessibleGroupsDataSource) convertAccessibleGroups(groups iam.ListAccessibleGroupsResponse, data accessibleGroupsModel) (*accessibleGroupsModel, diag.Diagnostics) { data.AccessibleGroups = []accessibleGroupModel{} for _, group := range groups { newGroup := accessibleGroupModel{ @@ -198,8 +198,8 @@ func (a *accessibleGroups) convertAccessibleGroups(groups iam.ListAccessibleGrou return &data, nil } -func (a *accessibleGroups) convertAccessibleSubgroups(subgroups []iam.AccessibleSubGroup, remainingNesting int) ([]accessibleSubgroupModel, diag.Diagnostics) { - groups := []accessibleSubgroupModel{} +func (a *accessibleGroupsDataSource) convertAccessibleSubgroups(subgroups []iam.AccessibleSubGroup, remainingNesting int) ([]accessibleSubgroupModel, diag.Diagnostics) { + var groups []accessibleSubgroupModel for _, subgroup := range subgroups { newSubgroup := accessibleSubgroupModel{ diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go index 58d07a554..1fe7f228c 100644 --- a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go @@ -191,10 +191,10 @@ func TestAccessibleGroups(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -202,9 +202,9 @@ func TestAccessibleGroups(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.config), - Check: test.expectedChecks, - ExpectError: test.expectedError, + Config: testutils.LoadFixtureString(t, tc.config), + Check: tc.expectedChecks, + ExpectError: tc.expectedError, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go index ad5cc9364..8e8afaaa3 100644 --- a/pkg/providers/iam/data_akamai_iam_account_switch_keys.go +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go @@ -24,7 +24,7 @@ type ( meta meta.Meta } - accountSwitchKeysDataSourceModel struct { + accountSwitchKeysModel struct { ClientID types.String `tfsdk:"client_id"` Filter types.String `tfsdk:"filter"` AccountSwitchKeys []accountSwitchKey `tfsdk:"account_switch_keys"` @@ -36,17 +36,15 @@ type ( } ) -// NewAccountSwitchKeysDataSource returns a new account switch keys data source +// NewAccountSwitchKeysDataSource returns a new account switch keys data source. func NewAccountSwitchKeysDataSource() datasource.DataSource { return &accountSwitchKeysDataSource{} } -// Metadata configures data source's meta information func (d *accountSwitchKeysDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_account_switch_keys" } -// Configure configures data source at the beginning of the lifecycle func (d *accountSwitchKeysDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -62,7 +60,6 @@ func (d *accountSwitchKeysDataSource) Configure(_ context.Context, req datasourc d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *accountSwitchKeysDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Identity and Access Management account switch keys", @@ -96,11 +93,10 @@ func (d *accountSwitchKeysDataSource) Schema(_ context.Context, _ datasource.Sch } } -// Read is called when the provider must read data source values in order to update state func (d *accountSwitchKeysDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Account Switch Keys DataSource Read") - var data accountSwitchKeysDataSourceModel + var data accountSwitchKeysModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) if resp.Diagnostics.HasError() { return diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go index eeb347164..a9567bc29 100644 --- a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go @@ -70,11 +70,11 @@ func TestAccountSwitchKeys(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(client) + if tc.init != nil { + tc.init(client) } useClient(client, func() { @@ -83,9 +83,9 @@ func TestAccountSwitchKeys(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataAccountSwitchKeys/%s", test.givenTF)), + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataAccountSwitchKeys/%s", tc.givenTF)), Check: checkAccountSwitchKeysAttrs(), - ExpectError: test.error, + ExpectError: tc.error, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis.go b/pkg/providers/iam/data_akamai_iam_allowed_apis.go index ff8f52511..d2a5995b1 100644 --- a/pkg/providers/iam/data_akamai_iam_allowed_apis.go +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis.go @@ -2,13 +2,13 @@ package iam import ( "context" + "errors" "fmt" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -16,6 +16,9 @@ import ( var ( _ datasource.DataSource = &allowedAPIsDataSource{} _ datasource.DataSourceWithConfigure = &allowedAPIsDataSource{} + + // ErrIAMListAllowedAPIs is returned when ListAllowedAPIs fails. + ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") ) type ( @@ -23,7 +26,7 @@ type ( meta meta.Meta } - allowedAPIsSourceModel struct { + allowedAPIsModel struct { Username types.String `tfsdk:"username"` ClientType types.String `tfsdk:"client_type"` AllowAccountSwitch types.Bool `tfsdk:"allow_account_switch"` @@ -47,12 +50,10 @@ func NewAllowedAPIsDataSource() datasource.DataSource { return &allowedAPIsDataSource{} } -// Metadata configures data source's meta information func (d *allowedAPIsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_allowed_apis" } -// Configure configures data source at the beginning of the lifecycle func (d *allowedAPIsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -68,7 +69,6 @@ func (d *allowedAPIsDataSource) Configure(_ context.Context, req datasource.Conf d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *allowedAPIsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Identity and Access Management allowed APIs", @@ -79,14 +79,14 @@ func (d *allowedAPIsDataSource) Schema(_ context.Context, _ datasource.SchemaReq }, "client_type": schema.StringAttribute{ Optional: true, - Description: "Filters data by client type, either USER_CLIENT, SERVICE_ACCOUNT, or default CLIENT", + Description: "Filters data by client type, either USER_CLIENT, SERVICE_ACCOUNT, or default CLIENT.", }, "allow_account_switch": schema.BoolAttribute{ Optional: true, Description: "Includes account a user can switch to, false by default.", }, "allowed_apis": schema.ListNestedAttribute{ - Description: "List of available APIs for the user", + Description: "List of available APIs for the user.", Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -128,14 +128,12 @@ func (d *allowedAPIsDataSource) Schema(_ context.Context, _ datasource.SchemaReq }, }, } - } -// Read is called when the provider must read data source values in order to update state func (d *allowedAPIsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Allowed APIs DataSource Read") - var data allowedAPIsSourceModel + var data allowedAPIsModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } @@ -151,15 +149,12 @@ func (d *allowedAPIsDataSource) Read(ctx context.Context, req datasource.ReadReq return } - if resp.Diagnostics.Append(data.read(apis)...); resp.Diagnostics.HasError() { - return - } + data.read(apis) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - } -func (d *allowedAPIsSourceModel) read(allowedAPIs iam.ListAllowedAPIsResponse) diag.Diagnostics { +func (d *allowedAPIsModel) read(allowedAPIs iam.ListAllowedAPIsResponse) { var apis []apiModel for _, api := range allowedAPIs { accessLevels := make([]types.String, 0, len(api.AccessLevels)) @@ -181,6 +176,4 @@ func (d *allowedAPIsSourceModel) read(allowedAPIs iam.ListAllowedAPIsResponse) d } d.AllowedAPIs = apis - return nil - } diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go index 01aa05e0a..b3f238e7d 100644 --- a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go @@ -121,11 +121,11 @@ func TestDataAllowedAPIs(t *testing.T) { mockData: basicTestDataForAllowedAPIsNoOptional, }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(t, client, test.mockData) + if tc.init != nil { + tc.init(t, client, tc.mockData) } useClient(client, func() { @@ -134,9 +134,9 @@ func TestDataAllowedAPIs(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.configPath), - Check: checkAllowedAPIsAttrs(test.mockData), - ExpectError: test.error, + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkAllowedAPIsAttrs(tc.mockData), + ExpectError: tc.error, }, }, }) @@ -174,7 +174,6 @@ func expectFullListAllowedAPIs(_ *testing.T, client *iam.Mock, data testDataForA } client.On("ListAllowedAPIs", mock.Anything, listAllowedAPIsReq).Return(listAllowedAPIsRes, nil).Times(timesToRun) - } func checkAllowedAPIsAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { @@ -208,6 +207,6 @@ func checkAllowedAPIsAttrs(data testDataForAllowedAPIs) resource.TestCheckFunc { checksFuncs = append(checksFuncs, resource.TestCheckResourceAttr(name, fmt.Sprintf("allowed_apis.%d.service_provider_id", i), strconv.FormatInt(api.serviceProviderID, 10))) } - return resource.ComposeAggregateTestCheckFunc(checksFuncs...) + return resource.ComposeAggregateTestCheckFunc(checksFuncs...) } diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users.go b/pkg/providers/iam/data_akamai_iam_authorized_users.go index 19b85940f..4b45d77be 100644 --- a/pkg/providers/iam/data_akamai_iam_authorized_users.go +++ b/pkg/providers/iam/data_akamai_iam_authorized_users.go @@ -8,7 +8,6 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -23,11 +22,11 @@ type ( meta meta.Meta } - authorizedUsersDataSourceModel struct { - AuthorizedUsers []userModel `tfsdk:"authorized_users"` + authorizedUsersModel struct { + AuthorizedUsers []authorizedUserModel `tfsdk:"authorized_users"` } - userModel struct { + authorizedUserModel struct { Email types.String `tfsdk:"email"` Username types.String `tfsdk:"username"` FirstName types.String `tfsdk:"first_name"` @@ -41,29 +40,27 @@ func NewAuthorizedUsersDataSource() datasource.DataSource { return &authorizedUsersDataSource{} } -// Metadata configures data source's meta information -func (a *authorizedUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, response *datasource.MetadataResponse) { - response.TypeName = "akamai_iam_authorized_users" +func (a *authorizedUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = "akamai_iam_authorized_users" } -// Configure configures data source at the beginning of the lifecycle -func (a *authorizedUsersDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { - if request.ProviderData == nil { +func (a *authorizedUsersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { return } defer func() { if r := recover(); r != nil { - response.Diagnostics.AddError( + resp.Diagnostics.AddError( "Unexpected Data Source Configure Type", fmt.Sprintf("Expected meta.Meta, got: %T. Please report this issue to the provider developers.", - request.ProviderData)) + req.ProviderData)) } }() - a.meta = meta.Must(request.ProviderData) + a.meta = meta.Must(req.ProviderData) } -func (a *authorizedUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, response *datasource.SchemaResponse) { - response.Schema = schema.Schema{ +func (a *authorizedUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ Description: "List of authorized API client users", Attributes: map[string]schema.Attribute{ "authorized_users": schema.ListNestedAttribute{ @@ -97,42 +94,39 @@ func (a *authorizedUsersDataSource) Schema(_ context.Context, _ datasource.Schem } } -func (a *authorizedUsersDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { +func (a *authorizedUsersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Authorized Users DataSource Read") - var data authorizedUsersDataSourceModel - if response.Diagnostics.Append(request.Config.Get(ctx, &data)...); response.Diagnostics.HasError() { + var data authorizedUsersModel + if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } client := inst.Client(a.meta) users, err := client.ListAuthorizedUsers(ctx) if err != nil { - response.Diagnostics.AddError("Failed to fetch authorized users:", err.Error()) + resp.Diagnostics.AddError("Failed to fetch authorized users:", err.Error()) return } - if response.Diagnostics.Append(data.read(users)...); response.Diagnostics.HasError() { - return - } + data.read(users) - response.Diagnostics.Append(response.State.Set(ctx, &data)...) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (d *authorizedUsersDataSourceModel) read(authorisedUsers iam.ListAuthorizedUsersResponse) diag.Diagnostics { - var users []userModel - for _, user := range authorisedUsers { - authorizedUser := userModel{ - Email: types.StringValue(user.Email), - Username: types.StringValue(user.Username), - FirstName: types.StringValue(user.FirstName), - LastName: types.StringValue(user.LastName), - UIIdentityID: types.StringValue(user.UIIdentityID), +func (d *authorizedUsersModel) read(authorisedUsers iam.ListAuthorizedUsersResponse) { + var users []authorizedUserModel + for _, u := range authorisedUsers { + authorizedUser := authorizedUserModel{ + Email: types.StringValue(u.Email), + Username: types.StringValue(u.Username), + FirstName: types.StringValue(u.FirstName), + LastName: types.StringValue(u.LastName), + UIIdentityID: types.StringValue(u.UIIdentityID), } users = append(users, authorizedUser) } d.AuthorizedUsers = users - return nil } diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go index f4cc10a1e..e328d9f90 100644 --- a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go @@ -72,11 +72,11 @@ func TestAuthorizedUsers(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(t, client, test.mockData) + if tc.init != nil { + tc.init(t, client, tc.mockData) } useClient(client, func() { @@ -85,9 +85,9 @@ func TestAuthorizedUsers(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.configPath), - Check: checkAuthorizedUsersAttrs(test.mockData), - ExpectError: test.error, + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkAuthorizedUsersAttrs(tc.mockData), + ExpectError: tc.error, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties.go b/pkg/providers/iam/data_akamai_iam_blocked_properties.go index 8494cf37d..6faa526c0 100644 --- a/pkg/providers/iam/data_akamai_iam_blocked_properties.go +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties.go @@ -14,41 +14,41 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" ) -var _ datasource.DataSource = &blockedPropertiesDataSource{} -var _ datasource.DataSourceWithConfigure = &blockedPropertiesDataSource{} +var ( + _ datasource.DataSource = &blockedPropertiesDataSource{} + _ datasource.DataSourceWithConfigure = &blockedPropertiesDataSource{} +) -// NewBlockedPropertiesDataSource returns all the properties that are blocked for a certain user in a group +// NewBlockedPropertiesDataSource returns all the properties that are blocked for a certain user in a group. func NewBlockedPropertiesDataSource() datasource.DataSource { return &blockedPropertiesDataSource{} } -// blockedPropertiesDataSource defines the data source implementation for fetching Blocked Properties information -type blockedPropertiesDataSource struct { - meta meta.Meta -} +type ( + blockedPropertiesDataSource struct { + meta meta.Meta + } -// blockedPropertiesDataSource describes the data source data model for BlockedPropertiesDataSource -type blockedPropertiesDataSourceModel struct { - GroupID types.Int64 `tfsdk:"group_id"` - ContractID types.String `tfsdk:"contract_id"` - UIIdentityID types.String `tfsdk:"ui_identity_id"` - BlockedProperties []blockedPropertyIDsModel `tfsdk:"blocked_properties"` -} + blockedPropertiesModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + ContractID types.String `tfsdk:"contract_id"` + UIIdentityID types.String `tfsdk:"ui_identity_id"` + BlockedProperties []blockedPropertyIDsModel `tfsdk:"blocked_properties"` + } -type blockedPropertyIDsModel struct { - PropertyID types.String `tfsdk:"property_id"` - AssetID types.Int64 `tfsdk:"asset_id"` -} + blockedPropertyIDsModel struct { + PropertyID types.String `tfsdk:"property_id"` + AssetID types.Int64 `tfsdk:"asset_id"` + } +) -// Metadata configures data source's meta information func (d *blockedPropertiesDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_blocked_properties" } -// Schema is used to define data source's terraform schema func (d *blockedPropertiesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Blocked Properties data source", + MarkdownDescription: "Blocked Properties data source.", Attributes: map[string]schema.Attribute{ "group_id": schema.Int64Attribute{ Required: true, @@ -69,11 +69,11 @@ func (d *blockedPropertiesDataSource) Schema(_ context.Context, _ datasource.Sch Attributes: map[string]schema.Attribute{ "property_id": schema.StringAttribute{ Computed: true, - Description: "PAPI's blocked property ID", + Description: "PAPI's blocked property ID.", }, "asset_id": schema.Int64Attribute{ Computed: true, - Description: "IAM's blocked property ID", + Description: "IAM's blocked property ID.", }, }, }, @@ -82,7 +82,6 @@ func (d *blockedPropertiesDataSource) Schema(_ context.Context, _ datasource.Sch } } -// Configure configures data source at the beginning of the lifecycle func (d *blockedPropertiesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider @@ -101,11 +100,10 @@ func (d *blockedPropertiesDataSource) Configure(_ context.Context, req datasourc d.meta = meta.Must(req.ProviderData) } -// Read is called when the provider must read data source values in order to update state func (d *blockedPropertiesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - tflog.Debug(ctx, "BlockedPropertiesDataSource Read") + tflog.Debug(ctx, "Blocked Properties DataSource Read") - var data blockedPropertiesDataSourceModel + var data blockedPropertiesModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go index 089b6d2fc..ec2875366 100644 --- a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go @@ -96,22 +96,23 @@ func TestBlockedPropertiesDataSource(t *testing.T) { expectError: regexp.MustCompile(`The argument "ui_identity_id" is required, but no definition was found`), }, } - for name, test := range tests { + + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} papiClient := &papi.Mock{} - if test.init != nil { - test.init(client, papiClient) + if tc.init != nil { + tc.init(client, papiClient) } useIAMandPAPIClient(client, papiClient, func() { resource.Test(t, resource.TestCase{ IsUnitTest: true, ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataBlockedProperties/%s", test.givenTF)), - Check: test.expectedCheck, - ExpectError: test.expectError, + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataBlockedProperties/%s", tc.givenTF)), + Check: tc.expectedCheck, + ExpectError: tc.expectError, }}, }) }) diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block.go b/pkg/providers/iam/data_akamai_iam_cidr_block.go index 18352aa55..b1f28c590 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block.go @@ -2,6 +2,7 @@ package iam import ( "context" + "errors" "fmt" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" @@ -9,7 +10,6 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -17,6 +17,9 @@ import ( var ( _ datasource.DataSource = &cidrBlockDataSource{} _ datasource.DataSourceWithConfigure = &cidrBlockDataSource{} + + // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails. + ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") ) type ( @@ -24,7 +27,7 @@ type ( meta meta.Meta } - cidrBlockSourceModel struct { + cidrBlockModel struct { CIDRBlockID types.Int64 `tfsdk:"cidr_block_id"` Actions *actions `tfsdk:"actions"` CIDRBlock types.String `tfsdk:"cidr_block"` @@ -42,17 +45,15 @@ type ( } ) -// NewCIDRBlockDataSource returns a new iam CIDR block data source +// NewCIDRBlockDataSource returns a new iam CIDR block data source. func NewCIDRBlockDataSource() datasource.DataSource { return &cidrBlockDataSource{} } -// Metadata configures data source's meta information func (d *cidrBlockDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_cidr_block" } -// Configure configures data source at the beginning of the lifecycle func (d *cidrBlockDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -68,10 +69,9 @@ func (d *cidrBlockDataSource) Configure(_ context.Context, req datasource.Config d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *cidrBlockDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "Identity and Access Management CIDR block", + Description: "Identity and Access Management CIDR block.", Attributes: map[string]schema.Attribute{ "cidr_block_id": schema.Int64Attribute{ Required: true, @@ -123,11 +123,10 @@ func (d *cidrBlockDataSource) Schema(_ context.Context, _ datasource.SchemaReque } } -// Read is called when the provider must read data source values in order to update state func (d *cidrBlockDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM CIDR Block DataSource Read") - var data cidrBlockSourceModel + var data cidrBlockModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } @@ -143,15 +142,12 @@ func (d *cidrBlockDataSource) Read(ctx context.Context, req datasource.ReadReque return } - if resp.Diagnostics.Append(data.read(cidrBlock)...); resp.Diagnostics.HasError() { - return - } + data.read(cidrBlock) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - } -func (d *cidrBlockSourceModel) read(cidrBlock *iam.GetCIDRBlockResponse) diag.Diagnostics { +func (d *cidrBlockModel) read(cidrBlock *iam.GetCIDRBlockResponse) { d.CIDRBlock = types.StringValue(cidrBlock.CIDRBlock) d.CreatedBy = types.StringValue(cidrBlock.CreatedBy) d.CreatedDate = types.StringValue(date.FormatRFC3339Nano(cidrBlock.CreatedDate)) @@ -170,9 +166,5 @@ func (d *cidrBlockSourceModel) read(cidrBlock *iam.GetCIDRBlockResponse) diag.Di d.Comments = types.StringValue(*cidrBlock.Comments) } else { d.Comments = types.StringNull() - } - - return nil - } diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go index edb1d79b5..9e58f7515 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go @@ -77,11 +77,12 @@ func TestDataCIDRBlock(t *testing.T) { error: regexp.MustCompile("test error"), }, } - for name, test := range tests { + + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(t, client, test.mockData) + if tc.init != nil { + tc.init(t, client, tc.mockData) } useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -89,9 +90,9 @@ func TestDataCIDRBlock(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.configPath), + Config: testutils.LoadFixtureString(t, tc.configPath), Check: checkCIDRBlockAttrs(), - ExpectError: test.error, + ExpectError: tc.error, }, }, }) @@ -143,6 +144,6 @@ func expectGetCIDRBlock(t *testing.T, client *iam.Mock, data testDataForCIDRBloc Edit: data.actions.edit, } } - client.On("GetCIDRBlock", mock.Anything, getCIDRBlockReq).Return(&getCIDRBlockResp, nil).Times(timesToRun) + client.On("GetCIDRBlock", mock.Anything, getCIDRBlockReq).Return(&getCIDRBlockResp, nil).Times(timesToRun) } diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go index 4c0683a76..e43fa66bc 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go @@ -2,6 +2,7 @@ package iam import ( "context" + "errors" "fmt" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" @@ -9,7 +10,6 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -17,6 +17,9 @@ import ( var ( _ datasource.DataSource = &cidrBlocksDataSource{} _ datasource.DataSourceWithConfigure = &cidrBlocksDataSource{} + + // ErrIAMListCIDRBlocks is returned when ListCIDRBlocks fails. + ErrIAMListCIDRBlocks = errors.New("IAM list CIDR blocks failed") ) type ( @@ -25,21 +28,19 @@ type ( } cidrBlocksSourceModel struct { - CIDRBlocks []cidrBlockSourceModel `tfsdk:"cidr_blocks"` + CIDRBlocks []cidrBlockModel `tfsdk:"cidr_blocks"` } ) -// NewCIDRBlocksDataSource returns a new iam CIDR block data source +// NewCIDRBlocksDataSource returns a new iam CIDR blocks data source. func NewCIDRBlocksDataSource() datasource.DataSource { return &cidrBlocksDataSource{} } -// Metadata configures data source's meta information func (d *cidrBlocksDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_cidr_blocks" } -// Configure configures data source at the beginning of the lifecycle func (d *cidrBlocksDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -55,13 +56,12 @@ func (d *cidrBlocksDataSource) Configure(_ context.Context, req datasource.Confi d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *cidrBlocksDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "Identity and Access Management CIDR block", + Description: "Identity and Access Management CIDR blocks.", Attributes: map[string]schema.Attribute{ "cidr_blocks": schema.ListNestedAttribute{ - Description: "List of CIDR blocks on account's allowlist", + Description: "List of CIDR blocks on account's allowlist.", Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -118,7 +118,6 @@ func (d *cidrBlocksDataSource) Schema(_ context.Context, _ datasource.SchemaRequ } } -// Read is called when the provider must read data source values in order to update state func (d *cidrBlocksDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM CIDR Blocks DataSource Read") @@ -137,17 +136,14 @@ func (d *cidrBlocksDataSource) Read(ctx context.Context, req datasource.ReadRequ return } - if resp.Diagnostics.Append(data.read(cidrBlocks)...); resp.Diagnostics.HasError() { - return - } + data.read(cidrBlocks) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - } -func (d *cidrBlocksSourceModel) read(cidrBlocks iam.ListCIDRBlocksResponse) diag.Diagnostics { +func (d *cidrBlocksSourceModel) read(cidrBlocks iam.ListCIDRBlocksResponse) { for _, cidrBlock := range cidrBlocks { - block := cidrBlockSourceModel{ + block := cidrBlockModel{ CIDRBlock: types.StringValue(cidrBlock.CIDRBlock), Enabled: types.BoolValue(cidrBlock.Enabled), CIDRBlockID: types.Int64Value(cidrBlock.CIDRBlockID), @@ -167,11 +163,8 @@ func (d *cidrBlocksSourceModel) read(cidrBlocks iam.ListCIDRBlocksResponse) diag block.Comments = types.StringValue(*cidrBlock.Comments) } else { block.Comments = types.StringNull() - } d.CIDRBlocks = append(d.CIDRBlocks, block) } - - return nil } diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go index 2f3464587..01e41c4cf 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go @@ -65,11 +65,11 @@ func TestDataCIDRBlocks(t *testing.T) { error: regexp.MustCompile("test error"), }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(client) + if tc.init != nil { + tc.init(client) } useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -77,9 +77,9 @@ func TestDataCIDRBlocks(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.configPath), + Config: testutils.LoadFixtureString(t, tc.configPath), Check: checkCIDRBlocksAttrs(), - ExpectError: test.error, + ExpectError: tc.error, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_contact_types.go b/pkg/providers/iam/data_akamai_iam_contact_types.go index eb949d9cb..76ab4fa55 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types.go @@ -11,13 +11,13 @@ import ( func dataSourceIAMContactTypes() *schema.Resource { return &schema.Resource{ - Description: "Retrieve all contact types that Akamai supports", + Description: "Retrieve all contact types that Akamai supports.", ReadContext: dataIAMContactTypesRead, Schema: map[string]*schema.Schema{ "contact_types": { Type: schema.TypeSet, Computed: true, - Description: "Supported contact types", + Description: "Supported contact types.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, @@ -38,7 +38,7 @@ func dataIAMContactTypesRead(ctx context.Context, d *schema.ResourceData, m inte return diag.FromErr(err) } - types := []interface{}{} + var types []interface{} for _, ct := range res { types = append(types, ct) } diff --git a/pkg/providers/iam/data_akamai_iam_countries.go b/pkg/providers/iam/data_akamai_iam_countries.go index b0ea4e5c5..a7c3e9d9b 100644 --- a/pkg/providers/iam/data_akamai_iam_countries.go +++ b/pkg/providers/iam/data_akamai_iam_countries.go @@ -11,13 +11,13 @@ import ( func dataSourceIAMCountries() *schema.Resource { return &schema.Resource{ - Description: "List all the possible countries that Akamai supports", + Description: "List all the possible countries that Akamai supports.", ReadContext: dataIAMCountriesRead, Schema: map[string]*schema.Schema{ "countries": { Type: schema.TypeSet, Computed: true, - Description: "Supported countries", + Description: "Supported countries.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_grantable_roles.go b/pkg/providers/iam/data_akamai_iam_grantable_roles.go index 8cea4d54c..d70dc8025 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles.go @@ -12,28 +12,28 @@ import ( func dataSourceIAMGrantableRoles() *schema.Resource { return &schema.Resource{ - Description: "Get roles for the current account and contract", + Description: "Get roles for the current account and contract.", ReadContext: dataIAMGrantableRolesRead, Schema: map[string]*schema.Schema{ "grantable_roles": { Type: schema.TypeList, Computed: true, - Description: "List of grantable roles", + Description: "List of grantable roles.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "granted_role_id": { Type: schema.TypeInt, - Description: "Granted role ID", + Description: "Granted role ID.", Computed: true, }, "name": { Type: schema.TypeString, - Description: "Granted role name", + Description: "Granted role name.", Computed: true, }, "description": { Type: schema.TypeString, - Description: "Granted role description", + Description: "Granted role description.", Computed: true, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_group.go b/pkg/providers/iam/data_akamai_iam_group.go index 9c8dd0ffe..dfc30a5df 100644 --- a/pkg/providers/iam/data_akamai_iam_group.go +++ b/pkg/providers/iam/data_akamai_iam_group.go @@ -21,29 +21,26 @@ var ( const maxSupportedGroupNesting = 50 -// NewGroupDataSource returns all the details for a group +// NewGroupDataSource returns all the details for a group. func NewGroupDataSource() datasource.DataSource { return &groupDataSource{} } type ( - - // groupDataSource defines the data source implementation for fetching Group information groupDataSource struct { meta meta.Meta } - // groupDataSourceModel describes the data source data model for groupDataSource - groupDataSourceModel struct { - GroupID types.Int64 `tfsdk:"group_id"` - GroupName types.String `tfsdk:"group_name"` - Actions *actions `tfsdk:"actions"` - CreatedBy types.String `tfsdk:"created_by"` - CreatedDate types.String `tfsdk:"created_date"` - ModifiedBy types.String `tfsdk:"modified_by"` - ModifiedDate types.String `tfsdk:"modified_date"` - ParentGroupID types.Int64 `tfsdk:"parent_group_id"` - SubGroups []groupDataSourceModel `tfsdk:"sub_groups"` + groupModel struct { + GroupID types.Int64 `tfsdk:"group_id"` + GroupName types.String `tfsdk:"group_name"` + Actions *actions `tfsdk:"actions"` + CreatedBy types.String `tfsdk:"created_by"` + CreatedDate types.String `tfsdk:"created_date"` + ModifiedBy types.String `tfsdk:"modified_by"` + ModifiedDate types.String `tfsdk:"modified_date"` + ParentGroupID types.Int64 `tfsdk:"parent_group_id"` + SubGroups []groupModel `tfsdk:"sub_groups"` } ) @@ -107,20 +104,17 @@ func (d *groupDataSource) groupSchemaAttributes(remainingNesting int) map[string return groupAttributes } -// Schema is used to define data source's terraform schema func (d *groupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "IAM Group data source", + MarkdownDescription: "IAM Group data source.", Attributes: d.groupSchemaAttributes(maxSupportedGroupNesting + 1), } } -// Metadata configures data source's meta information func (d *groupDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_group" } -// Configure configures data source at the beginning of the lifecycle func (d *groupDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider @@ -139,11 +133,10 @@ func (d *groupDataSource) Configure(_ context.Context, req datasource.ConfigureR d.meta = meta.Must(req.ProviderData) } -// Read is called when the provider must read data source values in order to update state func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Group DataSource Read") - var data groupDataSourceModel + var data groupModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } @@ -169,7 +162,7 @@ func (d *groupDataSource) Read(ctx context.Context, req datasource.ReadRequest, } // convertGroupData converts the response from the IAM client into the groupDataSourceModel structure -func (d *groupDataSource) convertGroupData(group *iam.Group, data groupDataSourceModel, remainingNesting int) (groupDataSourceModel, diag.Diagnostics) { +func (d *groupDataSource) convertGroupData(group *iam.Group, data groupModel, remainingNesting int) (groupModel, diag.Diagnostics) { data.GroupName = types.StringValue(group.GroupName) data.CreatedBy = types.StringValue(group.CreatedBy) data.CreatedDate = types.StringValue(date.FormatRFC3339Nano(group.CreatedDate)) @@ -185,18 +178,18 @@ func (d *groupDataSource) convertGroupData(group *iam.Group, data groupDataSourc } } - var subGroups []groupDataSourceModel + var subGroups []groupModel if remainingNesting > 1 { for _, subGroup := range group.SubGroups { - subGroupData, diags := d.convertGroupData(&subGroup, groupDataSourceModel{}, remainingNesting-1) + subGroupData, diags := d.convertGroupData(&subGroup, groupModel{}, remainingNesting-1) if diags.HasError() { - return groupDataSourceModel{}, diags + return groupModel{}, diags } subGroups = append(subGroups, subGroupData) } data.SubGroups = subGroups } else if remainingNesting <= 1 && len(group.SubGroups) > 0 { - return groupDataSourceModel{}, diag.Diagnostics{diag.NewErrorDiagnostic( + return groupModel{}, diag.Diagnostics{diag.NewErrorDiagnostic( "unsupported subgroup depth", fmt.Sprintf("Subgroup %d contains more subgroups and exceeds the total supported limit of nesting %d.", group.GroupID, maxSupportedGroupNesting), )} diff --git a/pkg/providers/iam/data_akamai_iam_group_test.go b/pkg/providers/iam/data_akamai_iam_group_test.go index 9a6b50dbb..d0dc873a9 100644 --- a/pkg/providers/iam/data_akamai_iam_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_group_test.go @@ -121,10 +121,10 @@ func TestGroupDataSource(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -132,9 +132,9 @@ func TestGroupDataSource(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, "testdata/TestDataGroup/%s", test.givenTF), - Check: test.expectedChecks, - ExpectError: test.expectedError, + Config: testutils.LoadFixtureString(t, "testdata/TestDataGroup/%s", tc.givenTF), + Check: tc.expectedChecks, + ExpectError: tc.expectedError, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index f3bc1e2d6..f75d1332d 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -12,10 +12,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// Resource schema for akamai_iam_groups data source func dataSourceIAMGroups() *schema.Resource { return &schema.Resource{ - Description: `List all groups in which you have a scope of "admin" for the current account and contract`, + Description: `List all groups in which you have a scope of "admin" for the current account and contract.`, ReadContext: dataIAMGroupsRead, Schema: map[string]*schema.Schema{ "groups": nestedGroupsSchema(maxSupportedGroupNesting), // Can handle groups with nesting up to 50 levels deep @@ -25,52 +24,52 @@ func dataSourceIAMGroups() *schema.Resource { // nestedGroupsSchema builds a nested groups schema to the given depth func nestedGroupsSchema(depth int) *schema.Schema { - schem := map[string]*schema.Schema{ + nestedSchema := map[string]*schema.Schema{ "name": { Type: schema.TypeString, - Description: "The group's name", + Description: "The group's name.", Computed: true, }, "group_id": { Type: schema.TypeString, - Description: "A unique identifier for each group", + Description: "A unique identifier for each group.", Computed: true, }, "parent_group_id": { Type: schema.TypeString, - Description: "Identifies the parent group to which a group belongs", + Description: "Identifies the parent group to which a group belongs.", Computed: true, }, "time_created": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the group was originally created", + Description: "ISO 8601 timestamp indicating when the group was originally created.", Computed: true, }, "time_modified": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the group was last updated", + Description: "ISO 8601 timestamp indicating when the group was last updated.", Computed: true, }, "modified_by": { Type: schema.TypeString, - Description: "The username or email of the last person to edit the group", + Description: "The username or email of the last person to edit the group.", Computed: true, }, "created_by": { Type: schema.TypeString, - Description: "The user name or email of the person who created the group", + Description: "The user name or email of the person who created the group.", Computed: true, }, } if depth > 1 { - schem["sub_groups"] = nestedGroupsSchema(depth - 1) + nestedSchema["sub_groups"] = nestedGroupsSchema(depth - 1) } return &schema.Schema{ Type: schema.TypeSet, Computed: true, - Elem: &schema.Resource{Schema: schem}, + Elem: &schema.Resource{Schema: nestedSchema}, } } diff --git a/pkg/providers/iam/data_akamai_iam_password_policy.go b/pkg/providers/iam/data_akamai_iam_password_policy.go index 4fc8405df..360613d83 100644 --- a/pkg/providers/iam/data_akamai_iam_password_policy.go +++ b/pkg/providers/iam/data_akamai_iam_password_policy.go @@ -21,7 +21,7 @@ type ( meta meta.Meta } - passwordPolicyDataSourceModel struct { + passwordPolicyModel struct { PwClass types.String `tfsdk:"pw_class"` CaseDif types.Int64 `tfsdk:"case_dif"` MaxRepeating types.Int64 `tfsdk:"max_repeating"` @@ -34,17 +34,15 @@ type ( } ) -// NewPasswordPolicyDataSource returns a new password policy data source +// NewPasswordPolicyDataSource returns a new password policy data source. func NewPasswordPolicyDataSource() datasource.DataSource { return &passwordPolicyDataSource{} } -// Metadata configures data source's meta information func (d *passwordPolicyDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_password_policy" } -// Configure configures data source at the beginning of the lifecycle func (d *passwordPolicyDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -60,10 +58,9 @@ func (d *passwordPolicyDataSource) Configure(_ context.Context, req datasource.C d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *passwordPolicyDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "Identity and Access Management password policy", + Description: "Identity and Access Management password policy.", Attributes: map[string]schema.Attribute{ "pw_class": schema.StringAttribute{ Computed: true, @@ -105,11 +102,10 @@ func (d *passwordPolicyDataSource) Schema(_ context.Context, _ datasource.Schema } } -// Read is called when the provider must read data source values in order to update state func (d *passwordPolicyDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Password Policy DataSource Read") - var data passwordPolicyDataSourceModel + var data passwordPolicyModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) if resp.Diagnostics.HasError() { return diff --git a/pkg/providers/iam/data_akamai_iam_password_policy_test.go b/pkg/providers/iam/data_akamai_iam_password_policy_test.go index 1819a44da..73d86fb7b 100644 --- a/pkg/providers/iam/data_akamai_iam_password_policy_test.go +++ b/pkg/providers/iam/data_akamai_iam_password_policy_test.go @@ -48,11 +48,11 @@ func TestPasswordPolicy(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(client) + if tc.init != nil { + tc.init(client) } useClient(client, func() { @@ -63,7 +63,7 @@ func TestPasswordPolicy(t *testing.T) { { Config: testutils.LoadFixtureString(t, "testdata/TestDataPasswordPolicy/default.tf"), Check: checkPasswordPolicyAttrs(), - ExpectError: test.error, + ExpectError: tc.error, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_property_users.go b/pkg/providers/iam/data_akamai_iam_property_users.go index 835f3d589..3ecba89b2 100644 --- a/pkg/providers/iam/data_akamai_iam_property_users.go +++ b/pkg/providers/iam/data_akamai_iam_property_users.go @@ -26,7 +26,7 @@ type ( meta meta.Meta } - propertyUsersDataSourceModel struct { + propertyUsersModel struct { AssetID types.String `tfsdk:"asset_id"` UserType types.String `tfsdk:"user_type"` Users []propertyUser `tfsdk:"users"` @@ -41,17 +41,15 @@ type ( } ) -// NewPropertyUsersDataSource returns a new iam property users data source +// NewPropertyUsersDataSource returns a new iam property users data source. func NewPropertyUsersDataSource() datasource.DataSource { return &propertyUsersDataSource{} } -// Metadata configures data source's meta information func (d *propertyUsersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_property_users" } -// Configure configures data source at the beginning of the lifecycle func (d *propertyUsersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -67,7 +65,6 @@ func (d *propertyUsersDataSource) Configure(_ context.Context, req datasource.Co d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *propertyUsersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Identity and Access Management property users data source. Lists users for " + @@ -123,11 +120,10 @@ func (d *propertyUsersDataSource) Schema(_ context.Context, _ datasource.SchemaR } } -// Read is called when the provider must read data source values in order to update state func (d *propertyUsersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Property Users DataSource Read") - var data propertyUsersDataSourceModel + var data propertyUsersModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) if resp.Diagnostics.HasError() { @@ -158,7 +154,7 @@ func (d *propertyUsersDataSource) Read(ctx context.Context, req datasource.ReadR return } - for _, user := range *users { + for _, user := range users { data.Users = append(data.Users, newPropertyUser(user)) } diff --git a/pkg/providers/iam/data_akamai_iam_property_users_test.go b/pkg/providers/iam/data_akamai_iam_property_users_test.go index 096e1cb76..6d40e4291 100644 --- a/pkg/providers/iam/data_akamai_iam_property_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_property_users_test.go @@ -39,7 +39,7 @@ func TestDataPropertyUsers(t *testing.T) { mockListUsersForProperty := func(iamMock *iam.Mock, req iam.ListUsersForPropertyRequest, users ...iam.UsersForProperty) { iamMock.On("ListUsersForProperty", mock.Anything, req). - Return((*iam.ListUsersForPropertyResponse)(&users), nil).Times(3) + Return((iam.ListUsersForPropertyResponse)(users), nil).Times(3) } tests := map[string]struct { @@ -178,11 +178,12 @@ func TestDataPropertyUsers(t *testing.T) { error: regexp.MustCompile("list users failed"), }, } - for name, test := range tests { + + for name, tc := range tests { t.Run(name, func(t *testing.T) { iamMock := iam.Mock{} - if test.init != nil { - test.init(t, &iamMock) + if tc.init != nil { + tc.init(t, &iamMock) } useClient(&iamMock, func() { @@ -190,9 +191,9 @@ func TestDataPropertyUsers(t *testing.T) { ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.configPath), - Check: test.check, - ExpectError: test.error, + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: tc.check, + ExpectError: tc.error, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_role.go b/pkg/providers/iam/data_akamai_iam_role.go index 5ae3b4b9f..6b533e441 100644 --- a/pkg/providers/iam/data_akamai_iam_role.go +++ b/pkg/providers/iam/data_akamai_iam_role.go @@ -15,8 +15,10 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" ) -var _ datasource.DataSource = &roleDataSource{} -var _ datasource.DataSourceWithConfigure = &roleDataSource{} +var ( + _ datasource.DataSource = &roleDataSource{} + _ datasource.DataSourceWithConfigure = &roleDataSource{} +) // NewRoleDataSource returns all the details for a role. func NewRoleDataSource() datasource.DataSource { @@ -24,14 +26,11 @@ func NewRoleDataSource() datasource.DataSource { } type ( - - // roleDataSource defines the data source implementation for fetching details for a role. roleDataSource struct { meta meta.Meta } - // roleDataSourceModel describes the data source data model for roleDataSource. - roleDataSourceModel struct { + roleModel struct { RoleID types.Int64 `tfsdk:"role_id"` Actions *actions `tfsdk:"actions"` CreatedBy types.String `tfsdk:"created_by"` @@ -41,19 +40,17 @@ type ( RoleDescription types.String `tfsdk:"role_description"` RoleName types.String `tfsdk:"role_name"` Type types.String `tfsdk:"type"` - GrantedRoles []GrantedRole `tfsdk:"granted_roles"` - Users []User `tfsdk:"users"` + GrantedRoles []grantedRole `tfsdk:"granted_roles"` + Users []user `tfsdk:"users"` } - // GrantedRole contains details about Granted roles for the account. - GrantedRole struct { + grantedRole struct { GrantedRoleID types.Int64 `tfsdk:"granted_role_id"` GrantedRoleName types.String `tfsdk:"granted_role_name"` GrantedRoleDescription types.String `tfsdk:"granted_role_description"` } - // User is one of the Users on the account who share the same role. - User struct { + user struct { AccountID types.String `tfsdk:"account_id"` Email types.String `tfsdk:"email"` FirstName types.String `tfsdk:"first_name"` @@ -63,10 +60,9 @@ type ( } ) -// Schema is used to define data source's terraform schema func (d *roleDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Role data source", + MarkdownDescription: "Role data source.", Attributes: map[string]schema.Attribute{ "role_id": schema.Int64Attribute{ Required: true, @@ -173,12 +169,10 @@ func (d *roleDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, r } } -// Metadata configures data source's meta information func (d *roleDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_role" } -// Configure configures data source at the beginning of the lifecycle func (d *roleDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider @@ -197,11 +191,10 @@ func (d *roleDataSource) Configure(_ context.Context, req datasource.ConfigureRe d.meta = meta.Must(req.ProviderData) } -// Read is called when the provider must read data source values in order to update state func (d *roleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Role DataSource Read") - var data roleDataSourceModel + var data roleModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } @@ -223,7 +216,7 @@ func (d *roleDataSource) Read(ctx context.Context, req datasource.ReadRequest, r resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (m *roleDataSourceModel) setAttributes(role *iam.Role) { +func (m *roleModel) setAttributes(role *iam.Role) { m.CreatedBy = types.StringValue(role.CreatedBy) m.CreatedDate = types.StringValue(date.FormatRFC3339Nano(role.CreatedDate)) @@ -240,22 +233,22 @@ func (m *roleDataSourceModel) setAttributes(role *iam.Role) { } } - for _, grantedRole := range role.GrantedRoles { - grantedRoleObject := GrantedRole{ - GrantedRoleID: types.Int64Value(grantedRole.RoleID), - GrantedRoleName: types.StringValue(grantedRole.RoleName), - GrantedRoleDescription: types.StringValue(grantedRole.Description), + for _, r := range role.GrantedRoles { + grantedRoleObject := grantedRole{ + GrantedRoleID: types.Int64Value(r.RoleID), + GrantedRoleName: types.StringValue(r.RoleName), + GrantedRoleDescription: types.StringValue(r.Description), } m.GrantedRoles = append(m.GrantedRoles, grantedRoleObject) } - for _, user := range role.Users { - userObject := User{ - AccountID: types.StringValue(user.AccountID), - Email: types.StringValue(user.Email), - FirstName: types.StringValue(user.FirstName), - LastName: types.StringValue(user.LastName), - LastLoginDate: types.StringValue(user.LastLoginDate.String()), - UIIdentityID: types.StringValue(user.UIIdentityID), + for _, u := range role.Users { + userObject := user{ + AccountID: types.StringValue(u.AccountID), + Email: types.StringValue(u.Email), + FirstName: types.StringValue(u.FirstName), + LastName: types.StringValue(u.LastName), + LastLoginDate: types.StringValue(u.LastLoginDate.String()), + UIIdentityID: types.StringValue(u.UIIdentityID), } m.Users = append(m.Users, userObject) diff --git a/pkg/providers/iam/data_akamai_iam_role_test.go b/pkg/providers/iam/data_akamai_iam_role_test.go index 1270e6b5d..02307b906 100644 --- a/pkg/providers/iam/data_akamai_iam_role_test.go +++ b/pkg/providers/iam/data_akamai_iam_role_test.go @@ -112,18 +112,19 @@ func TestRoleDataSource(t *testing.T) { expectError: regexp.MustCompile(`The argument "role_id" is required, but no definition was found`), }, } - for name, test := range tests { + + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(client) + if tc.init != nil { + tc.init(client) } var checkFuncs []resource.TestCheckFunc - for k, v := range test.expectedAttributes { + for k, v := range tc.expectedAttributes { checkFuncs = append(checkFuncs, resource.TestCheckResourceAttr("data.akamai_iam_role.test", k, v)) } - for _, v := range test.expectedMissingAttributes { + for _, v := range tc.expectedMissingAttributes { checkFuncs = append(checkFuncs, resource.TestCheckNoResourceAttr("data.akamai_iam_role.test", v)) } useClient(client, func() { @@ -131,9 +132,9 @@ func TestRoleDataSource(t *testing.T) { IsUnitTest: true, ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), Steps: []resource.TestStep{{ - Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataRole/%s", test.givenTF)), + Config: testutils.LoadFixtureString(t, fmt.Sprintf("testdata/TestDataRole/%s", tc.givenTF)), Check: resource.ComposeAggregateTestCheckFunc(checkFuncs...), - ExpectError: test.expectError, + ExpectError: tc.expectError, }}, }) }) diff --git a/pkg/providers/iam/data_akamai_iam_roles.go b/pkg/providers/iam/data_akamai_iam_roles.go index f70c06898..ea26b2175 100644 --- a/pkg/providers/iam/data_akamai_iam_roles.go +++ b/pkg/providers/iam/data_akamai_iam_roles.go @@ -14,7 +14,7 @@ import ( func dataSourceIAMRoles() *schema.Resource { return &schema.Resource{ - Description: "Get roles for the current account and contract", + Description: "Get roles for the current account and contract.", ReadContext: dataIAMRolesRead, Schema: map[string]*schema.Schema{ // outputs @@ -25,42 +25,42 @@ func dataSourceIAMRoles() *schema.Resource { Schema: map[string]*schema.Schema{ "role_id": { Type: schema.TypeString, - Description: "A unique identifier for each role", + Description: "A unique identifier for each role.", Computed: true, }, "name": { Type: schema.TypeString, - Description: "The role's name", + Description: "The role's name.", Computed: true, }, "description": { Type: schema.TypeString, - Description: "The role's description", + Description: "The role's description.", Computed: true, }, "type": { Type: schema.TypeString, - Description: "Whether the role is a standard role or a custom role", + Description: "Whether the role is a standard role or a custom role.", Computed: true, }, "time_created": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the role was originally created", + Description: "ISO 8601 timestamp indicating when the role was originally created.", Computed: true, }, "time_modified": { Type: schema.TypeString, - Description: "ISO 8601 timestamp indicating when the role was last updated", + Description: "ISO 8601 timestamp indicating when the role was last updated.", Computed: true, }, "modified_by": { Type: schema.TypeString, - Description: "The username or email of the last person to edit the role", + Description: "The username or email of the last person to edit the role.", Computed: true, }, "created_by": { Type: schema.TypeString, - Description: "The user name or email of the person who created the role", + Description: "The user name or email of the person who created the role.", Computed: true, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_states.go b/pkg/providers/iam/data_akamai_iam_states.go index 12b3342a3..4c559a103 100644 --- a/pkg/providers/iam/data_akamai_iam_states.go +++ b/pkg/providers/iam/data_akamai_iam_states.go @@ -12,18 +12,18 @@ import ( func dataSourceIAMStates() *schema.Resource { return &schema.Resource{ - Description: "List US states or Canadian provinces", + Description: "List US states or Canadian provinces.", ReadContext: dataIAMStatesRead, Schema: map[string]*schema.Schema{ "country": { Type: schema.TypeString, Required: true, - Description: "Specifies a US state or Canadian province", + Description: "Specifies a US state or Canadian province.", }, "states": { Type: schema.TypeSet, Computed: true, - Description: "Supported states", + Description: "Supported states.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_supported_langs.go b/pkg/providers/iam/data_akamai_iam_supported_langs.go index cbe1c984f..466ef4ace 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs.go @@ -11,13 +11,13 @@ import ( func dataSourceIAMLanguages() *schema.Resource { return &schema.Resource{ - Description: "List all the possible languages Akamai supports", + Description: "List all the possible languages Akamai supports.", ReadContext: dataIAMLanguagesRead, Schema: map[string]*schema.Schema{ "languages": { Type: schema.TypeSet, Computed: true, - Description: "Languages supported by Akamai", + Description: "Languages supported by Akamai.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_timeout_policies.go b/pkg/providers/iam/data_akamai_iam_timeout_policies.go index 3fa7b1ee8..3182c895e 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies.go @@ -11,13 +11,13 @@ import ( func dataSourceIAMTimeoutPolicies() *schema.Resource { return &schema.Resource{ - Description: "Lists all session timeout policies Akamai supports", + Description: "Lists all session timeout policies Akamai supports.", ReadContext: dataIAMTimeoutPoliciesRead, Schema: map[string]*schema.Schema{ "policies": { Type: schema.TypeMap, Computed: true, - Description: "Session timeout policies", + Description: "Session timeout policies.", Elem: &schema.Schema{Type: schema.TypeInt}, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_timezones.go b/pkg/providers/iam/data_akamai_iam_timezones.go index c5281e1b8..278555b36 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones.go +++ b/pkg/providers/iam/data_akamai_iam_timezones.go @@ -13,7 +13,7 @@ import ( func dataSourceIAMTimezones() *schema.Resource { return &schema.Resource{ - Description: "List all the possible time zones Akamai supports", + Description: "List all the possible time zones Akamai supports.", ReadContext: dataIAMTimezonesRead, Schema: map[string]*schema.Schema{ "timezones": { @@ -23,22 +23,22 @@ func dataSourceIAMTimezones() *schema.Resource { Schema: map[string]*schema.Schema{ "timezone": { Type: schema.TypeString, - Description: "The time zone ID", + Description: "The time zone ID.", Computed: true, }, "description": { Type: schema.TypeString, - Description: "The description of a time zone, including the GMT +/-", + Description: "The description of a time zone, including the GMT +/-.", Computed: true, }, "offset": { Type: schema.TypeString, - Description: "The time zone offset from GMT", + Description: "The time zone offset from GMT.", Computed: true, }, "posix": { Type: schema.TypeString, - Description: "The time zone posix", + Description: "The time zone posix.", Computed: true, }, }, diff --git a/pkg/providers/iam/data_akamai_iam_user.go b/pkg/providers/iam/data_akamai_iam_user.go index f21b2f67c..0f579dc61 100644 --- a/pkg/providers/iam/data_akamai_iam_user.go +++ b/pkg/providers/iam/data_akamai_iam_user.go @@ -2,6 +2,7 @@ package iam import ( "context" + "errors" "fmt" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" @@ -17,15 +18,17 @@ import ( var ( _ datasource.DataSource = &userDataSource{} _ datasource.DataSourceWithConfigure = &userDataSource{} + + // ErrIAMGetUser is returned when GetUser fails. + ErrIAMGetUser = errors.New("IAM get user failed") ) type ( - //userDataSource defines iam user datasource userDataSource struct { meta meta.Meta } - //userDataSourceModel defines structure of datasource attributes - userDataSourceModel struct { + + userModel struct { UIIdentityID types.String `tfsdk:"ui_identity_id"` AccountID types.String `tfsdk:"account_id"` Actions *actionsModel `tfsdk:"actions"` @@ -66,6 +69,7 @@ type ( ResetPassword types.Bool `tfsdk:"reset_password"` ThirdPartyAccess types.Bool `tfsdk:"third_party_access"` } + authGrantsModel struct { GroupID types.Int64 `tfsdk:"group_id"` GroupName types.String `tfsdk:"group_name"` @@ -75,6 +79,7 @@ type ( RoleName types.String `tfsdk:"role_name"` SubGroups []authGrantsModel `tfsdk:"sub_groups"` } + notificationsModel struct { Options optionsModel `tfsdk:"options"` EnableEmailNotifications types.Bool `tfsdk:"enable_email_notifications"` @@ -89,17 +94,15 @@ type ( } ) -// NewUserDataSource returns a new iam user data source +// NewUserDataSource returns a new iam user data source. func NewUserDataSource() datasource.DataSource { return &userDataSource{} } -// Metadata configures data source's meta information func (d *userDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_user" } -// Configure configures data source at the beginning of the lifecycle func (d *userDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -115,10 +118,9 @@ func (d *userDataSource) Configure(_ context.Context, req datasource.ConfigureRe d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "IAM User Data Source", + Description: "IAM User Data Source.", Attributes: map[string]schema.Attribute{ "ui_identity_id": schema.StringAttribute{ Required: true, @@ -371,17 +373,16 @@ func nestedAuthGrant(depth int) *schema.ListNestedAttribute { return &authGrant } -// Read is called when the provider must read data source values in order to update state func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM User DataSource Read") - var data userDataSourceModel + var data userModel if resp.Diagnostics.Append(req.Config.Get(ctx, &data)...); resp.Diagnostics.HasError() { return } client := inst.Client(d.meta) - user, err := client.GetUser(ctx, iam.GetUserRequest{ + usr, err := client.GetUser(ctx, iam.GetUserRequest{ IdentityID: data.UIIdentityID.ValueString(), Actions: true, AuthGrants: true, @@ -392,7 +393,7 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r return } - if resp.Diagnostics.Append(data.setAttributes(user)...); resp.Diagnostics.HasError() { + if resp.Diagnostics.Append(data.setAttributes(usr)...); resp.Diagnostics.HasError() { return } @@ -400,7 +401,7 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r } -func (d *userDataSourceModel) setAttributes(user *iam.User) diag.Diagnostics { +func (d *userModel) setAttributes(user *iam.User) diag.Diagnostics { d.UIIdentityID = types.StringValue(user.IdentityID) d.AccountID = types.StringValue(user.AccountID) d.AdditionalAuthentication = types.StringValue(string(user.AdditionalAuthentication)) diff --git a/pkg/providers/iam/data_akamai_iam_user_test.go b/pkg/providers/iam/data_akamai_iam_user_test.go index 51c493492..00941f501 100644 --- a/pkg/providers/iam/data_akamai_iam_user_test.go +++ b/pkg/providers/iam/data_akamai_iam_user_test.go @@ -68,6 +68,7 @@ type ( roleName string subgroup []*authGrantData } + notificationData struct { options optionsData enableEmailNotifications bool @@ -178,6 +179,7 @@ var ( groupID: 1234, groupName: "TestName", } + basicAuthGrantDataMaxSubgroup = authGrantData{ roleDescription: "testDesc", roleName: "admin", @@ -267,7 +269,7 @@ func expectGetUser(_ *testing.T, client *iam.Mock, data testDataForUser, times i Notifications: true, } - user := iam.User{ + usr := iam.User{ IdentityID: data.uiIdentityID, IsLocked: data.isLocked, LastLoginDate: data.lastLoginDate, @@ -328,10 +330,11 @@ func expectGetUser(_ *testing.T, client *iam.Mock, data testDataForUser, times i } userAuthGrantList = append(userAuthGrantList, userAuthGrant) } - user.AuthGrants = userAuthGrantList + usr.AuthGrants = userAuthGrantList - client.On("GetUser", mock.Anything, getUserReq).Return(&user, nil).Times(times) + client.On("GetUser", mock.Anything, getUserReq).Return(&usr, nil).Times(times) } + func expectGetUserMaxAuthGranSubGroups(_ *testing.T, client *iam.Mock, data testDataForUser, times, subGroupsDepth int) { getUserReq := iam.GetUserRequest{ IdentityID: data.uiIdentityID, @@ -340,7 +343,7 @@ func expectGetUserMaxAuthGranSubGroups(_ *testing.T, client *iam.Mock, data test Notifications: true, } - user := iam.User{ + usr := iam.User{ IdentityID: data.uiIdentityID, IsLocked: data.isLocked, LastLoginDate: data.lastLoginDate, @@ -402,9 +405,9 @@ func expectGetUserMaxAuthGranSubGroups(_ *testing.T, client *iam.Mock, data test } userAuthGrantList = append(userAuthGrantList, userAuthGrant) } - user.AuthGrants = userAuthGrantList + usr.AuthGrants = userAuthGrantList - client.On("GetUser", mock.Anything, getUserReq).Return(&user, nil).Times(times) + client.On("GetUser", mock.Anything, getUserReq).Return(&usr, nil).Times(times) } func checkUserAttrs(data testDataForUser) resource.TestCheckFunc { diff --git a/pkg/providers/iam/data_akamai_iam_users.go b/pkg/providers/iam/data_akamai_iam_users.go index 67f8529d5..55529c7fa 100644 --- a/pkg/providers/iam/data_akamai_iam_users.go +++ b/pkg/providers/iam/data_akamai_iam_users.go @@ -60,17 +60,15 @@ type ( } ) -// NewUsersDataSource returns a new iam users data source +// NewUsersDataSource returns a new iam users data source. func NewUsersDataSource() datasource.DataSource { return &usersDataSource{} } -// Metadata configures data source's meta information func (d *usersDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_users" } -// Configure configures data source at the beginning of the lifecycle func (d *usersDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return @@ -86,17 +84,16 @@ func (d *usersDataSource) Configure(_ context.Context, req datasource.ConfigureR d.meta = meta.Must(req.ProviderData) } -// Schema is used to define data source's terraform schema func (d *usersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "Identity and Access Management users", + Description: "Identity and Access Management users.", Attributes: map[string]schema.Attribute{ "group_id": schema.Int64Attribute{ Optional: true, Description: "Filters users for a specific group.", }, "users": schema.ListNestedAttribute{ - Description: "List of users in the account", + Description: "List of users in the account.", Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -231,7 +228,6 @@ func (d *usersDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, }}} } -// Read is called when the provider must read data source values in order to update state func (d *usersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Users DataSource Read") @@ -249,7 +245,7 @@ func (d *usersDataSource) Read(ctx context.Context, req datasource.ReadRequest, Actions: true, }) if err != nil { - resp.Diagnostics.AddError(fmt.Sprintf("%s:", ErrIAMListUsers), err.Error()) + resp.Diagnostics.AddError("list users failed: ", err.Error()) return } @@ -258,46 +254,45 @@ func (d *usersDataSource) Read(ctx context.Context, req datasource.ReadRequest, } resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - } func (d *usersModel) read(users []iam.UserListItem) diag.Diagnostics { - for _, user := range users { - authGrants, diags := readAuthGrantSubGroups(user.AuthGrants, maxSupportedGroupNesting) + for _, usr := range users { + authGrants, diags := readAuthGrantSubGroups(usr.AuthGrants, maxSupportedGroupNesting) if diags.HasError() { return diags } - userItem := userItem{ - AccountID: types.StringValue(user.AccountID), - AdditionalAuthentication: types.StringValue(string(user.AdditionalAuthentication)), - AdditionalAuthenticationConfigured: types.BoolValue(user.AdditionalAuthenticationConfigured), + usrItem := userItem{ + AccountID: types.StringValue(usr.AccountID), + AdditionalAuthentication: types.StringValue(string(usr.AdditionalAuthentication)), + AdditionalAuthenticationConfigured: types.BoolValue(usr.AdditionalAuthenticationConfigured), AuthGrants: authGrants, - Email: types.StringValue(user.Email), - FirstName: types.StringValue(user.FirstName), - IsLocked: types.BoolValue(user.IsLocked), - LastName: types.StringValue(user.LastName), - LastLoginDate: types.StringValue(date.FormatRFC3339Nano(user.LastLoginDate)), - TFAConfigured: types.BoolValue(user.TFAConfigured), - TFAEnabled: types.BoolValue(user.TFAEnabled), - UIIdentityID: types.StringValue(user.IdentityID), - UIUserName: types.StringValue(user.UserName), + Email: types.StringValue(usr.Email), + FirstName: types.StringValue(usr.FirstName), + IsLocked: types.BoolValue(usr.IsLocked), + LastName: types.StringValue(usr.LastName), + LastLoginDate: types.StringValue(date.FormatRFC3339Nano(usr.LastLoginDate)), + TFAConfigured: types.BoolValue(usr.TFAConfigured), + TFAEnabled: types.BoolValue(usr.TFAEnabled), + UIIdentityID: types.StringValue(usr.IdentityID), + UIUserName: types.StringValue(usr.UserName), } - if user.Actions != nil { - userItem.Actions = &userActions{ - Delete: types.BoolValue(user.Actions.Delete), - APIClient: types.BoolValue(user.Actions.APIClient), - CanEditMFA: types.BoolValue(user.Actions.CanEditMFA), - CanEditNone: types.BoolValue(user.Actions.CanEditNone), - CanEditTFA: types.BoolValue(user.Actions.CanEditTFA), - Edit: types.BoolValue(user.Actions.Edit), - EditProfile: types.BoolValue(user.Actions.EditProfile), - IsCloneable: types.BoolValue(user.Actions.IsCloneable), - ResetPassword: types.BoolValue(user.Actions.ResetPassword), - ThirdPartyAccess: types.BoolValue(user.Actions.ThirdPartyAccess), + if usr.Actions != nil { + usrItem.Actions = &userActions{ + Delete: types.BoolValue(usr.Actions.Delete), + APIClient: types.BoolValue(usr.Actions.APIClient), + CanEditMFA: types.BoolValue(usr.Actions.CanEditMFA), + CanEditNone: types.BoolValue(usr.Actions.CanEditNone), + CanEditTFA: types.BoolValue(usr.Actions.CanEditTFA), + Edit: types.BoolValue(usr.Actions.Edit), + EditProfile: types.BoolValue(usr.Actions.EditProfile), + IsCloneable: types.BoolValue(usr.Actions.IsCloneable), + ResetPassword: types.BoolValue(usr.Actions.ResetPassword), + ThirdPartyAccess: types.BoolValue(usr.Actions.ThirdPartyAccess), } } - d.Users = append(d.Users, userItem) + d.Users = append(d.Users, usrItem) } return nil } diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go index dfbef470b..f85c82c2d 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go @@ -16,12 +16,12 @@ import ( ) var ( - _ datasource.DataSource = &usersAffectedByMovingGroup{} - _ datasource.DataSourceWithConfigure = &usersAffectedByMovingGroup{} + _ datasource.DataSource = &usersAffectedByMovingGroupDataSource{} + _ datasource.DataSourceWithConfigure = &usersAffectedByMovingGroupDataSource{} ) type ( - usersAffectedByMovingGroup struct { + usersAffectedByMovingGroupDataSource struct { meta meta.Meta } @@ -43,16 +43,16 @@ type ( } ) -// NewUsersAffectedByMovingGroupDataSource returns new users affected by moving group data source +// NewUsersAffectedByMovingGroupDataSource returns new users affected by moving group data source. func NewUsersAffectedByMovingGroupDataSource() datasource.DataSource { - return &usersAffectedByMovingGroup{} + return &usersAffectedByMovingGroupDataSource{} } -func (a *usersAffectedByMovingGroup) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { +func (a *usersAffectedByMovingGroupDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "akamai_iam_users_affected_by_moving_group" } -func (a *usersAffectedByMovingGroup) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (a *usersAffectedByMovingGroupDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -67,7 +67,7 @@ func (a *usersAffectedByMovingGroup) Configure(_ context.Context, req datasource a.meta = meta.Must(req.ProviderData) } -func (a *usersAffectedByMovingGroup) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (a *usersAffectedByMovingGroupDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "source_group_id": schema.Int64Attribute{ @@ -87,7 +87,7 @@ func (a *usersAffectedByMovingGroup) Schema(_ context.Context, _ datasource.Sche }, "users": schema.ListNestedAttribute{ Computed: true, - Description: "The list of affected users", + Description: "The list of affected users.", NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "account_id": schema.StringAttribute{ @@ -96,7 +96,7 @@ func (a *usersAffectedByMovingGroup) Schema(_ context.Context, _ datasource.Sche }, "email": schema.StringAttribute{ Computed: true, - Description: "The user's email address", + Description: "The user's email address.", }, "first_name": schema.StringAttribute{ Computed: true, @@ -125,7 +125,7 @@ func (a *usersAffectedByMovingGroup) Schema(_ context.Context, _ datasource.Sche } } -func (a *usersAffectedByMovingGroup) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +func (a *usersAffectedByMovingGroupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { tflog.Debug(ctx, "IAM Users affected by moving group Datasource Read") var data usersAffectedByMovingGroupModel @@ -151,16 +151,16 @@ func (a *usersAffectedByMovingGroup) Read(ctx context.Context, req datasource.Re } func convertUsersAffectedByMove(users []iam.GroupUser) []userAffectedByMovingGroupModel { - convertedUsers := []userAffectedByMovingGroupModel{} - for _, user := range users { + var convertedUsers []userAffectedByMovingGroupModel + for _, u := range users { convertedUser := userAffectedByMovingGroupModel{ - AccountID: types.StringValue(user.AccountID), - Email: types.StringValue(user.Email), - FirstName: types.StringValue(user.FirstName), - LastName: types.StringValue(user.LastName), - UIIdentityID: types.StringValue(user.IdentityID), - UIUsername: types.StringValue(user.UserName), - LastLoginDate: types.StringValue(date.FormatRFC3339Nano(user.LastLoginDate)), + AccountID: types.StringValue(u.AccountID), + Email: types.StringValue(u.Email), + FirstName: types.StringValue(u.FirstName), + LastName: types.StringValue(u.LastName), + UIIdentityID: types.StringValue(u.IdentityID), + UIUsername: types.StringValue(u.UserName), + LastLoginDate: types.StringValue(date.FormatRFC3339Nano(u.LastLoginDate)), } convertedUsers = append(convertedUsers, convertedUser) } diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go index bf25c70f0..3fae69594 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go @@ -139,10 +139,10 @@ func TestUsersAffectedByMovingGroup(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -150,9 +150,9 @@ func TestUsersAffectedByMovingGroup(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.config), - Check: test.expectedChecks, - ExpectError: test.expectedError, + Config: testutils.LoadFixtureString(t, tc.config), + Check: tc.expectedChecks, + ExpectError: tc.expectedError, }, }, }) diff --git a/pkg/providers/iam/data_akamai_iam_users_test.go b/pkg/providers/iam/data_akamai_iam_users_test.go index 049c0f2e6..77576ebd3 100644 --- a/pkg/providers/iam/data_akamai_iam_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_users_test.go @@ -134,11 +134,12 @@ func TestDataUsers(t *testing.T) { mockData: basicTestDataForUsers, }, } - for name, test := range tests { + + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(t, client, test.mockData, test.groupID) + if tc.init != nil { + tc.init(t, client, tc.mockData, tc.groupID) } useClient(client, func() { resource.UnitTest(t, resource.TestCase{ @@ -146,9 +147,9 @@ func TestDataUsers(t *testing.T) { IsUnitTest: true, Steps: []resource.TestStep{ { - Config: testutils.LoadFixtureString(t, test.configPath), - Check: checkUsersAttrs(test.groupID, len(test.mockData) == 0), - ExpectError: test.expectedError, + Config: testutils.LoadFixtureString(t, tc.configPath), + Check: checkUsersAttrs(tc.groupID, len(tc.mockData) == 0), + ExpectError: tc.expectedError, }, }, }) diff --git a/pkg/providers/iam/iam_errors.go b/pkg/providers/iam/iam_errors.go deleted file mode 100644 index 8f5f7843f..000000000 --- a/pkg/providers/iam/iam_errors.go +++ /dev/null @@ -1,16 +0,0 @@ -package iam - -import "errors" - -var ( - // ErrIAMListAllowedAPIs is returned when ListAllowedAPIs fails - ErrIAMListAllowedAPIs = errors.New("IAM list allowed APIs failed") - // ErrIAMGetCIDRBlock is returned when GetCIDRBlock fails - ErrIAMGetCIDRBlock = errors.New("IAM get CIDR block failed") - // ErrIAMListUsers is returned when ListUsers fails - ErrIAMListUsers = errors.New("IAM list users failed") - // ErrIAMGetUser is returned when GetUser fails - ErrIAMGetUser = errors.New("IAM get user failed") - // ErrIAMListCIDRBlocks is returned when ListCIDRBlocks fails - ErrIAMListCIDRBlocks = errors.New("IAM list CIDR blocks failed") -) diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 14e854e6a..059c315a6 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -40,12 +40,6 @@ func NewSubprovider() *Subprovider { return inst } -func withClient(c iam.IAM) option { - return func(p *Subprovider) { - p.client = c - } -} - // Client returns the IAM interface func (p *Subprovider) Client(meta meta.Meta) iam.IAM { if p.client != nil { diff --git a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go index d0efa325f..5a1ede69d 100644 --- a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go +++ b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go @@ -16,7 +16,7 @@ import ( func resourceIAMBlockedUserProperties() *schema.Resource { return &schema.Resource{ - Description: "Manage a user in your account", + Description: "Manage a user in your account.", CreateContext: resourceIAMBlockedUserPropertiesCreate, ReadContext: resourceIAMBlockedUserPropertiesRead, UpdateContext: resourceIAMBlockedUserPropertiesUpdate, @@ -28,20 +28,20 @@ func resourceIAMBlockedUserProperties() *schema.Resource { "identity_id": { Type: schema.TypeString, Required: true, - Description: "A unique identifier for a user's profile, which corresponds to a user's actual profile or client ID", + Description: "A unique identifier for a user's profile, which corresponds to a user's actual profile or client ID.", }, "group_id": { Type: schema.TypeInt, ForceNew: true, Required: true, - Description: "A unique identifier for a group", + Description: "A unique identifier for a group.", }, "blocked_properties": { Type: schema.TypeList, Required: true, MinItems: 1, Elem: &schema.Schema{Type: schema.TypeInt}, - Description: "List of properties to block for a user", + Description: "List of properties to block for a user.", }, }, } diff --git a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go index e162e98bd..ecb21d3f5 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 @@ -165,15 +165,15 @@ func TestResourceIAMBlockedUserProperties(t *testing.T) { }, }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) @@ -181,7 +181,6 @@ func TestResourceIAMBlockedUserProperties(t *testing.T) { } } -// read func expectListBlockedProperties(m *iam.Mock, request iam.ListBlockedPropertiesRequest, response []int64, err error) *mock.Call { on := m.On("ListBlockedProperties", mock.Anything, request) if err != nil { @@ -190,7 +189,6 @@ func expectListBlockedProperties(m *iam.Mock, request iam.ListBlockedPropertiesR return on.Return(response, nil) } -// create/update func expectUpdateBlockedProperties(m *iam.Mock, request iam.UpdateBlockedPropertiesRequest, response []int64, err error) *mock.Call { on := m.On("UpdateBlockedProperties", mock.Anything, request) if err != nil { diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block.go b/pkg/providers/iam/resource_akamai_iam_cidr_block.go index a6f9196ab..c9cb76269 100644 --- a/pkg/providers/iam/resource_akamai_iam_cidr_block.go +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block.go @@ -21,20 +21,18 @@ import ( ) var ( - _ resource.Resource = &CIDRBlockResource{} - _ resource.ResourceWithImportState = &CIDRBlockResource{} + _ resource.Resource = &cidrBlockResource{} + _ resource.ResourceWithImportState = &cidrBlockResource{} ) -// CIDRBlockResource represents akamai_iam_cidr_block resource -type CIDRBlockResource struct { +type cidrBlockResource struct { meta meta.Meta } -// NewCIDRBlockResource returns new akamai_iam_cidr_block resource -func NewCIDRBlockResource() resource.Resource { return &CIDRBlockResource{} } +// NewCIDRBlockResource returns new akamai_iam_cidr_block resource. +func NewCIDRBlockResource() resource.Resource { return &cidrBlockResource{} } -// CIDRBlockResourceModel represents model of akamai_iam_cidr_block resource -type CIDRBlockResourceModel struct { +type cidrBlockResourceModel struct { CIDR types.String `tfsdk:"cidr_block"` Enabled types.Bool `tfsdk:"enabled"` Comments types.String `tfsdk:"comments"` @@ -46,13 +44,11 @@ type CIDRBlockResourceModel struct { ModifiedDate types.String `tfsdk:"modified_date"` } -// Metadata implements resource.Resource. -func (r *CIDRBlockResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *cidrBlockResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "akamai_iam_cidr_block" } -// Schema implements resource.Resource. -func (r *CIDRBlockResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *cidrBlockResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "cidr_block": schema.StringAttribute{ @@ -123,8 +119,7 @@ func (r *CIDRBlockResource) Schema(_ context.Context, _ resource.SchemaRequest, } } -// Configure implements resource.ResourceWithConfigure. -func (r *CIDRBlockResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *cidrBlockResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { if req.ProviderData == nil { // ProviderData is nil when Configure is run first time as part of ValidateDataSourceConfig in framework provider return @@ -142,10 +137,9 @@ func (r *CIDRBlockResource) Configure(_ context.Context, req resource.ConfigureR r.meta = meta.Must(req.ProviderData) } -// Create implements resource.Resource. -func (r *CIDRBlockResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *cidrBlockResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { tflog.Debug(ctx, "Creating CIDR Block resource") - var plan CIDRBlockResourceModel + var plan cidrBlockResourceModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) @@ -161,7 +155,7 @@ func (r *CIDRBlockResource) Create(ctx context.Context, req resource.CreateReque resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } -func (r *CIDRBlockResource) create(ctx context.Context, plan *CIDRBlockResourceModel) error { +func (r *cidrBlockResource) create(ctx context.Context, plan *cidrBlockResourceModel) error { client := inst.Client(r.meta) resp, err := client.CreateCIDRBlock(ctx, iam.CreateCIDRBlockRequest{ @@ -187,10 +181,9 @@ func (r *CIDRBlockResource) create(ctx context.Context, plan *CIDRBlockResourceM return nil } -// Read implements resource.Resource. -func (r *CIDRBlockResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *cidrBlockResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { tflog.Debug(ctx, "Reading CIDR Block Resource") - var state CIDRBlockResourceModel + var state cidrBlockResourceModel resp.Diagnostics.Append(req.State.Get(ctx, &state)...) if resp.Diagnostics.HasError() { @@ -205,7 +198,7 @@ func (r *CIDRBlockResource) Read(ctx context.Context, req resource.ReadRequest, resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } -func (r *CIDRBlockResource) read(ctx context.Context, data *CIDRBlockResourceModel) error { +func (r *cidrBlockResource) read(ctx context.Context, data *cidrBlockResourceModel) error { client := inst.Client(r.meta) cidr, err := client.GetCIDRBlock(ctx, iam.GetCIDRBlockRequest{ @@ -221,10 +214,9 @@ func (r *CIDRBlockResource) read(ctx context.Context, data *CIDRBlockResourceMod return nil } -// Update implements resource.Resource. -func (r *CIDRBlockResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *cidrBlockResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { tflog.Debug(ctx, "Updating CIDR Block Resource") - var plan CIDRBlockResourceModel + var plan cidrBlockResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { @@ -239,7 +231,7 @@ func (r *CIDRBlockResource) Update(ctx context.Context, req resource.UpdateReque resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } -func (r *CIDRBlockResource) update(ctx context.Context, plan *CIDRBlockResourceModel) error { +func (r *cidrBlockResource) update(ctx context.Context, plan *cidrBlockResourceModel) error { client := inst.Client(r.meta) _, err := client.UpdateCIDRBlock(ctx, iam.UpdateCIDRBlockRequest{ @@ -257,11 +249,10 @@ func (r *CIDRBlockResource) update(ctx context.Context, plan *CIDRBlockResourceM return nil } -// Delete implements resource.Resource. -func (r *CIDRBlockResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { +func (r *cidrBlockResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { tflog.Debug(ctx, "Deleting CIDR Block Resource") - var state *CIDRBlockResourceModel + var state *cidrBlockResourceModel resp.Diagnostics.Append(req.State.Get(ctx, &state)...) if resp.Diagnostics.HasError() { return @@ -279,8 +270,7 @@ func (r *CIDRBlockResource) Delete(ctx context.Context, req resource.DeleteReque resp.State.RemoveResource(ctx) } -// ImportState implements resource.ResourceWithImportState. -func (r *CIDRBlockResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *cidrBlockResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { tflog.Debug(ctx, "Importing CIDR Block Resource") cidrBlockID, err := strconv.ParseInt(req.ID, 10, 64) @@ -289,7 +279,7 @@ func (r *CIDRBlockResource) ImportState(ctx context.Context, req resource.Import return } - data := &CIDRBlockResourceModel{} + data := &cidrBlockResourceModel{} // in import, we only need to set cidr block ID to allow read function to fill other attributes data.CIDRBlockID = types.Int64Value(cidrBlockID) @@ -302,7 +292,7 @@ func (r *CIDRBlockResource) ImportState(ctx context.Context, req resource.Import resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (m *CIDRBlockResourceModel) setData(resp *iam.GetCIDRBlockResponse) { +func (m *cidrBlockResourceModel) setData(resp *iam.GetCIDRBlockResponse) { if resp.Actions != nil { m.Actions = getActionFor(resp.Actions.Edit, resp.Actions.Delete) } else { diff --git a/pkg/providers/iam/resource_akamai_iam_group.go b/pkg/providers/iam/resource_akamai_iam_group.go index 0b78047f6..7bbd36e76 100644 --- a/pkg/providers/iam/resource_akamai_iam_group.go +++ b/pkg/providers/iam/resource_akamai_iam_group.go @@ -14,7 +14,7 @@ import ( func resourceIAMGroup() *schema.Resource { return &schema.Resource{ - Description: "Manage a group in your account", + Description: "Manage a group in your account.", CreateContext: resourceIAMGroupCreate, ReadContext: resourceIAMGroupRead, UpdateContext: resourceIAMGroupUpdate, @@ -26,18 +26,18 @@ func resourceIAMGroup() *schema.Resource { "parent_group_id": { Type: schema.TypeInt, Required: true, - Description: "Unique identifier for the parent group", + Description: "Unique identifier for the parent group.", }, "name": { Type: schema.TypeString, Required: true, - Description: "Human readable name for a group", + Description: "Human readable name for a group.", }, "sub_groups": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeInt}, Computed: true, - Description: "Subgroups IDs", + Description: "Subgroups IDs.", }, }, } diff --git a/pkg/providers/iam/resource_akamai_iam_group_test.go b/pkg/providers/iam/resource_akamai_iam_group_test.go index 26dac8031..3770e4b5c 100644 --- a/pkg/providers/iam/resource_akamai_iam_group_test.go +++ b/pkg/providers/iam/resource_akamai_iam_group_test.go @@ -137,15 +137,15 @@ func TestResourceGroup(t *testing.T) { }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go index ba457c2e6..c12e0887a 100644 --- a/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist.go @@ -13,30 +13,25 @@ import ( ) var ( - _ resource.Resource = &IPAllowlistResource{} - - _ resource.ResourceWithConfigure = &IPAllowlistResource{} - - _ resource.ResourceWithImportState = &IPAllowlistResource{} + _ resource.Resource = &ipAllowlistResource{} + _ resource.ResourceWithConfigure = &ipAllowlistResource{} + _ resource.ResourceWithImportState = &ipAllowlistResource{} ) -// IPAllowlistResource represents akamai_iam_ip_allowlist resource -type IPAllowlistResource struct { +type ipAllowlistResource struct { meta meta.Meta } -// NewIPAllowlistResource returns new akamai_iam_ip_allowlist resource +// NewIPAllowlistResource returns new akamai_iam_ip_allowlist resource. func NewIPAllowlistResource() resource.Resource { - return &IPAllowlistResource{} + return &ipAllowlistResource{} } -// IPAllowlistResourceModel represents model of akamai_iam_ip_allowlist resource -type IPAllowlistResourceModel struct { +type ipAllowlistModel struct { Enable types.Bool `tfsdk:"enable"` } -// Configure implements resource.ResourceWithConfigure. -func (r *IPAllowlistResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *ipAllowlistResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -54,13 +49,11 @@ func (r *IPAllowlistResource) Configure(_ context.Context, req resource.Configur r.meta = meta.Must(req.ProviderData) } -// Metadata implements resource.Resource. -func (r IPAllowlistResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *ipAllowlistResource) Metadata(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "akamai_iam_ip_allowlist" } -// Schema implements resource.Resource. -func (r IPAllowlistResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *ipAllowlistResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "enable": schema.BoolAttribute{ @@ -71,10 +64,9 @@ func (r IPAllowlistResource) Schema(_ context.Context, _ resource.SchemaRequest, } } -// Create implements resource.Resource. -func (r IPAllowlistResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *ipAllowlistResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { tflog.Debug(ctx, "Creating IP Allowlist resource") - var plan *IPAllowlistResourceModel + var plan *ipAllowlistModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) @@ -94,7 +86,7 @@ func (r IPAllowlistResource) Create(ctx context.Context, req resource.CreateRequ resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } -func (r IPAllowlistResource) enableIPAllowlist(ctx context.Context) diag.Diagnostics { +func (r *ipAllowlistResource) enableIPAllowlist(ctx context.Context) diag.Diagnostics { var diags diag.Diagnostics client := inst.Client(r.meta) status, err := client.GetIPAllowlistStatus(ctx) @@ -112,7 +104,7 @@ func (r IPAllowlistResource) enableIPAllowlist(ctx context.Context) diag.Diagnos return nil } -func (r IPAllowlistResource) disableIPAllowlist(ctx context.Context) diag.Diagnostics { +func (r *ipAllowlistResource) disableIPAllowlist(ctx context.Context) diag.Diagnostics { var diags diag.Diagnostics client := inst.Client(r.meta) status, err := client.GetIPAllowlistStatus(ctx) @@ -130,10 +122,9 @@ func (r IPAllowlistResource) disableIPAllowlist(ctx context.Context) diag.Diagno return nil } -// Read implements resource.Resource. -func (r IPAllowlistResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *ipAllowlistResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { tflog.Debug(ctx, "Reading IP Allowlist Resource") - var oldState *IPAllowlistResourceModel + var oldState *ipAllowlistModel client := inst.Client(r.meta) resp.Diagnostics.Append(req.State.Get(ctx, &oldState)...) if resp.Diagnostics.HasError() { @@ -149,11 +140,10 @@ func (r IPAllowlistResource) Read(ctx context.Context, req resource.ReadRequest, resp.Diagnostics.Append(resp.State.Set(ctx, &oldState)...) } -// Update implements resource.Resource. -func (r IPAllowlistResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *ipAllowlistResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { tflog.Debug(ctx, "Updating IP Allowlist Resource") var diags diag.Diagnostics - var plan *IPAllowlistResourceModel + var plan *ipAllowlistModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) @@ -175,9 +165,8 @@ func (r IPAllowlistResource) Update(ctx context.Context, req resource.UpdateRequ resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } -// Delete implements resource.Resource. -func (r IPAllowlistResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var plan *IPAllowlistResourceModel +func (r *ipAllowlistResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var plan *ipAllowlistModel // Read Terraform state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &plan)...) @@ -197,8 +186,7 @@ func (r IPAllowlistResource) Delete(ctx context.Context, req resource.DeleteRequ resp.State.RemoveResource(ctx) } -// ImportState implements resource.ResourceWithImportState. -func (r IPAllowlistResource) ImportState(ctx context.Context, _ resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *ipAllowlistResource) ImportState(ctx context.Context, _ resource.ImportStateRequest, resp *resource.ImportStateResponse) { tflog.Debug(ctx, "Importing IP Allowlist Resource") client := inst.Client(r.meta) status, err := client.GetIPAllowlistStatus(ctx) @@ -206,7 +194,7 @@ func (r IPAllowlistResource) ImportState(ctx context.Context, _ resource.ImportS resp.Diagnostics.AddError("cannot fetch IP Allowlist status", err.Error()) return } - var state = &IPAllowlistResourceModel{} + var state = &ipAllowlistModel{} state.Enable = types.BoolValue(status.Enabled) resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) } diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go index 917fc3323..bbd19842f 100644 --- a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/mock" ) -func TestResourceIAMIPAllowlistResource(t *testing.T) { +func TestIPAllowlistResource(t *testing.T) { t.Parallel() tests := map[string]struct { configPath string @@ -173,17 +173,17 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { }, }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - if test.init != nil { - test.init(t, client) + if tc.init != nil { + tc.init(t, client) } useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) @@ -191,47 +191,45 @@ func TestResourceIAMIPAllowlistResource(t *testing.T) { } } -func TestImportIAMIPAllowlistResource(t *testing.T) { - { - tests := map[string]struct { - importID string - configPath string - init func(*testing.T, *iam.Mock) - mockData []commonDataForResource - stateCheck func(s []*terraform.InstanceState) error - }{ - "import": { - importID: " ", - init: func(t *testing.T, m *iam.Mock) { - // Import - mockReadIPAllowlistStatus(m, true).Twice() - }, - stateCheck: checkImportEnabledIPAllowlistForSpecificUser(), +func TestImportIPAllowlistResource(t *testing.T) { + tests := map[string]struct { + importID string + configPath string + init func(*testing.T, *iam.Mock) + mockData []commonDataForResource + stateCheck func(s []*terraform.InstanceState) error + }{ + "import": { + importID: " ", + init: func(t *testing.T, m *iam.Mock) { + // Import + mockReadIPAllowlistStatus(m, true).Twice() }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - client := &iam.Mock{} - test.init(t, client) - useClient(client, func() { - resource.UnitTest(t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), - Steps: []resource.TestStep{ - { - ImportStateCheck: test.stateCheck, - ImportStateId: test.importID, - ImportState: true, - ResourceName: "akamai_iam_ip_allowlist.test", - Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), - }, + stateCheck: checkImportEnabledIPAllowlistForSpecificUser(), + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + client := &iam.Mock{} + test.init(t, client) + useClient(client, func() { + resource.UnitTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + ImportStateCheck: test.stateCheck, + ImportStateId: test.importID, + ImportState: true, + ResourceName: "akamai_iam_ip_allowlist.test", + Config: testutils.LoadFixtureString(t, "./testdata/TestResIPAllowlist/enable.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_iam_ip_allowlist.test", "enable", "true")), }, - }) + }, }) - client.AssertExpectations(t) }) - } + client.AssertExpectations(t) + }) } } diff --git a/pkg/providers/iam/resource_akamai_iam_role.go b/pkg/providers/iam/resource_akamai_iam_role.go index 0a1ef78c4..7168a603b 100644 --- a/pkg/providers/iam/resource_akamai_iam_role.go +++ b/pkg/providers/iam/resource_akamai_iam_role.go @@ -25,12 +25,12 @@ func resourceIAMRole() *schema.Resource { "name": { Type: schema.TypeString, Required: true, - Description: "The name you supply for a role", + Description: "The name you supply for a role.", }, "description": { Type: schema.TypeString, Required: true, - Description: "The description for a role", + Description: "The description for a role.", }, "granted_roles": { Type: schema.TypeSet, @@ -38,13 +38,13 @@ func resourceIAMRole() *schema.Resource { Type: schema.TypeInt, }, Required: true, - Description: "The list of existing unique identifiers for the granted roles", + Description: "The list of existing unique identifiers for the granted roles.", }, "type": { Type: schema.TypeString, Computed: true, Optional: true, - Description: "The role type which indicates whether it's a standard role provided by Akamai or a custom role for the account", + Description: "The role type which indicates whether it's a standard role provided by Akamai or a custom role for the account.", }, }, } diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index cfa566f4e..ac76ffd51 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -27,7 +27,7 @@ var international = regexp.MustCompile(`^\+[02-9][\d\s\-]{0,40}$`) func resourceIAMUser() *schema.Resource { return &schema.Resource{ - Description: "Manage a user in your account", + Description: "Manage a user in your account.", CreateContext: resourceIAMUserCreate, ReadContext: resourceIAMUserRead, UpdateContext: resourceIAMUserUpdate, @@ -41,29 +41,29 @@ func resourceIAMUser() *schema.Resource { "first_name": { Type: schema.TypeString, Required: true, - Description: "The user's first name", + Description: "The user's first name.", }, "last_name": { Type: schema.TypeString, Required: true, - Description: "The user's surname", + Description: "The user's surname.", }, "email": { Type: schema.TypeString, Required: true, - Description: "The user's email address", + Description: "The user's email address.", StateFunc: stateEmail, DiffSuppressFunc: suppressEmail, }, "country": { Type: schema.TypeString, Required: true, - Description: "As part of the user's location, the value can be any that are available from the view-supported-countries operation", + Description: "As part of the user's location, the value can be any that are available from the view-supported-countries operation.", }, "phone": { Type: schema.TypeString, Optional: true, - Description: "The user's main phone number", + Description: "The user's main phone number.", DiffSuppressFunc: suppressPhone, StateFunc: statePhone, ValidateFunc: validatePhone, @@ -71,17 +71,17 @@ func resourceIAMUser() *schema.Resource { "enable_tfa": { Type: schema.TypeBool, Optional: true, - Description: "Indicates whether two-factor authentication is allowed", + Description: "Indicates whether two-factor authentication is allowed.", }, "enable_mfa": { Type: schema.TypeBool, Optional: true, - Description: "Indicates whether multi-factor authentication is allowed", + Description: "Indicates whether multi-factor authentication is allowed.", }, "auth_grants_json": { Type: schema.TypeString, Required: true, - Description: "A user's per-group role assignments, in JSON form", + Description: "A user's per-group role assignments, in JSON form.", ValidateDiagFunc: validateAuthGrantsJS, DiffSuppressFunc: suppressAuthGrantsJS, StateFunc: stateAuthGrantsJS, @@ -92,30 +92,30 @@ func resourceIAMUser() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - Description: "To help characterize the user, the value can be any that are available from the view-contact-types operation", + Description: "To help characterize the user, the value can be any that are available from the view-contact-types operation.", }, "job_title": { Type: schema.TypeString, Optional: true, - Description: "The user's position at your company", + Description: "The user's position at your company.", }, "time_zone": { Type: schema.TypeString, Optional: true, Computed: true, - Description: "The user's time zone. The value can be any that are available from the view-time-zones operation", + Description: "The user's time zone. The value can be any that are available from the view-time-zones operation.", }, "secondary_email": { Type: schema.TypeString, Optional: true, - Description: "The user's secondary email address", + Description: "The user's secondary email address.", StateFunc: stateEmail, DiffSuppressFunc: suppressEmail, }, "mobile_phone": { Type: schema.TypeString, Optional: true, - Description: "The user's mobile phone number", + Description: "The user's mobile phone number.", DiffSuppressFunc: suppressPhone, StateFunc: statePhone, ValidateFunc: validatePhone, @@ -124,71 +124,71 @@ func resourceIAMUser() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - Description: "The user's street address", + Description: "The user's street address.", }, "city": { Type: schema.TypeString, Optional: true, - Description: "The user's city", + Description: "The user's city.", }, "state": { Type: schema.TypeString, Optional: true, - Description: "The user's state", + Description: "The user's state.", }, "zip_code": { Type: schema.TypeString, Optional: true, - Description: "The user's five-digit ZIP code", + Description: "The user's five-digit ZIP code.", }, "preferred_language": { Type: schema.TypeString, Optional: true, Computed: true, - Description: "The value can be any that are available from the view-languages operation", + Description: "The value can be any that are available from the view-languages operation.", }, "session_timeout": { Type: schema.TypeInt, Optional: true, Computed: true, - Description: "The number of seconds it takes for the user's Control Center session to time out if there hasn't been any activity", + Description: "The number of seconds it takes for the user's Control Center session to time out if there hasn't been any activity.", }, // Purely computed "user_name": { Type: schema.TypeString, Computed: true, - Description: "A user's `loginId`. Typically, a user's email address", + Description: "A user's `loginId`. Typically, a user's email address.", }, "last_login": { Type: schema.TypeString, Computed: true, - Description: "ISO 8601 timestamp indicating when the user last logged in", + Description: "ISO 8601 timestamp indicating when the user last logged in.", }, "password_expired_after": { Type: schema.TypeString, Computed: true, - Description: "The date a user's password expires", + Description: "The date a user's password expires.", }, "tfa_configured": { Type: schema.TypeBool, Computed: true, - Description: "Indicates whether two-factor authentication is configured", + Description: "Indicates whether two-factor authentication is configured.", }, "email_update_pending": { Type: schema.TypeBool, Computed: true, - Description: "Indicates whether email update is pending", + Description: "Indicates whether email update is pending.", }, "lock": { Type: schema.TypeBool, Optional: true, - Description: "Flag to block a user account", + Description: "Flag to block a user account.", Default: false, }, "password": { Type: schema.TypeString, - Description: "New password for a user", + Description: "New password for a user.", Optional: true, Sensitive: true, }, @@ -204,23 +204,23 @@ func resourceIAMUser() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, - Description: "Enables notifications for expiring API client credentials", + Description: "Enables notifications for expiring API client credentials.", }, "new_user_notification": { Type: schema.TypeBool, Optional: true, Default: true, - Description: "Enables notifications for group administrators when the user creates other new users", + Description: "Enables notifications for group administrators when the user creates other new users.", }, "password_expiry": { Type: schema.TypeBool, Required: true, - Description: "Enables notifications for expiring passwords", + Description: "Enables notifications for expiring passwords.", }, "proactive": { Type: schema.TypeList, Required: true, - Description: "Products for which the user gets notifications for service issues", + Description: "Products for which the user gets notifications for service issues.", Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -228,7 +228,7 @@ func resourceIAMUser() *schema.Resource { "upgrade": { Type: schema.TypeList, Required: true, - Description: "Products for which the user receives notifications for upgrades", + Description: "Products for which the user receives notifications for upgrades.", Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -236,7 +236,7 @@ func resourceIAMUser() *schema.Resource { "enable_email_notifications": { Type: schema.TypeBool, Required: true, - Description: "Enables email notifications", + Description: "Enables email notifications.", }, }, }, diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index bfe8fb906..9d01a1382 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -940,15 +940,15 @@ func TestResourceUser(t *testing.T) { }, }, } - for name, test := range tests { + for name, tc := range tests { t.Run(name, func(t *testing.T) { client := &iam.Mock{} - test.init(client) + tc.init(client) useClient(client, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), IsUnitTest: true, - Steps: test.steps, + Steps: tc.steps, }) }) client.AssertExpectations(t) From 8779b584dc68fa47d1f76a81d2623825a6551e17 Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Tue, 1 Oct 2024 15:26:09 +0200 Subject: [PATCH 43/54] DXE-4211 Correction of networklist to correct client name in provider to align Edgegrid --- pkg/providers/networklists/provider.go | 8 ++++---- pkg/providers/networklists/provider_test.go | 2 +- .../resource_akamai_networklist_activations.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/providers/networklists/provider.go b/pkg/providers/networklists/provider.go index ebe59f29c..4e6592934 100644 --- a/pkg/providers/networklists/provider.go +++ b/pkg/providers/networklists/provider.go @@ -16,7 +16,7 @@ import ( type ( // Subprovider gathers networklists resources and data sources Subprovider struct { - client networklists.NTWRKLISTS + client networklists.NetworkList } option func(p *Subprovider) @@ -43,14 +43,14 @@ func NewSubprovider(opts ...option) *Subprovider { return inst } -func withClient(c networklists.NTWRKLISTS) option { +func withClient(c networklists.NetworkList) option { return func(p *Subprovider) { p.client = c } } -// Client returns the NTWRKLISTS interface -func (p *Subprovider) Client(meta meta.Meta) networklists.NTWRKLISTS { +// Client returns the NetworkList interface +func (p *Subprovider) Client(meta meta.Meta) networklists.NetworkList { if p.client != nil { return p.client } diff --git a/pkg/providers/networklists/provider_test.go b/pkg/providers/networklists/provider_test.go index 904b12db2..af364f83c 100644 --- a/pkg/providers/networklists/provider_test.go +++ b/pkg/providers/networklists/provider_test.go @@ -16,7 +16,7 @@ func TestMain(m *testing.M) { var clientLock sync.Mutex // useClient swaps out the client on the global instance for the duration of the given func -func useClient(client networklists.NTWRKLISTS, f func()) { +func useClient(client networklists.NetworkList, f func()) { clientLock.Lock() orig := inst.client inst.client = client diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations.go b/pkg/providers/networklists/resource_akamai_networklist_activations.go index 804e6eca8..ab191bbc1 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_activations.go +++ b/pkg/providers/networklists/resource_akamai_networklist_activations.go @@ -134,7 +134,7 @@ func resourceActivationsCreate(ctx context.Context, d *schema.ResourceData, m in return resourceActivationsRead(ctx, d, m) } -func createActivation(ctx context.Context, client networklists.NTWRKLISTS, params networklists.CreateActivationsRequest) (*networklists.CreateActivationsResponse, diag.Diagnostics) { +func createActivation(ctx context.Context, client networklists.NetworkList, params networklists.CreateActivationsRequest) (*networklists.CreateActivationsResponse, diag.Diagnostics) { createNetworkListActivationMutex.Lock() defer func() { createNetworkListActivationMutex.Unlock() @@ -263,7 +263,7 @@ func resourceActivationsDelete(_ context.Context, _ *schema.ResourceData, m inte } } -func lookupActivation(ctx context.Context, client networklists.NTWRKLISTS, query networklists.GetActivationRequest) (*networklists.GetActivationResponse, error) { +func lookupActivation(ctx context.Context, client networklists.NetworkList, query networklists.GetActivationRequest) (*networklists.GetActivationResponse, error) { activation, err := client.GetActivation(ctx, query) if err != nil { return nil, err @@ -278,7 +278,7 @@ func suppressFieldsForNetworkListActivation(_, oldValue, newValue string, d *sch return true } -func pollActivation(ctx context.Context, client networklists.NTWRKLISTS, activationStatus string, activationID int) error { +func pollActivation(ctx context.Context, client networklists.NetworkList, activationStatus string, activationID int) error { retriesMax := 5 retries5xx := 0 From d82f5f56b5ad0657b1f986ed2a2e14406460c2db Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Tue, 1 Oct 2024 16:12:38 +0200 Subject: [PATCH 44/54] DXE-4211 Bump v8 to v9 --- build/internal/docker_jenkins.bash | 2 +- build/internal/package/nexus-release.bash | 2 +- build/internal/releaser/goreleaser_build.bash | 2 +- go.mod | 4 ++-- go.sum | 4 ++-- pkg/akamai/configure_context.go | 4 ++-- pkg/akamai/configure_context_test.go | 6 +++--- pkg/akamai/edgegrid.go | 2 +- pkg/akamai/edgegrid_test.go | 2 +- pkg/akamai/sdk_provider_test.go | 2 +- pkg/meta/meta.go | 2 +- pkg/meta/meta_test.go | 2 +- pkg/providers/appsec/config_versions.go | 2 +- ...kamai_appsec_advanced_settings_attack_payload_logging.go | 2 +- ..._appsec_advanced_settings_attack_payload_logging_test.go | 2 +- ...ta_akamai_appsec_advanced_settings_evasive_path_match.go | 2 +- ...amai_appsec_advanced_settings_evasive_path_match_test.go | 2 +- .../appsec/data_akamai_appsec_advanced_settings_logging.go | 2 +- .../data_akamai_appsec_advanced_settings_logging_test.go | 2 +- .../data_akamai_appsec_advanced_settings_pii_learning.go | 2 +- ...ata_akamai_appsec_advanced_settings_pii_learning_test.go | 2 +- .../data_akamai_appsec_advanced_settings_pragma_header.go | 2 +- .../data_akamai_appsec_advanced_settings_pragma_test.go | 2 +- .../appsec/data_akamai_appsec_advanced_settings_prefetch.go | 2 +- .../data_akamai_appsec_advanced_settings_prefetch_test.go | 2 +- .../data_akamai_appsec_advanced_settings_request_body.go | 2 +- ...ata_akamai_appsec_advanced_settings_request_body_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_api_endpoints.go | 2 +- .../appsec/data_akamai_appsec_api_endpoints_test.go | 2 +- .../appsec/data_akamai_appsec_api_hostname_coverage.go | 2 +- ...ata_akamai_appsec_api_hostname_coverage_match_targets.go | 2 +- ...kamai_appsec_api_hostname_coverage_match_targets_test.go | 2 +- .../data_akamai_appsec_api_hostname_coverage_overlapping.go | 2 +- ..._akamai_appsec_api_hostname_coverage_overlapping_test.go | 2 +- .../appsec/data_akamai_appsec_api_hostname_coverage_test.go | 2 +- .../appsec/data_akamai_appsec_api_request_constraints.go | 2 +- .../data_akamai_appsec_api_request_constraints_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_attack_groups.go | 2 +- .../appsec/data_akamai_appsec_attack_groups_test.go | 2 +- .../appsec/data_akamai_appsec_bypass_network_lists.go | 2 +- .../appsec/data_akamai_appsec_bypass_network_lists_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_configuration.go | 2 +- .../appsec/data_akamai_appsec_configuration_test.go | 2 +- .../appsec/data_akamai_appsec_configuration_version.go | 2 +- .../appsec/data_akamai_appsec_configuration_version_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_contracts_groups.go | 2 +- .../appsec/data_akamai_appsec_contracts_groups_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_custom_deny.go | 2 +- pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go | 2 +- .../appsec/data_akamai_appsec_custom_rule_actions.go | 2 +- .../appsec/data_akamai_appsec_custom_rule_actions_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_custom_rules.go | 2 +- .../appsec/data_akamai_appsec_custom_rules_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval_groups.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go | 2 +- .../data_akamai_appsec_eval_penalty_box_conditions.go | 2 +- .../data_akamai_appsec_eval_penalty_box_conditions_test.go | 2 +- .../appsec/data_akamai_appsec_eval_penalty_box_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval_rules.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_eval_test.go | 2 +- .../appsec/data_akamai_appsec_export_configuration.go | 2 +- .../appsec/data_akamai_appsec_export_configuration_test.go | 2 +- .../appsec/data_akamai_appsec_failover_hostnames.go | 2 +- .../appsec/data_akamai_appsec_failover_hostnames_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_ip_geo.go | 2 +- pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go | 2 +- .../appsec/data_akamai_appsec_malware_content_types.go | 2 +- .../appsec/data_akamai_appsec_malware_content_types_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_malware_policies.go | 2 +- .../appsec/data_akamai_appsec_malware_policies_test.go | 2 +- .../appsec/data_akamai_appsec_malware_policy_actions.go | 2 +- .../data_akamai_appsec_malware_policy_actions_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_match_targets.go | 2 +- .../appsec/data_akamai_appsec_match_targets_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_penalty_box.go | 2 +- .../appsec/data_akamai_appsec_penalty_box_conditions.go | 2 +- .../data_akamai_appsec_penalty_box_conditions_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_rate_policies.go | 2 +- .../appsec/data_akamai_appsec_rate_policies_test.go | 2 +- .../appsec/data_akamai_appsec_rate_policy_actions.go | 2 +- .../appsec/data_akamai_appsec_rate_policy_actions_test.go | 2 +- .../appsec/data_akamai_appsec_reputation_analysis.go | 2 +- .../appsec/data_akamai_appsec_reputation_analysis_test.go | 2 +- .../appsec/data_akamai_appsec_reputation_profile_actions.go | 2 +- .../data_akamai_appsec_reputation_profile_actions_test.go | 2 +- .../appsec/data_akamai_appsec_reputation_profiles.go | 2 +- .../appsec/data_akamai_appsec_reputation_profiles_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go | 2 +- .../appsec/data_akamai_appsec_rule_upgrade_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_rules.go | 2 +- pkg/providers/appsec/data_akamai_appsec_rules_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_security_policy.go | 2 +- .../data_akamai_appsec_security_policy_protections.go | 2 +- .../data_akamai_appsec_security_policy_protections_test.go | 2 +- .../appsec/data_akamai_appsec_security_policy_test.go | 2 +- .../appsec/data_akamai_appsec_selectable_hostnames.go | 2 +- .../appsec/data_akamai_appsec_selectable_hostnames_test.go | 2 +- .../appsec/data_akamai_appsec_selected_hostnames.go | 2 +- .../appsec/data_akamai_appsec_selected_hostnames_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_siem_definitions.go | 2 +- .../appsec/data_akamai_appsec_siem_definitions_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_siem_settings.go | 2 +- .../appsec/data_akamai_appsec_siem_settings_test.go | 2 +- .../data_akamai_appsec_slow_post_protection_settings.go | 2 +- ...data_akamai_appsec_slow_post_protection_settings_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_threat_intel.go | 2 +- .../appsec/data_akamai_appsec_threat_intel_test.go | 2 +- .../appsec/data_akamai_appsec_tuning_recommendations.go | 2 +- .../data_akamai_appsec_tuning_recommendations_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_version_notes.go | 2 +- .../appsec/data_akamai_appsec_version_notes_test.go | 2 +- pkg/providers/appsec/data_akamai_appsec_waf_mode.go | 2 +- pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go | 2 +- .../appsec/data_akamai_appsec_wap_selected_hostnames.go | 2 +- .../data_akamai_appsec_wap_selected_hostnames_test.go | 2 +- pkg/providers/appsec/diff_suppress_funcs.go | 2 +- pkg/providers/appsec/provider.go | 2 +- pkg/providers/appsec/provider_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_activations.go | 2 +- .../appsec/resource_akamai_appsec_activations_test.go | 2 +- ...kamai_appsec_advanced_settings_attack_payload_logging.go | 2 +- ..._appsec_advanced_settings_attack_payload_logging_test.go | 2 +- ...ce_akamai_appsec_advanced_settings_evasive_path_match.go | 2 +- ...amai_appsec_advanced_settings_evasive_path_match_test.go | 2 +- .../resource_akamai_appsec_advanced_settings_logging.go | 2 +- ...resource_akamai_appsec_advanced_settings_logging_test.go | 2 +- ...resource_akamai_appsec_advanced_settings_pii_learning.go | 2 +- ...rce_akamai_appsec_advanced_settings_pii_learning_test.go | 2 +- ...esource_akamai_appsec_advanced_settings_pragma_header.go | 2 +- .../resource_akamai_appsec_advanced_settings_pragma_test.go | 2 +- .../resource_akamai_appsec_advanced_settings_prefetch.go | 2 +- ...esource_akamai_appsec_advanced_settings_prefetch_test.go | 2 +- ...resource_akamai_appsec_advanced_settings_request_body.go | 2 +- ...rce_akamai_appsec_advanced_settings_request_body_test.go | 2 +- .../resource_akamai_appsec_api_constraints_protection.go | 2 +- ...esource_akamai_appsec_api_constraints_protection_test.go | 2 +- .../resource_akamai_appsec_api_request_constraints.go | 2 +- .../resource_akamai_appsec_api_request_constraints_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_attack_group.go | 2 +- .../appsec/resource_akamai_appsec_attack_group_test.go | 2 +- .../appsec/resource_akamai_appsec_bypass_network_lists.go | 2 +- .../resource_akamai_appsec_bypass_network_lists_test.go | 2 +- .../appsec/resource_akamai_appsec_configuration.go | 2 +- .../appsec/resource_akamai_appsec_configuration_rename.go | 2 +- .../resource_akamai_appsec_configuration_rename_test.go | 2 +- .../appsec/resource_akamai_appsec_configuration_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_custom_deny.go | 2 +- .../appsec/resource_akamai_appsec_custom_deny_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_custom_rule.go | 2 +- .../appsec/resource_akamai_appsec_custom_rule_action.go | 2 +- .../resource_akamai_appsec_custom_rule_action_test.go | 2 +- .../appsec/resource_akamai_appsec_custom_rule_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_eval.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_eval_group.go | 2 +- .../appsec/resource_akamai_appsec_eval_group_test.go | 2 +- .../appsec/resource_akamai_appsec_eval_penalty_box.go | 2 +- .../resource_akamai_appsec_eval_penalty_box_conditions.go | 2 +- ...source_akamai_appsec_eval_penalty_box_conditions_test.go | 2 +- .../appsec/resource_akamai_appsec_eval_penalty_box_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_eval_rule.go | 2 +- .../appsec/resource_akamai_appsec_eval_rule_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_eval_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_ip_geo.go | 2 +- .../appsec/resource_akamai_appsec_ip_geo_protection.go | 2 +- .../appsec/resource_akamai_appsec_ip_geo_protection_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go | 2 +- .../appsec/resource_akamai_appsec_malware_policy.go | 2 +- .../appsec/resource_akamai_appsec_malware_policy_action.go | 2 +- .../resource_akamai_appsec_malware_policy_action_test.go | 2 +- .../appsec/resource_akamai_appsec_malware_policy_actions.go | 2 +- .../resource_akamai_appsec_malware_policy_actions_test.go | 2 +- .../appsec/resource_akamai_appsec_malware_policy_test.go | 2 +- .../appsec/resource_akamai_appsec_malware_protection.go | 2 +- .../resource_akamai_appsec_malware_protection_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_match_target.go | 2 +- .../appsec/resource_akamai_appsec_match_target_sequence.go | 2 +- .../resource_akamai_appsec_match_target_sequence_test.go | 2 +- .../appsec/resource_akamai_appsec_match_target_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_penalty_box.go | 2 +- .../appsec/resource_akamai_appsec_penalty_box_conditions.go | 2 +- .../resource_akamai_appsec_penalty_box_conditions_test.go | 2 +- .../appsec/resource_akamai_appsec_penalty_box_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_rate_policy.go | 2 +- .../appsec/resource_akamai_appsec_rate_policy_action.go | 2 +- .../resource_akamai_appsec_rate_policy_action_test.go | 2 +- .../appsec/resource_akamai_appsec_rate_policy_test.go | 2 +- .../appsec/resource_akamai_appsec_rate_protection.go | 2 +- .../appsec/resource_akamai_appsec_rate_protection_test.go | 2 +- .../appsec/resource_akamai_appsec_reputation_analysis.go | 2 +- .../resource_akamai_appsec_reputation_analysis_test.go | 2 +- .../appsec/resource_akamai_appsec_reputation_profile.go | 2 +- .../resource_akamai_appsec_reputation_profile_action.go | 2 +- ...resource_akamai_appsec_reputation_profile_action_test.go | 2 +- .../resource_akamai_appsec_reputation_profile_test.go | 2 +- .../appsec/resource_akamai_appsec_reputation_protection.go | 2 +- .../resource_akamai_appsec_reputation_protection_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_rule.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_rule_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go | 2 +- .../appsec/resource_akamai_appsec_rule_upgrade_test.go | 2 +- .../appsec/resource_akamai_appsec_security_policy.go | 2 +- ...rce_akamai_appsec_security_policy_default_protections.go | 2 +- ...kamai_appsec_security_policy_default_protections_test.go | 2 +- .../appsec/resource_akamai_appsec_security_policy_rename.go | 2 +- .../resource_akamai_appsec_security_policy_rename_test.go | 2 +- .../appsec/resource_akamai_appsec_security_policy_test.go | 2 +- .../appsec/resource_akamai_appsec_selected_hostname.go | 2 +- .../appsec/resource_akamai_appsec_selected_hostname_test.go | 2 +- .../appsec/resource_akamai_appsec_siem_settings.go | 2 +- .../appsec/resource_akamai_appsec_siem_settings_test.go | 2 +- .../resource_akamai_appsec_slow_post_protection_setting.go | 2 +- ...ource_akamai_appsec_slow_post_protection_setting_test.go | 2 +- .../appsec/resource_akamai_appsec_slowpost_protection.go | 2 +- .../resource_akamai_appsec_slowpost_protection_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_threat_intel.go | 2 +- .../appsec/resource_akamai_appsec_threat_intel_test.go | 2 +- .../appsec/resource_akamai_appsec_version_notes.go | 2 +- .../appsec/resource_akamai_appsec_version_notes_test.go | 2 +- pkg/providers/appsec/resource_akamai_appsec_waf_mode.go | 2 +- .../appsec/resource_akamai_appsec_waf_mode_test.go | 2 +- .../appsec/resource_akamai_appsec_waf_protection.go | 2 +- .../appsec/resource_akamai_appsec_waf_protection_test.go | 2 +- .../appsec/resource_akamai_appsec_wap_selected_hostnames.go | 2 +- .../resource_akamai_appsec_wap_selected_hostnames_test.go | 2 +- pkg/providers/appsec/templates.go | 2 +- pkg/providers/botman/cache.go | 2 +- .../botman/data_akamai_botman_akamai_bot_category.go | 2 +- .../botman/data_akamai_botman_akamai_bot_category_action.go | 2 +- .../data_akamai_botman_akamai_bot_category_action_test.go | 2 +- .../botman/data_akamai_botman_akamai_bot_category_test.go | 2 +- .../botman/data_akamai_botman_akamai_defined_bot.go | 2 +- .../botman/data_akamai_botman_akamai_defined_bot_test.go | 2 +- .../botman/data_akamai_botman_bot_analytics_cookie.go | 2 +- .../botman/data_akamai_botman_bot_analytics_cookie_test.go | 2 +- .../data_akamai_botman_bot_analytics_cookie_values_test.go | 2 +- .../botman/data_akamai_botman_bot_category_exception.go | 2 +- .../data_akamai_botman_bot_category_exception_test.go | 2 +- pkg/providers/botman/data_akamai_botman_bot_detection.go | 2 +- .../botman/data_akamai_botman_bot_detection_action.go | 2 +- .../botman/data_akamai_botman_bot_detection_action_test.go | 2 +- .../botman/data_akamai_botman_bot_detection_test.go | 2 +- .../data_akamai_botman_bot_endpoint_coverage_report.go | 2 +- .../data_akamai_botman_bot_endpoint_coverage_report_test.go | 2 +- .../botman/data_akamai_botman_bot_management_settings.go | 2 +- .../data_akamai_botman_bot_management_settings_test.go | 2 +- pkg/providers/botman/data_akamai_botman_challenge_action.go | 2 +- .../botman/data_akamai_botman_challenge_action_test.go | 2 +- .../botman/data_akamai_botman_challenge_injection_rules.go | 2 +- .../data_akamai_botman_challenge_injection_rules_test.go | 2 +- .../data_akamai_botman_challenge_interception_rules.go | 2 +- .../data_akamai_botman_challenge_interception_rules_test.go | 2 +- .../botman/data_akamai_botman_client_side_security.go | 2 +- .../botman/data_akamai_botman_client_side_security_test.go | 2 +- .../botman/data_akamai_botman_conditional_action.go | 2 +- .../botman/data_akamai_botman_conditional_action_test.go | 2 +- ...i_botman_content_protection_javascript_injection_rule.go | 2 +- ...man_content_protection_javascript_injection_rule_test.go | 2 +- .../botman/data_akamai_botman_content_protection_rule.go | 2 +- .../data_akamai_botman_content_protection_rule_sequence.go | 2 +- ...a_akamai_botman_content_protection_rule_sequence_test.go | 2 +- .../data_akamai_botman_content_protection_rule_test.go | 2 +- .../botman/data_akamai_botman_custom_bot_category.go | 2 +- .../botman/data_akamai_botman_custom_bot_category_action.go | 2 +- .../data_akamai_botman_custom_bot_category_action_test.go | 2 +- .../data_akamai_botman_custom_bot_category_item_sequence.go | 2 +- ..._akamai_botman_custom_bot_category_item_sequence_test.go | 2 +- .../data_akamai_botman_custom_bot_category_sequence.go | 2 +- .../data_akamai_botman_custom_bot_category_sequence_test.go | 2 +- .../botman/data_akamai_botman_custom_bot_category_test.go | 2 +- pkg/providers/botman/data_akamai_botman_custom_client.go | 2 +- .../botman/data_akamai_botman_custom_client_sequence.go | 2 +- .../data_akamai_botman_custom_client_sequence_test.go | 2 +- .../botman/data_akamai_botman_custom_client_test.go | 2 +- pkg/providers/botman/data_akamai_botman_custom_code.go | 2 +- pkg/providers/botman/data_akamai_botman_custom_code_test.go | 2 +- .../botman/data_akamai_botman_custom_defined_bot.go | 2 +- .../botman/data_akamai_botman_custom_defined_bot_test.go | 2 +- .../botman/data_akamai_botman_custom_deny_action.go | 2 +- .../botman/data_akamai_botman_custom_deny_action_test.go | 2 +- .../botman/data_akamai_botman_javascript_injection.go | 2 +- .../botman/data_akamai_botman_javascript_injection_test.go | 2 +- .../data_akamai_botman_recategorized_akamai_defined_bot.go | 2 +- ...a_akamai_botman_recategorized_akamai_defined_bot_test.go | 2 +- pkg/providers/botman/data_akamai_botman_response_action.go | 2 +- .../botman/data_akamai_botman_response_action_test.go | 2 +- .../botman/data_akamai_botman_serve_alternate_action.go | 2 +- .../data_akamai_botman_serve_alternate_action_test.go | 2 +- .../botman/data_akamai_botman_transactional_endpoint.go | 2 +- .../data_akamai_botman_transactional_endpoint_protection.go | 2 +- ..._akamai_botman_transactional_endpoint_protection_test.go | 2 +- .../data_akamai_botman_transactional_endpoint_test.go | 2 +- pkg/providers/botman/provider.go | 2 +- pkg/providers/botman/provider_test.go | 2 +- .../resource_akamai_botman_akamai_bot_category_action.go | 2 +- ...esource_akamai_botman_akamai_bot_category_action_test.go | 2 +- .../botman/resource_akamai_botman_bot_analytics_cookie.go | 2 +- .../resource_akamai_botman_bot_analytics_cookie_test.go | 2 +- .../botman/resource_akamai_botman_bot_category_exception.go | 2 +- .../resource_akamai_botman_bot_category_exception_test.go | 2 +- .../botman/resource_akamai_botman_bot_detection_action.go | 2 +- .../resource_akamai_botman_bot_detection_action_test.go | 2 +- .../resource_akamai_botman_bot_management_settings.go | 2 +- .../resource_akamai_botman_bot_management_settings_test.go | 2 +- .../botman/resource_akamai_botman_challenge_action.go | 2 +- .../botman/resource_akamai_botman_challenge_action_test.go | 2 +- .../resource_akamai_botman_challenge_injection_rules.go | 2 +- ...resource_akamai_botman_challenge_injection_rules_test.go | 2 +- .../resource_akamai_botman_challenge_interception_rules.go | 2 +- ...ource_akamai_botman_challenge_interception_rules_test.go | 2 +- .../botman/resource_akamai_botman_client_side_security.go | 2 +- .../resource_akamai_botman_client_side_security_test.go | 2 +- .../botman/resource_akamai_botman_conditional_action.go | 2 +- .../resource_akamai_botman_conditional_action_test.go | 2 +- ...i_botman_content_protection_javascript_injection_rule.go | 2 +- ...man_content_protection_javascript_injection_rule_test.go | 2 +- .../resource_akamai_botman_content_protection_rule.go | 2 +- ...source_akamai_botman_content_protection_rule_sequence.go | 2 +- ...e_akamai_botman_content_protection_rule_sequence_test.go | 2 +- .../resource_akamai_botman_content_protection_rule_test.go | 2 +- .../botman/resource_akamai_botman_custom_bot_category.go | 2 +- .../resource_akamai_botman_custom_bot_category_action.go | 2 +- ...esource_akamai_botman_custom_bot_category_action_test.go | 2 +- ...ource_akamai_botman_custom_bot_category_item_sequence.go | 2 +- ..._akamai_botman_custom_bot_category_item_sequence_test.go | 2 +- .../resource_akamai_botman_custom_bot_category_sequence.go | 2 +- ...ource_akamai_botman_custom_bot_category_sequence_test.go | 2 +- .../resource_akamai_botman_custom_bot_category_test.go | 2 +- .../botman/resource_akamai_botman_custom_client.go | 2 +- .../botman/resource_akamai_botman_custom_client_sequence.go | 2 +- .../resource_akamai_botman_custom_client_sequence_test.go | 2 +- .../botman/resource_akamai_botman_custom_client_test.go | 2 +- pkg/providers/botman/resource_akamai_botman_custom_code.go | 2 +- .../botman/resource_akamai_botman_custom_code_test.go | 2 +- .../botman/resource_akamai_botman_custom_defined_bot.go | 2 +- .../resource_akamai_botman_custom_defined_bot_test.go | 2 +- .../botman/resource_akamai_botman_custom_deny_action.go | 2 +- .../resource_akamai_botman_custom_deny_action_test.go | 2 +- .../botman/resource_akamai_botman_javascript_injection.go | 2 +- .../resource_akamai_botman_javascript_injection_test.go | 2 +- ...source_akamai_botman_recategorized_akamai_defined_bot.go | 2 +- ...e_akamai_botman_recategorized_akamai_defined_bot_test.go | 2 +- .../botman/resource_akamai_botman_serve_alternate_action.go | 2 +- .../resource_akamai_botman_serve_alternate_action_test.go | 2 +- .../botman/resource_akamai_botman_transactional_endpoint.go | 2 +- ...ource_akamai_botman_transactional_endpoint_protection.go | 2 +- ..._akamai_botman_transactional_endpoint_protection_test.go | 2 +- .../resource_akamai_botman_transactional_endpoint_test.go | 2 +- pkg/providers/clientlists/data_akamai_clientlist_lists.go | 2 +- .../clientlists/data_akamai_clientlist_lists_test.go | 2 +- pkg/providers/clientlists/provider.go | 2 +- pkg/providers/clientlists/provider_test.go | 2 +- .../clientlists/resource_akamai_clientlists_list.go | 2 +- .../resource_akamai_clientlists_list_activation.go | 2 +- .../resource_akamai_clientlists_list_activation_test.go | 2 +- .../clientlists/resource_akamai_clientlists_list_test.go | 2 +- pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go | 2 +- .../cloudaccess/data_akamai_cloudaccess_key_properties.go | 2 +- .../data_akamai_cloudaccess_key_properties_test.go | 2 +- .../cloudaccess/data_akamai_cloudaccess_key_test.go | 2 +- .../cloudaccess/data_akamai_cloudaccess_key_versions.go | 2 +- .../data_akamai_cloudaccess_key_versions_test.go | 2 +- pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go | 2 +- .../cloudaccess/data_akamai_cloudaccess_keys_test.go | 2 +- pkg/providers/cloudaccess/provider.go | 2 +- pkg/providers/cloudaccess/provider_test.go | 2 +- .../cloudaccess/resource_akamai_cloudaccess_key.go | 2 +- .../cloudaccess/resource_akamai_cloudaccess_key_test.go | 2 +- .../data_akamai_cloudlets_api_prioritization_match_rule.go | 2 +- .../data_akamai_cloudlets_application_load_balancer.go | 2 +- ...akamai_cloudlets_application_load_balancer_match_rule.go | 2 +- .../data_akamai_cloudlets_application_load_balancer_test.go | 2 +- ...ata_akamai_cloudlets_audience_segmentation_match_rule.go | 2 +- .../data_akamai_cloudlets_edge_redirector_match_rule.go | 2 +- .../data_akamai_cloudlets_forward_rewrite_match_rule.go | 2 +- .../data_akamai_cloudlets_phased_release_match_rule.go | 2 +- pkg/providers/cloudlets/data_akamai_cloudlets_policy.go | 2 +- .../cloudlets/data_akamai_cloudlets_policy_activation.go | 6 +++--- .../data_akamai_cloudlets_policy_activation_test.go | 4 ++-- .../cloudlets/data_akamai_cloudlets_policy_test.go | 2 +- .../data_akamai_cloudlets_request_control_match_rule.go | 2 +- .../cloudlets/data_akamai_cloudlets_shared_policy.go | 2 +- .../cloudlets/data_akamai_cloudlets_shared_policy_test.go | 2 +- ...ta_akamai_cloudlets_visitor_prioritization_match_rule.go | 2 +- pkg/providers/cloudlets/match_rules.go | 2 +- pkg/providers/cloudlets/match_rules_test.go | 2 +- pkg/providers/cloudlets/policy_version_test.go | 4 ++-- pkg/providers/cloudlets/policy_version_v2.go | 2 +- pkg/providers/cloudlets/policy_version_v3.go | 2 +- pkg/providers/cloudlets/provider.go | 4 ++-- pkg/providers/cloudlets/provider_test.go | 4 ++-- .../resource_akamai_cloudlets_application_load_balancer.go | 4 ++-- ...akamai_cloudlets_application_load_balancer_activation.go | 4 ++-- ...i_cloudlets_application_load_balancer_activation_test.go | 2 +- ...ource_akamai_cloudlets_application_load_balancer_test.go | 2 +- pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go | 6 +++--- .../resource_akamai_cloudlets_policy_activation.go | 6 +++--- .../resource_akamai_cloudlets_policy_activation_test.go | 4 ++-- .../resource_akamai_cloudlets_policy_activation_v2.go | 2 +- .../resource_akamai_cloudlets_policy_activation_v3.go | 4 ++-- .../cloudlets/resource_akamai_cloudlets_policy_test.go | 4 ++-- .../cloudlets/resource_akamai_cloudlets_policy_v2.go | 2 +- .../cloudlets/resource_akamai_cloudlets_policy_v3.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_capacities.go | 2 +- .../data_akamai_cloudwrapper_capacities_test.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_configuration.go | 2 +- .../data_akamai_cloudwrapper_configuration_test.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_configurations.go | 2 +- .../data_akamai_cloudwrapper_configurations_test.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_location.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_location_test.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_locations.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_locations_test.go | 2 +- .../cloudwrapper/data_akamai_cloudwrapper_properties.go | 2 +- .../data_akamai_cloudwrapper_properties_test.go | 2 +- pkg/providers/cloudwrapper/provider_test.go | 2 +- .../cloudwrapper/resource_akamai_cloudwrapper_activation.go | 2 +- .../resource_akamai_cloudwrapper_activation_test.go | 2 +- .../resource_akamai_cloudwrapper_configuration.go | 2 +- .../resource_akamai_cloudwrapper_configuration_model.go | 2 +- .../resource_akamai_cloudwrapper_configuration_test.go | 2 +- pkg/providers/cps/data_akamai_cps_csr.go | 4 ++-- pkg/providers/cps/data_akamai_cps_csr_test.go | 2 +- pkg/providers/cps/data_akamai_cps_deployments.go | 4 ++-- pkg/providers/cps/data_akamai_cps_deployments_test.go | 2 +- pkg/providers/cps/data_akamai_cps_enrollment.go | 4 ++-- pkg/providers/cps/data_akamai_cps_enrollment_test.go | 2 +- pkg/providers/cps/data_akamai_cps_enrollments.go | 4 ++-- pkg/providers/cps/data_akamai_cps_enrollments_test.go | 2 +- pkg/providers/cps/enrollments.go | 4 ++-- pkg/providers/cps/enrollments_mocks.go | 2 +- pkg/providers/cps/enrollments_test.go | 2 +- pkg/providers/cps/provider.go | 2 +- pkg/providers/cps/provider_test.go | 2 +- pkg/providers/cps/resource_akamai_cps_dv_enrollment.go | 4 ++-- pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go | 2 +- pkg/providers/cps/resource_akamai_cps_dv_validation.go | 4 ++-- pkg/providers/cps/resource_akamai_cps_dv_validation_test.go | 2 +- .../cps/resource_akamai_cps_third_party_enrollment.go | 4 ++-- .../cps/resource_akamai_cps_third_party_enrollment_test.go | 2 +- pkg/providers/cps/resource_akamai_cps_upload_certificate.go | 4 ++-- .../cps/resource_akamai_cps_upload_certificate_test.go | 2 +- pkg/providers/cps/tools/enrollment.go | 2 +- pkg/providers/cps/tools/enrollment_test.go | 2 +- pkg/providers/datastream/connectors.go | 2 +- pkg/providers/datastream/connectors_test.go | 2 +- .../datastream/data_akamai_datastream_activation_history.go | 2 +- .../data_akamai_datastream_activation_history_test.go | 2 +- .../datastream/data_akamai_datastream_dataset_fields.go | 4 ++-- .../data_akamai_datastream_dataset_fields_test.go | 2 +- pkg/providers/datastream/data_akamai_datastreams.go | 4 ++-- pkg/providers/datastream/data_akamai_datastreams_test.go | 2 +- pkg/providers/datastream/provider.go | 2 +- pkg/providers/datastream/provider_test.go | 2 +- pkg/providers/datastream/resource_akamai_datastream.go | 4 ++-- pkg/providers/datastream/resource_akamai_datastream_test.go | 2 +- pkg/providers/datastream/stream.go | 2 +- pkg/providers/datastream/stream_test.go | 2 +- pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go | 2 +- .../dns/data_akamai_dns_zone_dnssec_status_test.go | 2 +- pkg/providers/dns/data_authorities_set.go | 4 ++-- pkg/providers/dns/data_authorities_set_test.go | 2 +- pkg/providers/dns/data_dns_record_set.go | 4 ++-- pkg/providers/dns/data_dns_record_set_test.go | 2 +- pkg/providers/dns/provider.go | 2 +- pkg/providers/dns/provider_test.go | 2 +- pkg/providers/dns/resource_akamai_dns_record.go | 4 ++-- pkg/providers/dns/resource_akamai_dns_record_test.go | 4 ++-- pkg/providers/dns/resource_akamai_dns_zone.go | 4 ++-- pkg/providers/dns/resource_akamai_dns_zone_test.go | 2 +- pkg/providers/edgeworkers/bundle_hash.go | 2 +- pkg/providers/edgeworkers/bundle_hash_test.go | 2 +- pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go | 4 ++-- .../edgeworkers/data_akamai_edgekv_group_items_test.go | 2 +- pkg/providers/edgeworkers/data_akamai_edgekv_groups.go | 4 ++-- pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go | 2 +- pkg/providers/edgeworkers/data_akamai_edgeworker.go | 4 ++-- .../edgeworkers/data_akamai_edgeworker_activation.go | 4 ++-- .../edgeworkers/data_akamai_edgeworker_activation_test.go | 2 +- pkg/providers/edgeworkers/data_akamai_edgeworker_test.go | 2 +- .../edgeworkers/data_akamai_edgeworkers_resource_tier.go | 2 +- .../data_akamai_edgeworkers_resource_tier_test.go | 2 +- pkg/providers/edgeworkers/provider.go | 2 +- pkg/providers/edgeworkers/provider_test.go | 2 +- pkg/providers/edgeworkers/resource_akamai_edgekv.go | 4 ++-- .../edgeworkers/resource_akamai_edgekv_group_items.go | 4 ++-- .../edgeworkers/resource_akamai_edgekv_group_items_test.go | 2 +- pkg/providers/edgeworkers/resource_akamai_edgekv_test.go | 2 +- pkg/providers/edgeworkers/resource_akamai_edgeworker.go | 4 ++-- .../edgeworkers/resource_akamai_edgeworker_test.go | 2 +- .../edgeworkers/resource_akamai_edgeworkers_activation.go | 4 ++-- .../resource_akamai_edgeworkers_activation_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_asmap.go | 2 +- pkg/providers/gtm/data_akamai_gtm_asmap_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_cidrmap.go | 2 +- pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_datacenter.go | 4 ++-- pkg/providers/gtm/data_akamai_gtm_datacenter_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_datacenters.go | 4 ++-- pkg/providers/gtm/data_akamai_gtm_datacenters_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_default_datacenter.go | 4 ++-- .../gtm/data_akamai_gtm_default_datacenter_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_domain.go | 2 +- pkg/providers/gtm/data_akamai_gtm_domain_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_domains.go | 2 +- pkg/providers/gtm/data_akamai_gtm_domains_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_geomap.go | 2 +- pkg/providers/gtm/data_akamai_gtm_geomap_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_geomaps.go | 2 +- pkg/providers/gtm/data_akamai_gtm_geomaps_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_resource.go | 2 +- pkg/providers/gtm/data_akamai_gtm_resource_test.go | 2 +- pkg/providers/gtm/data_akamai_gtm_resources.go | 2 +- pkg/providers/gtm/data_akamai_gtm_resources_test.go | 2 +- pkg/providers/gtm/provider.go | 2 +- pkg/providers/gtm/provider_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_asmap.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_asmap_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_cidrmap.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_datacenter.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_domain.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_domain_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_geomap.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_geomap_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_property.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_property_test.go | 2 +- pkg/providers/gtm/resource_akamai_gtm_resource.go | 4 ++-- pkg/providers/gtm/resource_akamai_gtm_resource_test.go | 2 +- pkg/providers/iam/data_akamai_iam_accessible_groups.go | 2 +- pkg/providers/iam/data_akamai_iam_accessible_groups_test.go | 2 +- pkg/providers/iam/data_akamai_iam_account_switch_keys.go | 2 +- .../iam/data_akamai_iam_account_switch_keys_test.go | 2 +- pkg/providers/iam/data_akamai_iam_allowed_apis.go | 2 +- pkg/providers/iam/data_akamai_iam_allowed_apis_test.go | 2 +- pkg/providers/iam/data_akamai_iam_authorized_users.go | 2 +- pkg/providers/iam/data_akamai_iam_authorized_users_test.go | 2 +- pkg/providers/iam/data_akamai_iam_blocked_properties.go | 4 ++-- .../iam/data_akamai_iam_blocked_properties_test.go | 4 ++-- pkg/providers/iam/data_akamai_iam_cidr_block.go | 2 +- pkg/providers/iam/data_akamai_iam_cidr_block_test.go | 2 +- pkg/providers/iam/data_akamai_iam_cidr_blocks.go | 2 +- pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go | 2 +- pkg/providers/iam/data_akamai_iam_contact_types.go | 2 +- pkg/providers/iam/data_akamai_iam_contact_types_test.go | 2 +- pkg/providers/iam/data_akamai_iam_countries.go | 2 +- pkg/providers/iam/data_akamai_iam_countries_test.go | 2 +- pkg/providers/iam/data_akamai_iam_grantable_roles.go | 4 ++-- pkg/providers/iam/data_akamai_iam_grantable_roles_test.go | 2 +- pkg/providers/iam/data_akamai_iam_group.go | 2 +- pkg/providers/iam/data_akamai_iam_group_test.go | 2 +- pkg/providers/iam/data_akamai_iam_groups.go | 4 ++-- pkg/providers/iam/data_akamai_iam_groups_test.go | 2 +- pkg/providers/iam/data_akamai_iam_password_policy_test.go | 2 +- pkg/providers/iam/data_akamai_iam_property_users.go | 2 +- pkg/providers/iam/data_akamai_iam_property_users_test.go | 2 +- pkg/providers/iam/data_akamai_iam_role.go | 2 +- pkg/providers/iam/data_akamai_iam_role_test.go | 2 +- pkg/providers/iam/data_akamai_iam_roles.go | 4 ++-- pkg/providers/iam/data_akamai_iam_roles_test.go | 2 +- pkg/providers/iam/data_akamai_iam_states.go | 4 ++-- pkg/providers/iam/data_akamai_iam_states_test.go | 2 +- pkg/providers/iam/data_akamai_iam_supported_langs.go | 2 +- pkg/providers/iam/data_akamai_iam_supported_langs_test.go | 2 +- pkg/providers/iam/data_akamai_iam_timeout_policies.go | 2 +- pkg/providers/iam/data_akamai_iam_timeout_policies_test.go | 2 +- pkg/providers/iam/data_akamai_iam_timezones.go | 4 ++-- pkg/providers/iam/data_akamai_iam_timezones_test.go | 2 +- pkg/providers/iam/data_akamai_iam_user.go | 2 +- pkg/providers/iam/data_akamai_iam_user_test.go | 2 +- pkg/providers/iam/data_akamai_iam_users.go | 2 +- .../iam/data_akamai_iam_users_affected_by_moving_group.go | 2 +- .../data_akamai_iam_users_affected_by_moving_group_test.go | 2 +- pkg/providers/iam/data_akamai_iam_users_test.go | 2 +- pkg/providers/iam/provider.go | 4 ++-- pkg/providers/iam/provider_test.go | 4 ++-- .../iam/resource_akamai_iam_blocked_user_properties.go | 4 ++-- .../iam/resource_akamai_iam_blocked_user_properties_test.go | 2 +- pkg/providers/iam/resource_akamai_iam_cidr_block.go | 2 +- pkg/providers/iam/resource_akamai_iam_cidr_block_test.go | 2 +- pkg/providers/iam/resource_akamai_iam_group.go | 4 ++-- pkg/providers/iam/resource_akamai_iam_group_test.go | 2 +- pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go | 2 +- pkg/providers/iam/resource_akamai_iam_role.go | 4 ++-- pkg/providers/iam/resource_akamai_iam_role_test.go | 2 +- pkg/providers/iam/resource_akamai_iam_user.go | 4 ++-- pkg/providers/iam/resource_akamai_iam_user_test.go | 2 +- pkg/providers/imaging/data_akamai_imaging_policy_image.go | 2 +- pkg/providers/imaging/data_akamai_imaging_policy_video.go | 2 +- pkg/providers/imaging/imagewriter/convert-image.gen.go | 2 +- pkg/providers/imaging/provider.go | 2 +- pkg/providers/imaging/provider_test.go | 2 +- .../imaging/resource_akamai_imaging_policy_image.go | 4 ++-- .../imaging/resource_akamai_imaging_policy_image_test.go | 2 +- pkg/providers/imaging/resource_akamai_imaging_policy_set.go | 4 ++-- .../imaging/resource_akamai_imaging_policy_set_test.go | 2 +- .../imaging/resource_akamai_imaging_policy_video.go | 4 ++-- .../imaging/resource_akamai_imaging_policy_video_test.go | 2 +- pkg/providers/imaging/videowriter/convert-video.gen.go | 2 +- .../networklists/data_akamai_network_network_lists.go | 2 +- .../data_akamai_networklist_network_lists_test.go | 2 +- pkg/providers/networklists/provider.go | 2 +- pkg/providers/networklists/provider_test.go | 2 +- .../networklists/resource_akamai_networklist_activations.go | 2 +- .../resource_akamai_networklist_activations_test.go | 2 +- .../resource_akamai_networklist_network_list.go | 2 +- .../resource_akamai_networklist_network_list_description.go | 2 +- ...urce_akamai_networklist_network_list_description_test.go | 2 +- ...resource_akamai_networklist_network_list_subscription.go | 2 +- ...rce_akamai_networklist_network_list_subscription_test.go | 2 +- .../resource_akamai_networklist_network_list_test.go | 2 +- pkg/providers/property/data_akamai_contracts.go | 4 ++-- pkg/providers/property/data_akamai_contracts_test.go | 2 +- pkg/providers/property/data_akamai_cp_code.go | 2 +- pkg/providers/property/data_akamai_cp_code_test.go | 2 +- pkg/providers/property/data_akamai_properties.go | 4 ++-- pkg/providers/property/data_akamai_properties_search.go | 2 +- .../property/data_akamai_properties_search_test.go | 2 +- pkg/providers/property/data_akamai_properties_test.go | 2 +- pkg/providers/property/data_akamai_property.go | 2 +- pkg/providers/property/data_akamai_property_activation.go | 4 ++-- .../property/data_akamai_property_activation_test.go | 2 +- pkg/providers/property/data_akamai_property_hostnames.go | 4 ++-- .../property/data_akamai_property_hostnames_test.go | 2 +- pkg/providers/property/data_akamai_property_include.go | 2 +- .../property/data_akamai_property_include_activation.go | 2 +- .../data_akamai_property_include_activation_test.go | 2 +- .../property/data_akamai_property_include_parents.go | 2 +- .../property/data_akamai_property_include_parents_test.go | 2 +- .../property/data_akamai_property_include_rules.go | 4 ++-- .../property/data_akamai_property_include_rules_test.go | 2 +- pkg/providers/property/data_akamai_property_include_test.go | 2 +- pkg/providers/property/data_akamai_property_includes.go | 2 +- .../property/data_akamai_property_includes_test.go | 2 +- pkg/providers/property/data_akamai_property_products.go | 4 ++-- .../property/data_akamai_property_products_test.go | 2 +- .../property/data_akamai_property_rule_formats_test.go | 2 +- pkg/providers/property/data_akamai_property_rules.go | 2 +- .../property/data_akamai_property_rules_builder.go | 2 +- .../property/data_akamai_property_rules_template_test.go | 2 +- pkg/providers/property/data_akamai_property_rules_test.go | 2 +- pkg/providers/property/data_akamai_property_test.go | 2 +- pkg/providers/property/data_property_akamai_contract.go | 4 ++-- .../property/data_property_akamai_contract_test.go | 2 +- pkg/providers/property/data_property_akamai_group.go | 4 ++-- pkg/providers/property/data_property_akamai_group_test.go | 2 +- pkg/providers/property/data_property_akamai_groups.go | 2 +- pkg/providers/property/data_property_akamai_groups_test.go | 2 +- pkg/providers/property/diff_suppress_funcs.go | 2 +- pkg/providers/property/diff_suppress_funcs_test.go | 2 +- pkg/providers/property/helpers.go | 4 ++-- pkg/providers/property/helpers_test.go | 2 +- pkg/providers/property/log_fields.go | 2 +- pkg/providers/property/provider.go | 6 +++--- pkg/providers/property/provider_test.go | 6 +++--- pkg/providers/property/resource_akamai_cp_code.go | 2 +- pkg/providers/property/resource_akamai_cp_code_test.go | 2 +- pkg/providers/property/resource_akamai_edge_hostname.go | 4 ++-- .../property/resource_akamai_edge_hostname_test.go | 4 ++-- pkg/providers/property/resource_akamai_property.go | 4 ++-- .../property/resource_akamai_property_activation.go | 4 ++-- .../resource_akamai_property_activation_schema_v0.go | 2 +- .../property/resource_akamai_property_activation_test.go | 2 +- .../resource_akamai_property_activation_unit_test.go | 2 +- .../property/resource_akamai_property_bootstrap.go | 2 +- .../property/resource_akamai_property_bootstrap_test.go | 4 ++-- pkg/providers/property/resource_akamai_property_common.go | 2 +- .../property/resource_akamai_property_helpers_test.go | 4 ++-- pkg/providers/property/resource_akamai_property_include.go | 4 ++-- .../property/resource_akamai_property_include_activation.go | 4 ++-- .../resource_akamai_property_include_activation_test.go | 2 +- .../property/resource_akamai_property_include_test.go | 4 ++-- pkg/providers/property/resource_akamai_property_test.go | 4 ++-- pkg/providers/property/ruleformats/builder.go | 2 +- pkg/providers/property/ruleformats/rules_schema_reader.go | 2 +- 679 files changed, 773 insertions(+), 773 deletions(-) diff --git a/build/internal/docker_jenkins.bash b/build/internal/docker_jenkins.bash index 6cdb840dd..5c93c5dac 100755 --- a/build/internal/docker_jenkins.bash +++ b/build/internal/docker_jenkins.bash @@ -91,7 +91,7 @@ docker exec akatf-container sh -c 'git clone ssh://git@git.source.akamai.com:799 echo "Checkout branches" docker exec akatf-container sh -c 'cd edgegrid; git checkout ${EDGEGRID_BRANCH_NAME}; cd ../terraform-provider-akamai; git checkout ${PROVIDER_BRANCH_NAME}; - go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8=../edgegrid' + go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9=../edgegrid' echo "Installing terraform" docker exec akatf-container sh -c 'cd terraform-provider-akamai; make tools.terraform' diff --git a/build/internal/package/nexus-release.bash b/build/internal/package/nexus-release.bash index cfeb8909e..0f0fe1631 100755 --- a/build/internal/package/nexus-release.bash +++ b/build/internal/package/nexus-release.bash @@ -84,7 +84,7 @@ checkout_edgegrid() { } adjust_edgegrid() { - go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8="./akamaiopen-edgegrid-golang" + go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9="./akamaiopen-edgegrid-golang" go mod tidy -compat=1.21.12 } diff --git a/build/internal/releaser/goreleaser_build.bash b/build/internal/releaser/goreleaser_build.bash index 6c3b271c8..5a6909db2 100755 --- a/build/internal/releaser/goreleaser_build.bash +++ b/build/internal/releaser/goreleaser_build.bash @@ -1,4 +1,4 @@ cd /workspace/terraform-provider-akamai -go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8=../akamaiopen-edgegrid-golang/ +go mod edit -replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9=../akamaiopen-edgegrid-golang/ git tag v10.0.0 goreleaser build --single-target --skip-validate --config ./.goreleaser.yml --output /root/.terraform.d/plugins/registry.terraform.io/akamai/akamai/10.0.0/linux_amd64/terraform-provider-akamai_v10.0.0 diff --git a/go.mod b/go.mod index 2e78b9b3e..59d541883 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/akamai/terraform-provider-akamai/v6 go 1.21 require ( - github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.4.0 + github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 v9.0.0 github.com/allegro/bigcache/v2 v2.2.5 github.com/apex/log v1.9.0 github.com/dlclark/regexp2 v1.10.0 @@ -91,4 +91,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -// replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 => ../AkamaiOPEN-edgegrid-golang +// replace github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 => ../AkamaiOPEN-edgegrid-golang diff --git a/go.sum b/go.sum index 4f14017bc..d1aaa5029 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97 github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.4.0 h1:zZJimNqkV3o7qZqBnprKyHCqUOTzoEaabG4qB3z0E2g= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.4.0/go.mod h1:2xRRnHx8dnw0i8IZPYOI0I7xbr1gnAN1uIYo7acMIbg= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 v9.0.0 h1:TGI1yfVRiKC9qWT35YJeA1Rtiofx9CtTfATZE3lopyQ= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v9 v9.0.0/go.mod h1:1tYxzSXTnUxMbzafz3QhRSj1rc9Ag6iF8rju1AyqMuo= github.com/allegro/bigcache/v2 v2.2.5 h1:mRc8r6GQjuJsmSKQNPsR5jQVXc8IJ1xsW5YXUYMLfqI= github.com/allegro/bigcache/v2 v2.2.5/go.mod h1:FppZsIO+IZk7gCuj5FiIDHGygD9xvWQcqg1uIPMb6tY= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI= diff --git a/pkg/akamai/configure_context.go b/pkg/akamai/configure_context.go index dc68c220b..105529c9b 100644 --- a/pkg/akamai/configure_context.go +++ b/pkg/akamai/configure_context.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/akamai/configure_context_test.go b/pkg/akamai/configure_context_test.go index 19210cc32..93847f226 100644 --- a/pkg/akamai/configure_context_test.go +++ b/pkg/akamai/configure_context_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/retryablehttp" "github.com/stretchr/testify/assert" diff --git a/pkg/akamai/edgegrid.go b/pkg/akamai/edgegrid.go index 303897e74..cb5051cd4 100644 --- a/pkg/akamai/edgegrid.go +++ b/pkg/akamai/edgegrid.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" ) // ErrWrongEdgeGridConfiguration is returned when the configuration could not be read diff --git a/pkg/akamai/edgegrid_test.go b/pkg/akamai/edgegrid_test.go index 466ca47e6..4daea7d45 100644 --- a/pkg/akamai/edgegrid_test.go +++ b/pkg/akamai/edgegrid_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/akamai/sdk_provider_test.go b/pkg/akamai/sdk_provider_test.go index b4497c7b3..7e3924b28 100644 --- a/pkg/akamai/sdk_provider_test.go +++ b/pkg/akamai/sdk_provider_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgegrid" "github.com/akamai/terraform-provider-akamai/v6/pkg/akamai" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go index 76cbc177f..3dc23bcb2 100644 --- a/pkg/meta/meta.go +++ b/pkg/meta/meta.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/apex/log" "github.com/hashicorp/go-hclog" diff --git a/pkg/meta/meta_test.go b/pkg/meta/meta_test.go index af559b879..95d8c6e94 100644 --- a/pkg/meta/meta_test.go +++ b/pkg/meta/meta_test.go @@ -3,7 +3,7 @@ package meta import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/hashicorp/go-hclog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/providers/appsec/config_versions.go b/pkg/providers/appsec/config_versions.go index b4c59ea3c..194d08582 100644 --- a/pkg/providers/appsec/config_versions.go +++ b/pkg/providers/appsec/config_versions.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go index 0059da090..537ee2b51 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go index acbf3e564..cae070683 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_attack_payload_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go index 2d8b5a209..b753d530e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go index a55045e22..58a8b55b3 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_evasive_path_match_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go index c032586af..fa13d15a9 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go index fa2b7bc48..5e6f97560 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go index 2a3b68249..ee22e6521 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go index a2b30ab36..a6b6da4dd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pii_learning_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go index e4b3d33f0..765562e6a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_header.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go index 45f26d296..1d4331676 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_pragma_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go index 92ae835f1..bf1208343 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go index b831f214a..0ab23793f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_prefetch_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go index 15f830de1..a00c0b4d2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go index 6d8a3b28c..fd66ecedd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_advanced_settings_request_body_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go b/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go index 0f6ee9df8..7ccf1fbdc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_endpoints.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go b/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go index 73e79124b..1127ae601 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_endpoints_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go index c524aacf7..dcd2bc329 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go index a97832f3e..836c086aa 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go index 0a72b1cb5..766b463ff 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_match_targets_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go index d34a5d146..045df0ef2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go index 5d8cc00ae..21f91e297 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_overlapping_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go index e3e6a7e9e..b4c442094 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_hostname_coverage_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go index c4455a1d5..05f8d9d78 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go index b21d66065..aeb63db9b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_api_request_constraints_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_attack_groups.go b/pkg/providers/appsec/data_akamai_appsec_attack_groups.go index 201575bc3..82d0e6724 100644 --- a/pkg/providers/appsec/data_akamai_appsec_attack_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_attack_groups.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go b/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go index 5b94af02c..5a2efb1c2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_attack_groups_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go index bf637a83b..05a800669 100644 --- a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go +++ b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go index ec93517a2..c11f76378 100644 --- a/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_bypass_network_lists_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration.go b/pkg/providers/appsec/data_akamai_appsec_configuration.go index ff2f84a19..d6979f24a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_test.go b/pkg/providers/appsec/data_akamai_appsec_configuration_test.go index f2d779437..a4a8abd07 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_version.go b/pkg/providers/appsec/data_akamai_appsec_configuration_version.go index 905c64741..a6ab98d18 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_version.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_version.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go b/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go index 7b6775734..5839c72ba 100644 --- a/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_configuration_version_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go b/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go index 11be6ebda..a5ea7753c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_contracts_groups.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go b/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go index 1abab46ff..fd9f5d4dc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_contracts_groups_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_deny.go b/pkg/providers/appsec/data_akamai_appsec_custom_deny.go index 7b20f0751..e12b1567e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_deny.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_deny.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go b/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go index c95c70482..953435e61 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_deny_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go index 88c2a8a2b..9c6df772a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go index 42a878928..2b8cad02c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rule_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rules.go b/pkg/providers/appsec/data_akamai_appsec_custom_rules.go index b527763f3..19f8334d8 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rules.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go index d345516f9..fa7d32b66 100644 --- a/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_custom_rules_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval.go b/pkg/providers/appsec/data_akamai_appsec_eval.go index 9196520fa..a0b9a2823 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_groups.go b/pkg/providers/appsec/data_akamai_appsec_eval_groups.go index a5f611aa3..e85c1899d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_groups.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_groups.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go index da0b089c1..dc936eba1 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_groups_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go index f444b972d..e3a8da9b9 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go index fca28e254..8d9a169e5 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go index 06f82ecb5..cedbf2159 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_conditions_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go index 26434f7f8..89476452f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_rules.go b/pkg/providers/appsec/data_akamai_appsec_eval_rules.go index 414daef14..4f7ca1f6e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_rules.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go index dcb61b08e..60cdf1683 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_rules_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_eval_test.go b/pkg/providers/appsec/data_akamai_appsec_eval_test.go index 779f539fe..625634a4e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_eval_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_eval_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_export_configuration.go b/pkg/providers/appsec/data_akamai_appsec_export_configuration.go index ccda47ba2..049ea2e6c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_export_configuration.go +++ b/pkg/providers/appsec/data_akamai_appsec_export_configuration.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go b/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go index b8f38f21c..97c2ac19b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_export_configuration_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go index 3b4dfadbd..c64159e81 100644 --- a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go index 1954366b4..273c40d63 100644 --- a/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_failover_hostnames_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_ip_geo.go b/pkg/providers/appsec/data_akamai_appsec_ip_geo.go index 2da6c313e..39f71d71e 100644 --- a/pkg/providers/appsec/data_akamai_appsec_ip_geo.go +++ b/pkg/providers/appsec/data_akamai_appsec_ip_geo.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go b/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go index 9be2ac16b..f4a0369d8 100644 --- a/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_ip_geo_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go b/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go index a2342968c..78563f156 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_content_types.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go b/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go index b9d8d10fb..6e87387e9 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_content_types_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policies.go b/pkg/providers/appsec/data_akamai_appsec_malware_policies.go index 31c049c76..c84c68302 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policies.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policies.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go b/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go index 390479f7e..074ad8606 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policies_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go index 71bf04f53..356f32983 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go index bd0108dae..95c9853ed 100644 --- a/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_malware_policy_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_match_targets.go b/pkg/providers/appsec/data_akamai_appsec_match_targets.go index 866d69c36..6403292bf 100644 --- a/pkg/providers/appsec/data_akamai_appsec_match_targets.go +++ b/pkg/providers/appsec/data_akamai_appsec_match_targets.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go b/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go index 333876b2d..8e6fc1235 100644 --- a/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_match_targets_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box.go index f33bd8662..de4e6b76a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go index a909942d7..b0823546b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go index 52a5c5e38..d2065447c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box_conditions_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go b/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go index 6713f6e00..6ceb25d25 100644 --- a/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policies.go b/pkg/providers/appsec/data_akamai_appsec_rate_policies.go index 17a4c6022..b3fba418b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policies.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policies.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go b/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go index 5fd4984ad..5b3ee03eb 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policies_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go index d69c4d3a7..32871d60c 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go index a58b8597b..319b3e569 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rate_policy_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go index 2b642e287..f2f3194dc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go index 121032441..f26934d3d 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_analysis_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go index 6698f1b07..c4726c22a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go index ba7d82cef..ce62a7924 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profile_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go index 05a6b7f62..80d01c35b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go index cc3fe5850..b503401e4 100644 --- a/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_reputation_profiles_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go index 85e24fb57..3de51f148 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go +++ b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go index 67f06acf9..9f915e3b0 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rule_upgrade_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_rules.go b/pkg/providers/appsec/data_akamai_appsec_rules.go index 617620e7d..396021630 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rules.go +++ b/pkg/providers/appsec/data_akamai_appsec_rules.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_rules_test.go b/pkg/providers/appsec/data_akamai_appsec_rules_test.go index a411e216f..20e08dbb1 100644 --- a/pkg/providers/appsec/data_akamai_appsec_rules_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_rules_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy.go b/pkg/providers/appsec/data_akamai_appsec_security_policy.go index 1048a472c..3e809ebc4 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go index 9de5ffb44..87cf7b178 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go index eee52f61e..211bf3510 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_protections_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go b/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go index 4b7f9c0c5..897213822 100644 --- a/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_security_policy_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go index bdcf7523b..5baab7029 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go index 22d81cf45..9a498759f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_selectable_hostnames_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go index 7b000e1e3..1718f4c71 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go index 5b2259bea..090d0a6cc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_selected_hostnames_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go b/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go index 421463425..95f5c8067 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_definitions.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go b/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go index be79b2797..51560932b 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_definitions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_settings.go b/pkg/providers/appsec/data_akamai_appsec_siem_settings.go index 1db282c82..d6fd6ca79 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go b/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go index ec1107c73..b5baeb71a 100644 --- a/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_siem_settings_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go index 2e46f7635..cd71352b5 100644 --- a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go +++ b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go index 9145d68b0..1aec232d3 100644 --- a/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_slow_post_protection_settings_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_threat_intel.go b/pkg/providers/appsec/data_akamai_appsec_threat_intel.go index e16bd039a..11a3c208f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_threat_intel.go +++ b/pkg/providers/appsec/data_akamai_appsec_threat_intel.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go b/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go index 09307073d..922a8c764 100644 --- a/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_threat_intel_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go index e35263b38..9b61c1bcc 100644 --- a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go +++ b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" diff --git a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go index 015567996..301268d90 100644 --- a/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_tuning_recommendations_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_version_notes.go b/pkg/providers/appsec/data_akamai_appsec_version_notes.go index f727bc8ca..bea4aefcd 100644 --- a/pkg/providers/appsec/data_akamai_appsec_version_notes.go +++ b/pkg/providers/appsec/data_akamai_appsec_version_notes.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go b/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go index a04829a97..1a4ea5200 100644 --- a/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_version_notes_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_waf_mode.go b/pkg/providers/appsec/data_akamai_appsec_waf_mode.go index 392ef79bd..2ee5a6cff 100644 --- a/pkg/providers/appsec/data_akamai_appsec_waf_mode.go +++ b/pkg/providers/appsec/data_akamai_appsec_waf_mode.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go b/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go index 8a4e973ae..8e0f0837f 100644 --- a/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_waf_mode_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go index 216676649..e355a4899 100644 --- a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go +++ b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go index 682c7323e..706008ae2 100644 --- a/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go +++ b/pkg/providers/appsec/data_akamai_appsec_wap_selected_hostnames_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/diff_suppress_funcs.go b/pkg/providers/appsec/diff_suppress_funcs.go index 8a62efd45..5892fc6ac 100644 --- a/pkg/providers/appsec/diff_suppress_funcs.go +++ b/pkg/providers/appsec/diff_suppress_funcs.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/appsec/provider.go b/pkg/providers/appsec/provider.go index eb1b9fb71..10148222a 100644 --- a/pkg/providers/appsec/provider.go +++ b/pkg/providers/appsec/provider.go @@ -4,7 +4,7 @@ package appsec import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/appsec/provider_test.go b/pkg/providers/appsec/provider_test.go index 127884fac..56bbc877f 100644 --- a/pkg/providers/appsec/provider_test.go +++ b/pkg/providers/appsec/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/appsec/resource_akamai_appsec_activations.go b/pkg/providers/appsec/resource_akamai_appsec_activations.go index 50933d06c..3690f84ac 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_activations.go +++ b/pkg/providers/appsec/resource_akamai_appsec_activations.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/go-hclog" diff --git a/pkg/providers/appsec/resource_akamai_appsec_activations_test.go b/pkg/providers/appsec/resource_akamai_appsec_activations_test.go index 7f5a41141..3ae81985c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_activations_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_activations_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go index 8f5c6a060..010868760 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go index 93b1f6ee6..774d7b1ab 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_attack_payload_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go index 2a1896c58..40a716cec 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go index 36d77dc77..4752edc8a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_evasive_path_match_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go index 65d44f25b..d39221798 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go index 60a2f14a8..6349d82e1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_logging_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go index 8bc291d33..fbef0bc26 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go index 808773cf5..a342059a0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pii_learning_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go index 9a1844df8..62a1b2b73 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_header.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go index 7b8f7f5f0..1ff249bdd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_pragma_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go index f553f5e13..fef016363 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go index 0132428e0..ae1edddd6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_prefetch_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go index 76d685985..b0e5b2038 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go index 55a1effd5..ca0b1dd6f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_advanced_settings_request_body_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go index b542bfca8..67bdc25d8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go index a1d32ae90..8de106ca3 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_constraints_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go index 6af5ab00a..cfca2712a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go index cd033b414..17f77d826 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_api_request_constraints_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_attack_group.go b/pkg/providers/appsec/resource_akamai_appsec_attack_group.go index 96f3c845c..ee0e56aba 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_attack_group.go +++ b/pkg/providers/appsec/resource_akamai_appsec_attack_group.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go b/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go index 4b1cd8adc..c304814fe 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_attack_group_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go index 37faa9689..12ecc2098 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go +++ b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go index 05c69e463..f46275576 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_bypass_network_lists_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration.go b/pkg/providers/appsec/resource_akamai_appsec_configuration.go index f8a335fd4..31dff58cd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go index 24bedfbf8..cc360b746 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename.go @@ -5,7 +5,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go index 5d763d34e..673e33ed0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_rename_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go b/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go index 2fec878f8..e92340655 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_configuration_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go b/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go index dfbb5b5e9..133cadc91 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_deny.go @@ -7,7 +7,7 @@ import ( "log" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go b/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go index d0bf1ceb6..e7282c7ce 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_deny_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go index 89dc81e26..2249035a1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go index cf2bbac0e..0376ffc7f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go index b477d01d3..c44ffdd44 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go index e7f2a20ef..0936c3fae 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_custom_rule_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval.go b/pkg/providers/appsec/resource_akamai_appsec_eval.go index 5f59dcbe8..b1b45a05c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_group.go b/pkg/providers/appsec/resource_akamai_appsec_eval_group.go index fa6e98011..d525d6df8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_group.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_group.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go index fcc848e5b..e11b4a5ce 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_group_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go index 2e3fd869f..60ee3d635 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go index 8d7932082..7f519b309 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go index 51f3c5180..e383747af 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_conditions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go index 2e167e49d..bea87c1eb 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go b/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go index c0c2b5aa1..91bf0eef8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_rule.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go index aad6f047b..12e787d25 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_rule_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_eval_test.go b/pkg/providers/appsec/resource_akamai_appsec_eval_test.go index b6cb1ade1..79ae3a1cd 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_eval_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_eval_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go index 26aba5bc1..deb532991 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go index 5f4d03cd5..c8eb0edae 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go index 0257710ee..c8c4fc4f6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go index 490a2b210..fc2dd8d87 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_ip_geo_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go index 6f7e5fc62..6a05fd264 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go index e2b766969..459d942e0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go index 5f28c1feb..4f359c75c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go index 0b429acd0..1222c370f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go index 6d551242c..3d967711d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_actions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go index deb4c7042..ae0490349 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_policy_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go b/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go index 7461797a0..7ec7468df 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go index e8b472ea2..701f4ca31 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_malware_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target.go b/pkg/providers/appsec/resource_akamai_appsec_match_target.go index 9f703002a..f435570bc 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target.go @@ -8,7 +8,7 @@ import ( "sort" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go index 60938a8e0..dd5f4f517 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go index 485133a1a..077f9efff 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_sequence_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go b/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go index 301a3e643..246698e7b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_match_target_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go index 79432ab8a..07a4e560d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go index 0e0ab7772..abd7d7aee 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go index 7e90f2e87..ad5db0805 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_conditions_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go index 1560545dc..b36d54bc7 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_penalty_box_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go index 33f8749ba..600f76b97 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go index 899c7b739..102df8a7a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go index b2c219434..8417f3c2a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go index 71522e747..3de6fbc6f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_policy_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go b/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go index 3534a8c45..ae8d76c8e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go index 0d4777187..546cc6877 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rate_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go index d767ac40c..bccc8663f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go index c65798db7..d3c7139ef 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_analysis_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go index d6da76651..7c1d3e36f 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go index 9e2f7e9ce..a6bc704cf 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go index d5559ba9d..9e1b7377c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go index a6cf6b892..9e171a258 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_profile_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go index 55f18093a..7a1224eae 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go index 7c189e4c9..d43bcd459 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_reputation_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule.go b/pkg/providers/appsec/resource_akamai_appsec_rule.go index 82c20d75a..8220e995e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule.go @@ -8,7 +8,7 @@ import ( "strconv" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_test.go b/pkg/providers/appsec/resource_akamai_appsec_rule_test.go index 3a18b4783..9604836f0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go index 70e13fddc..8e3e18077 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go index 47828d12b..5bcdf70b8 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_rule_upgrade_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy.go index 2aec6397d..bb898d7c6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go index 8ee6db539..8e2eab0ff 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go index 0b7a2a31a..e0b2dbff0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_default_protections_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go index 849491dfe..a75ed2aa4 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go index 2404aa27c..c49274fb1 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_rename_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go b/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go index 22a2bb143..d9100b8d2 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_security_policy_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go index 3fa8a24f2..25454a75c 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go +++ b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go index 7ce77b312..94dfcebd6 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_selected_hostname_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go index d06130ee4..30d3e31f3 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go index fbc5a1983..30a30a42d 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/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go index d54c3657e..aa16c4c7d 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go index 3ab426ad3..fccba7898 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slow_post_protection_setting_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go index e25243e4b..fcaf0d006 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go index 4f35777e1..09cf756a0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_slowpost_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go b/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go index f5fc76565..12cba1c4e 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go +++ b/pkg/providers/appsec/resource_akamai_appsec_threat_intel.go @@ -9,7 +9,7 @@ import ( "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go b/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go index db5f7717a..7fc3d4c8b 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_threat_intel_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_version_notes.go b/pkg/providers/appsec/resource_akamai_appsec_version_notes.go index 1faeab356..453f9777a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_version_notes.go +++ b/pkg/providers/appsec/resource_akamai_appsec_version_notes.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go b/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go index 176506dfd..43fb78c47 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_version_notes_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go b/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go index 8beb5a89b..af58d8913 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_mode.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go b/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go index 3445e40a3..4be97bc52 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_mode_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go b/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go index 4e219be88..c9cba9781 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_protection.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go b/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go index f95235531..c2dffa352 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_waf_protection_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go index 7e26e69a5..64dd2911a 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go +++ b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go index 550ad7722..5b1e82712 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_wap_selected_hostnames_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/appsec/templates.go b/pkg/providers/appsec/templates.go index e2d34d311..e7a0c7cbf 100644 --- a/pkg/providers/appsec/templates.go +++ b/pkg/providers/appsec/templates.go @@ -8,7 +8,7 @@ import ( "strings" "text/template" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/appsec" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" "github.com/jedib0t/go-pretty/v6/table" ) diff --git a/pkg/providers/botman/cache.go b/pkg/providers/botman/cache.go index 02b3189e1..f46f290cd 100644 --- a/pkg/providers/botman/cache.go +++ b/pkg/providers/botman/cache.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/cache" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go index 3abf4a51a..855e39e32 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go index 26aa2e916..5c7da7fe1 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go index eb78c4191..047537b5f 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go index f3a24ee7f..b53040ab9 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_bot_category_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go index f082a6aa4..17551b4a6 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go index f485d6955..ab3371099 100644 --- a/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go +++ b/pkg/providers/botman/data_akamai_botman_akamai_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go index 6d2804ba3..cec1076f8 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go index 627f08352..a13f2d30e 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go index 2948a0c30..7b5faecf5 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_analytics_cookie_values_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_category_exception.go b/pkg/providers/botman/data_akamai_botman_bot_category_exception.go index 329a6a120..81fcc737d 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_category_exception.go +++ b/pkg/providers/botman/data_akamai_botman_bot_category_exception.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go b/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go index 48a51550d..3c55d8d68 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_category_exception_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection.go b/pkg/providers/botman/data_akamai_botman_bot_detection.go index cc508a594..36b4005d6 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection_action.go b/pkg/providers/botman/data_akamai_botman_bot_detection_action.go index ec3e5cc6c..4d4512f2c 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_action.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_action.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go b/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go index c44af60f8..a49bb6fd2 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_detection_test.go b/pkg/providers/botman/data_akamai_botman_bot_detection_test.go index da0828d0b..cc00a8bbf 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_detection_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_detection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go index 7975203a1..6721afc4d 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go +++ b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go index 38d0a3069..b4cc13f92 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_endpoint_coverage_report_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_bot_management_settings.go b/pkg/providers/botman/data_akamai_botman_bot_management_settings.go index ed76cc249..24b9584b3 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_management_settings.go +++ b/pkg/providers/botman/data_akamai_botman_bot_management_settings.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go b/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go index 272335b1f..cdb28f508 100644 --- a/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go +++ b/pkg/providers/botman/data_akamai_botman_bot_management_settings_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_action.go b/pkg/providers/botman/data_akamai_botman_challenge_action.go index a9e1e9c14..4f5496a56 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_action.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_action_test.go b/pkg/providers/botman/data_akamai_botman_challenge_action_test.go index 718276d43..d1a43f1b8 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go index 7ce1726ab..07b789104 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go index 4703a1061..2cc412640 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_injection_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go index 81df446c4..3805a8637 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go index 71bedf62b..b457dad5e 100644 --- a/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go +++ b/pkg/providers/botman/data_akamai_botman_challenge_interception_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_client_side_security.go b/pkg/providers/botman/data_akamai_botman_client_side_security.go index b80146ef9..2b67f1ec0 100644 --- a/pkg/providers/botman/data_akamai_botman_client_side_security.go +++ b/pkg/providers/botman/data_akamai_botman_client_side_security.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_client_side_security_test.go b/pkg/providers/botman/data_akamai_botman_client_side_security_test.go index e505ca011..ca5c0d550 100644 --- a/pkg/providers/botman/data_akamai_botman_client_side_security_test.go +++ b/pkg/providers/botman/data_akamai_botman_client_side_security_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_conditional_action.go b/pkg/providers/botman/data_akamai_botman_conditional_action.go index 7d9af97d7..d52d48ef9 100644 --- a/pkg/providers/botman/data_akamai_botman_conditional_action.go +++ b/pkg/providers/botman/data_akamai_botman_conditional_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_conditional_action_test.go b/pkg/providers/botman/data_akamai_botman_conditional_action_test.go index f096479d6..905fe1379 100644 --- a/pkg/providers/botman/data_akamai_botman_conditional_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_conditional_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go index b197799a9..0fe6097db 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go index 68a9a559d..d4683518d 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_javascript_injection_rule_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule.go index be9edb73f..1302a1345 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go index 0cc104333..a4b5015d4 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go index 0c72c30ff..214516849 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go b/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go index 8750fd849..ddca84913 100644 --- a/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go +++ b/pkg/providers/botman/data_akamai_botman_content_protection_rule_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category.go index 2277afe26..d17f3409f 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go index cf55dee6a..eb80c75d3 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go index 7c0aff92c..d823f3f21 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go index 20fa1062e..486732960 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go index f0d1008eb..eae76bd0f 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_item_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go index 23e704157..7cf341fa9 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go index 182dcd04a..5ca9df4b7 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go b/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go index 0943327d4..04408aa66 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_bot_category_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client.go b/pkg/providers/botman/data_akamai_botman_custom_client.go index bf8f4ea57..dd7f63138 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go b/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go index 4e1ff2de1..91326cfb1 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go b/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go index 35555a7d2..c2184c545 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_client_test.go b/pkg/providers/botman/data_akamai_botman_custom_client_test.go index f45bcd2ef..3f1bdcc17 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_client_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_client_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_code.go b/pkg/providers/botman/data_akamai_botman_custom_code.go index cabce58e6..43fe46b61 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_code.go +++ b/pkg/providers/botman/data_akamai_botman_custom_code.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_code_test.go b/pkg/providers/botman/data_akamai_botman_custom_code_test.go index efff5f4ca..6369e51e7 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_code_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_code_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go b/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go index 790dd31ee..0c505401a 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_custom_defined_bot.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go b/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go index 15fe9cbba..ea5106e4d 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_custom_deny_action.go b/pkg/providers/botman/data_akamai_botman_custom_deny_action.go index b9dcb4211..0eb63fb11 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_deny_action.go +++ b/pkg/providers/botman/data_akamai_botman_custom_deny_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go b/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go index 60662baf3..e44c5a174 100644 --- a/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_custom_deny_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_javascript_injection.go b/pkg/providers/botman/data_akamai_botman_javascript_injection.go index a90ee731a..75f037f40 100644 --- a/pkg/providers/botman/data_akamai_botman_javascript_injection.go +++ b/pkg/providers/botman/data_akamai_botman_javascript_injection.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go b/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go index 046a8222d..187f48843 100644 --- a/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go +++ b/pkg/providers/botman/data_akamai_botman_javascript_injection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go index 3270fab58..017576361 100644 --- a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go +++ b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go index 2abbd003d..98aaeeec8 100644 --- a/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go +++ b/pkg/providers/botman/data_akamai_botman_recategorized_akamai_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_response_action.go b/pkg/providers/botman/data_akamai_botman_response_action.go index 0f7e02833..84e82fa9f 100644 --- a/pkg/providers/botman/data_akamai_botman_response_action.go +++ b/pkg/providers/botman/data_akamai_botman_response_action.go @@ -6,7 +6,7 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_response_action_test.go b/pkg/providers/botman/data_akamai_botman_response_action_test.go index 06313b324..fb8bbbbe2 100644 --- a/pkg/providers/botman/data_akamai_botman_response_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_response_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go b/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go index 2a2c694a3..39f8e0da0 100644 --- a/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go +++ b/pkg/providers/botman/data_akamai_botman_serve_alternate_action.go @@ -7,7 +7,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go b/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go index f2ab04cc4..5691152d1 100644 --- a/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go +++ b/pkg/providers/botman/data_akamai_botman_serve_alternate_action_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go index ac72e8c1c..dddb7024f 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go index 27ac84a4a..32c32ab37 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go index 3b514c60d..02a508106 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_protection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go index e26bd5981..3aae5f391 100644 --- a/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go +++ b/pkg/providers/botman/data_akamai_botman_transactional_endpoint_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/provider.go b/pkg/providers/botman/provider.go index 56b081c3e..909979a6b 100644 --- a/pkg/providers/botman/provider.go +++ b/pkg/providers/botman/provider.go @@ -4,7 +4,7 @@ package botman import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/appsec" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" diff --git a/pkg/providers/botman/provider_test.go b/pkg/providers/botman/provider_test.go index c32a19fce..c62939ab0 100644 --- a/pkg/providers/botman/provider_test.go +++ b/pkg/providers/botman/provider_test.go @@ -7,7 +7,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go index 00bfc5f3e..2b688340b 100644 --- a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go +++ b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go index a21a3596e..10c61238b 100644 --- a/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_akamai_bot_category_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go index bc3bd9c95..b45bd9791 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go index 35f143ab5..3fea428b2 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_analytics_cookie_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go b/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go index 458f45c47..40f66ad4e 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_category_exception.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go b/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go index 4fe13310c..6822644aa 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_category_exception_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go b/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go index 1525b9d06..01c615649 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_detection_action.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go b/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go index 1d4f0c1f4..60156dc69 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_detection_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go b/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go index 853af02cf..5584fc6b6 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_management_settings.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go b/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go index 7f8e70c46..ffb81d678 100644 --- a/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go +++ b/pkg/providers/botman/resource_akamai_botman_bot_management_settings_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_action.go b/pkg/providers/botman/resource_akamai_botman_challenge_action.go index f89a53cd6..ba3f70094 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_action.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go b/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go index fbb3d7986..fbd04380f 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go index 790480eb0..44c7365c5 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go index 3978be2fa..886fe29f2 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_injection_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go index a7d3d6a31..08f09ac30 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules.go @@ -5,7 +5,7 @@ import ( "encoding/json" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go index 3c536ddcb..6e37da9ba 100644 --- a/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go +++ b/pkg/providers/botman/resource_akamai_botman_challenge_interception_rules_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_client_side_security.go b/pkg/providers/botman/resource_akamai_botman_client_side_security.go index ba1fede3c..fe69aa0db 100644 --- a/pkg/providers/botman/resource_akamai_botman_client_side_security.go +++ b/pkg/providers/botman/resource_akamai_botman_client_side_security.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go b/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go index 94af3ddbb..d2a9e6fd0 100644 --- a/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go +++ b/pkg/providers/botman/resource_akamai_botman_client_side_security_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_conditional_action.go b/pkg/providers/botman/resource_akamai_botman_conditional_action.go index cce2dc185..710213b93 100644 --- a/pkg/providers/botman/resource_akamai_botman_conditional_action.go +++ b/pkg/providers/botman/resource_akamai_botman_conditional_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go b/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go index eb4891cbc..f319b9f0a 100644 --- a/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_conditional_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go index dd0476461..4458f0275 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go index 0b7f2c443..99e85fb27 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_javascript_injection_rule_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go index f3481e6f2..2c64a5258 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go index 5692c697e..dc749d734 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go index ccaad2c32..b4f7a3d87 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go index 945b68045..c712851f2 100644 --- a/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go +++ b/pkg/providers/botman/resource_akamai_botman_content_protection_rule_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go index 03edf2e63..9583ec61c 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go index c386b19f9..5367cab0e 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go index b709df334..f1db00f55 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go index dd9bf9943..d5102d4fe 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go index 09d53e42d..040874723 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_item_sequence_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go index 7eaf9029e..4d2a91cbb 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go index c779f666a..b42ccb997 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go index c01bc21e8..f3443c472 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_bot_category_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client.go b/pkg/providers/botman/resource_akamai_botman_custom_client.go index 1d506e0ca..b2a3bd4d9 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go index ba320cd03..6b1f4d75d 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go index e9b4636b2..dc93d35fc 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_sequence_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_client_test.go b/pkg/providers/botman/resource_akamai_botman_custom_client_test.go index a532abb44..0e9c5ecb9 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_client_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_client_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_code.go b/pkg/providers/botman/resource_akamai_botman_custom_code.go index a48ebf5d5..d15ee914e 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_code.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_code.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_code_test.go b/pkg/providers/botman/resource_akamai_botman_custom_code_test.go index 4fbc0d76a..2ee4399fe 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_code_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_code_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go index ba2270009..074bb09bf 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go index 2057479dc..727c58d8d 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_defined_bot_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go b/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go index ab6f7ec9f..b646ead95 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_deny_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go b/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go index 81c54cfc8..643e078b9 100644 --- a/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_custom_deny_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_javascript_injection.go b/pkg/providers/botman/resource_akamai_botman_javascript_injection.go index 285a0e2ac..c55cdd587 100644 --- a/pkg/providers/botman/resource_akamai_botman_javascript_injection.go +++ b/pkg/providers/botman/resource_akamai_botman_javascript_injection.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go b/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go index 45af0ce5b..c8349b4db 100644 --- a/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go +++ b/pkg/providers/botman/resource_akamai_botman_javascript_injection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go index c086d2858..9274b5a58 100644 --- a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go +++ b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go index 61a7276d8..c24fb440a 100644 --- a/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go +++ b/pkg/providers/botman/resource_akamai_botman_recategorized_akamai_defined_bot_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go index 65e376c37..a54d0f633 100644 --- a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go +++ b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go index eedbcb72b..ae2bb739a 100644 --- a/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go +++ b/pkg/providers/botman/resource_akamai_botman_serve_alternate_action_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go index df8fe4fec..8b5671e17 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint.go @@ -6,7 +6,7 @@ import ( "fmt" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go index 373f426ca..10f649bda 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go index 50d44e065..201f1210f 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_protection_test.go @@ -3,7 +3,7 @@ package botman import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go index 195d05570..f7718af09 100644 --- a/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go +++ b/pkg/providers/botman/resource_akamai_botman_transactional_endpoint_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/botman" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/botman" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/clientlists/data_akamai_clientlist_lists.go b/pkg/providers/clientlists/data_akamai_clientlist_lists.go index f72b19235..bc6360f62 100644 --- a/pkg/providers/clientlists/data_akamai_clientlist_lists.go +++ b/pkg/providers/clientlists/data_akamai_clientlist_lists.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go b/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go index 8fe05d39d..3f3ad7b2e 100644 --- a/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go +++ b/pkg/providers/clientlists/data_akamai_clientlist_lists_test.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/clientlists/provider.go b/pkg/providers/clientlists/provider.go index 3ee537bc5..46984079e 100644 --- a/pkg/providers/clientlists/provider.go +++ b/pkg/providers/clientlists/provider.go @@ -4,7 +4,7 @@ package clientlists import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/clientlists/provider_test.go b/pkg/providers/clientlists/provider_test.go index 8e9e5be15..86ad0e338 100644 --- a/pkg/providers/clientlists/provider_test.go +++ b/pkg/providers/clientlists/provider_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list.go b/pkg/providers/clientlists/resource_akamai_clientlists_list.go index b2a0f8bdd..76405c5a3 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list.go @@ -8,7 +8,7 @@ import ( "reflect" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go index 65b4fe72a..299beb5af 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go index 266aae0d5..1a58dab1a 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list_activation_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go b/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go index 30bbbe960..61c2db74f 100644 --- a/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go +++ b/pkg/providers/clientlists/resource_akamai_clientlists_list_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/clientlists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/clientlists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go index bc4ef0dfd..569d20ba2 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go index d1ffafe48..fa7de6060 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go index 5c22f137c..6a84c3af2 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_properties_test.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go index a38f238c9..c47810183 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go index 9b6f83517..eeac29306 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go index 27e815081..5d063d53e 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_key_versions_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go index 83c8082b3..8f52454bb 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go index f5615462f..0ccbb1cd5 100644 --- a/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go +++ b/pkg/providers/cloudaccess/data_akamai_cloudaccess_keys_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cloudaccess/provider.go b/pkg/providers/cloudaccess/provider.go index 886baf7bf..d59076a1c 100644 --- a/pkg/providers/cloudaccess/provider.go +++ b/pkg/providers/cloudaccess/provider.go @@ -2,7 +2,7 @@ package cloudaccess import ( - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudaccess/provider_test.go b/pkg/providers/cloudaccess/provider_test.go index fa8ea09f9..280744f98 100644 --- a/pkg/providers/cloudaccess/provider_test.go +++ b/pkg/providers/cloudaccess/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go index c782ef9fa..0e2483004 100644 --- a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go +++ b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go index 989016d6e..23d1beedc 100644 --- a/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go +++ b/pkg/providers/cloudaccess/resource_akamai_cloudaccess_key_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudaccess" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudaccess" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go index e67c55f3d..9148b7653 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_api_prioritization_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go index a5aef0417..8802cdc81 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go index efbb31055..319ec47c2 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_match_rule.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go index 857670952..f83dd9358 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_application_load_balancer_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go index 2c83fd712..5b0913771 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_audience_segmentation_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go index c90704920..bfce95e5c 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_edge_redirector_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go index d933b3e9a..54031add3 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_forward_rewrite_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go index 1ce886f52..7c4863da3 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_phased_release_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go index a46b502ed..0ba7e3a20 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go index 1667d5ba3..14c3a6873 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go index e33d89aba..367f3b75f 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_activation_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go index e35a397c2..8620ed48f 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_policy_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go index da88021e8..aa908523e 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_request_control_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go index 8b4e0a7dc..ce1531991 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go index a32424ea2..4b5e140e0 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_shared_policy_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go b/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go index edd473f76..3630e1695 100644 --- a/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go +++ b/pkg/providers/cloudlets/data_akamai_cloudlets_visitor_prioritization_match_rule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/match_rules.go b/pkg/providers/cloudlets/match_rules.go index 778798c38..b461de770 100644 --- a/pkg/providers/cloudlets/match_rules.go +++ b/pkg/providers/cloudlets/match_rules.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/cloudlets/match_rules_test.go b/pkg/providers/cloudlets/match_rules_test.go index 0a2d602c9..91fbee552 100644 --- a/pkg/providers/cloudlets/match_rules_test.go +++ b/pkg/providers/cloudlets/match_rules_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/require" "github.com/tj/assert" diff --git a/pkg/providers/cloudlets/policy_version_test.go b/pkg/providers/cloudlets/policy_version_test.go index ddd0fc58c..3d353ed16 100644 --- a/pkg/providers/cloudlets/policy_version_test.go +++ b/pkg/providers/cloudlets/policy_version_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/pkg/providers/cloudlets/policy_version_v2.go b/pkg/providers/cloudlets/policy_version_v2.go index b6027d109..0bfac4a34 100644 --- a/pkg/providers/cloudlets/policy_version_v2.go +++ b/pkg/providers/cloudlets/policy_version_v2.go @@ -3,7 +3,7 @@ package cloudlets import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" ) type v2VersionStrategy struct { diff --git a/pkg/providers/cloudlets/policy_version_v3.go b/pkg/providers/cloudlets/policy_version_v3.go index 63e81338b..7bb56f2ca 100644 --- a/pkg/providers/cloudlets/policy_version_v3.go +++ b/pkg/providers/cloudlets/policy_version_v3.go @@ -3,7 +3,7 @@ package cloudlets import ( "context" - cloudlets "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + cloudlets "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" ) type v3VersionStrategy struct { diff --git a/pkg/providers/cloudlets/provider.go b/pkg/providers/cloudlets/provider.go index 4820b8709..b5e77724f 100644 --- a/pkg/providers/cloudlets/provider.go +++ b/pkg/providers/cloudlets/provider.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" ) diff --git a/pkg/providers/cloudlets/provider_test.go b/pkg/providers/cloudlets/provider_test.go index 62c8a3995..110dcb0a2 100644 --- a/pkg/providers/cloudlets/provider_test.go +++ b/pkg/providers/cloudlets/provider_test.go @@ -4,10 +4,10 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" ) func TestMain(m *testing.M) { diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go index ab50e7caa..40cf37498 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ozzo "github.com/go-ozzo/ozzo-validation/v4" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go index 32bd866fe..4a4494320 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go index 136664c5a..d808a8951 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_activation_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go index 80d04de78..fa0e1e12d 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_application_load_balancer_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go index 5da6246d0..a3c3cb633 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy.go @@ -10,9 +10,9 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go index e0cda453c..0e0144394 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation.go @@ -12,9 +12,9 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go index 2d01b0e55..773e2426c 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go index 6bd672448..344547772 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v2.go @@ -8,7 +8,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go index e5ed14488..87c1fbea9 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_activation_v3.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go index 33c1ed4ff..246e8f48c 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go index 710a8bcab..17ac81bcd 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v2.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go index 1f3332d67..5a7f1dcd0 100644 --- a/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go +++ b/pkg/providers/cloudlets/resource_akamai_cloudlets_policy_v3.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudlets/v3" + v3 "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudlets/v3" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go index 7cf66fb53..ef83399d6 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/attr" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go index c85266cd4..8c23e8329 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_capacities_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go index f0b21d246..ec2c3a8c3 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go index 6187b4884..cd5394b95 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configuration_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go index 8216a5f1c..9f23c0630 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go index 281c2ebde..0c59002c6 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_configurations_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go index 391f45ff3..ed31274f5 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go index fcf6a8d62..edf98916f 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_location_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go index 1dbb44cdf..d4cecfbc6 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go index 245a7decb..485db0868 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_locations_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go index eb63fc2c4..aeaabd924 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go index c14f2861d..8d2580830 100644 --- a/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go +++ b/pkg/providers/cloudwrapper/data_akamai_cloudwrapper_properties_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/provider_test.go b/pkg/providers/cloudwrapper/provider_test.go index 5764867ff..063006af1 100644 --- a/pkg/providers/cloudwrapper/provider_test.go +++ b/pkg/providers/cloudwrapper/provider_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/akamai" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go index 655f0dae4..4806594bd 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" "github.com/hashicorp/terraform-plugin-framework/attr" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go index 4a5e6c932..5f3cf5781 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_activation_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go index 7def24d00..1af20e7a9 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go index 9bd6b0b8b..d648d7b3a 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_model.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/replacer" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" diff --git a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go index d2f50445b..c9c0a489f 100644 --- a/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go +++ b/pkg/providers/cloudwrapper/resource_akamai_cloudwrapper_configuration_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cloudwrapper" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cloudwrapper" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jinzhu/copier" diff --git a/pkg/providers/cps/data_akamai_cps_csr.go b/pkg/providers/cps/data_akamai_cps_csr.go index 1536d49da..e20d6a1ba 100644 --- a/pkg/providers/cps/data_akamai_cps_csr.go +++ b/pkg/providers/cps/data_akamai_cps_csr.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/data_akamai_cps_csr_test.go b/pkg/providers/cps/data_akamai_cps_csr_test.go index bebd98a95..44e2540ad 100644 --- a/pkg/providers/cps/data_akamai_cps_csr_test.go +++ b/pkg/providers/cps/data_akamai_cps_csr_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/data_akamai_cps_deployments.go b/pkg/providers/cps/data_akamai_cps_deployments.go index 6c150aea3..75d4bb8cc 100644 --- a/pkg/providers/cps/data_akamai_cps_deployments.go +++ b/pkg/providers/cps/data_akamai_cps_deployments.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/cps/data_akamai_cps_deployments_test.go b/pkg/providers/cps/data_akamai_cps_deployments_test.go index 6e100b3f9..e885608dc 100644 --- a/pkg/providers/cps/data_akamai_cps_deployments_test.go +++ b/pkg/providers/cps/data_akamai_cps_deployments_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cps/data_akamai_cps_enrollment.go b/pkg/providers/cps/data_akamai_cps_enrollment.go index 9728e21f4..cb3fb03d1 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollment.go +++ b/pkg/providers/cps/data_akamai_cps_enrollment.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" cpstools "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" diff --git a/pkg/providers/cps/data_akamai_cps_enrollment_test.go b/pkg/providers/cps/data_akamai_cps_enrollment_test.go index ff0969990..0c51a6d42 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollment_test.go +++ b/pkg/providers/cps/data_akamai_cps_enrollment_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/data_akamai_cps_enrollments.go b/pkg/providers/cps/data_akamai_cps_enrollments.go index ec41e8510..d9305ee40 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollments.go +++ b/pkg/providers/cps/data_akamai_cps_enrollments.go @@ -3,8 +3,8 @@ package cps import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" cpstools "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" diff --git a/pkg/providers/cps/data_akamai_cps_enrollments_test.go b/pkg/providers/cps/data_akamai_cps_enrollments_test.go index 88b229389..7ece70bf0 100644 --- a/pkg/providers/cps/data_akamai_cps_enrollments_test.go +++ b/pkg/providers/cps/data_akamai_cps_enrollments_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/cps/tools" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/enrollments.go b/pkg/providers/cps/enrollments.go index 0dd339896..bb793569e 100644 --- a/pkg/providers/cps/enrollments.go +++ b/pkg/providers/cps/enrollments.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/enrollments_mocks.go b/pkg/providers/cps/enrollments_mocks.go index c57703e64..a6e5e31b0 100644 --- a/pkg/providers/cps/enrollments_mocks.go +++ b/pkg/providers/cps/enrollments_mocks.go @@ -1,6 +1,6 @@ package cps -import "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" +import "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" func mockLetsEncryptChallenges() *cps.Change { allowedInput := cps.AllowedInput{ diff --git a/pkg/providers/cps/enrollments_test.go b/pkg/providers/cps/enrollments_test.go index 722ded0dc..31f88ae9b 100644 --- a/pkg/providers/cps/enrollments_test.go +++ b/pkg/providers/cps/enrollments_test.go @@ -3,7 +3,7 @@ package cps import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/cps/provider.go b/pkg/providers/cps/provider.go index 759156a4c..a61f80898 100644 --- a/pkg/providers/cps/provider.go +++ b/pkg/providers/cps/provider.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" ) diff --git a/pkg/providers/cps/provider_test.go b/pkg/providers/cps/provider_test.go index 394c9e14e..67f029bb4 100644 --- a/pkg/providers/cps/provider_test.go +++ b/pkg/providers/cps/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go b/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go index 98dd00723..d860f5712 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_enrollment.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go b/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go index e55b85385..355714fe0 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_enrollment_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/resource_akamai_cps_dv_validation.go b/pkg/providers/cps/resource_akamai_cps_dv_validation.go index 08fbec155..9ffa53fbb 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_validation.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_validation.go @@ -7,8 +7,8 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go b/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go index 99a2a3bd7..8c2efb508 100644 --- a/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go +++ b/pkg/providers/cps/resource_akamai_cps_dv_validation_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go index 974e489e2..5304d16ef 100644 --- a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go +++ b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go index 635a23a3f..643f7b890 100644 --- a/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go +++ b/pkg/providers/cps/resource_akamai_cps_third_party_enrollment_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/cps/resource_akamai_cps_upload_certificate.go b/pkg/providers/cps/resource_akamai_cps_upload_certificate.go index 1d21b6080..d6b6cf2b3 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go index 257d1559d..9321b2b6c 100644 --- a/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go +++ b/pkg/providers/cps/resource_akamai_cps_upload_certificate_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/cps/tools/enrollment.go b/pkg/providers/cps/tools/enrollment.go index c08596633..4b73e0ed7 100644 --- a/pkg/providers/cps/tools/enrollment.go +++ b/pkg/providers/cps/tools/enrollment.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/cps/tools/enrollment_test.go b/pkg/providers/cps/tools/enrollment_test.go index 91937747e..ddd1f0ee7 100644 --- a/pkg/providers/cps/tools/enrollment_test.go +++ b/pkg/providers/cps/tools/enrollment_test.go @@ -3,7 +3,7 @@ package tools import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/cps" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/cps" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/providers/datastream/connectors.go b/pkg/providers/datastream/connectors.go index a903a9a36..2c9202a3c 100644 --- a/pkg/providers/datastream/connectors.go +++ b/pkg/providers/datastream/connectors.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/datastream/connectors_test.go b/pkg/providers/datastream/connectors_test.go index f79576d96..0ddb60286 100644 --- a/pkg/providers/datastream/connectors_test.go +++ b/pkg/providers/datastream/connectors_test.go @@ -3,7 +3,7 @@ package datastream import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/datastream/data_akamai_datastream_activation_history.go b/pkg/providers/datastream/data_akamai_datastream_activation_history.go index ccfb27059..775256acc 100644 --- a/pkg/providers/datastream/data_akamai_datastream_activation_history.go +++ b/pkg/providers/datastream/data_akamai_datastream_activation_history.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" ) func dataAkamaiDatastreamActivationHistory() *schema.Resource { diff --git a/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go b/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go index 929030739..0038dbf2c 100644 --- a/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go +++ b/pkg/providers/datastream/data_akamai_datastream_activation_history_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go b/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go index b0f45290a..ddd0d4020 100644 --- a/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go +++ b/pkg/providers/datastream/data_akamai_datastream_dataset_fields.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go b/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go index d5e26b9f4..5bfc05c71 100644 --- a/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go +++ b/pkg/providers/datastream/data_akamai_datastream_dataset_fields_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/datastream/data_akamai_datastreams.go b/pkg/providers/datastream/data_akamai_datastreams.go index 3ec3ceaf5..85c6eee9f 100644 --- a/pkg/providers/datastream/data_akamai_datastreams.go +++ b/pkg/providers/datastream/data_akamai_datastreams.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/datastream/data_akamai_datastreams_test.go b/pkg/providers/datastream/data_akamai_datastreams_test.go index 12528dff8..fa49f64bf 100644 --- a/pkg/providers/datastream/data_akamai_datastreams_test.go +++ b/pkg/providers/datastream/data_akamai_datastreams_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/datastream/provider.go b/pkg/providers/datastream/provider.go index 627ec01c7..4226ee4b0 100644 --- a/pkg/providers/datastream/provider.go +++ b/pkg/providers/datastream/provider.go @@ -4,7 +4,7 @@ package datastream import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/datastream/provider_test.go b/pkg/providers/datastream/provider_test.go index 14cfe4791..62181dbc8 100644 --- a/pkg/providers/datastream/provider_test.go +++ b/pkg/providers/datastream/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/datastream/resource_akamai_datastream.go b/pkg/providers/datastream/resource_akamai_datastream.go index 41b1b7051..d6d3b77ad 100644 --- a/pkg/providers/datastream/resource_akamai_datastream.go +++ b/pkg/providers/datastream/resource_akamai_datastream.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" diff --git a/pkg/providers/datastream/resource_akamai_datastream_test.go b/pkg/providers/datastream/resource_akamai_datastream_test.go index d47b8736c..9f7550e76 100644 --- a/pkg/providers/datastream/resource_akamai_datastream_test.go +++ b/pkg/providers/datastream/resource_akamai_datastream_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/datastream/stream.go b/pkg/providers/datastream/stream.go index f9fa18e71..48aae93d7 100644 --- a/pkg/providers/datastream/stream.go +++ b/pkg/providers/datastream/stream.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/datastream/stream_test.go b/pkg/providers/datastream/stream_test.go index 0e7ecdf0e..dd264e324 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/v8/pkg/datastream" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/datastream" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go index 2fbf774ce..9baa3a422 100644 --- a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go +++ b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go index 7aff7c065..64276daf2 100644 --- a/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go +++ b/pkg/providers/dns/data_akamai_dns_zone_dnssec_status_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/dns/data_authorities_set.go b/pkg/providers/dns/data_authorities_set.go index 017be1d30..7132e5bce 100644 --- a/pkg/providers/dns/data_authorities_set.go +++ b/pkg/providers/dns/data_authorities_set.go @@ -6,8 +6,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/dns/data_authorities_set_test.go b/pkg/providers/dns/data_authorities_set_test.go index 885784f4f..11216197e 100644 --- a/pkg/providers/dns/data_authorities_set_test.go +++ b/pkg/providers/dns/data_authorities_set_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/dns/data_dns_record_set.go b/pkg/providers/dns/data_dns_record_set.go index 04f33e200..a59893720 100644 --- a/pkg/providers/dns/data_dns_record_set.go +++ b/pkg/providers/dns/data_dns_record_set.go @@ -5,8 +5,8 @@ import ( "fmt" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/dns/data_dns_record_set_test.go b/pkg/providers/dns/data_dns_record_set_test.go index e4dadfae5..3e85b7a67 100644 --- a/pkg/providers/dns/data_dns_record_set_test.go +++ b/pkg/providers/dns/data_dns_record_set_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/dns/provider.go b/pkg/providers/dns/provider.go index 47f8e222c..7e1051644 100644 --- a/pkg/providers/dns/provider.go +++ b/pkg/providers/dns/provider.go @@ -4,7 +4,7 @@ package dns import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/dns/provider_test.go b/pkg/providers/dns/provider_test.go index 49fb59aba..8192225d7 100644 --- a/pkg/providers/dns/provider_test.go +++ b/pkg/providers/dns/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/dns/resource_akamai_dns_record.go b/pkg/providers/dns/resource_akamai_dns_record.go index 8411708f5..bf1b63fa3 100644 --- a/pkg/providers/dns/resource_akamai_dns_record.go +++ b/pkg/providers/dns/resource_akamai_dns_record.go @@ -16,8 +16,8 @@ import ( "sync" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index c0540d00c..d2158b66c 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/dns/resource_akamai_dns_zone.go b/pkg/providers/dns/resource_akamai_dns_zone.go index d50e07516..779c437cc 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone.go +++ b/pkg/providers/dns/resource_akamai_dns_zone.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/dns/resource_akamai_dns_zone_test.go b/pkg/providers/dns/resource_akamai_dns_zone_test.go index 0743c8851..37ca83f88 100644 --- a/pkg/providers/dns/resource_akamai_dns_zone_test.go +++ b/pkg/providers/dns/resource_akamai_dns_zone_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/dns" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/bundle_hash.go b/pkg/providers/edgeworkers/bundle_hash.go index 7b04843eb..1b0734cfb 100644 --- a/pkg/providers/edgeworkers/bundle_hash.go +++ b/pkg/providers/edgeworkers/bundle_hash.go @@ -8,7 +8,7 @@ import ( "io" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" ) type bundleFile struct { diff --git a/pkg/providers/edgeworkers/bundle_hash_test.go b/pkg/providers/edgeworkers/bundle_hash_test.go index ee0ae929c..a14de62ee 100644 --- a/pkg/providers/edgeworkers/bundle_hash_test.go +++ b/pkg/providers/edgeworkers/bundle_hash_test.go @@ -7,7 +7,7 @@ import ( "io" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go index 32ddae962..7e93d97b6 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go index a4a59b54e..19ff09b4f 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_group_items_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go b/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go index 6b30789ab..f370ef95d 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_groups.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go b/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go index a441a2cf1..4b551e1e3 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgekv_groups_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker.go b/pkg/providers/edgeworkers/data_akamai_edgeworker.go index ada40cd81..08067f334 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go index b912abc93..61a58158c 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go index a80f31bc4..bf62e47fe 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_activation_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go index 78c649b1f..f59dd1dee 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworker_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go index 7a016c639..4f44b77a5 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go index 1d614e8f1..bdbbee0bd 100644 --- a/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go +++ b/pkg/providers/edgeworkers/data_akamai_edgeworkers_resource_tier_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/provider.go b/pkg/providers/edgeworkers/provider.go index 6f09bff54..de57385b9 100644 --- a/pkg/providers/edgeworkers/provider.go +++ b/pkg/providers/edgeworkers/provider.go @@ -4,7 +4,7 @@ package edgeworkers import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/edgeworkers/provider_test.go b/pkg/providers/edgeworkers/provider_test.go index f3193de45..6edf0a48e 100644 --- a/pkg/providers/edgeworkers/provider_test.go +++ b/pkg/providers/edgeworkers/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv.go b/pkg/providers/edgeworkers/resource_akamai_edgekv.go index 7cd88a75d..a40efe59d 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go index 1e1717176..23208fe60 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go index 5674f6fe1..77d6e2df3 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_group_items_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go b/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go index ac62ed9a0..c9e29cb1a 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgekv_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go index 1fe2334b1..46e518093 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker.go @@ -14,8 +14,8 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go index dfbd801b2..2621fe92a 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworker_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go index dfdf2d9a5..0c54c8f53 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/collections" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go index f8e5d68fa..a0a4153b9 100644 --- a/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go +++ b/pkg/providers/edgeworkers/resource_akamai_edgeworkers_activation_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/edgeworkers" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/edgeworkers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_asmap.go b/pkg/providers/gtm/data_akamai_gtm_asmap.go index 4dbd12594..d73f4aeb9 100644 --- a/pkg/providers/gtm/data_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/data_akamai_gtm_asmap.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_asmap_test.go b/pkg/providers/gtm/data_akamai_gtm_asmap_test.go index ace6e17c2..02c47656f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_asmap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_asmap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_cidrmap.go b/pkg/providers/gtm/data_akamai_gtm_cidrmap.go index 9a6ac308c..db8ecf393 100644 --- a/pkg/providers/gtm/data_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/data_akamai_gtm_cidrmap.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go index abe05b5cd..3953feb03 100644 --- a/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_cidrmap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_datacenter.go index e92339baa..acbbdcb8f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go index 9f49ae785..8692ea6a8 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenter_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters.go b/pkg/providers/gtm/data_akamai_gtm_datacenters.go index 9a71fa03c..0e3c32b86 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters.go @@ -3,8 +3,8 @@ package gtm import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go index e90c74836..5e00e9fdc 100644 --- a/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_datacenters_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go index 284ef8497..98967b6a0 100644 --- a/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go +++ b/pkg/providers/gtm/data_akamai_gtm_default_datacenter.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" diff --git a/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go b/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go index 423fe225a..574d4a70e 100644 --- a/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_default_datacenter_test.go @@ -3,7 +3,7 @@ package gtm import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_domain.go b/pkg/providers/gtm/data_akamai_gtm_domain.go index 081e907da..77cf71b96 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domain.go +++ b/pkg/providers/gtm/data_akamai_gtm_domain.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_domain_test.go b/pkg/providers/gtm/data_akamai_gtm_domain_test.go index c1b288b6d..1f2cc82bb 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domain_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_domain_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/gtm/data_akamai_gtm_domains.go b/pkg/providers/gtm/data_akamai_gtm_domains.go index 0f38c6baa..769b8a231 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domains.go +++ b/pkg/providers/gtm/data_akamai_gtm_domains.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_domains_test.go b/pkg/providers/gtm/data_akamai_gtm_domains_test.go index 69b309249..0bb43808d 100644 --- a/pkg/providers/gtm/data_akamai_gtm_domains_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_domains_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_geomap.go b/pkg/providers/gtm/data_akamai_gtm_geomap.go index b701c12e1..4d7661d99 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomap.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_geomap_test.go b/pkg/providers/gtm/data_akamai_gtm_geomap_test.go index cfd0fc77a..c98813682 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomap_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_geomaps.go b/pkg/providers/gtm/data_akamai_gtm_geomaps.go index 450c2a7b7..92f150057 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomaps.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomaps.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go b/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go index bd836b8e5..172f194bd 100644 --- a/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_geomaps_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_resource.go b/pkg/providers/gtm/data_akamai_gtm_resource.go index 86fd64a3f..859325fd8 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resource.go +++ b/pkg/providers/gtm/data_akamai_gtm_resource.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_resource_test.go b/pkg/providers/gtm/data_akamai_gtm_resource_test.go index 53ef8c2e7..569ffff4f 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resource_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_resource_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/data_akamai_gtm_resources.go b/pkg/providers/gtm/data_akamai_gtm_resources.go index 0c8dcb02f..b7287adcd 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resources.go +++ b/pkg/providers/gtm/data_akamai_gtm_resources.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/gtm/data_akamai_gtm_resources_test.go b/pkg/providers/gtm/data_akamai_gtm_resources_test.go index a856314cb..92d10cc13 100644 --- a/pkg/providers/gtm/data_akamai_gtm_resources_test.go +++ b/pkg/providers/gtm/data_akamai_gtm_resources_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/provider.go b/pkg/providers/gtm/provider.go index c4fa5bba0..704cfddb1 100644 --- a/pkg/providers/gtm/provider.go +++ b/pkg/providers/gtm/provider.go @@ -2,7 +2,7 @@ package gtm import ( - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/gtm/provider_test.go b/pkg/providers/gtm/provider_test.go index 31d3b3921..edb946c4b 100644 --- a/pkg/providers/gtm/provider_test.go +++ b/pkg/providers/gtm/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap.go b/pkg/providers/gtm/resource_akamai_gtm_asmap.go index ca70ec467..e0a22333f 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap.go @@ -6,8 +6,8 @@ import ( "net/http" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go index 5e0dfea7f..27b27060b 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go index 61d74dd9b..88b91d306 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go index a49e882ea..8ed53f841 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go index c9e8437da..5096cb6d9 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter.go @@ -8,8 +8,8 @@ import ( "strings" "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go index b61402ab0..a9ae175cb 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_datacenter_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain.go b/pkg/providers/gtm/resource_akamai_gtm_domain.go index e09c7c459..935ffcf33 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_domain.go +++ b/pkg/providers/gtm/resource_akamai_gtm_domain.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/gtm/resource_akamai_gtm_domain_test.go b/pkg/providers/gtm/resource_akamai_gtm_domain_test.go index 86d0bdb1c..07c7a0631 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/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap.go b/pkg/providers/gtm/resource_akamai_gtm_geomap.go index d8551eda2..e89aa91ad 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go index 40bf9e8b7..a0e58e808 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 964ee240a..29fbe9480 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 864488f55..66b33610a 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource.go b/pkg/providers/gtm/resource_akamai_gtm_resource.go index e2200aae9..1a0c48fc4 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource.go @@ -6,8 +6,8 @@ import ( "fmt" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go index a92750557..48987ecd1 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_resource_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_resource_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/gtm" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/gtm" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups.go b/pkg/providers/iam/data_akamai_iam_accessible_groups.go index 8f251e555..ecbde906b 100644 --- a/pkg/providers/iam/data_akamai_iam_accessible_groups.go +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go index 1fe7f228c..a0b1bef5a 100644 --- a/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_accessible_groups_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go index 8e8afaaa3..5ef862ca8 100644 --- a/pkg/providers/iam/data_akamai_iam_account_switch_keys.go +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go index a9567bc29..ac19acb12 100644 --- a/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go +++ b/pkg/providers/iam/data_akamai_iam_account_switch_keys_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis.go b/pkg/providers/iam/data_akamai_iam_allowed_apis.go index d2a5995b1..cdcff6ea3 100644 --- a/pkg/providers/iam/data_akamai_iam_allowed_apis.go +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go index b3f238e7d..0850d5d47 100644 --- a/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go +++ b/pkg/providers/iam/data_akamai_iam_allowed_apis_test.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users.go b/pkg/providers/iam/data_akamai_iam_authorized_users.go index 4b45d77be..34ad39950 100644 --- a/pkg/providers/iam/data_akamai_iam_authorized_users.go +++ b/pkg/providers/iam/data_akamai_iam_authorized_users.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" diff --git a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go index e328d9f90..a1a21fe5c 100644 --- a/pkg/providers/iam/data_akamai_iam_authorized_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_authorized_users_test.go @@ -7,7 +7,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties.go b/pkg/providers/iam/data_akamai_iam_blocked_properties.go index 6faa526c0..cf5b50c45 100644 --- a/pkg/providers/iam/data_akamai_iam_blocked_properties.go +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go index ec2875366..1d92ee4db 100644 --- a/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go +++ b/pkg/providers/iam/data_akamai_iam_blocked_properties_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block.go b/pkg/providers/iam/data_akamai_iam_cidr_block.go index b1f28c590..f617b5c0c 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go index 9e58f7515..aacb2f05c 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_block_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_block_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go index e43fa66bc..71be27ab5 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go index 01e41c4cf..7d63cc88a 100644 --- a/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go +++ b/pkg/providers/iam/data_akamai_iam_cidr_blocks_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/iam/data_akamai_iam_contact_types.go b/pkg/providers/iam/data_akamai_iam_contact_types.go index 76ab4fa55..c9e80fc3c 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_contact_types_test.go b/pkg/providers/iam/data_akamai_iam_contact_types_test.go index f5b9a60ff..7eb8faefd 100644 --- a/pkg/providers/iam/data_akamai_iam_contact_types_test.go +++ b/pkg/providers/iam/data_akamai_iam_contact_types_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_countries.go b/pkg/providers/iam/data_akamai_iam_countries.go index a7c3e9d9b..6a23f3c42 100644 --- a/pkg/providers/iam/data_akamai_iam_countries.go +++ b/pkg/providers/iam/data_akamai_iam_countries.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_countries_test.go b/pkg/providers/iam/data_akamai_iam_countries_test.go index fd50aa7e9..ea2624ba9 100644 --- a/pkg/providers/iam/data_akamai_iam_countries_test.go +++ b/pkg/providers/iam/data_akamai_iam_countries_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_grantable_roles.go b/pkg/providers/iam/data_akamai_iam_grantable_roles.go index d70dc8025..bac00f314 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go b/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go index c2fdc20d0..847dfe9a0 100644 --- a/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_grantable_roles_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_group.go b/pkg/providers/iam/data_akamai_iam_group.go index dfc30a5df..9c8a047b0 100644 --- a/pkg/providers/iam/data_akamai_iam_group.go +++ b/pkg/providers/iam/data_akamai_iam_group.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_group_test.go b/pkg/providers/iam/data_akamai_iam_group_test.go index d0dc873a9..520adf006 100644 --- a/pkg/providers/iam/data_akamai_iam_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_group_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/iam/data_akamai_iam_groups.go b/pkg/providers/iam/data_akamai_iam_groups.go index f75d1332d..45152aa5e 100644 --- a/pkg/providers/iam/data_akamai_iam_groups.go +++ b/pkg/providers/iam/data_akamai_iam_groups.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/iam/data_akamai_iam_groups_test.go b/pkg/providers/iam/data_akamai_iam_groups_test.go index bffc29942..da4461ba1 100644 --- a/pkg/providers/iam/data_akamai_iam_groups_test.go +++ b/pkg/providers/iam/data_akamai_iam_groups_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_password_policy_test.go b/pkg/providers/iam/data_akamai_iam_password_policy_test.go index 73d86fb7b..3cf73053a 100644 --- a/pkg/providers/iam/data_akamai_iam_password_policy_test.go +++ b/pkg/providers/iam/data_akamai_iam_password_policy_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_property_users.go b/pkg/providers/iam/data_akamai_iam_property_users.go index 3ecba89b2..d969ef3b8 100644 --- a/pkg/providers/iam/data_akamai_iam_property_users.go +++ b/pkg/providers/iam/data_akamai_iam_property_users.go @@ -5,7 +5,7 @@ import ( "fmt" "regexp" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" diff --git a/pkg/providers/iam/data_akamai_iam_property_users_test.go b/pkg/providers/iam/data_akamai_iam_property_users_test.go index 6d40e4291..71fee6f67 100644 --- a/pkg/providers/iam/data_akamai_iam_property_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_property_users_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_role.go b/pkg/providers/iam/data_akamai_iam_role.go index 6b533e441..2b29268b6 100644 --- a/pkg/providers/iam/data_akamai_iam_role.go +++ b/pkg/providers/iam/data_akamai_iam_role.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" diff --git a/pkg/providers/iam/data_akamai_iam_role_test.go b/pkg/providers/iam/data_akamai_iam_role_test.go index 02307b906..7866ee9c2 100644 --- a/pkg/providers/iam/data_akamai_iam_role_test.go +++ b/pkg/providers/iam/data_akamai_iam_role_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_roles.go b/pkg/providers/iam/data_akamai_iam_roles.go index ea26b2175..76f985bb5 100644 --- a/pkg/providers/iam/data_akamai_iam_roles.go +++ b/pkg/providers/iam/data_akamai_iam_roles.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/iam/data_akamai_iam_roles_test.go b/pkg/providers/iam/data_akamai_iam_roles_test.go index ad8c6d9b8..dd4e0309c 100644 --- a/pkg/providers/iam/data_akamai_iam_roles_test.go +++ b/pkg/providers/iam/data_akamai_iam_roles_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/iam/data_akamai_iam_states.go b/pkg/providers/iam/data_akamai_iam_states.go index 4c559a103..bf4220cef 100644 --- a/pkg/providers/iam/data_akamai_iam_states.go +++ b/pkg/providers/iam/data_akamai_iam_states.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_states_test.go b/pkg/providers/iam/data_akamai_iam_states_test.go index e9f2323c0..b2af348f9 100644 --- a/pkg/providers/iam/data_akamai_iam_states_test.go +++ b/pkg/providers/iam/data_akamai_iam_states_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_supported_langs.go b/pkg/providers/iam/data_akamai_iam_supported_langs.go index 466ef4ace..1a0e253b5 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_supported_langs_test.go b/pkg/providers/iam/data_akamai_iam_supported_langs_test.go index 1ec1a02b5..cc88fda18 100644 --- a/pkg/providers/iam/data_akamai_iam_supported_langs_test.go +++ b/pkg/providers/iam/data_akamai_iam_supported_langs_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_timeout_policies.go b/pkg/providers/iam/data_akamai_iam_timeout_policies.go index 3182c895e..e2e26fa94 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies.go @@ -3,7 +3,7 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go b/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go index 03ecacdc8..14a8c07a7 100644 --- a/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go +++ b/pkg/providers/iam/data_akamai_iam_timeout_policies_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_timezones.go b/pkg/providers/iam/data_akamai_iam_timezones.go index 278555b36..bcada811e 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones.go +++ b/pkg/providers/iam/data_akamai_iam_timezones.go @@ -3,8 +3,8 @@ package iam import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/iam/data_akamai_iam_timezones_test.go b/pkg/providers/iam/data_akamai_iam_timezones_test.go index da5316c72..0b65b60e0 100644 --- a/pkg/providers/iam/data_akamai_iam_timezones_test.go +++ b/pkg/providers/iam/data_akamai_iam_timezones_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/data_akamai_iam_user.go b/pkg/providers/iam/data_akamai_iam_user.go index 0f579dc61..66d8617eb 100644 --- a/pkg/providers/iam/data_akamai_iam_user.go +++ b/pkg/providers/iam/data_akamai_iam_user.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_user_test.go b/pkg/providers/iam/data_akamai_iam_user_test.go index 00941f501..80731af68 100644 --- a/pkg/providers/iam/data_akamai_iam_user_test.go +++ b/pkg/providers/iam/data_akamai_iam_user_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/iam/data_akamai_iam_users.go b/pkg/providers/iam/data_akamai_iam_users.go index 55529c7fa..1a8f96579 100644 --- a/pkg/providers/iam/data_akamai_iam_users.go +++ b/pkg/providers/iam/data_akamai_iam_users.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go index f85c82c2d..980b7f054 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" diff --git a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go index 3fae69594..4a9c173fb 100644 --- a/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go +++ b/pkg/providers/iam/data_akamai_iam_users_affected_by_moving_group_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/iam/data_akamai_iam_users_test.go b/pkg/providers/iam/data_akamai_iam_users_test.go index 77576ebd3..655a95e74 100644 --- a/pkg/providers/iam/data_akamai_iam_users_test.go +++ b/pkg/providers/iam/data_akamai_iam_users_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/iam/provider.go b/pkg/providers/iam/provider.go index 059c315a6..ee4a352e4 100644 --- a/pkg/providers/iam/provider.go +++ b/pkg/providers/iam/provider.go @@ -4,8 +4,8 @@ package iam import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/iam/provider_test.go b/pkg/providers/iam/provider_test.go index f5e5e3dba..bf3ba93d7 100644 --- a/pkg/providers/iam/provider_test.go +++ b/pkg/providers/iam/provider_test.go @@ -4,8 +4,8 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) 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 5a1ede69d..86c32be85 100644 --- a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go +++ b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 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 ecb21d3f5..f08ee9b70 100644 --- a/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go +++ b/pkg/providers/iam/resource_akamai_iam_blocked_user_properties_test.go @@ -5,7 +5,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block.go b/pkg/providers/iam/resource_akamai_iam_cidr_block.go index c9cb76269..78721b87b 100644 --- a/pkg/providers/iam/resource_akamai_iam_cidr_block.go +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" diff --git a/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go b/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go index c76c9ebd6..df64d2ee1 100644 --- a/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go +++ b/pkg/providers/iam/resource_akamai_iam_cidr_block_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/iam/resource_akamai_iam_group.go b/pkg/providers/iam/resource_akamai_iam_group.go index 7bbd36e76..d8c0eb2ca 100644 --- a/pkg/providers/iam/resource_akamai_iam_group.go +++ b/pkg/providers/iam/resource_akamai_iam_group.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/iam/resource_akamai_iam_group_test.go b/pkg/providers/iam/resource_akamai_iam_group_test.go index 3770e4b5c..bf38a6108 100644 --- a/pkg/providers/iam/resource_akamai_iam_group_test.go +++ b/pkg/providers/iam/resource_akamai_iam_group_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go index bbd19842f..f5a2b86f3 100644 --- a/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go +++ b/pkg/providers/iam/resource_akamai_iam_ip_allowlist_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/pkg/providers/iam/resource_akamai_iam_role.go b/pkg/providers/iam/resource_akamai_iam_role.go index 7168a603b..adae33a34 100644 --- a/pkg/providers/iam/resource_akamai_iam_role.go +++ b/pkg/providers/iam/resource_akamai_iam_role.go @@ -4,8 +4,8 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/iam/resource_akamai_iam_role_test.go b/pkg/providers/iam/resource_akamai_iam_role_test.go index 01008be1a..025361d60 100644 --- a/pkg/providers/iam/resource_akamai_iam_role_test.go +++ b/pkg/providers/iam/resource_akamai_iam_role_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/iam/resource_akamai_iam_user.go b/pkg/providers/iam/resource_akamai_iam_user.go index ac76ffd51..4d3775b11 100644 --- a/pkg/providers/iam/resource_akamai_iam_user.go +++ b/pkg/providers/iam/resource_akamai_iam_user.go @@ -9,8 +9,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/iam/resource_akamai_iam_user_test.go b/pkg/providers/iam/resource_akamai_iam_user_test.go index 9d01a1382..60ce0f516 100644 --- a/pkg/providers/iam/resource_akamai_iam_user_test.go +++ b/pkg/providers/iam/resource_akamai_iam_user_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/imaging/data_akamai_imaging_policy_image.go b/pkg/providers/imaging/data_akamai_imaging_policy_image.go index 513f29f38..bc9f0d36b 100644 --- a/pkg/providers/imaging/data_akamai_imaging_policy_image.go +++ b/pkg/providers/imaging/data_akamai_imaging_policy_image.go @@ -7,7 +7,7 @@ import ( "encoding/json" "io" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/imaging/imagewriter" diff --git a/pkg/providers/imaging/data_akamai_imaging_policy_video.go b/pkg/providers/imaging/data_akamai_imaging_policy_video.go index 72a5150ea..bf9862e0d 100644 --- a/pkg/providers/imaging/data_akamai_imaging_policy_video.go +++ b/pkg/providers/imaging/data_akamai_imaging_policy_video.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/imaging/videowriter" diff --git a/pkg/providers/imaging/imagewriter/convert-image.gen.go b/pkg/providers/imaging/imagewriter/convert-image.gen.go index e95316a09..39118e44d 100644 --- a/pkg/providers/imaging/imagewriter/convert-image.gen.go +++ b/pkg/providers/imaging/imagewriter/convert-image.gen.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/imaging/provider.go b/pkg/providers/imaging/provider.go index 3040aa9e8..1a86058b7 100644 --- a/pkg/providers/imaging/provider.go +++ b/pkg/providers/imaging/provider.go @@ -4,7 +4,7 @@ package imaging import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" "github.com/hashicorp/terraform-plugin-framework/datasource" diff --git a/pkg/providers/imaging/provider_test.go b/pkg/providers/imaging/provider_test.go index 3dfd74400..c88dbff38 100644 --- a/pkg/providers/imaging/provider_test.go +++ b/pkg/providers/imaging/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_image.go b/pkg/providers/imaging/resource_akamai_imaging_policy_image.go index 08c7c6ee1..d4188b9f8 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_image.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_image.go @@ -10,8 +10,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go b/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go index 89836abb0..7cd8d5809 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_image_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_set.go b/pkg/providers/imaging/resource_akamai_imaging_policy_set.go index 5199da58f..0d927d4fd 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_set.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_set.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go b/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go index c08755eec..49c6c1680 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_set_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_video.go b/pkg/providers/imaging/resource_akamai_imaging_policy_video.go index 2c9538a1a..7a75ee82b 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_video.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_video.go @@ -10,8 +10,8 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go b/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go index b301b1cf0..d964448c0 100644 --- a/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go +++ b/pkg/providers/imaging/resource_akamai_imaging_policy_video_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/imaging/videowriter/convert-video.gen.go b/pkg/providers/imaging/videowriter/convert-video.gen.go index 9490a3ba6..4bd609fa7 100644 --- a/pkg/providers/imaging/videowriter/convert-video.gen.go +++ b/pkg/providers/imaging/videowriter/convert-video.gen.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/imaging" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/imaging" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/networklists/data_akamai_network_network_lists.go b/pkg/providers/networklists/data_akamai_network_network_lists.go index f0509b466..c885bbe40 100644 --- a/pkg/providers/networklists/data_akamai_network_network_lists.go +++ b/pkg/providers/networklists/data_akamai_network_network_lists.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go b/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go index 231907a33..5810c1e13 100644 --- a/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go +++ b/pkg/providers/networklists/data_akamai_networklist_network_lists_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + network "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/provider.go b/pkg/providers/networklists/provider.go index 4e6592934..1b527868e 100644 --- a/pkg/providers/networklists/provider.go +++ b/pkg/providers/networklists/provider.go @@ -4,7 +4,7 @@ package networklists import ( "sync" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" diff --git a/pkg/providers/networklists/provider_test.go b/pkg/providers/networklists/provider_test.go index af364f83c..5fe1ee9fd 100644 --- a/pkg/providers/networklists/provider_test.go +++ b/pkg/providers/networklists/provider_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" ) diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations.go b/pkg/providers/networklists/resource_akamai_networklist_activations.go index ab191bbc1..9b48a4a26 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_activations.go +++ b/pkg/providers/networklists/resource_akamai_networklist_activations.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/go-hclog" diff --git a/pkg/providers/networklists/resource_akamai_networklist_activations_test.go b/pkg/providers/networklists/resource_akamai_networklist_activations_test.go index 6321fe0f9..81e7ac509 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_activations_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_activations_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list.go b/pkg/providers/networklists/resource_akamai_networklist_network_list.go index be3d91ae2..547f75039 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list.go @@ -7,7 +7,7 @@ import ( "sort" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go index 9d9bc4866..10ce3e305 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_description.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go index fe93f21b1..7b640535d 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_description_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go index 0e3e4c2ae..6fc958ff7 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go index 23c3bf211..a79c1595f 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_subscription_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go b/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go index dfc701bc5..60ae47e04 100644 --- a/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go +++ b/pkg/providers/networklists/resource_akamai_networklist_network_list_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/networklists" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/networklists" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_contracts.go b/pkg/providers/property/data_akamai_contracts.go index 638d7a6a8..3f4b837db 100644 --- a/pkg/providers/property/data_akamai_contracts.go +++ b/pkg/providers/property/data_akamai_contracts.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/data_akamai_contracts_test.go b/pkg/providers/property/data_akamai_contracts_test.go index 254351705..a7117bf28 100644 --- a/pkg/providers/property/data_akamai_contracts_test.go +++ b/pkg/providers/property/data_akamai_contracts_test.go @@ -3,7 +3,7 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_cp_code.go b/pkg/providers/property/data_akamai_cp_code.go index 59793f073..597a89561 100644 --- a/pkg/providers/property/data_akamai_cp_code.go +++ b/pkg/providers/property/data_akamai_cp_code.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/property/data_akamai_cp_code_test.go b/pkg/providers/property/data_akamai_cp_code_test.go index 2f093cca3..71223ee2f 100644 --- a/pkg/providers/property/data_akamai_cp_code_test.go +++ b/pkg/providers/property/data_akamai_cp_code_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_properties.go b/pkg/providers/property/data_akamai_properties.go index 54d5675bb..e4b3d0402 100644 --- a/pkg/providers/property/data_akamai_properties.go +++ b/pkg/providers/property/data_akamai_properties.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_properties_search.go b/pkg/providers/property/data_akamai_properties_search.go index 000ca6f22..01f9b4c42 100644 --- a/pkg/providers/property/data_akamai_properties_search.go +++ b/pkg/providers/property/data_akamai_properties_search.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/property/data_akamai_properties_search_test.go b/pkg/providers/property/data_akamai_properties_search_test.go index a7937aac8..43451f396 100644 --- a/pkg/providers/property/data_akamai_properties_search_test.go +++ b/pkg/providers/property/data_akamai_properties_search_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_properties_test.go b/pkg/providers/property/data_akamai_properties_test.go index a3de9c344..469ea7da6 100644 --- a/pkg/providers/property/data_akamai_properties_test.go +++ b/pkg/providers/property/data_akamai_properties_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property.go b/pkg/providers/property/data_akamai_property.go index 31a22ca30..e08529f39 100644 --- a/pkg/providers/property/data_akamai_property.go +++ b/pkg/providers/property/data_akamai_property.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" ) diff --git a/pkg/providers/property/data_akamai_property_activation.go b/pkg/providers/property/data_akamai_property_activation.go index 6a8a2921c..81671ecf9 100644 --- a/pkg/providers/property/data_akamai_property_activation.go +++ b/pkg/providers/property/data_akamai_property_activation.go @@ -3,8 +3,8 @@ package property import ( "context" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_activation_test.go b/pkg/providers/property/data_akamai_property_activation_test.go index 5eb7ac802..b7e36ef8d 100644 --- a/pkg/providers/property/data_akamai_property_activation_test.go +++ b/pkg/providers/property/data_akamai_property_activation_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_hostnames.go b/pkg/providers/property/data_akamai_property_hostnames.go index f48b17318..64f5783e9 100644 --- a/pkg/providers/property/data_akamai_property_hostnames.go +++ b/pkg/providers/property/data_akamai_property_hostnames.go @@ -5,8 +5,8 @@ import ( "errors" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_property_hostnames_test.go b/pkg/providers/property/data_akamai_property_hostnames_test.go index 9a9a1304f..639da19c4 100644 --- a/pkg/providers/property/data_akamai_property_hostnames_test.go +++ b/pkg/providers/property/data_akamai_property_hostnames_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_include.go b/pkg/providers/property/data_akamai_property_include.go index 4d1ff562e..5bde6078b 100644 --- a/pkg/providers/property/data_akamai_property_include.go +++ b/pkg/providers/property/data_akamai_property_include.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" diff --git a/pkg/providers/property/data_akamai_property_include_activation.go b/pkg/providers/property/data_akamai_property_include_activation.go index 78585cfbe..51122665a 100644 --- a/pkg/providers/property/data_akamai_property_include_activation.go +++ b/pkg/providers/property/data_akamai_property_include_activation.go @@ -6,7 +6,7 @@ import ( "sort" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_include_activation_test.go b/pkg/providers/property/data_akamai_property_include_activation_test.go index 1e634067d..886160b42 100644 --- a/pkg/providers/property/data_akamai_property_include_activation_test.go +++ b/pkg/providers/property/data_akamai_property_include_activation_test.go @@ -6,7 +6,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/property/data_akamai_property_include_parents.go b/pkg/providers/property/data_akamai_property_include_parents.go index 3d77e0c73..a7c24e866 100644 --- a/pkg/providers/property/data_akamai_property_include_parents.go +++ b/pkg/providers/property/data_akamai_property_include_parents.go @@ -4,7 +4,7 @@ import ( "context" "strconv" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_include_parents_test.go b/pkg/providers/property/data_akamai_property_include_parents_test.go index 18b7bc579..1bf8093da 100644 --- a/pkg/providers/property/data_akamai_property_include_parents_test.go +++ b/pkg/providers/property/data_akamai_property_include_parents_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_include_rules.go b/pkg/providers/property/data_akamai_property_include_rules.go index 18bc41e7b..fc17bd801 100644 --- a/pkg/providers/property/data_akamai_property_include_rules.go +++ b/pkg/providers/property/data_akamai_property_include_rules.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_include_rules_test.go b/pkg/providers/property/data_akamai_property_include_rules_test.go index 9c56019c5..3d2a4701f 100644 --- a/pkg/providers/property/data_akamai_property_include_rules_test.go +++ b/pkg/providers/property/data_akamai_property_include_rules_test.go @@ -8,7 +8,7 @@ import ( "strconv" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/property/data_akamai_property_include_test.go b/pkg/providers/property/data_akamai_property_include_test.go index 37ed7b37a..7ad2fc7dd 100644 --- a/pkg/providers/property/data_akamai_property_include_test.go +++ b/pkg/providers/property/data_akamai_property_include_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_includes.go b/pkg/providers/property/data_akamai_property_includes.go index 4d416ed4a..c673b9511 100644 --- a/pkg/providers/property/data_akamai_property_includes.go +++ b/pkg/providers/property/data_akamai_property_includes.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_includes_test.go b/pkg/providers/property/data_akamai_property_includes_test.go index 2baa857ae..8b86939a8 100644 --- a/pkg/providers/property/data_akamai_property_includes_test.go +++ b/pkg/providers/property/data_akamai_property_includes_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_products.go b/pkg/providers/property/data_akamai_property_products.go index 7284d58cf..f33a297b0 100644 --- a/pkg/providers/property/data_akamai_property_products.go +++ b/pkg/providers/property/data_akamai_property_products.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_property_products_test.go b/pkg/providers/property/data_akamai_property_products_test.go index 0e0a4ac08..a49674eb3 100644 --- a/pkg/providers/property/data_akamai_property_products_test.go +++ b/pkg/providers/property/data_akamai_property_products_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_rule_formats_test.go b/pkg/providers/property/data_akamai_property_rule_formats_test.go index 163c75103..b59990a77 100644 --- a/pkg/providers/property/data_akamai_property_rule_formats_test.go +++ b/pkg/providers/property/data_akamai_property_rule_formats_test.go @@ -3,7 +3,7 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_rules.go b/pkg/providers/property/data_akamai_property_rules.go index 8be464d67..8eb1a07cb 100644 --- a/pkg/providers/property/data_akamai_property_rules.go +++ b/pkg/providers/property/data_akamai_property_rules.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_akamai_property_rules_builder.go b/pkg/providers/property/data_akamai_property_rules_builder.go index cef4a9b3d..958194215 100644 --- a/pkg/providers/property/data_akamai_property_rules_builder.go +++ b/pkg/providers/property/data_akamai_property_rules_builder.go @@ -7,7 +7,7 @@ import ( "encoding/json" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/providers/property/ruleformats" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_akamai_property_rules_template_test.go b/pkg/providers/property/data_akamai_property_rules_template_test.go index c643ca4db..f03c399f5 100644 --- a/pkg/providers/property/data_akamai_property_rules_template_test.go +++ b/pkg/providers/property/data_akamai_property_rules_template_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_akamai_property_rules_test.go b/pkg/providers/property/data_akamai_property_rules_test.go index eb29a24f9..7dae88bff 100644 --- a/pkg/providers/property/data_akamai_property_rules_test.go +++ b/pkg/providers/property/data_akamai_property_rules_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_akamai_property_test.go b/pkg/providers/property/data_akamai_property_test.go index 0b0157e6d..d611ec0a1 100644 --- a/pkg/providers/property/data_akamai_property_test.go +++ b/pkg/providers/property/data_akamai_property_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/data_property_akamai_contract.go b/pkg/providers/property/data_property_akamai_contract.go index 80a79bbbf..f75d90019 100644 --- a/pkg/providers/property/data_property_akamai_contract.go +++ b/pkg/providers/property/data_property_akamai_contract.go @@ -4,8 +4,8 @@ import ( "context" "errors" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_property_akamai_contract_test.go b/pkg/providers/property/data_property_akamai_contract_test.go index cb65d2fb2..13cfb6370 100644 --- a/pkg/providers/property/data_property_akamai_contract_test.go +++ b/pkg/providers/property/data_property_akamai_contract_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) diff --git a/pkg/providers/property/data_property_akamai_group.go b/pkg/providers/property/data_property_akamai_group.go index ad4373fea..591fcec5a 100644 --- a/pkg/providers/property/data_property_akamai_group.go +++ b/pkg/providers/property/data_property_akamai_group.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" akameta "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/data_property_akamai_group_test.go b/pkg/providers/property/data_property_akamai_group_test.go index 7ca83034d..72727a937 100644 --- a/pkg/providers/property/data_property_akamai_group_test.go +++ b/pkg/providers/property/data_property_akamai_group_test.go @@ -4,7 +4,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/data_property_akamai_groups.go b/pkg/providers/property/data_property_akamai_groups.go index 3bcb7e836..7fcbfac47 100644 --- a/pkg/providers/property/data_property_akamai_groups.go +++ b/pkg/providers/property/data_property_akamai_groups.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/hash" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/data_property_akamai_groups_test.go b/pkg/providers/property/data_property_akamai_groups_test.go index 04dbc264b..612634b65 100644 --- a/pkg/providers/property/data_property_akamai_groups_test.go +++ b/pkg/providers/property/data_property_akamai_groups_test.go @@ -4,7 +4,7 @@ import ( "log" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/pkg/providers/property/diff_suppress_funcs.go b/pkg/providers/property/diff_suppress_funcs.go index 4961856b8..1a180ce13 100644 --- a/pkg/providers/property/diff_suppress_funcs.go +++ b/pkg/providers/property/diff_suppress_funcs.go @@ -6,7 +6,7 @@ import ( "reflect" "sort" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/diff_suppress_funcs_test.go b/pkg/providers/property/diff_suppress_funcs_test.go index cb59e3934..df9eceb69 100644 --- a/pkg/providers/property/diff_suppress_funcs_test.go +++ b/pkg/providers/property/diff_suppress_funcs_test.go @@ -3,7 +3,7 @@ package property import ( "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/tj/assert" ) diff --git a/pkg/providers/property/helpers.go b/pkg/providers/property/helpers.go index a34ecece7..c62036c72 100644 --- a/pkg/providers/property/helpers.go +++ b/pkg/providers/property/helpers.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/apex/log" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/helpers_test.go b/pkg/providers/property/helpers_test.go index ce13f4591..3a321cf5a 100644 --- a/pkg/providers/property/helpers_test.go +++ b/pkg/providers/property/helpers_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/stretchr/testify/assert" ) diff --git a/pkg/providers/property/log_fields.go b/pkg/providers/property/log_fields.go index d121e8639..c4e72d5e7 100644 --- a/pkg/providers/property/log_fields.go +++ b/pkg/providers/property/log_fields.go @@ -5,7 +5,7 @@ import ( "github.com/apex/log" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" ) // Get loggable fields from given arguments diff --git a/pkg/providers/property/provider.go b/pkg/providers/property/provider.go index 2ebac4e0f..563987260 100644 --- a/pkg/providers/property/provider.go +++ b/pkg/providers/property/provider.go @@ -6,9 +6,9 @@ import ( "encoding/json" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" "github.com/akamai/terraform-provider-akamai/v6/pkg/subprovider" diff --git a/pkg/providers/property/provider_test.go b/pkg/providers/property/provider_test.go index 7ffd86977..2df3db291 100644 --- a/pkg/providers/property/provider_test.go +++ b/pkg/providers/property/provider_test.go @@ -5,9 +5,9 @@ import ( "sync" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/go-hclog" ) diff --git a/pkg/providers/property/resource_akamai_cp_code.go b/pkg/providers/property/resource_akamai_cp_code.go index 15a79c4b3..276828e29 100644 --- a/pkg/providers/property/resource_akamai_cp_code.go +++ b/pkg/providers/property/resource_akamai_cp_code.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/property/resource_akamai_cp_code_test.go b/pkg/providers/property/resource_akamai_cp_code_test.go index f7285c8ea..ba2780455 100644 --- a/pkg/providers/property/resource_akamai_cp_code_test.go +++ b/pkg/providers/property/resource_akamai_cp_code_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/pkg/providers/property/resource_akamai_edge_hostname.go b/pkg/providers/property/resource_akamai_edge_hostname.go index c7d12815c..c8107ecd9 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname.go +++ b/pkg/providers/property/resource_akamai_edge_hostname.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/property/resource_akamai_edge_hostname_test.go b/pkg/providers/property/resource_akamai_edge_hostname_test.go index 35cff0cce..304536cfb 100644 --- a/pkg/providers/property/resource_akamai_edge_hostname_test.go +++ b/pkg/providers/property/resource_akamai_edge_hostname_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/internal/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/resource_akamai_property.go b/pkg/providers/property/resource_akamai_property.go index 7c3b42c5c..6bf665efb 100644 --- a/pkg/providers/property/resource_akamai_property.go +++ b/pkg/providers/property/resource_akamai_property.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/resource_akamai_property_activation.go b/pkg/providers/property/resource_akamai_property_activation.go index ddb5d1914..da1690e03 100644 --- a/pkg/providers/property/resource_akamai_property_activation.go +++ b/pkg/providers/property/resource_akamai_property_activation.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" diff --git a/pkg/providers/property/resource_akamai_property_activation_schema_v0.go b/pkg/providers/property/resource_akamai_property_activation_schema_v0.go index d4de1bced..8bdbddebd 100644 --- a/pkg/providers/property/resource_akamai_property_activation_schema_v0.go +++ b/pkg/providers/property/resource_akamai_property_activation_schema_v0.go @@ -1,7 +1,7 @@ package property import ( - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/pkg/providers/property/resource_akamai_property_activation_test.go b/pkg/providers/property/resource_akamai_property_activation_test.go index 75675a023..25b2310bb 100644 --- a/pkg/providers/property/resource_akamai_property_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_test.go @@ -5,7 +5,7 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/mock" diff --git a/pkg/providers/property/resource_akamai_property_activation_unit_test.go b/pkg/providers/property/resource_akamai_property_activation_unit_test.go index ba0acbb5c..e4254d0b8 100644 --- a/pkg/providers/property/resource_akamai_property_activation_unit_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_unit_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/date" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/resource_akamai_property_bootstrap.go b/pkg/providers/property/resource_akamai_property_bootstrap.go index 30707acf3..b94dd3ea8 100644 --- a/pkg/providers/property/resource_akamai_property_bootstrap.go +++ b/pkg/providers/property/resource_akamai_property_bootstrap.go @@ -7,7 +7,7 @@ import ( "regexp" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/framework/modifiers" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/resource_akamai_property_bootstrap_test.go b/pkg/providers/property/resource_akamai_property_bootstrap_test.go index 5b2db8db0..ea1bb0b98 100644 --- a/pkg/providers/property/resource_akamai_property_bootstrap_test.go +++ b/pkg/providers/property/resource_akamai_property_bootstrap_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" diff --git a/pkg/providers/property/resource_akamai_property_common.go b/pkg/providers/property/resource_akamai_property_common.go index f4c68c58e..4a1b71696 100644 --- a/pkg/providers/property/resource_akamai_property_common.go +++ b/pkg/providers/property/resource_akamai_property_common.go @@ -6,7 +6,7 @@ import ( "context" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/resource_akamai_property_helpers_test.go b/pkg/providers/property/resource_akamai_property_helpers_test.go index 5983e2d03..af6ff3f0f 100644 --- a/pkg/providers/property/resource_akamai_property_helpers_test.go +++ b/pkg/providers/property/resource_akamai_property_helpers_test.go @@ -4,8 +4,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/stretchr/testify/mock" ) diff --git a/pkg/providers/property/resource_akamai_property_include.go b/pkg/providers/property/resource_akamai_property_include.go index 065fbc951..669d8248b 100644 --- a/pkg/providers/property/resource_akamai_property_include.go +++ b/pkg/providers/property/resource_akamai_property_include.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/logger" "github.com/akamai/terraform-provider-akamai/v6/pkg/meta" diff --git a/pkg/providers/property/resource_akamai_property_include_activation.go b/pkg/providers/property/resource_akamai_property_include_activation.go index c62fc76f7..4b944a7b1 100644 --- a/pkg/providers/property/resource_akamai_property_include_activation.go +++ b/pkg/providers/property/resource_akamai_property_include_activation.go @@ -11,8 +11,8 @@ import ( "strings" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/session" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/str" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/timeouts" diff --git a/pkg/providers/property/resource_akamai_property_include_activation_test.go b/pkg/providers/property/resource_akamai_property_include_activation_test.go index 07334672b..569e262d2 100644 --- a/pkg/providers/property/resource_akamai_property_include_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_include_activation_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/providers/property/resource_akamai_property_include_test.go b/pkg/providers/property/resource_akamai_property_include_test.go index de9b8cc10..6210dab4c 100644 --- a/pkg/providers/property/resource_akamai_property_include_test.go +++ b/pkg/providers/property/resource_akamai_property_include_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/hapi" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/hapi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/pkg/providers/property/resource_akamai_property_test.go b/pkg/providers/property/resource_akamai_property_test.go index f3e136f14..ba88f08bd 100644 --- a/pkg/providers/property/resource_akamai_property_test.go +++ b/pkg/providers/property/resource_akamai_property_test.go @@ -11,8 +11,8 @@ import ( "strings" "testing" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/iam" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/iam" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/test" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/testutils" diff --git a/pkg/providers/property/ruleformats/builder.go b/pkg/providers/property/ruleformats/builder.go index dd4d523c1..3838937e8 100644 --- a/pkg/providers/property/ruleformats/builder.go +++ b/pkg/providers/property/ruleformats/builder.go @@ -6,7 +6,7 @@ import ( "fmt" "reflect" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/ptr" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" diff --git a/pkg/providers/property/ruleformats/rules_schema_reader.go b/pkg/providers/property/ruleformats/rules_schema_reader.go index 09a1131d6..2b92095da 100644 --- a/pkg/providers/property/ruleformats/rules_schema_reader.go +++ b/pkg/providers/property/ruleformats/rules_schema_reader.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/papi" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/papi" "github.com/akamai/terraform-provider-akamai/v6/pkg/common/tf" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) From b0f0bba135fa77f904b3bd327ce0054de60cec66 Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Wed, 2 Oct 2024 10:11:17 +0200 Subject: [PATCH 45/54] DXE-4211 Correction of property to remove product id and rule format from new mocks and align body and request names --- .../property/resource_akamai_property_helpers_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/providers/property/resource_akamai_property_helpers_test.go b/pkg/providers/property/resource_akamai_property_helpers_test.go index af6ff3f0f..a62337fdf 100644 --- a/pkg/providers/property/resource_akamai_property_helpers_test.go +++ b/pkg/providers/property/resource_akamai_property_helpers_test.go @@ -156,10 +156,8 @@ func (p *mockProperty) mockGetProperty() *mock.Call { GroupID: p.groupID, LatestVersion: p.latestVersion, // although optional in PAPI documentation, ProductID is not being set by PAPI in the response - ProductID: p.productID, PropertyID: p.propertyID, PropertyName: p.propertyName, - RuleFormat: p.ruleTree.ruleFormat, }, } @@ -312,7 +310,7 @@ func (p *mockProperty) mockMoveProperty() { } req := iam.MovePropertyRequest{ PropertyID: intPropertyID, - BodyParams: iam.MovePropertyReqBody{ + Body: iam.MovePropertyRequestBody{ DestinationGroupID: p.moveGroup.destinationGroupID, SourceGroupID: p.moveGroup.sourceGroupID, }, From 878e1f29eefce57a957c0d1a6513dae0c4073271 Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Wed, 2 Oct 2024 12:05:42 +0200 Subject: [PATCH 46/54] DXE-4211 Correction of gtm to align new mocks and wrapper. --- pkg/providers/gtm/resource_akamai_gtm_property.go | 9 +++------ .../gtm/resource_akamai_gtm_property_test.go | 15 +++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pkg/providers/gtm/resource_akamai_gtm_property.go b/pkg/providers/gtm/resource_akamai_gtm_property.go index 29fbe9480..97a05aca7 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property.go @@ -541,7 +541,7 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } logger.Debugf("Proposed New Property: [%v]", newProp) - cStatus, err := Client(meta).CreateProperty(ctx, gtm.CreatePropertyRequest{ + cStatus, err := createPropertyWithRetry(ctx, meta, logger, gtm.CreatePropertyRequest{ Property: newProp, DomainName: domain, }) @@ -583,7 +583,7 @@ func resourceGTMv1PropertyCreate(ctx context.Context, d *schema.ResourceData, m } -func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Interface, newProp *gtm.Property, domain string) (*gtm.CreatePropertyResponse, error) { +func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Interface, createPropertyRequest gtm.CreatePropertyRequest) (*gtm.CreatePropertyResponse, error) { // Initial backoff interval retryInterval := time.Second * 10 // Maximum retry interval @@ -591,10 +591,7 @@ func createPropertyWithRetry(ctx context.Context, meta meta.Meta, logger log.Int for { // Attempt to create the property - cStatus, err := Client(meta).CreateProperty(ctx, gtm.CreatePropertyRequest{ - Property: newProp, - DomainName: domain, - }) + cStatus, err := Client(meta).CreateProperty(ctx, createPropertyRequest) if err == nil { // Success, return the created property return cStatus, nil diff --git a/pkg/providers/gtm/resource_akamai_gtm_property_test.go b/pkg/providers/gtm/resource_akamai_gtm_property_test.go index 66b33610a..0756dfe94 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_property_test.go +++ b/pkg/providers/gtm/resource_akamai_gtm_property_test.go @@ -149,12 +149,12 @@ func TestResGTMProperty(t *testing.T) { }, }, "create property with retry on Property Validation Failure - no datacenter is assigned to map target": { + property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { // Simulate a retry scenario m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, ).Return(nil, >m.Error{ Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", StatusCode: http.StatusBadRequest, @@ -186,12 +186,12 @@ func TestResGTMProperty(t *testing.T) { }, }, "create property with retry on Property Validation Failure - other errors": { + property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { // Simulate a retry scenario m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, ).Return(nil, >m.Error{ Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", StatusCode: http.StatusBadRequest, @@ -208,12 +208,12 @@ func TestResGTMProperty(t *testing.T) { }, }, "create property with retry - context canceled": { + property: getBasicProperty(), init: func(t *testing.T, m *gtm.Mock) { // Simulate a retry scenario m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, ).Return(nil, >m.Error{ Type: "https://problems.luna.akamaiapis.net/config-gtm/v1/propertyValidationError", StatusCode: http.StatusBadRequest, @@ -224,8 +224,7 @@ func TestResGTMProperty(t *testing.T) { // Simulate context cancellation on the second attempt m.On("CreateProperty", mock.Anything, - getBasicProperty(), - gtmTestDomain, + gtm.CreatePropertyRequest{Property: getBasicProperty(), DomainName: gtmTestDomain}, ).Return(nil, context.Canceled).Once() }, steps: []resource.TestStep{ From 2e9866bd1aa771a0806d4c5affd9750a6dbd29e5 Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Wed, 2 Oct 2024 12:27:14 +0200 Subject: [PATCH 47/54] DXE-4211 Correction of dns unit test to align new wrappers. --- .../dns/resource_akamai_dns_record_test.go | 76 ++++++++----------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/pkg/providers/dns/resource_akamai_dns_record_test.go b/pkg/providers/dns/resource_akamai_dns_record_test.go index d2158b66c..66518e1e1 100644 --- a/pkg/providers/dns/resource_akamai_dns_record_test.go +++ b/pkg/providers/dns/resource_akamai_dns_record_test.go @@ -325,30 +325,28 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "origin.example.org", - RecordType: "SRV", - TTL: 300, - Active: false, - Target: []string{targetBig, targetSmall, targetTiny}, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "origin.example.org", + RecordType: "SRV", + TTL: 300, + Active: false, + Target: []string{targetBig, targetSmall, targetTiny}, + }, + Zone: "origin.org", + RecLock: []bool{false}, }, - "origin.org", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -374,10 +372,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -387,9 +383,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.srv_record" @@ -423,30 +417,28 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, ).Return(nil, notFound).Once() client.On("CreateRecord", mock.Anything, - &dns.RecordBody{ - Name: "origin.example.org", - RecordType: "SRV", - TTL: 300, - Active: false, - Target: []string{targetBig, targetSmall, targetTiny}, + dns.CreateRecordRequest{ + Record: &dns.RecordBody{ + Name: "origin.example.org", + RecordType: "SRV", + TTL: 300, + Active: false, + Target: []string{targetBig, targetSmall, targetTiny}, + }, + Zone: "origin.org", + RecLock: []bool{false}, }, - "origin.org", - []bool{false}, ).Return(nil) client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -472,10 +464,8 @@ func TestResDnsRecord(t *testing.T) { client.On("GetRecord", mock.Anything, - "origin.org", - "origin.example.org", - "SRV", - ).Return(&dns.RecordBody{ + dns.GetRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV"}, + ).Return(&dns.GetRecordResponse{ Name: "origin.example.org", RecordType: "SRV", TTL: 300, @@ -485,9 +475,7 @@ func TestResDnsRecord(t *testing.T) { client.On("DeleteRecord", mock.Anything, - mock.AnythingOfType("*dns.RecordBody"), - mock.AnythingOfType("string"), - mock.AnythingOfType("[]bool"), + dns.DeleteRecordRequest{Zone: "origin.org", Name: "origin.example.org", RecordType: "SRV", RecLock: []bool{false}}, ).Return(nil) resourceName := "akamai_dns_record.srv_record" From 7c286f0e2773f3a41ac3656daba97a75f638a8cf Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Thu, 3 Oct 2024 14:54:36 +0000 Subject: [PATCH 48/54] DXE-4108 Fix activation drift on create --- CHANGELOG.md | 4 +-- .../resource_akamai_property_activation.go | 8 ++++-- ...esource_akamai_property_activation_test.go | 28 +++++++++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd723e5f6..17856f229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -216,8 +216,8 @@ - - +* PAPI + * Fixed an issue with the `akamai_property_activation` resource where updating it with an active or previously active property version for a configuration without a state file didn’t trigger a new property activation. diff --git a/pkg/providers/property/resource_akamai_property_activation.go b/pkg/providers/property/resource_akamai_property_activation.go index da1690e03..4abcb8721 100644 --- a/pkg/providers/property/resource_akamai_property_activation.go +++ b/pkg/providers/property/resource_akamai_property_activation.go @@ -216,7 +216,6 @@ func resourcePropertyActivationCreate(ctx context.Context, d *schema.ResourceDat activation, err := lookupActivation(ctx, client, lookupActivationRequest{ propertyID: propertyID, - version: version, network: network, activationType: map[papi.ActivationType]struct{}{ papi.ActivationTypeActivate: {}, @@ -228,7 +227,7 @@ func resourcePropertyActivationCreate(ctx context.Context, d *schema.ResourceDat } // we create a new property activation in case of no previous activation, or deleted activation - if activation == nil || activation.ActivationType == papi.ActivationTypeDeactivate { + if activation == nil || activation.ActivationType == papi.ActivationTypeDeactivate || activation.PropertyVersion != version { notifySet, err := tf.GetSetValue("contact", d) if err != nil { return diag.FromErr(err) @@ -863,7 +862,10 @@ func lookupActivation(ctx context.Context, client papi.PAPI, query lookupActivat // There is an activation in progress, if it's for the same version/network/type we can re-use it _, matchingActivationType := query.activationType[a.ActivationType] - if a.PropertyVersion == query.version && matchingActivationType && a.Network == query.network { + // If query doesn't check version, it should not filter any activation + matchingVersion := query.version == 0 || a.PropertyVersion == query.version + matchingNetwork := a.Network == query.network + if matchingVersion && matchingActivationType && matchingNetwork { // find the most recent activation var aSubmitDate, err = date.Parse(a.SubmitDate) diff --git a/pkg/providers/property/resource_akamai_property_activation_test.go b/pkg/providers/property/resource_akamai_property_activation_test.go index 25b2310bb..1192c2a01 100644 --- a/pkg/providers/property/resource_akamai_property_activation_test.go +++ b/pkg/providers/property/resource_akamai_property_activation_test.go @@ -315,6 +315,34 @@ func TestResourcePAPIPropertyActivation(t *testing.T) { }, }, }, + "property activation when other version is already active": { + init: func(m *papi.Mock) { + // first step + // create + expectGetRuleTree(m, "prp_test", 1, ruleTreeResponseValid, nil).Once() + + firstActivationOnV1 := generateActivationItemMock("atv_activation1", note, 1, papi.ActivationTypeActivate, "2020-09-28T15:04:05Z", []string{"user@example.com"}) + activationOnV2 := generateActivationItemMock("atv_activation2", note, 2, papi.ActivationTypeActivate, "2020-10-28T15:04:05Z", []string{"user@example.com"}) + expectGetActivations(m, "prp_test", papi.GetActivationsResponse{Activations: papi.ActivationsItems{Items: []*papi.Activation{activationOnV2, firstActivationOnV1}}}, nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeActivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_activation1", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_activation1", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeActivate, "", []string{"user@example.com"}, nil).Once() + // read + activationOnV1 := generateActivationItemMock("atv_activation1", note, 1, papi.ActivationTypeActivate, "2020-11-28T15:05:05Z", []string{"user@example.com"}) + allActivations := papi.GetActivationsResponse{Activations: papi.ActivationsItems{Items: []*papi.Activation{activationOnV1, activationOnV2, firstActivationOnV1}}} + expectGetActivations(m, "prp_test", allActivations, nil).Once() + + // delete + expectGetActivations(m, "prp_test", allActivations, nil).Once() + expectCreateActivation(m, "prp_test", papi.ActivationTypeDeactivate, 1, "STAGING", []string{"user@example.com"}, "", "atv_update", true, nil).Once() + expectGetActivation(m, "prp_test", "atv_update", 1, "STAGING", papi.ActivationStatusActive, papi.ActivationTypeDeactivate, "", []string{"user@example.com"}, nil).Once() + }, + steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "./testdata/TestPropertyActivation/deactivated_in_other_source/resource_property_activation.tf"), + Check: resource.TestCheckResourceAttr("akamai_property_activation.test", "version", "1"), + }, + }, + }, "activation with custom timeout - lifecycle": { init: func(m *papi.Mock) { // first step From b4a53dbad763bd0501d9764907ef79312cf31612 Mon Sep 17 00:00:00 2001 From: Chaitanya Sanjay Bhangale Date: Thu, 26 Sep 2024 15:46:47 +0000 Subject: [PATCH 49/54] SECKSD-28444 Add support for SIEM Exceptions --- CHANGELOG.md | 15 ++ .../resource_akamai_appsec_siem_settings.go | 181 ++++++++++++++++++ ...source_akamai_appsec_siem_settings_test.go | 179 ++++++++++++++++- .../SiemSettingsExceptionsEnabled.json | 14 ++ .../match_by_id_exceptions_enabled.tf | 18 ++ ...ch_by_id_exceptions_enabled_empty_input.tf | 18 ++ 6 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json create mode 100644 pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf create mode 100644 pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf diff --git a/CHANGELOG.md b/CHANGELOG.md index 17856f229..58c95f29c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,21 @@ #### FEATURES/ENHANCEMENTS: +* Appsec + * Added `expections` block to `akamai_appsec_siem_settings` resource with following nested fields + * `api_request_constraints` + * `apr_protection` + * `bot_management` + * `client_rep` + * `custom_rules` + * `ip_geo` + * `malware_protection` + * `rate` + * `url_protection` + * `slow_post` + * `waf` + + * IAM * Added data source: * `akamai_iam_group` - read the details for a group diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go index 30d3e31f3..9b964bb86 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings.go @@ -61,6 +61,98 @@ func resourceSiemSettings() *schema.Resource { Required: true, Description: "Unique identifier of the SIEM settings being modified", }, + "exceptions": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ConfigMode: schema.SchemaConfigModeAttr, + Elem: getExceptionsResource(), + Description: "Describes all the protections and actions to be excluded from SIEM events", + }, + }, + } +} + +func getExceptionsResource() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ip_geo": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include ip geo events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "bot_management": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include bot management events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "rate": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include rate events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "url_protection": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include url protection events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "slow_post": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include slow post events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "custom_rules": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include custom rules events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "waf": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include waf events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "api_request_constraints": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include api request constraints events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "client_rep": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include client reputation events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "malware_protection": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include malware protection events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, + "apr_protection": { + Type: schema.TypeSet, + Optional: true, + Description: "Whether there should be an exception to include apr protection events in SIEM", + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + }, }, } } @@ -105,6 +197,11 @@ func resourceSiemSettingsCreate(ctx context.Context, d *schema.ResourceData, m i return diag.FromErr(err) } + exceptions, err := getAllExceptions(d) + if err != nil { + return diag.FromErr(err) + } + createSiemSettings := appsec.UpdateSiemSettingsRequest{ ConfigID: configID, Version: version, @@ -113,6 +210,7 @@ func resourceSiemSettingsCreate(ctx context.Context, d *schema.ResourceData, m i FirewallPolicyIds: spIDs, EnabledBotmanSiemEvents: enableBotmanSiem, SiemDefinitionID: siemID, + Exceptions: exceptions, } _, err = client.UpdateSiemSettings(ctx, createSiemSettings) @@ -171,6 +269,10 @@ func resourceSiemSettingsRead(ctx context.Context, d *schema.ResourceData, m int return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) } + if err := setActionsFromExceptions(d, siemsettings.Exceptions); err != nil { + return diag.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + return nil } @@ -214,6 +316,11 @@ func resourceSiemSettingsUpdate(ctx context.Context, d *schema.ResourceData, m i return diag.FromErr(err) } + exceptions, err := getAllExceptions(d) + if err != nil { + return diag.FromErr(err) + } + updateSiemSettings := appsec.UpdateSiemSettingsRequest{ ConfigID: configID, Version: version, @@ -222,6 +329,7 @@ func resourceSiemSettingsUpdate(ctx context.Context, d *schema.ResourceData, m i FirewallPolicyIds: spIDs, EnabledBotmanSiemEvents: enableBotmanSiem, SiemDefinitionID: siemID, + Exceptions: exceptions, } _, err = client.UpdateSiemSettings(ctx, updateSiemSettings) @@ -261,3 +369,76 @@ func resourceSiemSettingsDelete(ctx context.Context, d *schema.ResourceData, m i } return nil } + +func getAllExceptions(d *schema.ResourceData) ([]appsec.Exception, error) { + exceptions := make([]appsec.Exception, 0) + exceptionsMap := getConfigParamProtectionMapping() + exceptionsConfig, err := tf.GetListValue("exceptions", d) + if err != nil && !errors.Is(err, tf.ErrNotFound) { + return nil, fmt.Errorf(err.Error()) + } + + for _, exception := range exceptionsConfig { + exceptionMap := exception.(map[string]interface{}) + for key := range exceptionMap { + actions := make([]string, 0) + if _, ok := exceptionsMap[key]; ok { + actionsSet, ok := exceptionMap[key].(*schema.Set) + if !ok { + return nil, fmt.Errorf("wrong type conversion: expected *schema.Set, got %T", actionsSet) + } + for _, action := range actionsSet.List() { + actions = append(actions, action.(string)) + } + if len(actions) > 0 { + exceptions = append(exceptions, appsec.Exception{Protection: exceptionsMap[key], ActionTypes: actions}) + } + } + } + } + return exceptions, nil +} + +func setActionsFromExceptions(d *schema.ResourceData, exceptions []appsec.Exception) error { + if err := d.Set("exceptions", exceptionsToState(exceptions)); err != nil { + return fmt.Errorf("%s: %s", tf.ErrValueSet, err.Error()) + } + return nil +} + +func getConfigParamProtectionMapping() map[string]string { + exceptionsMap := map[string]string{ + "bot_management": "botmanagement", + "rate": "rate", + "ip_geo": "ipgeo", + "url_protection": "urlProtection", + "slow_post": "slowpost", + "custom_rules": "customrules", + "waf": "waf", + "api_request_constraints": "apirequestconstraints", + "client_rep": "clientrep", + "malware_protection": "malwareprotection", + "apr_protection": "aprProtection", + } + return exceptionsMap +} + +func exceptionsToState(exceptions []appsec.Exception) []interface{} { + exceptionsMap := getConfigParamProtectionMapping() + out := make([]interface{}, 0, len(exceptions)) + exceptionMap := make(map[string]interface{}) + + for configParamName, configParamVal := range exceptionsMap { + for _, t := range exceptions { + if configParamVal == t.Protection { + exceptionMap[configParamName] = t.ActionTypes + break + } + } + } + if len(exceptionMap) > 0 { + out = append(out, exceptionMap) + } + + return out +} diff --git a/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go b/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go index 30a30a42d..8dc926fe0 100644 --- a/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go +++ b/pkg/providers/appsec/resource_akamai_appsec_siem_settings_test.go @@ -2,6 +2,7 @@ package appsec import ( "encoding/json" + "regexp" "testing" "github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/appsec" @@ -43,7 +44,7 @@ func TestAkamaiSiemSettings_res_basic(t *testing.T) { client.On("UpdateSiemSettings", mock.Anything, - appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}}, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, Exceptions: []appsec.Exception{}}, ).Return(&updateSiemSettingsResponse, nil) client.On("RemoveSiemSettings", @@ -69,4 +70,180 @@ func TestAkamaiSiemSettings_res_basic(t *testing.T) { client.AssertExpectations(t) }) + t.Run("match by SiemSettings ID when SIEM exceptions are added", func(t *testing.T) { + client := &appsec.Mock{} + + updateSiemSettingsResponse := appsec.UpdateSiemSettingsResponse{} + err := json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &updateSiemSettingsResponse) + require.NoError(t, err) + + getSiemSettingsResponse := appsec.GetSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &getSiemSettingsResponse) + require.NoError(t, err) + + removeSiemSettingsResponse := appsec.RemoveSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &removeSiemSettingsResponse) + require.NoError(t, err) + + config := appsec.GetConfigurationResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResConfiguration/LatestConfiguration.json"), &config) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&config, nil) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponse, nil) + + client.On("UpdateSiemSettings", + mock.Anything, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, + Exceptions: []appsec.Exception{ + { + Protection: "rate", + ActionTypes: []string{"alert"}, + }, + }}, + ).Return(&updateSiemSettingsResponse, nil) + + client.On("RemoveSiemSettings", + mock.Anything, + appsec.RemoveSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: false, EnabledBotmanSiemEvents: false, FirewallPolicyIds: []string(nil)}, + ).Return(&removeSiemSettingsResponse, nil) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("match by SiemSettings ID when SIEM exceptions are added with empty actions", func(t *testing.T) { + client := &appsec.Mock{} + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + ExpectError: regexp.MustCompile(`Error: Not enough list items`), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) + + t.Run("update after removing exceptions block", func(t *testing.T) { + client := &appsec.Mock{} + + updateSiemSettingsResponse := appsec.UpdateSiemSettingsResponse{} + err := json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &updateSiemSettingsResponse) + require.NoError(t, err) + + updateSiemSettingsResponseNoExceptions := appsec.UpdateSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettings.json"), &updateSiemSettingsResponseNoExceptions) + require.NoError(t, err) + + getSiemSettingsResponse := appsec.GetSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &getSiemSettingsResponse) + require.NoError(t, err) + + getSiemSettingsResponseNoExceptions := appsec.GetSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettings.json"), &getSiemSettingsResponseNoExceptions) + require.NoError(t, err) + + removeSiemSettingsResponse := appsec.RemoveSiemSettingsResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json"), &removeSiemSettingsResponse) + require.NoError(t, err) + + config := appsec.GetConfigurationResponse{} + err = json.Unmarshal(testutils.LoadFixtureBytes(t, "testdata/TestResConfiguration/LatestConfiguration.json"), &config) + require.NoError(t, err) + + client.On("GetConfiguration", + mock.Anything, + appsec.GetConfigurationRequest{ConfigID: 43253}, + ).Return(&config, nil).Times(8) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponse, nil).Times(2) + + client.On("UpdateSiemSettings", + mock.Anything, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, + Exceptions: []appsec.Exception{ + { + Protection: "rate", + ActionTypes: []string{"alert"}, + }, + }}, + ).Return(&updateSiemSettingsResponse, nil).Times(1) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponse, nil).Times(1) + + client.On("UpdateSiemSettings", + mock.Anything, + appsec.UpdateSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: true, EnabledBotmanSiemEvents: true, SiemDefinitionID: 1, FirewallPolicyIds: []string{"12345"}, Exceptions: []appsec.Exception{}}, + ).Return(&updateSiemSettingsResponseNoExceptions, nil).Times(1) + + client.On("GetSiemSettings", + mock.Anything, + appsec.GetSiemSettingsRequest{ConfigID: 43253, Version: 7}, + ).Return(&getSiemSettingsResponseNoExceptions, nil).Times(2) + + client.On("RemoveSiemSettings", + mock.Anything, + appsec.RemoveSiemSettingsRequest{ConfigID: 43253, Version: 7, EnableForAllPolicies: false, EnableSiem: false, EnabledBotmanSiemEvents: false, FirewallPolicyIds: []string(nil)}, + ).Return(&removeSiemSettingsResponse, nil) + + useClient(client, func() { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), + Steps: []resource.TestStep{ + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + }, + { + Config: testutils.LoadFixtureString(t, "testdata/TestResSiemSettings/match_by_id.tf"), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("akamai_appsec_siem_settings.test", "id", "43253"), + ), + }, + }, + }) + }) + + client.AssertExpectations(t) + }) } diff --git a/pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json b/pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json new file mode 100644 index 000000000..87f8531da --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResSiemSettings/SiemSettingsExceptionsEnabled.json @@ -0,0 +1,14 @@ +{ + "enableForAllPolicies": false, + "enableSiem": true, + "enabledBotmanSiemEvents": true, + "siemDefinitionId": 1, + "firewallPolicyIds": ["12345"], + "exceptions": [ + { + "actionTypes": [ + "alert" + ], + "protection": "rate" + }] +} \ No newline at end of file diff --git a/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf new file mode 100644 index 000000000..e0a553186 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled.tf @@ -0,0 +1,18 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" + cache_enabled = false +} + +resource "akamai_appsec_siem_settings" "test" { + config_id = 43253 + enable_siem = true + enable_for_all_policies = false + enable_botman_siem = true + siem_id = 1 + security_policy_ids = ["12345"] + exceptions { + rate = ["alert"] + } + +} + diff --git a/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf new file mode 100644 index 000000000..074062113 --- /dev/null +++ b/pkg/providers/appsec/testdata/TestResSiemSettings/match_by_id_exceptions_enabled_empty_input.tf @@ -0,0 +1,18 @@ +provider "akamai" { + edgerc = "../../common/testutils/edgerc" + cache_enabled = false +} + +resource "akamai_appsec_siem_settings" "test" { + config_id = 43253 + enable_siem = true + enable_for_all_policies = false + enable_botman_siem = true + siem_id = 1 + security_policy_ids = ["12345"] + exceptions { + rate = ["alert"] + bot_management = [] + } +} + From dfd2ca18cb24fc3c36b66eef2bf15eb97a4c4189 Mon Sep 17 00:00:00 2001 From: Jakub Bilski Date: Fri, 4 Oct 2024 13:36:50 +0000 Subject: [PATCH 50/54] DXE-4280 Fix assignments initialization in GTM --- pkg/providers/gtm/resource_akamai_gtm_asmap.go | 1 - pkg/providers/gtm/resource_akamai_gtm_cidrmap.go | 2 -- pkg/providers/gtm/resource_akamai_gtm_geomap.go | 2 -- 3 files changed, 5 deletions(-) diff --git a/pkg/providers/gtm/resource_akamai_gtm_asmap.go b/pkg/providers/gtm/resource_akamai_gtm_asmap.go index e0a22333f..9610639f6 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_asmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_asmap.go @@ -456,7 +456,6 @@ func populateNewASMapObject(d *schema.ResourceData, m interface{}) (*gtm.ASMap, Name: asMapName, DefaultDatacenter: >m.DatacenterBase{}, Assignments: make([]gtm.ASAssignment, 1), - Links: make([]gtm.Link, 1), } populateASMapObject(d, asObj, m) diff --git a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go index 88b91d306..39af4f338 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_cidrmap.go @@ -402,8 +402,6 @@ func populateNewCIDRMapObject(meta meta.Meta, d *schema.ResourceData, m interfac cidrObj := >m.CIDRMap{ Name: cidrMapName, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]gtm.CIDRAssignment, 0), - Links: make([]gtm.Link, 1), } populateCIDRMapObject(d, cidrObj, m) diff --git a/pkg/providers/gtm/resource_akamai_gtm_geomap.go b/pkg/providers/gtm/resource_akamai_gtm_geomap.go index e89aa91ad..dd3b8962d 100644 --- a/pkg/providers/gtm/resource_akamai_gtm_geomap.go +++ b/pkg/providers/gtm/resource_akamai_gtm_geomap.go @@ -431,8 +431,6 @@ func populateNewGeoMapObject(d *schema.ResourceData, m interface{}) (*gtm.GeoMap geoObj := >m.GeoMap{ Name: name, DefaultDatacenter: >m.DatacenterBase{}, - Assignments: make([]gtm.GeoAssignment, 1), - Links: make([]gtm.Link, 1), } populateGeoMapObject(d, geoObj, m) From 2ada15df29a3677dedad7004e1ee3d2b309f9ba9 Mon Sep 17 00:00:00 2001 From: "Dzhafarov, Dawid" Date: Mon, 7 Oct 2024 16:10:49 +0200 Subject: [PATCH 51/54] DXE-4206 Fix client initialization --- pkg/providers/property/resource_akamai_property.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/providers/property/resource_akamai_property.go b/pkg/providers/property/resource_akamai_property.go index 6bf665efb..190ebb277 100644 --- a/pkg/providers/property/resource_akamai_property.go +++ b/pkg/providers/property/resource_akamai_property.go @@ -932,6 +932,7 @@ func resourcePropertyImport(ctx context.Context, d *schema.ResourceData, m inter var property *papi.Property var err error var v int + client = Client(meta.Must(m)) if !isDefaultVersion(version) { property, v, err = fetchProperty(ctx, client, propertyID, groupID, contractID, version) } else { From 0a841a32907872a28fb46262be7507ea197e9b84 Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Fri, 4 Oct 2024 15:42:03 +0200 Subject: [PATCH 52/54] DXE-4211 Update documentation links --- docs/data-sources/data-sources.md | 30 ++++++++++++++--------------- docs/guides/get-started.md | 32 +++++++++++++++---------------- docs/index.md | 30 ++++++++++++++--------------- docs/resources/resources.md | 30 ++++++++++++++--------------- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/docs/data-sources/data-sources.md b/docs/data-sources/data-sources.md index 3792a751c..d92db7db5 100644 --- a/docs/data-sources/data-sources.md +++ b/docs/data-sources/data-sources.md @@ -8,18 +8,18 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi | Subprovider | Description | |---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/appsec-datasources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/botman-datasources) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-datasources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/cli-data-sources) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/cam-ds) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/cw-data-sources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/cl-datasources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/ds-datasources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/edns-datasources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/ew-datasources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/gtm-datasources) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/iam-datasources) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/ivm-datasources) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/nl-datasources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/pm-datasources) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/appsec-datasources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/botman-datasources) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-datasources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/cli-data-sources) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/cam-ds) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/cw-data-sources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/cl-datasources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/ds-datasources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/edns-datasources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/ew-datasources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/gtm-datasources) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/iam-datasources) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/ivm-datasources) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/nl-datasources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/pm-datasources) | Define rules and behaviors that govern your website delivery based on match criteria. | diff --git a/docs/guides/get-started.md b/docs/guides/get-started.md index 408f748a3..ba3616d3d 100644 --- a/docs/guides/get-started.md +++ b/docs/guides/get-started.md @@ -21,7 +21,7 @@ Your Akamai Terraform configuration starts with listing us as a required provide required_providers { akamai = { source = "akamai/akamai" - version = "6.4.0" + version = "6.5.0" } } } @@ -99,21 +99,21 @@ Use the table to find information about the subprovider you’re using. | Subprovider | Description | |----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +|[Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | ### Get contract and group IDs diff --git a/docs/index.md b/docs/index.md index 6e45e5721..12c00001f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,21 +35,21 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi | Subprovider | Description | |----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/configure-appsec) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-botman) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-integration-guide) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-client-lists) | Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cam) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys. | +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloud-wrapper) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-cloudlets) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-datastream) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgedns) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-edgeworkers) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-gtm) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-iam) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-ivm) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-network-lists) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/set-up-property-provisioning) | Define rules and behaviors that govern your website delivery based on match criteria. | ## Links to resources diff --git a/docs/resources/resources.md b/docs/resources/resources.md index fc4c279eb..cf8390b80 100644 --- a/docs/resources/resources.md +++ b/docs/resources/resources.md @@ -8,18 +8,18 @@ We’ve moved our documentation to the Akamai TechDocs site. Use the table to fi | Subprovider | Description | |-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| [Application Security](https://techdocs.akamai.com/terraform/v6.4/docs/appsec-resources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | -| [Bot Manager](https://techdocs.akamai.com/terraform/v6.4/docs/botman-resources) | Identify, track, and respond to bot activity on your domain or in your app. | -| [Certificates](https://techdocs.akamai.com/terraform/v6.4/docs/cps-resources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | -| [Client Lists](https://techdocs.akamai.com/terraform/v6.4/docs/cli-resources) |Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| -| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.4/docs/cam-rc) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys.| -| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.4/docs/cw-resources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| -| [Cloudlets](https://techdocs.akamai.com/terraform/v6.4/docs/cl-resources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | -| [DataStream](https://techdocs.akamai.com/terraform/v6.4/docs/ds-resources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | -| [Edge DNS](https://techdocs.akamai.com/terraform/v6.4/docs/edns-resources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | -| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.4/docs/ew-resources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | -| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.4/docs/gtm-resources) | Use load balancing to manage website and mobile performance demands. | -| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.4/docs/iam-resources) | Create users and groups, and define policies that manage access to your Akamai applications. | -| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.4/docs/ivm-resources) | Automate image and video delivery optimizations for your website visitors. | -| [Network Lists](https://techdocs.akamai.com/terraform/v6.4/docs/nl-resources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | -| [Property](https://techdocs.akamai.com/terraform/v6.4/docs/pm-resources) | Define rules and behaviors that govern your website delivery based on match criteria. | +| [Application Security](https://techdocs.akamai.com/terraform/v6.5/docs/appsec-resources) | Manage security configurations, security policies, match targets, rate policies, and firewall rules. | +| [Bot Manager](https://techdocs.akamai.com/terraform/v6.5/docs/botman-resources) | Identify, track, and respond to bot activity on your domain or in your app. | +| [Certificates](https://techdocs.akamai.com/terraform/v6.5/docs/cps-resources) | Full life cycle management of SSL certificates for your ​Akamai​ CDN applications. | +| [Client Lists](https://techdocs.akamai.com/terraform/v6.5/docs/cli-resources) |Reduce harmful security attacks by allowing only trusted IP/CIDRs, locations, autonomous system numbers, and TLS fingerprints to access your services and content.| +| [Cloud Access Manager](https://techdocs.akamai.com/terraform/v6.5/docs/cam-rc) | Enable cloud origin authentication and securely store and manage your cloud origin credentials as access keys.| +| [Cloud Wrapper](https://techdocs.akamai.com/terraform/v6.5/docs/cw-resources) | Provide your customers with a more consistent user experience by adding a custom caching layer that improves the connection between your cloud infrastructure and the Akamai platform.| +| [Cloudlets](https://techdocs.akamai.com/terraform/v6.5/docs/cl-resources) | Solve specific business challenges using value-added apps that complement ​Akamai​'s core solutions. | +| [DataStream](https://techdocs.akamai.com/terraform/v6.5/docs/ds-resources) | Monitor activity on the ​Akamai​ platform and send live log data to a destination of your choice. | +| [Edge DNS](https://techdocs.akamai.com/terraform/v6.5/docs/edns-resources) | Replace or augment your DNS infrastructure with a cloud-based authoritative DNS solution. | +| [EdgeWorkers](https://techdocs.akamai.com/terraform/v6.5/docs/ew-resources) | Execute JavaScript functions at the edge to optimize site performance and customize web experiences. | +| [Global Traffic Management](https://techdocs.akamai.com/terraform/v6.5/docs/gtm-resources) | Use load balancing to manage website and mobile performance demands. | +| [Identity and Access Management](https://techdocs.akamai.com/terraform/v6.5/docs/iam-resources) | Create users and groups, and define policies that manage access to your Akamai applications. | +| [Image and Video Manager](https://techdocs.akamai.com/terraform/v6.5/docs/ivm-resources) | Automate image and video delivery optimizations for your website visitors. | +| [Network Lists](https://techdocs.akamai.com/terraform/v6.5/docs/nl-resources) | Automate the creation, deployment, and management of lists used in ​Akamai​ security products. | +| [Property](https://techdocs.akamai.com/terraform/v6.5/docs/pm-resources) | Define rules and behaviors that govern your website delivery based on match criteria. | From fa5bbcca466b9c24df3395888529bcff98afe689 Mon Sep 17 00:00:00 2001 From: "Mazur, Michal" Date: Fri, 4 Oct 2024 16:41:01 +0200 Subject: [PATCH 53/54] DXE-4211 Update changelog --- CHANGELOG.md | 261 ++++++++------------------------------------------- 1 file changed, 39 insertions(+), 222 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58c95f29c..719f47713 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,15 @@ # RELEASE NOTES -## X.X.X (X X, X) - -#### BREAKING CHANGES: - -* PAPI - * Modified resource `akamai_properties` to properly populate fields `product_id`, `rule_format` and `note` - - - - - - - - - - +## 6.5.0 (Oct 10, 2024) #### FEATURES/ENHANCEMENTS: +* Global + * Migrated Terraform to version 1.9.5. + * Updated SDK v2 and framework libraries. + * Appsec - * Added `expections` block to `akamai_appsec_siem_settings` resource with following nested fields + * Added the `exceptions` block to the `akamai_appsec_siem_settings` resource with these nested fields: * `api_request_constraints` * `apr_protection` * `bot_management` @@ -33,232 +22,60 @@ * `slow_post` * `waf` - -* IAM - * Added data source: - * `akamai_iam_group` - read the details for a group - -* IAM - * Added data source: - * `akamai_iam_role` - read the details for a role - -* IAM - * Added data source: - * `akamai_iam_authorized_users` - read the list of authorized API client users - -* IAM - * Added data sources: - * `akamai_iam_blocked_properties` - reads blocked properties for a certain user in a group - - -* IAM - * Added below attributes to the `resource_akamai_iam_user` resource. - * Added `user_notifications` attribute to support user notifications. - * Added `enable_mfa` attribute to support authentication of type "MFA". - * Updated `enable_tfa` to an optional field. - * Added `password` attribute to allow users to set password during the creation and update of an user. - -* IAM - * Added new data source: - * `akamai_iam_allowed_apis` - read the list of APIs available to the user - - -* IAM - * Added new data source: - * `akamai_iam_cidr_block` - read the CIDR block details - - - -* IAM - * Improved date handling to use `time.Time` instead of `string` - - - - - - - - - - - - - - -* IAM - * Added new resource: - * `akamai_iam_cidr_block` - manage CIDR block assigned to the allowlist - - - - - -* IAM - * Added new resource: - * `akamai_iam_ip_allowlist` - enable or disable your account's allowlist - - - +* GTM + * Added the retry logic to the `akamai_gtm_property` resource to handle errors caused by the prolonged creation time, leading to Property Validation Failure with the "no datacenter is assigned to map target (all others)" error from the API. + * IAM - * Added new data source - * `akamai_iam_users` - read list of users with access to the account + * Added new data sources: + * `akamai_iam_accessible_groups` - reads the groups and subgroups accessible for a given user. + * `akamai_iam_account_switch_keys` - reads the account switch keys. + * `akamai_iam_allowed_apis` - reads the list of APIs available to a given user. + * `akamai_iam_authorized_users` - reads the list of authorized API client users. + * `akamai_iam_blocked_properties` - reads blocked properties for a certain user in a group. + * `akamai_iam_cidr_block` - reads details of a specified CIDR block. + * `akamai_iam_cidr_blocks` - lists all CIDR blocks available to you on your allowlist. + * `akamai_iam_group` - reads details about a given group and any of its subgroups. + * `akamai_iam_password_policy` - reads the password policy parameters. + * `akamai_iam_property_users` - lists users for a given property or include. + * `akamai_iam_role` - reads details of a specified role. + * `akamai_iam_user` - reads details of a specific user account. + * `akamai_iam_users` - lists all users with access to your account. + * `akamai_iam_users_affected_by_moving_group` - lists the users affected by moving a group. + * Added new resources: + * `akamai_iam_cidr_block` - manages CIDR block assigned to the allowlist. + * `akamai_iam_ip_allowlist` - enables or disable your account's allowlist. + * Added new attributes to the `resource_akamai_iam_user` resource. + * `user_notifications` to support user notifications. + * `enable_mfa` to support authentication of type "MFA". + * `password` to allow users to set a password when creating and updating a user. + * Made the `enable_tfa` attribute optional in the `resource_akamai_iam_user` resource. + * Added the `asset_id` schema field (an IAM identifier of a property or include) to: + * The `akamai_property` resource and data source, + * The `akamai_property_include` resource and data source. + * Improved date handling to use `time.Time` instead of `string`. * PAPI * Added a new optional param to the import id of the `akamai_edge_hostname` resource. It allows to specify the product ID of the imported hostname and save it in the state. - - - - -* Global - * Migrated Terraform to version 1.9.5 - * Updated SDKv2 and framework libraries - - -* GTM - * Added retry logic to `akamai_gtm_property` resource to handle errors caused by prolonged creation time, leading to Property Validation Failure with "no datacenter is assigned to map target (all others)" error from the API. - - - - - - - -* IAM - * Added new data source - * `akamai_iam_user` - read details about a specific user account - - - - - - - - - - - - - - - - - - - - -* IAM - * Added new data source: - * `akamai_iam_account_switch_keys` - read the account switch keys - -* IAM: - * Added new datasource: - * `akamai_iam_accessible_groups` - read the groups and subgroups accessible for provided user - - - - - - - - - - - - - - - - - - - - - -* IAM - * Added new data source: - * `akamai_iam_cidr_blocks` - read the CIDR blocks details - - - -* IAM - * Added new data source: - * `akamai_iam_password_policy` - read the password policy parameters - - -* IAM - * Added data sources: - * `akamai_iam_property_users` - lists users for property or include - * Added schema field `asset_id` (IAM identifier of a property or include) to: - * `akamai_property` resource and data source, - * `akamai_property_include` resource and data source. - - - -* IAM - * Added new data source: - * `akamai_iam_users_affected_by_moving_group` - list the users affected by moving a group - - + * Modified the `akamai_properties` resource to properly populate the `product_id`, `rule_format` and `note` fields. #### BUG FIXES: - - * PAPI * Added support for status code `429 Too Many Requests` containing `X-RateLimit-Next` header. When `X-RateLimit-Next` is present, the wait time before retry is calculated as the time difference between this header and the `Date` header. - - - - - - - - - - - - - - - - - - - - - - -* PAPI * Fixed an issue with the `akamai_property_activation` resource where updating it with an active or previously active property version for a configuration without a state file didn’t trigger a new property activation. - - - - - - - - - - - - - - - - ## 6.4.0 (Sep 04, 2024) #### FEATURES/ENHANCEMENTS: * Global - * Updated SDKv2 and framework libraries as result of updating `terraform-plugin-testing` + * Updated SDK v2 and framework libraries as a result of updating `terraform-plugin-testing`. * Appsec - * Added `request_body_inspection_limit_override` field to `akamai_appsec_advanced_settings_request_body` resource + * Added the `request_body_inspection_limit_override` field to the `akamai_appsec_advanced_settings_request_body` resource. * CPS * Added `acknowledge_post_verification_warnings` to the `akamai_cps_dv_validation` resource to allow for acknowledgement of post-verification warnings From fcbfcdb44943bda887311fe53e8076bf3eba2faf Mon Sep 17 00:00:00 2001 From: Wojciech Zagrajczuk Date: Wed, 9 Oct 2024 10:14:13 +0000 Subject: [PATCH 54/54] DXE-4287 Disable fetching property versions as part of akamai_properties datasource and deprecate problematic fields Merge in DEVEXP/terraform-provider-akamai from bugfix/DXE-4287-rollback to release/v6.5.0 --- CHANGELOG.md | 6 +- .../property/data_akamai_properties.go | 64 +++++++++++++------ .../property/data_akamai_properties_test.go | 42 +----------- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 719f47713..5b0c09b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,7 +57,6 @@ * PAPI * Added a new optional param to the import id of the `akamai_edge_hostname` resource. It allows to specify the product ID of the imported hostname and save it in the state. - * Modified the `akamai_properties` resource to properly populate the `product_id`, `rule_format` and `note` fields. #### BUG FIXES: @@ -67,6 +66,11 @@ difference between this header and the `Date` header. * Fixed an issue with the `akamai_property_activation` resource where updating it with an active or previously active property version for a configuration without a state file didn’t trigger a new property activation. +#### DEPRECATIONS: + +* PAPI + * Deprecated fields `product_id` and `rule_format` from `akamai_properties` datasource. Please use `akamai_property` to fetch this data. + ## 6.4.0 (Sep 04, 2024) #### FEATURES/ENHANCEMENTS: diff --git a/pkg/providers/property/data_akamai_properties.go b/pkg/providers/property/data_akamai_properties.go index e4b3d0402..3ebbc1082 100644 --- a/pkg/providers/property/data_akamai_properties.go +++ b/pkg/providers/property/data_akamai_properties.go @@ -33,16 +33,48 @@ func dataSourceProperties() *schema.Resource { Description: "List of properties", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "contract_id": {Type: schema.TypeString, Computed: true}, - "group_id": {Type: schema.TypeString, Computed: true}, - "latest_version": {Type: schema.TypeInt, Computed: true}, - "note": {Type: schema.TypeString, Computed: true}, - "product_id": {Type: schema.TypeString, Computed: true}, - "production_version": {Type: schema.TypeInt, Computed: true}, - "property_id": {Type: schema.TypeString, Computed: true}, - "property_name": {Type: schema.TypeString, Computed: true}, - "rule_format": {Type: schema.TypeString, Computed: true}, - "staging_version": {Type: schema.TypeInt, Computed: true}, + "contract_id": { + Type: schema.TypeString, + Computed: true, + }, + "group_id": { + Type: schema.TypeString, + Computed: true, + }, + "latest_version": { + Type: schema.TypeInt, + Computed: true, + }, + "note": { + Type: schema.TypeString, + Computed: true, + }, + "product_id": { + Type: schema.TypeString, + Computed: true, + Deprecated: "This field is deprecated. Please use `akamai_property` to get this data", + }, + "production_version": { + Type: schema.TypeInt, + Computed: true, + }, + "property_id": { + Type: schema.TypeString, + Computed: true, + }, + "property_name": { + Type: schema.TypeString, + Computed: true, + }, + "rule_format": { + Type: schema.TypeString, + Computed: true, + Deprecated: "This field is deprecated. Please use `akamai_property` to get this data", + }, + "staging_version": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -81,7 +113,7 @@ func dataPropertiesRead(ctx context.Context, d *schema.ResourceData, m interface // setting concatenated id to uniquely identify data d.SetId(groupID + contractID) - properties, err := sliceResponseProperties(ctx, meta, propertiesResponse) + properties, err := sliceResponseProperties(propertiesResponse) if err != nil { return diag.FromErr(err) } @@ -93,24 +125,20 @@ func dataPropertiesRead(ctx context.Context, d *schema.ResourceData, m interface return nil } -func sliceResponseProperties(ctx context.Context, meta meta.Meta, propertiesResponse *papi.GetPropertiesResponse) ([]map[string]interface{}, error) { +func sliceResponseProperties(propertiesResponse *papi.GetPropertiesResponse) ([]map[string]interface{}, error) { var properties []map[string]interface{} for _, item := range propertiesResponse.Properties.Items { - propVersion, err := getPropertyVersion(ctx, meta, item) - if err != nil { - return nil, err - } property := map[string]interface{}{ "contract_id": item.ContractID, "group_id": item.GroupID, "latest_version": item.LatestVersion, "note": item.Note, - "product_id": propVersion.Version.ProductID, + "product_id": nil, "production_version": decodeVersion(item.ProductionVersion), "property_id": item.PropertyID, "property_name": item.PropertyName, - "rule_format": propVersion.Version.RuleFormat, + "rule_format": nil, "staging_version": decodeVersion(item.StagingVersion), } properties = append(properties, property) diff --git a/pkg/providers/property/data_akamai_properties_test.go b/pkg/providers/property/data_akamai_properties_test.go index 469ea7da6..c83e4e102 100644 --- a/pkg/providers/property/data_akamai_properties_test.go +++ b/pkg/providers/property/data_akamai_properties_test.go @@ -14,25 +14,13 @@ func TestDataProperties(t *testing.T) { t.Run("list properties", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items, "rule_format", "prd_1") + properties := decodePropertyItems(props.Items, "", "") client.On("GetProperties", mock.Anything, papi.GetPropertiesRequest{GroupID: "grp_test", ContractID: "ctr_test"}, ).Return(&papi.GetPropertiesResponse{Properties: props}, nil) - res := &papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - ProductID: "prd_1", - RuleFormat: "rule_format", - }, - } - - client.On("GetPropertyVersion", - mock.Anything, - mock.Anything, - ).Return(res, nil) - useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), @@ -49,25 +37,13 @@ func TestDataProperties(t *testing.T) { t.Run("list properties without group prefix", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items, "rule_format", "prd_1") + properties := decodePropertyItems(props.Items, "", "") client.On("GetProperties", mock.Anything, papi.GetPropertiesRequest{GroupID: "grp_test", ContractID: "ctr_test"}, ).Return(&papi.GetPropertiesResponse{Properties: props}, nil) - res := &papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - ProductID: "prd_1", - RuleFormat: "rule_format", - }, - } - - client.On("GetPropertyVersion", - mock.Anything, - mock.Anything, - ).Return(res, nil) - useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()), @@ -84,25 +60,13 @@ func TestDataProperties(t *testing.T) { t.Run("list properties without contract prefix", func(t *testing.T) { client := &papi.Mock{} props := papi.PropertiesItems{Items: buildPapiProperties()} - properties := decodePropertyItems(props.Items, "rule_format", "prd_1") + properties := decodePropertyItems(props.Items, "", "") client.On("GetProperties", mock.Anything, papi.GetPropertiesRequest{GroupID: "grp_test", ContractID: "ctr_test"}, ).Return(&papi.GetPropertiesResponse{Properties: props}, nil) - res := &papi.GetPropertyVersionsResponse{ - Version: papi.PropertyVersionGetItem{ - ProductID: "prd_1", - RuleFormat: "rule_format", - }, - } - - client.On("GetPropertyVersion", - mock.Anything, - mock.Anything, - ).Return(res, nil) - useClient(client, nil, func() { resource.UnitTest(t, resource.TestCase{ ProtoV6ProviderFactories: testutils.NewProtoV6ProviderFactory(NewSubprovider()),