Skip to content

Commit 72741e5

Browse files
Add Curation resource of API hub (GoogleCloudPlatform#14174)
1 parent 7cc1e01 commit 72741e5

3 files changed

Lines changed: 269 additions & 0 deletions

File tree

mmv1/products/apihub/Curation.yaml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
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: Curation
16+
description: Description
17+
base_url: projects/{{project}}/locations/{{location}}/curations
18+
update_mask: true
19+
self_link: projects/{{project}}/locations/{{location}}/curations/{{curation_id}}
20+
create_url: projects/{{project}}/locations/{{location}}/curations?curationId={{curation_id}}
21+
update_verb: PATCH
22+
id_format: projects/{{project}}/locations/{{location}}/curations/{{curation_id}}
23+
import_format:
24+
- projects/{{project}}/locations/{{location}}/curations/{{curation_id}}
25+
autogen_async: true
26+
autogen_status: Q3VyYXRpb24=
27+
examples:
28+
- name: apihub_curation_basic
29+
primary_resource_id: apihub_curation_basic
30+
vars:
31+
curation_id: 'test'
32+
# API hub instance needs to be created before this, and end to end creation of that resource using Terraform is not yet supported.
33+
exclude_test: true
34+
external_providers: ["time"]
35+
parameters:
36+
- name: location
37+
type: String
38+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
39+
immutable: true
40+
url_param_only: true
41+
required: true
42+
- name: curationId
43+
type: String
44+
description: |-
45+
The ID to use for the curation resource, which will become the final
46+
component of the curations's resource name. This field is optional.
47+
48+
* If provided, the same will be used. The service will throw an error if
49+
the specified ID is already used by another curation resource in the API
50+
hub.
51+
* If not provided, a system generated ID will be used.
52+
53+
This value should be 4-500 characters, and valid characters
54+
are /a-z[0-9]-_/.
55+
immutable: true
56+
url_param_only: true
57+
required: true
58+
properties:
59+
- name: name
60+
type: String
61+
description: |-
62+
Identifier. The name of the curation.
63+
64+
Format:
65+
`projects/{project}/locations/{location}/curations/{curation}`
66+
output: true
67+
- name: displayName
68+
type: String
69+
description: The display name of the curation.
70+
required: true
71+
- name: endpoint
72+
type: NestedObject
73+
description: |-
74+
The endpoint to be triggered for curation.
75+
The endpoint will be invoked with a request payload containing
76+
ApiMetadata.
77+
Response should contain curated data in the form of
78+
ApiMetadata.
79+
required: true
80+
immutable: true
81+
properties:
82+
- name: applicationIntegrationEndpointDetails
83+
type: NestedObject
84+
description: |-
85+
The details of the Application Integration endpoint to be triggered for
86+
curation.
87+
required: true
88+
immutable: true
89+
properties:
90+
- name: triggerId
91+
type: String
92+
description: The API trigger ID of the Application Integration workflow.
93+
required: true
94+
immutable: true
95+
- name: uri
96+
type: String
97+
description: |-
98+
The endpoint URI should be a valid REST URI for triggering an Application
99+
Integration.
100+
Format:
101+
`https://integrations.googleapis.com/v1/{name=projects/*/locations/*/integrations/*}:execute`
102+
or
103+
`https://{location}-integrations.googleapis.com/v1/{name=projects/*/locations/*/integrations/*}:execute`
104+
required: true
105+
immutable: true
106+
- name: lastExecutionState
107+
type: String
108+
description: |-
109+
The last execution state of the curation.
110+
Possible values:
111+
LAST_EXECUTION_STATE_UNSPECIFIED
112+
SUCCEEDED
113+
FAILED
114+
output: true
115+
- name: lastExecutionErrorMessage
116+
type: String
117+
description: |-
118+
Error message describing the failure, if any, during the last execution of
119+
the curation.
120+
output: true
121+
- name: description
122+
type: String
123+
description: The description of the curation.
124+
- name: pluginInstanceActions
125+
type: Array
126+
description: |-
127+
The plugin instances and associated actions that are using the curation.
128+
Note: A particular curation could be used by multiple plugin instances or
129+
multiple actions in a plugin instance.
130+
output: true
131+
item_type:
132+
type: NestedObject
133+
properties:
134+
- name: pluginInstance
135+
type: String
136+
description: |-
137+
Plugin instance that is using the curation.
138+
Format is
139+
`projects/{project}/locations/{locati on}/plugins/{plugin}/instances/{instance}`
140+
output: true
141+
- name: actionId
142+
type: String
143+
description: |-
144+
The action ID that is using the curation.
145+
This should map to one of the action IDs specified
146+
in action configs in the plugin.
147+
output: true
148+
- name: lastExecutionErrorCode
149+
type: String
150+
description: |-
151+
The error code of the last execution of the curation. The error code is
152+
populated only when the last execution state is failed.
153+
Possible values:
154+
ERROR_CODE_UNSPECIFIED
155+
INTERNAL_ERROR
156+
UNAUTHORIZED
157+
output: true
158+
- name: createTime
159+
type: String
160+
description: The time at which the curation was created.
161+
output: true
162+
- name: updateTime
163+
type: String
164+
description: The time at which the curation was last updated.
165+
output: true
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource "google_apihub_curation" "{{$.PrimaryResourceId}}" {
2+
location = "us-central1"
3+
curation_id = "{{index $.Vars "curation_id"}}"
4+
project = "apihub-terraform"
5+
display_name = "Test Curation"
6+
description = "This is a sample curation resource managed by Terraform."
7+
endpoint {
8+
application_integration_endpoint_details {
9+
trigger_id = "api_trigger/curation_API_1"
10+
uri = "https://integrations.googleapis.com/v1/projects/1082615593856/locations/us-central1/integrations/curation:execute"
11+
}
12+
}
13+
14+
}
15+
16+
17+
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package apihub_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
8+
"github.com/hashicorp/terraform-provider-google/google/acctest"
9+
)
10+
11+
func TestAccApihubCuration_apihubCurationBasic_Update(t *testing.T) {
12+
// This is added for reference, but the test needs to be skipped as it needs API hub instance as a prerequisite
13+
// But the support for that resources is not yet complete.
14+
t.Skip()
15+
16+
context := map[string]interface{}{
17+
"random_suffix": acctest.RandString(t, 10),
18+
}
19+
20+
acctest.VcrTest(t, resource.TestCase{
21+
PreCheck: func() { acctest.AccTestPreCheck(t) },
22+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
23+
ExternalProviders: map[string]resource.ExternalProvider{
24+
"time": {},
25+
},
26+
Steps: []resource.TestStep{
27+
{
28+
Config: testAccApihubCuration_apihubCuration_basic(context),
29+
},
30+
{
31+
ResourceName: "google_apihub_curation.apihub_curation_basic",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{"curation_id", "location"},
35+
},
36+
{
37+
Config: testAccApihubCuration_apihubCuration_update(context),
38+
},
39+
{
40+
ResourceName: "google_apihub_curation.apihub_curation_basic",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"curation_id", "location"},
44+
},
45+
},
46+
})
47+
}
48+
49+
func testAccApihubCuration_apihubCuration_basic(context map[string]interface{}) string {
50+
return acctest.Nprintf(`
51+
resource "google_apihub_curation" "apihub_curation_basic" {
52+
location = "us-central1"
53+
curation_id = "test%{random_suffix}"
54+
display_name = "Test Curation"
55+
description = "This is a sample curation resource managed by Terraform."
56+
endpoint {
57+
application_integration_endpoint_details {
58+
trigger_id = "api_trigger/curation_API_1"
59+
uri = "https://integrations.googleapis.com/v1/projects/1082615593856/locations/us-central1/integrations/curation:execute"
60+
}
61+
}
62+
63+
}
64+
65+
66+
`, context)
67+
}
68+
69+
func testAccApihubCuration_apihubCuration_update(context map[string]interface{}) string {
70+
return acctest.Nprintf(`
71+
resource "google_apihub_curation" "apihub_curation_basic" {
72+
location = "us-central1"
73+
curation_id = "test%{random_suffix}"
74+
display_name = "Test Curation Updated"
75+
description = "This is a sample updated curation resource managed by Terraform."
76+
endpoint {
77+
application_integration_endpoint_details {
78+
trigger_id = "api_trigger/curation_API_1"
79+
uri = "https://integrations.googleapis.com/v1/projects/1082615593856/locations/us-central1/integrations/curation:execute"
80+
}
81+
}
82+
83+
}
84+
85+
86+
`, context)
87+
}

0 commit comments

Comments
 (0)