Skip to content

Commit 3e68605

Browse files
Sachin-RungtaNandiniAgrawal15
authored andcommitted
Terraform support for Category and Term Resources (GoogleCloudPlatform#13923)
1 parent 4d8f5d8 commit 3e68605

File tree

9 files changed

+419
-3
lines changed

9 files changed

+419
-3
lines changed

mmv1/products/dataplex/Glossary.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ create_url: 'projects/{{project}}/locations/{{location}}/glossaries?glossary_id=
2020
update_verb: 'PATCH'
2121
update_mask: true
2222
timeouts:
23-
insert_minutes: 5
24-
update_minutes: 5
25-
delete_minutes: 5
23+
insert_minutes: 15
24+
update_minutes: 15
25+
delete_minutes: 15
2626
autogen_async: true
2727
import_format: ['projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}']
2828
async:
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
name: 'GlossaryCategory'
15+
description: |
16+
Represents a collection of categories and terms within a Glossary that are related to each other.
17+
base_url: 'projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/categories/{{category_id}}'
18+
self_link: 'projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/categories/{{category_id}}'
19+
create_url: 'projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/categories?category_id={{category_id}}'
20+
update_verb: 'PATCH'
21+
update_mask: true
22+
timeouts:
23+
insert_minutes: 15
24+
update_minutes: 15
25+
delete_minutes: 15
26+
autogen_async: true
27+
import_format: ['projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/categories/{{category_id}}']
28+
examples:
29+
- name: 'dataplex_glossary_category_basic'
30+
primary_resource_id: 'category_test_id'
31+
primary_resource_name: 'fmt.Sprintf("tf-test-category-basic%s", context["random_suffix"]), fmt.Sprintf("tf-test-glossary%s", context["random_suffix"])'
32+
vars:
33+
category_name: 'category-basic'
34+
- name: 'dataplex_glossary_category_full'
35+
primary_resource_id: 'category_test_id_full'
36+
primary_resource_name: 'fmt.Sprintf("tf-test-category-full%s", context["random_suffix"]), fmt.Sprintf("tf-test-glossary%s", context["random_suffix"])'
37+
vars:
38+
category_name: 'category-full'
39+
parameters:
40+
- name: 'location'
41+
type: String
42+
description: |
43+
The location where the glossary category should reside.
44+
url_param_only: true
45+
required: true
46+
immutable: true
47+
- name: 'glossaryId'
48+
type: String
49+
description: |
50+
The glossary id for creation.
51+
url_param_only: true
52+
immutable: true
53+
- name: 'categoryId'
54+
type: String
55+
description: |
56+
The category id for creation.
57+
url_param_only: true
58+
immutable: true
59+
properties:
60+
- name: 'name'
61+
type: String
62+
description: |
63+
The resource name of the GlossaryCategory. Format: projects/{projectId}/locations/{locationId}/glossaries/{glossaryId}/categories/{categoryId}
64+
output: true
65+
- name: 'displayName'
66+
type: String
67+
description: |
68+
User friendly display name of the GlossaryCategory. This is user-mutable. This will be same as the categoryId, if not specified.
69+
required: false
70+
- name: 'description'
71+
type: String
72+
description: |
73+
The user-mutable description of the GlossaryCategory.
74+
required: false
75+
- name: 'labels'
76+
type: KeyValueLabels
77+
description: |
78+
User-defined labels for the GlossaryCategory.
79+
required: false
80+
- name: 'uid'
81+
type: String
82+
description: |
83+
System generated unique id for the GlossaryCategory. This ID will be different if the GlossaryCategory is deleted and re-created with the same name.
84+
output: true
85+
- name: 'createTime'
86+
type: Timestamp
87+
description: |
88+
The time at which the GlossaryCategory was created.
89+
output: true
90+
- name: 'updateTime'
91+
type: Timestamp
92+
description: |
93+
The time at which the GlossaryCategory was last updated.
94+
output: true
95+
- name: 'parent'
96+
type: String
97+
description: |
98+
The immediate parent of the GlossaryCategory in the resource-hierarchy. It can either be a Glossary or a Category. Format: projects/{projectId}/locations/{locationId}/glossaries/{glossaryId} OR projects/{projectId}/locations/{locationId}/glossaries/{glossaryId}/categories/{categoryId}
99+
required: true
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
name: 'GlossaryTerm'
15+
description: |
16+
Represents a collection of terms within a Glossary that are related to each other.
17+
base_url: 'projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/terms/{{term_id}}'
18+
self_link: 'projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/terms/{{term_id}}'
19+
create_url: 'projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/terms?term_id={{term_id}}'
20+
update_verb: 'PATCH'
21+
update_mask: true
22+
timeouts:
23+
insert_minutes: 15
24+
update_minutes: 15
25+
delete_minutes: 15
26+
autogen_async: true
27+
import_format: ['projects/{{project}}/locations/{{location}}/glossaries/{{glossary_id}}/terms/{{term_id}}']
28+
examples:
29+
- name: 'dataplex_glossary_term_basic'
30+
primary_resource_id: 'term_test_id'
31+
primary_resource_name: 'fmt.Sprintf("tf-test-term-basic%s", context["random_suffix"]), fmt.Sprintf("tf-test-glossary%s", context["random_suffix"])'
32+
vars:
33+
term_name: 'term-basic'
34+
- name: 'dataplex_glossary_term_full'
35+
primary_resource_id: 'term_test_id_full'
36+
primary_resource_name: 'fmt.Sprintf("tf-test-term-full%s", context["random_suffix"]), fmt.Sprintf("tf-test-glossary%s", context["random_suffix"])'
37+
vars:
38+
term_name: 'term-full'
39+
parameters:
40+
- name: 'location'
41+
type: String
42+
description: |
43+
The location where the glossary term should reside.
44+
url_param_only: true
45+
required: true
46+
immutable: true
47+
- name: 'glossaryId'
48+
type: String
49+
description: |
50+
The glossary id for creation.
51+
url_param_only: true
52+
immutable: true
53+
- name: 'termId'
54+
type: String
55+
description: |
56+
The term id for creation.
57+
url_param_only: true
58+
immutable: true
59+
properties:
60+
- name: 'name'
61+
type: String
62+
description: |
63+
The resource name of the GlossaryTerm. Format: projects/{projectId}/locations/{locationId}/glossaries/{glossaryId}/categories/{termId}
64+
output: true
65+
- name: 'displayName'
66+
type: String
67+
description: |
68+
User friendly display name of the GlossaryTerm. This is user-mutable. This will be same as the termId, if not specified.
69+
required: false
70+
- name: 'description'
71+
type: String
72+
description: |
73+
The user-mutable description of the GlossaryTerm.
74+
required: false
75+
- name: 'labels'
76+
type: KeyValueLabels
77+
description: |
78+
User-defined labels for the GlossaryTerm.
79+
required: false
80+
- name: 'uid'
81+
type: String
82+
description: |
83+
System generated unique id for the GlossaryTerm. This ID will be different if the GlossaryTerm is deleted and re-created with the same name.
84+
output: true
85+
- name: 'createTime'
86+
type: Timestamp
87+
description: |
88+
The time at which the GlossaryTerm was created.
89+
output: true
90+
- name: 'updateTime'
91+
type: Timestamp
92+
description: |
93+
The time at which the GlossaryTerm was last updated.
94+
output: true
95+
- name: 'parent'
96+
type: String
97+
description: |
98+
The immediate parent of the GlossaryTerm in the resource-hierarchy. It can either be a Glossary or a Term. Format: projects/{projectId}/locations/{locationId}/glossaries/{glossaryId} OR projects/{projectId}/locations/{locationId}/glossaries/{glossaryId}/terms/{termId}
99+
required: true
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "google_dataplex_glossary" "{{$.PrimaryResourceId}}" {
2+
glossary_id = "tf-test-glossary%{random_suffix}"
3+
location = "us-central1"
4+
}
5+
6+
resource "google_dataplex_glossary_category" "{{$.PrimaryResourceId}}" {
7+
parent = "projects/${google_dataplex_glossary.category_test_id.project}/locations/us-central1/glossaries/${google_dataplex_glossary.category_test_id.glossary_id}"
8+
glossary_id = google_dataplex_glossary.category_test_id.glossary_id
9+
location = "us-central1"
10+
category_id = "tf-test-category-basic%{random_suffix}"
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_dataplex_glossary" "{{$.PrimaryResourceId}}" {
2+
glossary_id = "tf-test-glossary%{random_suffix}"
3+
location = "us-central1"
4+
}
5+
6+
resource "google_dataplex_glossary_category" "{{$.PrimaryResourceId}}" {
7+
parent = "projects/${google_dataplex_glossary.category_test_id_full.project}/locations/us-central1/glossaries/${google_dataplex_glossary.category_test_id_full.glossary_id}"
8+
glossary_id = google_dataplex_glossary.category_test_id_full.glossary_id
9+
location = "us-central1"
10+
category_id = "tf-test-category-full%{random_suffix}"
11+
12+
labels = { "tag": "test-tf" }
13+
display_name = "terraform category"
14+
description = "category created by Terraform"
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "google_dataplex_glossary" "{{$.PrimaryResourceId}}" {
2+
glossary_id = "tf-test-glossary%{random_suffix}"
3+
location = "us-central1"
4+
}
5+
6+
resource "google_dataplex_glossary_term" "{{$.PrimaryResourceId}}" {
7+
parent = "projects/${google_dataplex_glossary.term_test_id.project}/locations/us-central1/glossaries/${google_dataplex_glossary.term_test_id.glossary_id}"
8+
glossary_id = google_dataplex_glossary.term_test_id.glossary_id
9+
location = "us-central1"
10+
term_id = "tf-test-term-basic%{random_suffix}"
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_dataplex_glossary" "{{$.PrimaryResourceId}}" {
2+
glossary_id = "tf-test-glossary%{random_suffix}"
3+
location = "us-central1"
4+
}
5+
6+
resource "google_dataplex_glossary_term" "{{$.PrimaryResourceId}}" {
7+
parent = "projects/${google_dataplex_glossary.term_test_id_full.project}/locations/us-central1/glossaries/${google_dataplex_glossary.term_test_id_full.glossary_id}"
8+
glossary_id = google_dataplex_glossary.term_test_id_full.glossary_id
9+
location = "us-central1"
10+
term_id = "tf-test-term-full%{random_suffix}"
11+
12+
labels = { "tag": "test-tf" }
13+
display_name = "terraform term"
14+
description = "term created by Terraform"
15+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package dataplex_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
9+
"github.com/hashicorp/terraform-provider-google/google/acctest"
10+
)
11+
12+
func TestAccDataplexGlossaryCategory_update(t *testing.T) {
13+
t.Parallel()
14+
15+
context := map[string]interface{}{
16+
"random_suffix": acctest.RandString(t, 10),
17+
}
18+
19+
acctest.VcrTest(t, resource.TestCase{
20+
PreCheck: func() { acctest.AccTestPreCheck(t) },
21+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
22+
Steps: []resource.TestStep{
23+
{
24+
Config: testAccDataplexGlossaryCategory_dataplexGlossaryCategoryFull(context),
25+
},
26+
{
27+
ResourceName: "google_dataplex_glossary_category.category_test_id_full",
28+
ImportState: true,
29+
ImportStateVerify: true,
30+
ImportStateVerifyIgnore: []string{"category_id", "glossary_id", "labels", "location", "terraform_labels"},
31+
},
32+
{
33+
Config: testAccDataplexGlossaryCategory_update(context),
34+
ConfigPlanChecks: resource.ConfigPlanChecks{
35+
PreApply: []plancheck.PlanCheck{
36+
plancheck.ExpectResourceAction("google_dataplex_glossary_category.category_test_id_full", plancheck.ResourceActionUpdate),
37+
},
38+
},
39+
},
40+
{
41+
ResourceName: "google_dataplex_glossary_category.category_test_id_full",
42+
ImportState: true,
43+
ImportStateVerify: true,
44+
ImportStateVerifyIgnore: []string{"category_id", "glossary_id", "labels", "location", "terraform_labels"},
45+
},
46+
},
47+
})
48+
}
49+
50+
func testAccDataplexGlossaryCategory_update(context map[string]interface{}) string {
51+
return acctest.Nprintf(`
52+
resource "google_dataplex_glossary" "category_test_id_full" {
53+
glossary_id = "tf-test-glossary%{random_suffix}"
54+
location = "us-central1"
55+
}
56+
resource "google_dataplex_glossary_category" "category_test_id_full" {
57+
parent = "projects/${google_dataplex_glossary.category_test_id_full.project}/locations/us-central1/glossaries/${google_dataplex_glossary.category_test_id_full.glossary_id}"
58+
glossary_id = google_dataplex_glossary.category_test_id_full.glossary_id
59+
location = "us-central1"
60+
category_id = "tf-test-category-full%{random_suffix}"
61+
display_name = "terraform category updated"
62+
description = "category updated by Terraform"
63+
}
64+
`, context)
65+
}
66+
67+
func testAccDataplexGlossaryCategory_dataplexGlossaryCategoryFull(context map[string]interface{}) string {
68+
return acctest.Nprintf(`
69+
resource "google_dataplex_glossary" "category_test_id_full" {
70+
glossary_id = "tf-test-glossary%{random_suffix}"
71+
location = "us-central1"
72+
}
73+
resource "google_dataplex_glossary_category" "category_test_id_full" {
74+
parent = "projects/${google_dataplex_glossary.category_test_id_full.project}/locations/us-central1/glossaries/${google_dataplex_glossary.category_test_id_full.glossary_id}"
75+
glossary_id = google_dataplex_glossary.category_test_id_full.glossary_id
76+
location = "us-central1"
77+
category_id = "tf-test-category-full%{random_suffix}"
78+
labels = { "tag": "test-tf" }
79+
display_name = "terraform category"
80+
description = "category created by Terraform"
81+
}
82+
`, context)
83+
}

0 commit comments

Comments
 (0)