diff --git a/mmv1/products/apphub/ServiceProjectAttachment.yaml b/mmv1/products/apphub/ServiceProjectAttachment.yaml new file mode 100644 index 000000000000..724f60dc7d0e --- /dev/null +++ b/mmv1/products/apphub/ServiceProjectAttachment.yaml @@ -0,0 +1,110 @@ +# 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. + + +--- !ruby/object:Api::Resource +base_url: projects/{{project}}/locations/global/serviceProjectAttachments +create_url: projects/{{project}}/locations/global/serviceProjectAttachments?serviceProjectAttachmentId={{service_project_attachment_id}} +self_link: projects/{{project}}/locations/global/serviceProjectAttachments/{{service_project_attachment_id}} +id_format: projects/{{project}}/locations/global/serviceProjectAttachments/{{service_project_attachment_id}} +import_format: + - projects/{{project}}/locations/global/serviceProjectAttachments/{{service_project_attachment_id}} +name: ServiceProjectAttachment +description: | + Represents a Service project attachment to the Host Project. +immutable: true +autogen_async: true +custom_code: !ruby/object:Provider::Terraform::CustomCode + constants: 'templates/terraform/constants/apphub_service_project.go.erb' +examples: + - !ruby/object:Provider::Terraform::Examples + name: "service_project_attachment_basic" + pull_external: true + primary_resource_id: "example" + config_path: "templates/terraform/examples/apphub_service_project_attachment_basic.tf.erb" + vars: + service_project_attachment_id: "project-1" + test_env_vars: + org_id: :ORG_ID + host_project: :PROJECT_NAME + - !ruby/object:Provider::Terraform::Examples + name: "service_project_attachment_full" + pull_external: true + primary_resource_id: "example2" + config_path: "templates/terraform/examples/apphub_service_project_attachment_full.tf.erb" + vars: + service_project_attachment_id: "project-1" + test_env_vars: + org_id: :ORG_ID + host_project: :PROJECT_NAME +properties: + - !ruby/object:Api::Type::String + name: name + output: true + description: | + "Identifier. The resource name of a ServiceProjectAttachment. Format:\"projects/{host-project-id}/locations/global/serviceProjectAttachments/{service-project-id}.\" " + - !ruby/object:Api::Type::String + name: serviceProject + diff_suppress_func: 'ServiceProjectDiffSuppress' + custom_expand: 'templates/terraform/custom_expand/apphub_service_project.go.erb' + custom_flatten: 'templates/terraform/custom_flatten/apphub_service_project.go.erb' + description: | + "Immutable. Service project name in the format: \"projects/abc\" + or \"projects/123\". As input, project name with either project id or number + are accepted. As output, this field will contain project number. " + immutable: true + - !ruby/object:Api::Type::String + name: createTime + description: 'Output only. Create time. ' + output: true + - !ruby/object:Api::Type::String + name: uid + description: "Output only. A globally unique identifier (in UUID4 format) for the `ServiceProjectAttachment`. " + output: true + - !ruby/object:Api::Type::Enum + name: 'state' + description: | + ServiceProjectAttachment state. + output: true + values: + - :STATE_UNSPECIFIED + - :CREATING + - :ACTIVE + - :DELETING +parameters: + - !ruby/object:Api::Type::String + name: serviceProjectAttachmentId + description: "Required. The service project attachment identifier must contain the + project_id of the service project specified in the service_project_attachment.service_project + field. Hint: \"projects/{project_id}\" " + url_param_only: true + required: true + immutable: true +async: !ruby/object:Api::OpAsync + operation: !ruby/object:Api::OpAsync::Operation + path: name + base_url: "{{op_id}}" + wait_ms: 1000 + timeouts: + result: !ruby/object:Api::OpAsync::Result + path: response + resource_inside_response: true + status: !ruby/object:Api::OpAsync::Status + path: done + complete: true + allowed: + - true + - false + error: !ruby/object:Api::OpAsync::Error + path: error + message: message diff --git a/mmv1/templates/terraform/constants/apphub_service_project.go.erb b/mmv1/templates/terraform/constants/apphub_service_project.go.erb new file mode 100644 index 000000000000..55e38f6b1d44 --- /dev/null +++ b/mmv1/templates/terraform/constants/apphub_service_project.go.erb @@ -0,0 +1,4 @@ +// Suppress all diff for the field Service Project +func ServiceProjectDiffSuppress(_, _, _ string, _ *schema.ResourceData) bool { + return true +} \ No newline at end of file diff --git a/mmv1/templates/terraform/custom_expand/apphub_service_project.go.erb b/mmv1/templates/terraform/custom_expand/apphub_service_project.go.erb new file mode 100644 index 000000000000..716466f55f9b --- /dev/null +++ b/mmv1/templates/terraform/custom_expand/apphub_service_project.go.erb @@ -0,0 +1,6 @@ +func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + + service_project := "projects/" + d.Get("service_project_attachment_id").(string) + + return service_project, nil +} diff --git a/mmv1/templates/terraform/custom_flatten/apphub_service_project.go.erb b/mmv1/templates/terraform/custom_flatten/apphub_service_project.go.erb new file mode 100644 index 000000000000..05cb8d57c1d5 --- /dev/null +++ b/mmv1/templates/terraform/custom_flatten/apphub_service_project.go.erb @@ -0,0 +1,3 @@ +func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return nil +} diff --git a/mmv1/templates/terraform/examples/apphub_service_project_attachment_basic.tf.erb b/mmv1/templates/terraform/examples/apphub_service_project_attachment_basic.tf.erb new file mode 100644 index 000000000000..33d835bacc44 --- /dev/null +++ b/mmv1/templates/terraform/examples/apphub_service_project_attachment_basic.tf.erb @@ -0,0 +1,16 @@ +resource "google_apphub_service_project_attachment" "<%= ctx[:primary_resource_id] %>" { + service_project_attachment_id = google_project.service_project.project_id + depends_on = [time_sleep.wait_120s] +} + +resource "google_project" "service_project" { + project_id ="<%= ctx[:vars]['service_project_attachment_id'] %>" + name = "Service Project" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" +} + +resource "time_sleep" "wait_120s" { + depends_on = [google_project.service_project] + + create_duration = "120s" +} diff --git a/mmv1/templates/terraform/examples/apphub_service_project_attachment_full.tf.erb b/mmv1/templates/terraform/examples/apphub_service_project_attachment_full.tf.erb new file mode 100644 index 000000000000..f88c9b9ab7fa --- /dev/null +++ b/mmv1/templates/terraform/examples/apphub_service_project_attachment_full.tf.erb @@ -0,0 +1,17 @@ +resource "google_apphub_service_project_attachment" "<%= ctx[:primary_resource_id] %>" { + service_project_attachment_id = google_project.service_project_full.project_id + service_project = google_project.service_project_full.project_id + depends_on = [time_sleep.wait_120s] +} + +resource "google_project" "service_project_full" { + project_id ="<%= ctx[:vars]['service_project_attachment_id'] %>" + name = "Service Project Full" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" +} + +resource "time_sleep" "wait_120s" { + depends_on = [google_project.service_project_full] + + create_duration = "120s" +}