-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API hub product, with resource ApiHubInstance (#12499)
- Loading branch information
1 parent
0196090
commit cba2ae3
Showing
7 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Copyright 2024 Google Inc. | ||
# 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: ApiHubInstance | ||
description: |- | ||
An ApiHubInstance represents the instance resources of the API Hub. | ||
Currently, only one ApiHub instance is allowed for each project. | ||
Currently, updation/deletion of ApiHub instance is not allowed. | ||
base_url: projects/{{project}}/locations/{{location}}/apiHubInstances | ||
immutable: true | ||
self_link: '{{name}}' | ||
create_url: projects/{{project}}/locations/{{location}}/apiHubInstances?apiHubInstanceId={{api_hub_instance_id}} | ||
id_format: '{{name}}' | ||
import_format: | ||
- projects/{{project}}/locations/{{location}}/apiHubInstances/{{api_hub_instance_id}} | ||
custom_code: | ||
custom_import: 'templates/terraform/custom_import/apihub_api_hub_instance_set_id.go.tmpl' | ||
examples: | ||
- name: apihub_api_hub_instance_basic | ||
primary_resource_id: apihub-instance-without-search | ||
vars: | ||
instance_id: test-instance-basic | ||
exclude_test: true | ||
- name: apihub_api_hub_instance_full | ||
primary_resource_id: apihub-instance-search | ||
vars: | ||
instance_id: test-instance-full | ||
exclude_test: true | ||
autogen_async: true | ||
exclude_delete: true | ||
async: | ||
operation: | ||
timeouts: | ||
insert_minutes: 20 | ||
update_minutes: 20 | ||
delete_minutes: 20 | ||
base_url: '{{op_id}}' | ||
actions: | ||
- create | ||
- delete | ||
- update | ||
type: OpAsync | ||
result: | ||
resource_inside_response: true | ||
error: {} | ||
include_project: false | ||
autogen_status: QXBpSHViSW5zdGFuY2U= | ||
parameters: | ||
- name: location | ||
type: String | ||
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. | ||
immutable: true | ||
url_param_only: true | ||
required: true | ||
- name: apiHubInstanceId | ||
type: String | ||
description: |- | ||
Optional. Identifier to assign to the Api Hub instance. Must be unique within | ||
scope of the parent resource. If the field is not provided, | ||
system generated id will be used. | ||
This value should be 4-40 characters, and valid characters | ||
are `/a-z[0-9]-_/`. | ||
immutable: true | ||
url_param_only: true | ||
properties: | ||
- name: description | ||
type: String | ||
description: Optional. Description of the ApiHub instance. | ||
- name: name | ||
type: String | ||
description: |- | ||
Identifier. Format: | ||
`projects/{project}/locations/{location}/apiHubInstances/{apiHubInstance}`. | ||
output: true | ||
- name: createTime | ||
type: String | ||
description: Output only. Creation timestamp. | ||
output: true | ||
- name: updateTime | ||
type: String | ||
description: Output only. Last update timestamp. | ||
output: true | ||
- name: state | ||
type: String | ||
description: |- | ||
Output only. The current state of the ApiHub instance. | ||
Possible values: | ||
STATE_UNSPECIFIED | ||
INACTIVE | ||
CREATING | ||
ACTIVE | ||
UPDATING | ||
DELETING | ||
FAILED | ||
output: true | ||
- name: stateMessage | ||
type: String | ||
description: |- | ||
Output only. Extra information about ApiHub instance state. Currently the message | ||
would be populated when state is `FAILED`. | ||
output: true | ||
- name: config | ||
type: NestedObject | ||
description: Available configurations to provision an ApiHub Instance. | ||
required: true | ||
properties: | ||
- name: encryptionType | ||
type: String | ||
default_from_api: true | ||
description: |- | ||
Optional. Encryption type for the region. If the encryption type is CMEK, the | ||
cmek_key_name must be provided. If no encryption type is provided, | ||
GMEK will be used. | ||
Possible values: | ||
ENCRYPTION_TYPE_UNSPECIFIED | ||
GMEK | ||
CMEK | ||
- name: cmekKeyName | ||
type: String | ||
description: |- | ||
Optional. The Customer Managed Encryption Key (CMEK) used for data encryption. | ||
The CMEK name should follow the format of | ||
`projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)`, | ||
where the location must match the instance location. | ||
If the CMEK is not provided, a GMEK will be created for the instance. | ||
- name: disableSearch | ||
type: Boolean | ||
description: |- | ||
Optional. If true, the search will be disabled for the instance. The default value | ||
is false. | ||
- name: vertexLocation | ||
type: String | ||
description: Optional. The name of the Vertex AI location where the data store is stored. | ||
- name: labels | ||
type: KeyValueLabels | ||
description: |- | ||
Optional. Instance labels to represent user-provided metadata. | ||
Refer to cloud documentation on labels for more details. | ||
https://cloud.google.com/compute/docs/labeling-resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Google Inc. | ||
# 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: Apihub | ||
display_name: API hub | ||
scopes: | ||
- https://www.googleapis.com/auth/cloud-platform | ||
versions: | ||
- base_url: https://apihub.googleapis.com/v1/ | ||
name: ga |
22 changes: 22 additions & 0 deletions
22
mmv1/templates/terraform/custom_import/apihub_api_hub_instance_set_id.go.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
config := meta.(*transport_tpg.Config) | ||
if err := tpgresource.ParseImportId([]string{ | ||
"^projects/(?P<project>[^/]+)/locations/(?P<location>[^/]+)/apiHubInstances/(?P<api_hub_instance_id>[^/]+)$", | ||
"^(?P<project>[^/]+)/(?P<location>[^/]+)/(?P<api_hub_instance_id>[^/]+)$", | ||
"^(?P<location>[^/]+)/(?P<api_hub_instance_id>[^/]+)$", | ||
}, d, config); err != nil { | ||
return nil, err | ||
} | ||
|
||
// Set name based on the components | ||
if err := d.Set("name", "projects/{{"{{"}}project{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/apiHubInstances/{{"{{"}}api_hub_instance_id{{"}}"}}"); err != nil { | ||
return nil, fmt.Errorf("Error setting name: %s", err) | ||
} | ||
|
||
// Replace import id for the resource id | ||
id, err := tpgresource.ReplaceVars(d, config, d.Get("name").(string)) | ||
if err != nil { | ||
return nil, fmt.Errorf("Error constructing id: %s", err) | ||
} | ||
d.SetId(id) | ||
|
||
return []*schema.ResourceData{d}, nil |
6 changes: 6 additions & 0 deletions
6
mmv1/templates/terraform/examples/apihub_api_hub_instance_basic.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "google_apihub_api_hub_instance" "{{$.PrimaryResourceId}}"{ | ||
location = "us-central1" | ||
config { | ||
disable_search = true | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
mmv1/templates/terraform/examples/apihub_api_hub_instance_full.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "google_apihub_api_hub_instance" "{{$.PrimaryResourceId}}"{ | ||
project = "my-project" | ||
api_hub_instance_id = "{{index $.Vars "instance_id"}}" | ||
description = "Test API hub instance" | ||
location = "us-central1" | ||
config { | ||
encryption_type = "CMEK" | ||
cmek_key_name = "projects/my-project/locations/us-central1/keyRings/apihub/cryptoKeys/apihub-key" | ||
disable_search = false | ||
vertex_location = "us" | ||
} | ||
labels = { | ||
environment = "dev" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters