Skip to content

Commit 5a7e1f2

Browse files
committed
refactored space to space_id
1 parent 78f47f7 commit 5a7e1f2

File tree

7 files changed

+52
-29
lines changed

7 files changed

+52
-29
lines changed

mmv1/products/apigee/Space.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,28 @@ references:
1919
guides:
2020
"Managing Spaces": "https://cloud.google.com/apigee/docs/api-platform/system-administration/spaces/manage-spaces"
2121
api: "https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.spaces"
22-
docs:
23-
base_url: "organizations/{{org_id}}/spaces"
24-
self_link: "organizations/{{org_id}}/spaces/{{name}}"
22+
base_url: "{{org_id}}/spaces"
23+
create_url: "{{org_id}}/spaces?spaceId={{space_id}}"
24+
self_link: "{{org_id}}/spaces/{{space_id}}"
25+
update_verb: 'PATCH'
26+
update_mask: true
2527
import_format:
26-
- "organizations/{{org_id}}/spaces/{{name}}"
27-
- "{{org_id}}/{{name}}"
28+
- "{{org_id}}/spaces/{{space_id}}"
29+
- "{{org_id}}/{{space_id}}"
30+
autogen_async: true
2831
iam_policy:
2932
method_name_separator: ':'
30-
parent_resource_attribute: 'space'
33+
parent_resource_attribute: 'name'
3134
fetch_iam_policy_verb: 'GET'
3235
set_iam_policy_verb: 'POST'
3336
wrapped_policy_obj: false
3437
allowed_iam_role: 'roles/apigee.spaceViewer'
38+
import_format:
39+
- "{{org_id}}/spaces/{{space_id}}"
40+
- "{{org_id}}/{{space_id}}"
3541
examples:
3642
- name: "apigee_space_basic"
37-
primary_resource_id: "apigee_space"
43+
primary_resource_id: "space"
3844
vars:
3945
name: "my-space"
4046
display_name: "My Space"
@@ -44,8 +50,7 @@ parameters:
4450
- name: "orgId"
4551
type: String
4652
description: |
47-
The Apigee Organization associated with the Apigee Space,
48-
in the format `organizations/{{org_name}}`.
53+
The Apigee Organization associated with the Apigee Space, in the format `organizations/{{org_name}}`.
4954
url_param_only: true
5055
required: true
5156
immutable: true
@@ -60,8 +65,7 @@ properties:
6065
- name: "name"
6166
type: String
6267
description: |
63-
Identifier. Id of the space.
64-
This field is used as the resource name, and must follow AIP-122 guidelines.
68+
Identifier. Id of the space. This field is used as the resource name, and must follow AIP-122 guidelines.
6569
output: true
6670
- name: "displayName"
6771
type: String

mmv1/templates/terraform/examples/apigee_api_product_space.tf.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
data "google_client_config" "current" {}
22

33
resource "google_compute_network" "apigee_network" {
4-
name = "apigee-network"
4+
name = "apigee-network-{{index $.Vars "instance_name"}}"
55
}
66

77
resource "google_compute_global_address" "apigee_range" {
8-
name = "apigee-range"
8+
name = "apigee-range-{{index $.Vars "instance_name"}}"
99
purpose = "VPC_PEERING"
1010
address_type = "INTERNAL"
1111
prefix_length = 16
@@ -34,13 +34,13 @@ resource "google_apigee_instance" "apigee_instance" {
3434

3535
resource "google_apigee_space" "space" {
3636
org_id = google_apigee_organization.apigee_org.id
37-
name = "{{index $.Vars "space_name"}}"
37+
space_id = "{{index $.Vars "space_name"}}"
3838
display_name = "{{index $.Vars "space_display_name"}}"
3939
}
4040

4141
resource "google_apigee_api_product" "space_api_product" {
4242
org_id = google_apigee_organization.apigee_org.id
43-
space = google_apigee_space.space.name
43+
space = google_apigee_space.space.space_id
4444
name = "{{index $.Vars "product_name"}}"
4545
display_name = "My Space API Product"
4646

mmv1/templates/terraform/examples/apigee_space_basic.tf.tmpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
data "google_client_config" "current" {}
22

33
resource "google_compute_network" "apigee_network" {
4-
name = "apigee-network"
4+
name = "apigee-network-{{index $.Vars "name"}}"
55
}
66

77
resource "google_compute_global_address" "apigee_range" {
8-
name = "apigee-range"
8+
name = "apigee-range-{{index $.Vars "name"}}"
99
purpose = "VPC_PEERING"
1010
address_type = "INTERNAL"
1111
prefix_length = 16
@@ -28,6 +28,5 @@ resource "google_apigee_organization" "apigee_org" {
2828
resource "google_apigee_space" "space" {
2929
org_id = google_apigee_organization.apigee_org.id
3030
space_id = "{{index $.Vars "name"}}"
31-
name = "organizations/${google_apigee_organization.apigee_org.name}/spaces/{{index $.Vars "name"}}"
3231
display_name = "{{index $.Vars "display_name"}}"
3332
}

mmv1/third_party/terraform/services/apigee/resource_apigee_sharedflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func resourceApigeeSharedFlowDelete(d *schema.ResourceData, meta interface{}) er
349349
}
350350

351351
func resourceApigeeSharedFlowImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
352-
352+
353353
var id string
354354
var err error
355355

mmv1/third_party/terraform/services/apigee/resource_apigee_space_test.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@ import (
88
"github.com/hashicorp/terraform-provider-google/google/envvar"
99
)
1010

11-
func TestAccApigeeSpace_handwritten(t *testing.T) {
11+
func TestAccApigeeSpace_basicTest(t *testing.T) {
1212
t.Parallel()
1313

1414
context := map[string]interface{}{
1515
"org_id": envvar.GetTestOrgFromEnv(t),
1616
"billing_account": envvar.GetTestBillingAccountFromEnv(t),
17-
"space_name": "test-space-" + acctest.RandString(t, 10),
17+
"space_id": "test-space",
1818
"display_name": "Test Space",
19+
"random_suffix": acctest.RandString(t, 10),
1920
}
2021

2122
acctest.VcrTest(t, resource.TestCase{
2223
PreCheck: func() { acctest.AccTestPreCheck(t) },
2324
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
25+
ExternalProviders: map[string]resource.ExternalProvider{
26+
"time": {},
27+
},
2428
CheckDestroy: testAccCheckApigeeSpaceDestroyProducer(t),
2529
Steps: []resource.TestStep{
2630
{
27-
Config: testAccApigeeSpace_handwrittenConfig(context),
31+
Config: testAccApigeeSpace_basicTest(context),
2832
},
2933
{
3034
ResourceName: "google_apigee_space.primary",
@@ -35,11 +39,11 @@ func TestAccApigeeSpace_handwritten(t *testing.T) {
3539
})
3640
}
3741

38-
func testAccApigeeSpace_handwrittenConfig(context map[string]interface{}) string {
42+
func testAccApigeeSpace_basicTest(context map[string]interface{}) string {
3943
return acctest.Nprintf(`
4044
resource "google_project" "project" {
41-
project_id = "%{org_id}-%{space_name}"
42-
name = "%{org_id}-%{space_name}"
45+
project_id = "tf-test%{random_suffix}"
46+
name = "tf-test%{random_suffix}"
4347
org_id = "%{org_id}"
4448
billing_account = "%{billing_account}"
4549
deletion_policy = "DELETE"
@@ -50,9 +54,25 @@ resource "google_project_service" "apigee" {
5054
service = "apigee.googleapis.com"
5155
}
5256
57+
resource "google_project_service" "compute" {
58+
project = google_project.project.project_id
59+
service = "compute.googleapis.com"
60+
}
61+
62+
resource "google_project_service" "servicenetworking" {
63+
project = google_project.project.project_id
64+
service = "servicenetworking.googleapis.com"
65+
}
66+
67+
resource "time_sleep" "wait_120_seconds" {
68+
create_duration = "120s"
69+
depends_on = [google_project_service.compute, google_project_service.servicenetworking]
70+
}
71+
5372
resource "google_compute_network" "apigee_network" {
5473
name = "apigee-network"
5574
project = google_project.project.project_id
75+
depends_on = [time_sleep.wait_120_seconds]
5676
}
5777
5878
resource "google_compute_global_address" "apigee_range" {
@@ -82,9 +102,9 @@ resource "google_apigee_organization" "apigee_org" {
82102
83103
resource "google_apigee_space" "primary" {
84104
org_id = google_apigee_organization.apigee_org.id
85-
space_id = "%{space_name}"
86-
name = "organizations/${google_apigee_organization.apigee_org.name}/spaces/%{space_name}"
105+
space_id = "%{space_id}"
87106
display_name = "%{display_name}"
88107
}
89108
`, context)
90109
}
110+

mmv1/third_party/terraform/website/docs/r/apigee_api.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The following arguments are supported:
5353
(Required)
5454
Path to the config zip bundle.
5555

56-
* `space_id` -
56+
* `space` -
5757
(Optional)
5858
The id of the space.
5959

mmv1/third_party/terraform/website/docs/r/apigee_sharedflow.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The following arguments are supported:
3434
(Required)
3535
Path to the config zip bundle.
3636

37-
* `space_id` -
37+
* `space` -
3838
(Optional)
3939
The id of the space.
4040

0 commit comments

Comments
 (0)