Skip to content

Commit cba2ae3

Browse files
Add API hub product, with resource ApiHubInstance (#12499)
1 parent 0196090 commit cba2ae3

File tree

7 files changed

+225
-0
lines changed

7 files changed

+225
-0
lines changed
+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
---
15+
name: ApiHubInstance
16+
description: |-
17+
An ApiHubInstance represents the instance resources of the API Hub.
18+
Currently, only one ApiHub instance is allowed for each project.
19+
Currently, updation/deletion of ApiHub instance is not allowed.
20+
base_url: projects/{{project}}/locations/{{location}}/apiHubInstances
21+
immutable: true
22+
self_link: '{{name}}'
23+
create_url: projects/{{project}}/locations/{{location}}/apiHubInstances?apiHubInstanceId={{api_hub_instance_id}}
24+
id_format: '{{name}}'
25+
import_format:
26+
- projects/{{project}}/locations/{{location}}/apiHubInstances/{{api_hub_instance_id}}
27+
custom_code:
28+
custom_import: 'templates/terraform/custom_import/apihub_api_hub_instance_set_id.go.tmpl'
29+
examples:
30+
- name: apihub_api_hub_instance_basic
31+
primary_resource_id: apihub-instance-without-search
32+
vars:
33+
instance_id: test-instance-basic
34+
exclude_test: true
35+
- name: apihub_api_hub_instance_full
36+
primary_resource_id: apihub-instance-search
37+
vars:
38+
instance_id: test-instance-full
39+
exclude_test: true
40+
autogen_async: true
41+
exclude_delete: true
42+
async:
43+
operation:
44+
timeouts:
45+
insert_minutes: 20
46+
update_minutes: 20
47+
delete_minutes: 20
48+
base_url: '{{op_id}}'
49+
actions:
50+
- create
51+
- delete
52+
- update
53+
type: OpAsync
54+
result:
55+
resource_inside_response: true
56+
error: {}
57+
include_project: false
58+
autogen_status: QXBpSHViSW5zdGFuY2U=
59+
parameters:
60+
- name: location
61+
type: String
62+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
63+
immutable: true
64+
url_param_only: true
65+
required: true
66+
- name: apiHubInstanceId
67+
type: String
68+
description: |-
69+
Optional. Identifier to assign to the Api Hub instance. Must be unique within
70+
scope of the parent resource. If the field is not provided,
71+
system generated id will be used.
72+
73+
This value should be 4-40 characters, and valid characters
74+
are `/a-z[0-9]-_/`.
75+
immutable: true
76+
url_param_only: true
77+
properties:
78+
- name: description
79+
type: String
80+
description: Optional. Description of the ApiHub instance.
81+
- name: name
82+
type: String
83+
description: |-
84+
Identifier. Format:
85+
`projects/{project}/locations/{location}/apiHubInstances/{apiHubInstance}`.
86+
output: true
87+
- name: createTime
88+
type: String
89+
description: Output only. Creation timestamp.
90+
output: true
91+
- name: updateTime
92+
type: String
93+
description: Output only. Last update timestamp.
94+
output: true
95+
- name: state
96+
type: String
97+
description: |-
98+
Output only. The current state of the ApiHub instance.
99+
Possible values:
100+
STATE_UNSPECIFIED
101+
INACTIVE
102+
CREATING
103+
ACTIVE
104+
UPDATING
105+
DELETING
106+
FAILED
107+
output: true
108+
- name: stateMessage
109+
type: String
110+
description: |-
111+
Output only. Extra information about ApiHub instance state. Currently the message
112+
would be populated when state is `FAILED`.
113+
output: true
114+
- name: config
115+
type: NestedObject
116+
description: Available configurations to provision an ApiHub Instance.
117+
required: true
118+
properties:
119+
- name: encryptionType
120+
type: String
121+
default_from_api: true
122+
description: |-
123+
Optional. Encryption type for the region. If the encryption type is CMEK, the
124+
cmek_key_name must be provided. If no encryption type is provided,
125+
GMEK will be used.
126+
Possible values:
127+
ENCRYPTION_TYPE_UNSPECIFIED
128+
GMEK
129+
CMEK
130+
- name: cmekKeyName
131+
type: String
132+
description: |-
133+
Optional. The Customer Managed Encryption Key (CMEK) used for data encryption.
134+
The CMEK name should follow the format of
135+
`projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)`,
136+
where the location must match the instance location.
137+
If the CMEK is not provided, a GMEK will be created for the instance.
138+
- name: disableSearch
139+
type: Boolean
140+
description: |-
141+
Optional. If true, the search will be disabled for the instance. The default value
142+
is false.
143+
- name: vertexLocation
144+
type: String
145+
description: Optional. The name of the Vertex AI location where the data store is stored.
146+
- name: labels
147+
type: KeyValueLabels
148+
description: |-
149+
Optional. Instance labels to represent user-provided metadata.
150+
Refer to cloud documentation on labels for more details.
151+
https://cloud.google.com/compute/docs/labeling-resources

mmv1/products/apihub/product.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
---
15+
name: Apihub
16+
display_name: API hub
17+
scopes:
18+
- https://www.googleapis.com/auth/cloud-platform
19+
versions:
20+
- base_url: https://apihub.googleapis.com/v1/
21+
name: ga
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
config := meta.(*transport_tpg.Config)
2+
if err := tpgresource.ParseImportId([]string{
3+
"^projects/(?P<project>[^/]+)/locations/(?P<location>[^/]+)/apiHubInstances/(?P<api_hub_instance_id>[^/]+)$",
4+
"^(?P<project>[^/]+)/(?P<location>[^/]+)/(?P<api_hub_instance_id>[^/]+)$",
5+
"^(?P<location>[^/]+)/(?P<api_hub_instance_id>[^/]+)$",
6+
}, d, config); err != nil {
7+
return nil, err
8+
}
9+
10+
// Set name based on the components
11+
if err := d.Set("name", "projects/{{"{{"}}project{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/apiHubInstances/{{"{{"}}api_hub_instance_id{{"}}"}}"); err != nil {
12+
return nil, fmt.Errorf("Error setting name: %s", err)
13+
}
14+
15+
// Replace import id for the resource id
16+
id, err := tpgresource.ReplaceVars(d, config, d.Get("name").(string))
17+
if err != nil {
18+
return nil, fmt.Errorf("Error constructing id: %s", err)
19+
}
20+
d.SetId(id)
21+
22+
return []*schema.ResourceData{d}, nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "google_apihub_api_hub_instance" "{{$.PrimaryResourceId}}"{
2+
location = "us-central1"
3+
config {
4+
disable_search = true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_apihub_api_hub_instance" "{{$.PrimaryResourceId}}"{
2+
project = "my-project"
3+
api_hub_instance_id = "{{index $.Vars "instance_id"}}"
4+
description = "Test API hub instance"
5+
location = "us-central1"
6+
config {
7+
encryption_type = "CMEK"
8+
cmek_key_name = "projects/my-project/locations/us-central1/keyRings/apihub/cryptoKeys/apihub-key"
9+
disable_search = false
10+
vertex_location = "us"
11+
}
12+
labels = {
13+
environment = "dev"
14+
}
15+
}

mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ var ServicesListBeta = mapOf(
4646
"displayName" to "Apigee",
4747
"path" to "./google-beta/services/apigee"
4848
),
49+
"apihub" to mapOf(
50+
"name" to "apihub",
51+
"displayName" to "Apihub",
52+
"path" to "./google-beta/services/apihub"
53+
),
4954
"apikeys" to mapOf(
5055
"name" to "apikeys",
5156
"displayName" to "Apikeys",

mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ var ServicesListGa = mapOf(
4646
"displayName" to "Apigee",
4747
"path" to "./google/services/apigee"
4848
),
49+
"apihub" to mapOf(
50+
"name" to "apihub",
51+
"displayName" to "Apihub",
52+
"path" to "./google/services/apihub"
53+
),
4954
"apikeys" to mapOf(
5055
"name" to "apikeys",
5156
"displayName" to "Apikeys",

0 commit comments

Comments
 (0)