From 3881d8d9bfe991f37cb258d5936465841cd82d95 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 01/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 972fdebfd4e1..f00d32b12e6b 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 16ca92847a667e4e23c363ea97e7402162589e40 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:28 +0000 Subject: [PATCH 02/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index f00d32b12e6b..2357e99082bf 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me +# # # http://www.apache.org/licenses/LICENSE-2.0 # From 3a4dadb02ea399618efde36e7187ef5ba62b660c Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:54 +0000 Subject: [PATCH 03/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 2357e99082bf..972fdebfd4e1 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -3,7 +3,6 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software From 9e812b242a078136e0f97382247b2231d62658ce Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 04/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 972fdebfd4e1..f00d32b12e6b 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 0fb83a5a744c54581ece34ba28ba5b652d2615be Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Mon, 8 Mar 2021 14:45:44 +0000 Subject: [PATCH 05/38] Added code for Apigee environment groups --- mmv1/products/apigee/api.yaml | 51 ++++++++++++++++ mmv1/products/apigee/terraform.yaml | 23 +++++++ .../apigee_environment_group.go.erb | 42 +++++++++++++ .../apigee_environment_group_basic.tf.erb | 33 ++++++++++ ...apigee_environment_group_basic_test.tf.erb | 60 +++++++++++++++++++ 5 files changed, 209 insertions(+) create mode 100644 mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb create mode 100644 mmv1/templates/terraform/examples/apigee_environment_group_basic.tf.erb create mode 100644 mmv1/templates/terraform/examples/apigee_environment_group_basic_test.tf.erb diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index f00d32b12e6b..b392f7a725b8 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -264,3 +264,54 @@ objects: 'Creating an environment': 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-environment' api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments/create' + - !ruby/object:Api::Resource + name: 'Envgroup' + base_url: 'envgroups' + create_url: '{{org_id}}/envgroups' + self_link: '{{org_id}}/envgroups/{{name}}' + async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: !ruby/object:Api::OpAsync::Result + path: 'response' + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: True + allowed: + - True + - False + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + description: | + An `Environment group` in Apigee. + parameters: + - !ruby/object:Api::Type::String + name: 'orgId' + description: | + The Apigee Organization associated with the Apigee environment group, + in the format `organizations/{{org_name}}`. + required: true + input: true + url_param_only: true + properties: + - !ruby/object:Api::Type::String + name: 'name' + description: | + The resource ID of the environment group. + required: true + - !ruby/object:Api::Type::Array + name: 'hostnames' + description: | + Hostnames of the environment group. + required: false + item_type: Api::Type::String + input: true + references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Creating an environment': + 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-environment' + api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.envgroups/create' diff --git a/mmv1/products/apigee/terraform.yaml b/mmv1/products/apigee/terraform.yaml index 25f22d9e6059..2e566b6bf726 100644 --- a/mmv1/products/apigee/terraform.yaml +++ b/mmv1/products/apigee/terraform.yaml @@ -114,6 +114,29 @@ overrides: !ruby/object:Overrides::ResourceOverrides delete_minutes: 30 custom_code: !ruby/object:Provider::Terraform::CustomCode custom_import: templates/terraform/custom_import/apigee_environment.go.erb + Envgroup: !ruby/object:Overrides::Terraform::ResourceOverride + autogen_async: true + import_format: ["{{org_id}}/envgroups/{{name}}", "{{org_id}}/{{name}}"] + examples: + - !ruby/object:Provider::Terraform::Examples + name: "apigee_environment_group_basic" + skip_test: true + - !ruby/object:Provider::Terraform::Examples + # This is a more verbose version of the above that creates all + # the resources needed for the acceptance test. + name: "apigee_environment_group_basic_test" + primary_resource_id: "apigee_environment_group" + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + skip_docs: true + # Resource creation race + skip_vcr: true + timeouts: !ruby/object:Api::Timeouts + insert_minutes: 30 + delete_minutes: 30 + custom_code: !ruby/object:Provider::Terraform::CustomCode + custom_import: templates/terraform/custom_import/apigee_environment_group.go.erb files: !ruby/object:Provider::Config::Files # These files have templating (ERB) code that will be run. # This is usually to add licensing info, autogeneration notices, etc. diff --git a/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb b/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb new file mode 100644 index 000000000000..53ce71dd84b1 --- /dev/null +++ b/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb @@ -0,0 +1,42 @@ +config := meta.(*Config) + +// current import_formats cannot import fields with forward slashes in their value +if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { + return nil, err +} + +nameParts := strings.Split(d.Get("name").(string), "/") +if len(nameParts) == 4 { + // `organizations/{{org_name}}/environments/{{name}}` + orgId := fmt.Sprintf("organizations/%s", nameParts[1]) + if err := d.Set("org_id", orgId); err != nil { + return nil, fmt.Errorf("Error setting org_id: %s", err) + } + if err := d.Set("name", nameParts[3]); err != nil { + return nil, fmt.Errorf("Error setting name: %s", err) + } +} else if len(nameParts) == 3 { + // `organizations/{{org_name}}/{{name}}` + orgId := fmt.Sprintf("organizations/%s", nameParts[1]) + if err := d.Set("org_id", orgId); err != nil { + return nil, fmt.Errorf("Error setting org_id: %s", err) + } + if err := d.Set("name", nameParts[2]); err != nil { + return nil, fmt.Errorf("Error setting name: %s", err) + } +} else { + return nil, fmt.Errorf( + "Saw %s when the name is expected to have shape %s or %s", + d.Get("name"), + "organizations/{{org_name}}/envgroups/{{name}}", + "organizations/{{org_name}}/{{name}}") +} + +// Replace import id for the resource id +id, err := replaceVars(d, config, "{{org_id}}/envgroups/{{name}}") +if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) +} +d.SetId(id) + +return []*schema.ResourceData{d}, nil diff --git a/mmv1/templates/terraform/examples/apigee_environment_group_basic.tf.erb b/mmv1/templates/terraform/examples/apigee_environment_group_basic.tf.erb new file mode 100644 index 000000000000..62aa13edfc72 --- /dev/null +++ b/mmv1/templates/terraform/examples/apigee_environment_group_basic.tf.erb @@ -0,0 +1,33 @@ +data "google_client_config" "current" {} + +resource "google_compute_network" "apigee_network" { + name = "apigee-network" +} + +resource "google_compute_global_address" "apigee_range" { + name = "apigee-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.apigee_network.id +} + +resource "google_service_networking_connection" "apigee_vpc_connection" { + network = google_compute_network.apigee_network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.apigee_range.name] +} + +resource "google_apigee_organization" "apigee_org" { + analytics_region = "us-central1" + project_id = data.google_client_config.current.project + authorized_network = google_compute_network.apigee_network.id + depends_on = [google_service_networking_connection.apigee_vpc_connection] +} + +resource "google_apigee_envgroup" "env_grp" { + name = "tf-test%{random_suffix}" + hostnames = ["abc.foo.com"] + org_id = google_apigee_organization.apigee_org.id +} + diff --git a/mmv1/templates/terraform/examples/apigee_environment_group_basic_test.tf.erb b/mmv1/templates/terraform/examples/apigee_environment_group_basic_test.tf.erb new file mode 100644 index 000000000000..818fdc40a2c7 --- /dev/null +++ b/mmv1/templates/terraform/examples/apigee_environment_group_basic_test.tf.erb @@ -0,0 +1,60 @@ +resource "google_project" "project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" +} + +resource "google_project_service" "apigee" { + project = google_project.project.project_id + service = "apigee.googleapis.com" +} + +resource "google_project_service" "compute" { + project = google_project.project.project_id + service = "compute.googleapis.com" +} + +resource "google_project_service" "servicenetworking" { + project = google_project.project.project_id + service = "servicenetworking.googleapis.com" +} + +resource "google_compute_network" "apigee_network" { + name = "apigee-network" + project = google_project.project.project_id + depends_on = [google_project_service.compute] +} + +resource "google_compute_global_address" "apigee_range" { + name = "apigee-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.apigee_network.id + project = google_project.project.project_id +} + +resource "google_service_networking_connection" "apigee_vpc_connection" { + network = google_compute_network.apigee_network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.apigee_range.name] + depends_on = [google_project_service.servicenetworking] +} + +resource "google_apigee_organization" "apigee_org" { + analytics_region = "us-central1" + project_id = google_project.project.project_id + authorized_network = google_compute_network.apigee_network.id + depends_on = [ + google_service_networking_connection.apigee_vpc_connection, + google_project_service.apigee, + ] +} + +resource "google_apigee_envgroup" "<%= ctx[:primary_resource_id] %>" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + hostnames = ["abc.foo.com"] +} + From f0807a467b459aceb5af9cfbc9950f8b1744d88c Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Mon, 8 Mar 2021 15:50:51 +0000 Subject: [PATCH 06/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index b392f7a725b8..06d4493cce66 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 2576422a7672e08ec1b159a30e0287d4c61ed41b Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 07/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 06d4493cce66..b392f7a725b8 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From ded1602ddbd1a9d51aaacee330a2ad3b96ae0402 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:28 +0000 Subject: [PATCH 08/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index b392f7a725b8..cc9be7cc9a13 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me +# # # http://www.apache.org/licenses/LICENSE-2.0 # From dacf03761e482ec534d4276bd4027069939eefdf Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:54 +0000 Subject: [PATCH 09/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index cc9be7cc9a13..06d4493cce66 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -3,7 +3,6 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software From 739f7d520ad8e46d1fe3f8c0cd9d0921d9a073fc Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 10/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 06d4493cce66..b392f7a725b8 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From f4081043701ea87d4d04e8f706cc31af3bd8f278 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 9 Mar 2021 14:39:20 +0000 Subject: [PATCH 11/38] Incorporating review comments for Apigee environment groups --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index b392f7a725b8..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -303,13 +303,13 @@ objects: description: | The resource ID of the environment group. required: true + input: true - !ruby/object:Api::Type::Array name: 'hostnames' description: | Hostnames of the environment group. required: false item_type: Api::Type::String - input: true references: !ruby/object:Api::Resource::ReferenceLinks guides: 'Creating an environment': From 5b94a752589c2a70855875bc4fdffc87e0583fa5 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 9 Mar 2021 14:39:40 +0000 Subject: [PATCH 12/38] Incorporating review comments for Apigee environment groups --- .../terraform/custom_import/apigee_environment_group.go.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb b/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb index 53ce71dd84b1..51f7eba9a2a1 100644 --- a/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb +++ b/mmv1/templates/terraform/custom_import/apigee_environment_group.go.erb @@ -7,7 +7,7 @@ if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { nameParts := strings.Split(d.Get("name").(string), "/") if len(nameParts) == 4 { - // `organizations/{{org_name}}/environments/{{name}}` + // `organizations/{{org_name}}/envgroups/{{name}}` orgId := fmt.Sprintf("organizations/%s", nameParts[1]) if err := d.Set("org_id", orgId); err != nil { return nil, fmt.Errorf("Error setting org_id: %s", err) From 514f00f6f3821863310f0f4def6a1233ea7439bf Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 9 Mar 2021 22:17:24 +0000 Subject: [PATCH 13/38] Update reverse_check_membership.sh --- .../terraform-vcr-community/reverse_check_membership.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/containers/terraform-vcr-community/reverse_check_membership.sh b/.ci/containers/terraform-vcr-community/reverse_check_membership.sh index ec10b52697a7..48d8ec02748c 100755 --- a/.ci/containers/terraform-vcr-community/reverse_check_membership.sh +++ b/.ci/containers/terraform-vcr-community/reverse_check_membership.sh @@ -13,7 +13,7 @@ if $(echo $USER | fgrep -wq -e ndmckinley -e danawillow -e emilymye -e megan07 - exit 0 else echo "Checking GCP org membership" - GCP_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) + GCP_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) if [ "$GCP_MEMBER" != "404" ]; then echo "User is a GCP org member, exiting" exit 0 @@ -30,4 +30,4 @@ else fi # Pass PR number to runner, which expects it -sh /run_vcr_tests.sh $PR_NUMBER \ No newline at end of file +sh /run_vcr_tests.sh $PR_NUMBER From dfd3159a62facc586ba0920b1e420d2108a3a77c Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 9 Mar 2021 22:23:13 +0000 Subject: [PATCH 14/38] Update reverse_check_membership.sh --- .../terraform-vcr-community/reverse_check_membership.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/containers/terraform-vcr-community/reverse_check_membership.sh b/.ci/containers/terraform-vcr-community/reverse_check_membership.sh index 48d8ec02748c..a278d1f27e8d 100755 --- a/.ci/containers/terraform-vcr-community/reverse_check_membership.sh +++ b/.ci/containers/terraform-vcr-community/reverse_check_membership.sh @@ -19,7 +19,7 @@ else exit 0 else echo "Checking googlers org membership" - GOOGLERS_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) + GOOGLERS_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) if [ "$GOOGLERS_MEMBER" != "404" ]; then echo "User is a googlers org member, exiting" exit 0 From c499c9d4830cf9d3103c6bf72bf22313cf00dac6 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 9 Mar 2021 22:24:21 +0000 Subject: [PATCH 15/38] Update check_membership.sh --- .ci/containers/terraform-vcr-tester/check_membership.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/containers/terraform-vcr-tester/check_membership.sh b/.ci/containers/terraform-vcr-tester/check_membership.sh index 6eb64a20fa82..a27050b4fabb 100755 --- a/.ci/containers/terraform-vcr-tester/check_membership.sh +++ b/.ci/containers/terraform-vcr-tester/check_membership.sh @@ -11,12 +11,12 @@ if $(echo $USER | fgrep -wq -e ndmckinley -e danawillow -e emilymye -e megan07 - echo "User is on the list, not skipping." else echo "Checking GCP org membership" - GCP_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) + GCP_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) if [ "$GCP_MEMBER" != "404" ]; then echo "User is a GCP org member, continuing" else echo "Checking googlers org membership" - GOOGLERS_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) + GOOGLERS_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) if [ "$GOOGLERS_MEMBER" != "404" ]; then echo "User is a googlers org member, continuing" else @@ -27,4 +27,4 @@ else fi # Pass PR number to runner, which expects it -sh /run_vcr_tests.sh $PR_NUMBER \ No newline at end of file +sh /run_vcr_tests.sh $PR_NUMBER From 0ee64f67b1fdc6fd6481abb392e98af49f730281 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 9 Mar 2021 22:24:30 +0000 Subject: [PATCH 16/38] Update mmv1/products/apigee/api.yaml Co-authored-by: Sam Levenick --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 2167faac8c28ee95f77cd7f4e873db7adcbdd80c Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 17/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 3432e74fbc7394756a6400a081d2012b036f70e6 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:28 +0000 Subject: [PATCH 18/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..386da0be519e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me +# # # http://www.apache.org/licenses/LICENSE-2.0 # From e0af3d510aa19b471dea5d8933a84653665677b4 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:54 +0000 Subject: [PATCH 19/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 386da0be519e..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -3,7 +3,6 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software From bbf67fe92122864975d904fea8cd290867fe9019 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 20/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From a2e09a77d4178b089e8ab90285d19ba7792a980f Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Mon, 8 Mar 2021 15:50:51 +0000 Subject: [PATCH 21/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 39a0d835f1d3dac09fac3d1cfdbec157480f91df Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 22/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 76bc59b9f691da475b54b9cd5fc1b7580bc3b2eb Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:28 +0000 Subject: [PATCH 23/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..386da0be519e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me +# # # http://www.apache.org/licenses/LICENSE-2.0 # From 032df6d849f47f5797f53e548ac6d864279b49b3 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:54 +0000 Subject: [PATCH 24/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 386da0be519e..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -3,7 +3,6 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software From 78b3a33fcb16cfa98f6d682a0b83576af43a9795 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 25/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 41571030fbbf956ef7d6b040aabf9345b568804a Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:28 +0000 Subject: [PATCH 26/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..386da0be519e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me +# # # http://www.apache.org/licenses/LICENSE-2.0 # From 0a43f81b001edc414b8a53886a966036d75b481f Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:54 +0000 Subject: [PATCH 27/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 386da0be519e..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -3,7 +3,6 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software From c8f89b17e49e54b541904b278a3aebce5e84d95d Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 28/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 5fc1b0a52d55bca29f23723786ef7eef331e8843 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Mon, 8 Mar 2021 15:50:51 +0000 Subject: [PATCH 29/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 52708246fbb19311b4c6c180aa9865ada8c13445 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 30/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 3c46eb7e4656a6ef49081232a486b0690aed497d Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:28 +0000 Subject: [PATCH 31/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..386da0be519e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me +# # # http://www.apache.org/licenses/LICENSE-2.0 # From 8ad09f70d223c6bc400e013588eaf7eab0597de2 Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:36:54 +0000 Subject: [PATCH 32/38] Update api.yaml --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 386da0be519e..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -3,7 +3,6 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software From fa2cf8fa47ace724f023aa659d0e5b0a4e190fb8 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 2 Mar 2021 22:23:29 +0000 Subject: [PATCH 33/38] Added code for Apigee Environment --- mmv1/products/apigee/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..ae7ae3737d61 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,6 +2,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at +#me # # http://www.apache.org/licenses/LICENSE-2.0 # From 188448961e51b0f6dfc9eaa23c1d7b4b0058846c Mon Sep 17 00:00:00 2001 From: Priya Saxena <58476126+priya-saxena21@users.noreply.github.com> Date: Tue, 9 Mar 2021 22:24:30 +0000 Subject: [PATCH 34/38] Update mmv1/products/apigee/api.yaml Co-authored-by: Sam Levenick --- mmv1/products/apigee/api.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index ae7ae3737d61..4bce18f30f5e 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -#me # # http://www.apache.org/licenses/LICENSE-2.0 # From d9672a110b8bc231711c194bf85d874d12afa338 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 9 Mar 2021 22:58:21 +0000 Subject: [PATCH 35/38] fixing .ci errors --- .../terraform-vcr-community/reverse_check_membership.sh | 6 +++--- .ci/containers/terraform-vcr-tester/check_membership.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ci/containers/terraform-vcr-community/reverse_check_membership.sh b/.ci/containers/terraform-vcr-community/reverse_check_membership.sh index a278d1f27e8d..ec10b52697a7 100755 --- a/.ci/containers/terraform-vcr-community/reverse_check_membership.sh +++ b/.ci/containers/terraform-vcr-community/reverse_check_membership.sh @@ -13,13 +13,13 @@ if $(echo $USER | fgrep -wq -e ndmckinley -e danawillow -e emilymye -e megan07 - exit 0 else echo "Checking GCP org membership" - GCP_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) + GCP_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) if [ "$GCP_MEMBER" != "404" ]; then echo "User is a GCP org member, exiting" exit 0 else echo "Checking googlers org membership" - GOOGLERS_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) + GOOGLERS_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) if [ "$GOOGLERS_MEMBER" != "404" ]; then echo "User is a googlers org member, exiting" exit 0 @@ -30,4 +30,4 @@ else fi # Pass PR number to runner, which expects it -sh /run_vcr_tests.sh $PR_NUMBER +sh /run_vcr_tests.sh $PR_NUMBER \ No newline at end of file diff --git a/.ci/containers/terraform-vcr-tester/check_membership.sh b/.ci/containers/terraform-vcr-tester/check_membership.sh index a27050b4fabb..6eb64a20fa82 100755 --- a/.ci/containers/terraform-vcr-tester/check_membership.sh +++ b/.ci/containers/terraform-vcr-tester/check_membership.sh @@ -11,12 +11,12 @@ if $(echo $USER | fgrep -wq -e ndmckinley -e danawillow -e emilymye -e megan07 - echo "User is on the list, not skipping." else echo "Checking GCP org membership" - GCP_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) + GCP_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/GoogleCloudPlatform/members/$USER -o /dev/null) if [ "$GCP_MEMBER" != "404" ]; then echo "User is a GCP org member, continuing" else echo "Checking googlers org membership" - GOOGLERS_MEMBER=$(curl -sw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) + GOOGLERS_MEMBER=$(curl -Lsw '%{http_code}' -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/orgs/googlers/members/$USER -o /dev/null) if [ "$GOOGLERS_MEMBER" != "404" ]; then echo "User is a googlers org member, continuing" else @@ -27,4 +27,4 @@ else fi # Pass PR number to runner, which expects it -sh /run_vcr_tests.sh $PR_NUMBER +sh /run_vcr_tests.sh $PR_NUMBER \ No newline at end of file From 607467d1bbeeed8726de874781e6ad0564b33e78 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 16 Mar 2021 15:25:02 +0000 Subject: [PATCH 36/38] added code for instance attachments --- mmv1/products/apigee/api.yaml | 44 +++++++++++ mmv1/products/apigee/terraform.yaml | 23 ++++++ .../apigee_instance_attachment.go.erb | 42 +++++++++++ .../apigee_instance_attachment_basic.tf.erb | 71 ++++++++++++++++++ ...igee_instance_attachment_basic_test.tf.erb | 75 +++++++++++++++++++ 5 files changed, 255 insertions(+) create mode 100644 mmv1/templates/terraform/custom_import/apigee_instance_attachment.go.erb create mode 100644 mmv1/templates/terraform/examples/apigee_instance_attachment_basic.tf.erb create mode 100644 mmv1/templates/terraform/examples/apigee_instance_attachment_basic_test.tf.erb diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index 4bce18f30f5e..a7c5076b3ab8 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -314,3 +314,47 @@ objects: 'Creating an environment': 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-environment' api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.envgroups/create' + - !ruby/object:Api::Resource + name: 'InstanceAttachment' + base_url: '{{instance_id}}/attachments' + #create_url: '{{instance_id}}/attachments' + self_link: '{{instance_id}}/attachments/{{name}}' + async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: !ruby/object:Api::OpAsync::Result + path: 'response' + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: True + allowed: + - True + - False + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + input: true + description: | + An `Instance attachment` in Apigee. + parameters: + - !ruby/object:Api::Type::String + name: 'instanceId' + description: | + The Apigee instance associated with the Apigee environment, + in the format `organisations/{{org_name}}/instances/{{instance_name}}`. + required: true + url_param_only: true + properties: + - !ruby/object:Api::Type::String + name: 'environment' + description: | + The resource ID of the environment. + required: true + references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Creating an environment': + 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-environment' + api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.instances.attachments/create' diff --git a/mmv1/products/apigee/terraform.yaml b/mmv1/products/apigee/terraform.yaml index 2e566b6bf726..3915ce848c29 100644 --- a/mmv1/products/apigee/terraform.yaml +++ b/mmv1/products/apigee/terraform.yaml @@ -137,6 +137,29 @@ overrides: !ruby/object:Overrides::ResourceOverrides delete_minutes: 30 custom_code: !ruby/object:Provider::Terraform::CustomCode custom_import: templates/terraform/custom_import/apigee_environment_group.go.erb + InstanceAttachment: !ruby/object:Overrides::Terraform::ResourceOverride + autogen_async: true + import_format: ["{{instance_id}}/attachments/{{name}}", "{{instance_id}}/{{name}}"] + examples: + - !ruby/object:Provider::Terraform::Examples + name: "apigee_instance_attachment_basic" + skip_test: true + - !ruby/object:Provider::Terraform::Examples + # This is a more verbose version of the above that creates all + # the resources needed for the acceptance test. + name: "apigee_instance_attachment_basic_test" + primary_resource_id: "apigee_instance_attachment" + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + skip_docs: true + # Resource creation race + skip_vcr: true + timeouts: !ruby/object:Api::Timeouts + insert_minutes: 30 + delete_minutes: 30 + custom_code: !ruby/object:Provider::Terraform::CustomCode + custom_import: templates/terraform/custom_import/apigee_instance_attachment.go.erb files: !ruby/object:Provider::Config::Files # These files have templating (ERB) code that will be run. # This is usually to add licensing info, autogeneration notices, etc. diff --git a/mmv1/templates/terraform/custom_import/apigee_instance_attachment.go.erb b/mmv1/templates/terraform/custom_import/apigee_instance_attachment.go.erb new file mode 100644 index 000000000000..61f16f8c214e --- /dev/null +++ b/mmv1/templates/terraform/custom_import/apigee_instance_attachment.go.erb @@ -0,0 +1,42 @@ +config := meta.(*Config) + +// current import_formats cannot import fields with forward slashes in their value +if err := parseImportId([]string{"(?P.+)"}, d, config); err != nil { + return nil, err +} + +nameParts := strings.Split(d.Get("name").(string), "/") +if len(nameParts) == 5 { + // `organizations/{{org_name}}/instances/{{instance_name}}/attachments` + orgId := fmt.Sprintf("organizations/%s", nameParts[1]) + if err := d.Set("org_id", orgId); err != nil { + return nil, fmt.Errorf("Error setting org_id: %s", err) + } + if err := d.Set("instance_name", nameParts[4]); err != nil { + return nil, fmt.Errorf("Error setting name: %s", err) + } +} else if len(nameParts) == 4 { + // `organizations/{{org_name}}/instances/{{instance_name}}` + orgId := fmt.Sprintf("organizations/%s", nameParts[1]) + if err := d.Set("org_id", orgId); err != nil { + return nil, fmt.Errorf("Error setting org_id: %s", err) + } + if err := d.Set("instance_name", nameParts[3]); err != nil { + return nil, fmt.Errorf("Error setting name: %s", err) + } +} else { + return nil, fmt.Errorf( + "Saw %s when the name is expected to have shape %s or %s", + d.Get("name"), + "organizations/{{org_name}}/instances/{{instance_name}}/attachments", + "organizations/{{org_name}}/instances/{{instance_name}}") +} + +// Replace import id for the resource id +id, err := replaceVars(d, config, "{{org_id}}/instances/{{instance_name}}/attachments") +if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) +} +d.SetId(id) + +return []*schema.ResourceData{d}, nil diff --git a/mmv1/templates/terraform/examples/apigee_instance_attachment_basic.tf.erb b/mmv1/templates/terraform/examples/apigee_instance_attachment_basic.tf.erb new file mode 100644 index 000000000000..262ebcad5c48 --- /dev/null +++ b/mmv1/templates/terraform/examples/apigee_instance_attachment_basic.tf.erb @@ -0,0 +1,71 @@ +resource "google_project" "project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" +} + +resource "google_project_service" "apigee" { + project = google_project.project.project_id + service = "apigee.googleapis.com" +} + +resource "google_project_service" "compute" { + project = google_project.project.project_id + service = "compute.googleapis.com" +} + +resource "google_project_service" "servicenetworking" { + project = google_project.project.project_id + service = "servicenetworking.googleapis.com" +} + +resource "google_compute_network" "apigee_network" { + name = "apigee-network" + project = google_project.project.project_id + depends_on = [google_project_service.compute] +} + +resource "google_compute_global_address" "apigee_range" { + name = "apigee-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.apigee_network.id + project = google_project.project.project_id +} + +resource "google_service_networking_connection" "apigee_vpc_connection" { + network = google_compute_network.apigee_network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.apigee_range.name] + depends_on = [google_project_service.servicenetworking] +} + +resource "google_apigee_organization" "apigee_org" { + analytics_region = "us-central1" + project_id = google_project.project.project_id + authorized_network = google_compute_network.apigee_network.id + depends_on = [ + google_service_networking_connection.apigee_vpc_connection, + google_project_service.apigee, + ] +} + +resource "google_apigee_instance" "apigee_ins" { + name = "tf-test%{random_suffix}" + location = "us-central1-b" + org_id = google_apigee_organization.apigee_org.id +} + +resource "google_apigee_environment" "apigee_env" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + description = "Apigee Environment" + display_name = "environment-1" +} + +resource "google_apigee_instance_attachment" "<%= ctx[:primary_resource_id] %>" { + instance_id = google_apigee_instance.apigee_ins.id + environment = google_apigee_environment.apigee_env.id +} diff --git a/mmv1/templates/terraform/examples/apigee_instance_attachment_basic_test.tf.erb b/mmv1/templates/terraform/examples/apigee_instance_attachment_basic_test.tf.erb new file mode 100644 index 000000000000..d073dabd9b3c --- /dev/null +++ b/mmv1/templates/terraform/examples/apigee_instance_attachment_basic_test.tf.erb @@ -0,0 +1,75 @@ +resource "google_project" "project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" +} + +resource "google_project_service" "apigee" { + project = google_project.project.project_id + service = "apigee.googleapis.com" +} + +resource "google_project_service" "compute" { + project = google_project.project.project_id + service = "compute.googleapis.com" +} + +resource "google_project_service" "servicenetworking" { + project = google_project.project.project_id + service = "servicenetworking.googleapis.com" +} + +resource "google_compute_network" "apigee_network" { + name = "apigee-network" + project = google_project.project.project_id + depends_on = [google_project_service.compute] +} + +resource "google_compute_global_address" "apigee_range" { + name = "apigee-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.apigee_network.id + project = google_project.project.project_id +} + +resource "google_service_networking_connection" "apigee_vpc_connection" { + network = google_compute_network.apigee_network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.apigee_range.name] + depends_on = [google_project_service.servicenetworking] +} + +resource "google_apigee_organization" "apigee_org" { + analytics_region = "us-central1" + project_id = google_project.project.project_id + authorized_network = google_compute_network.apigee_network.id + depends_on = [ + google_service_networking_connection.apigee_vpc_connection, + google_project_service.apigee, + ] +} + +resource "google_apigee_instance" "apigee_instance" { + name = "tf-test%{random_suffix}" + location = "us-central1-b" + org_id = google_apigee_organization.apigee_org.id +} + +resource "google_apigee_environment" "apigee_env" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + description = "Apigee Environment" + display_name = "environment-1" +} + +resource "google_apigee_instance_attachment" "<%= ctx[:primary_resource_id] %>" { + instance_id = google_apigee_instance.apigee_instance.id + environment = "tf0-test%{random_suffix}" + depends_on = [ + google_apigee_instance.apigee_instance, + google_apigee_environment.apigee_env, + ] +} From 34f0fc3c7557aeaa0c6fdc1695b96be66324a193 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 30 Mar 2021 22:19:29 +0000 Subject: [PATCH 37/38] Added new resource for environment groups attachment --- mmv1/products/apigee/api.yaml | 50 +++++++++++++ mmv1/products/apigee/terraform.yaml | 24 +++++++ ...apigee_environment_group_attachment.go.erb | 18 +++++ ..._environment_group_attachment_basic.tf.erb | 71 +++++++++++++++++++ ...ronment_group_attachment_basic_test.tf.erb | 71 +++++++++++++++++++ 5 files changed, 234 insertions(+) create mode 100644 mmv1/templates/terraform/custom_import/apigee_environment_group_attachment.go.erb create mode 100644 mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic.tf.erb create mode 100644 mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic_test.tf.erb diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index dc2d29bdfd46..b9384922485c 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -363,3 +363,53 @@ objects: 'Creating an environment': 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-environment' api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.instances.attachments/create' + - !ruby/object:Api::Resource + name: 'EnvgroupAttachment' + base_url: '{{envgroup_id}}/attachments' + create_url: '{{envgroup_id}}/attachments' + delete_url: '{{envgroup_id}}/attachments/{{name}}' + self_link: '{{envgroup_id}}/attachments/{{name}}' + async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: 'name' + base_url: '{{op_id}}' + wait_ms: 1000 + result: !ruby/object:Api::OpAsync::Result + path: 'response' + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: 'done' + complete: True + allowed: + - True + - False + error: !ruby/object:Api::OpAsync::Error + path: 'error' + message: 'message' + input: true + description: | + An `Environment Group attachment` in Apigee. + parameters: + - !ruby/object:Api::Type::String + name: 'envgroupId' + description: | + The Apigee environment group associated with the Apigee environment, + in the format `organisations/{{org_name}}/envgroups/{{envgroup_name}}`. + required: true + url_param_only: true + properties: + - !ruby/object:Api::Type::String + name: 'environment' + description: | + The resource ID of the environment. + required: true + - !ruby/object:Api::Type::String + name: 'name' + description: | + The name of the newly created attachment (output parameter). + output: true + references: !ruby/object:Api::Resource::ReferenceLinks + guides: + 'Creating an environment': + 'https://cloud.google.com/apigee/docs/api-platform/get-started/create-environment' + api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.envgroups.attachments/create' diff --git a/mmv1/products/apigee/terraform.yaml b/mmv1/products/apigee/terraform.yaml index 2e6a4f78d393..de423f977481 100644 --- a/mmv1/products/apigee/terraform.yaml +++ b/mmv1/products/apigee/terraform.yaml @@ -161,6 +161,30 @@ overrides: !ruby/object:Overrides::ResourceOverrides delete_minutes: 30 custom_code: !ruby/object:Provider::Terraform::CustomCode custom_import: templates/terraform/custom_import/apigee_instance_attachment.go.erb + EnvgroupAttachment: !ruby/object:Overrides::Terraform::ResourceOverride + autogen_async: true + import_format: ["{{envgroup_id}}/attachments/{{name}}", "{{envgroup_id}}/{{name}}"] + delete_url: '{{envgroup_id}}/attachments/{{name}}' + examples: + - !ruby/object:Provider::Terraform::Examples + name: "apigee_environment_group_attachment_basic" + skip_test: true + - !ruby/object:Provider::Terraform::Examples + # This is a more verbose version of the above that creates all + # the resources needed for the acceptance test. + name: "apigee_environment_group_attachment_basic_test" + primary_resource_id: "apigee_environment_group_attachment" + test_env_vars: + org_id: :ORG_ID + billing_account: :BILLING_ACCT + skip_docs: true + # Resource creation race + skip_vcr: true + timeouts: !ruby/object:Api::Timeouts + insert_minutes: 30 + delete_minutes: 30 + custom_code: !ruby/object:Provider::Terraform::CustomCode + custom_import: templates/terraform/custom_import/apigee_environment_group_attachment.go.erb files: !ruby/object:Provider::Config::Files # These files have templating (ERB) code that will be run. # This is usually to add licensing info, autogeneration notices, etc. diff --git a/mmv1/templates/terraform/custom_import/apigee_environment_group_attachment.go.erb b/mmv1/templates/terraform/custom_import/apigee_environment_group_attachment.go.erb new file mode 100644 index 000000000000..9f50d60cdd73 --- /dev/null +++ b/mmv1/templates/terraform/custom_import/apigee_environment_group_attachment.go.erb @@ -0,0 +1,18 @@ +config := meta.(*Config) + +// current import_formats cannot import fields with forward slashes in their value +if err := parseImportId([]string{ + "(?P.+)/attachments/(?P.+)", + "(?P.+)/(?P.+)", + }, d, config); err != nil { + return nil, err + } + +// Replace import id for the resource id +id, err := replaceVars(d, config, "{{envgroup_id}}/attachments/{{name}}") +if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) +} +d.SetId(id) + +return []*schema.ResourceData{d}, nil diff --git a/mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic.tf.erb b/mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic.tf.erb new file mode 100644 index 000000000000..3c01f51b9890 --- /dev/null +++ b/mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic.tf.erb @@ -0,0 +1,71 @@ +resource "google_project" "project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" +} + +resource "google_project_service" "apigee" { + project = google_project.project.project_id + service = "apigee.googleapis.com" +} + +resource "google_project_service" "compute" { + project = google_project.project.project_id + service = "compute.googleapis.com" +} + +resource "google_project_service" "servicenetworking" { + project = google_project.project.project_id + service = "servicenetworking.googleapis.com" +} + +resource "google_compute_network" "apigee_network" { + name = "apigee-network" + project = google_project.project.project_id + depends_on = [google_project_service.compute] +} + +resource "google_compute_global_address" "apigee_range" { + name = "apigee-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.apigee_network.id + project = google_project.project.project_id +} + +resource "google_service_networking_connection" "apigee_vpc_connection" { + network = google_compute_network.apigee_network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.apigee_range.name] + depends_on = [google_project_service.servicenetworking] +} + +resource "google_apigee_organization" "apigee_org" { + analytics_region = "us-central1" + project_id = google_project.project.project_id + authorized_network = google_compute_network.apigee_network.id + depends_on = [ + google_service_networking_connection.apigee_vpc_connection, + google_project_service.apigee, + ] +} + +resource "google_apigee_envgroup" "apigee_envgroup" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + hostnames = ["abc.foo.com"] +} + +resource "google_apigee_environment" "apigee_env" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + description = "Apigee Environment" + display_name = "tf-test%{random_suffix}" +} + +resource "google_apigee_envgroup_attachment" "<%= ctx[:primary_resource_id] %>" { + envgroup_id = google_apigee_envgroup.apigee_envgroup.name + environment = google_apigee_environment.apigee_env.name +} diff --git a/mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic_test.tf.erb b/mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic_test.tf.erb new file mode 100644 index 000000000000..ec1b9d8182b8 --- /dev/null +++ b/mmv1/templates/terraform/examples/apigee_environment_group_attachment_basic_test.tf.erb @@ -0,0 +1,71 @@ +resource "google_project" "project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" +} + +resource "google_project_service" "apigee" { + project = google_project.project.project_id + service = "apigee.googleapis.com" +} + +resource "google_project_service" "compute" { + project = google_project.project.project_id + service = "compute.googleapis.com" +} + +resource "google_project_service" "servicenetworking" { + project = google_project.project.project_id + service = "servicenetworking.googleapis.com" +} + +resource "google_compute_network" "apigee_network" { + name = "apigee-network" + project = google_project.project.project_id + depends_on = [google_project_service.compute] +} + +resource "google_compute_global_address" "apigee_range" { + name = "apigee-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.apigee_network.id + project = google_project.project.project_id +} + +resource "google_service_networking_connection" "apigee_vpc_connection" { + network = google_compute_network.apigee_network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.apigee_range.name] + depends_on = [google_project_service.servicenetworking] +} + +resource "google_apigee_organization" "apigee_org" { + analytics_region = "us-central1" + project_id = google_project.project.project_id + authorized_network = google_compute_network.apigee_network.id + depends_on = [ + google_service_networking_connection.apigee_vpc_connection, + google_project_service.apigee, + ] +} + +resource "google_apigee_envgroup" "apigee_envgroup" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + hostnames = ["abc.foo.com"] +} + +resource "google_apigee_environment" "apigee_env" { + org_id = google_apigee_organization.apigee_org.id + name = "tf-test%{random_suffix}" + description = "Apigee Environment" + display_name = "tf-test%{random_suffix}" +} + +resource "google_apigee_envgroup_attachment" "<%= ctx[:primary_resource_id] %>" { + envgroup_id = google_apigee_envgroup.apigee_envgroup.id + environment = google_apigee_environment.apigee_env.name +} From b3dc97bbd65806e4acd76a3d57e911dd58db1cb7 Mon Sep 17 00:00:00 2001 From: Priya Saxena Date: Tue, 6 Apr 2021 16:16:33 +0000 Subject: [PATCH 38/38] Incorporating review comments --- mmv1/products/apigee/api.yaml | 2 +- mmv1/products/apigee/terraform.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mmv1/products/apigee/api.yaml b/mmv1/products/apigee/api.yaml index b9384922485c..6c3e66c6d077 100644 --- a/mmv1/products/apigee/api.yaml +++ b/mmv1/products/apigee/api.yaml @@ -394,7 +394,7 @@ objects: name: 'envgroupId' description: | The Apigee environment group associated with the Apigee environment, - in the format `organisations/{{org_name}}/envgroups/{{envgroup_name}}`. + in the format `organizations/{{org_name}}/envgroups/{{envgroup_name}}`. required: true url_param_only: true properties: diff --git a/mmv1/products/apigee/terraform.yaml b/mmv1/products/apigee/terraform.yaml index de423f977481..038eecbc961e 100644 --- a/mmv1/products/apigee/terraform.yaml +++ b/mmv1/products/apigee/terraform.yaml @@ -165,6 +165,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides autogen_async: true import_format: ["{{envgroup_id}}/attachments/{{name}}", "{{envgroup_id}}/{{name}}"] delete_url: '{{envgroup_id}}/attachments/{{name}}' + skip_sweeper: true examples: - !ruby/object:Provider::Terraform::Examples name: "apigee_environment_group_attachment_basic"