forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new resource for Service Project Attachment for Apphub
- Loading branch information
1 parent
0df7f3d
commit 51d1afd
Showing
7 changed files
with
221 additions
and
61 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,102 @@ | ||
# 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" | ||
primary_resource_id: "example" | ||
config_path: "templates/terraform/examples/apphub_service_project_attachment_basic.tf.erb" | ||
vars: | ||
service_project_attachment_id: "project-1" | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "service_project_attachment_full" | ||
primary_resource_id: "example2" | ||
config_path: "templates/terraform/examples/apphub_service_project_attachment_full.tf.erb" | ||
vars: | ||
service_project_attachment_id: "project-1" | ||
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: | | ||
"Required. 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 |
4 changes: 4 additions & 0 deletions
4
mmv1/templates/terraform/constants/apphub_service_project.go.erb
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,4 @@ | ||
// Suppress all diff for the field Service Project | ||
func ServiceProjectDiffSuppress(_, _, _ string, _ *schema.ResourceData) bool { | ||
return true | ||
} |
3 changes: 0 additions & 3 deletions
3
mmv1/templates/terraform/decoders/apphub_service_project.go.erb
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...mples/apphub_service_project_basic.tf.erb → ...b_service_project_attachment_basic.tf.erb
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
resource "google_apphub_service_project" "<%= ctx[:primary_resource_id] %>" { | ||
resource "google_apphub_service_project_attachment" "<%= ctx[:primary_resource_id] %>" { | ||
service_project_attachment_id = google_project.service_project.project_id | ||
} | ||
|
||
resource "google_project" "service_project" { | ||
project_id ="<%= ctx[:vars]['service_project_attachment_id'] %>" | ||
name = "Service Project" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
mmv1/templates/terraform/examples/apphub_service_project_attachment_full.tf.erb
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,9 @@ | ||
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 | ||
} | ||
|
||
resource "google_project" "service_project_full" { | ||
project_id ="<%= ctx[:vars]['service_project_attachment_id'] %>" | ||
name = "Service Project Full" | ||
} |
104 changes: 104 additions & 0 deletions
104
.../third_party/terraform/services/apphub/resource_apphub_service_project_attachment_test.go
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,104 @@ | ||
package apphub_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
func TestAccApphubServiceProjectAttachment_serviceProjectAttachmentUpdateBasic(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
CheckDestroy: testAccCheckApphubServiceProjectAttachmentDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccApphubServiceProjectAttachment_serviceProjectAttachmentBasicExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_apphub_service_project_attachment.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_project_attachment_id"}, | ||
}, | ||
{ | ||
Config: testAccApphubServiceProjectAttachment_serviceProjectAttachmentUpdateBasic(context), | ||
}, | ||
{ | ||
ResourceName: "google_apphub_service_project_attachment.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_project_attachment_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccApphubServiceProjectAttachment_serviceProjectAttachmentUpdateBasic(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_apphub_service_project_attachment" "example" { | ||
service_project_attachment_id = google_project.service_project_new.project_id | ||
} | ||
resource "google_project" "service_project_new" { | ||
project_id ="tf-test-project-2%{random_suffix}" | ||
name = "Service Project New" | ||
} | ||
`, context) | ||
} | ||
|
||
func TestAccApphubServiceProjectAttachment_serviceProjectAttachmentUpdateFull(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
CheckDestroy: testAccCheckApphubServiceProjectAttachmentDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccApphubServiceProjectAttachment_serviceProjectAttachmentFullExample(context), | ||
}, | ||
{ | ||
ResourceName: "google_apphub_service_project_attachment.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_project_attachment_id"}, | ||
}, | ||
{ | ||
Config: testAccApphubServiceProjectAttachment_serviceProjectAttachmentUpdateFull(context), | ||
}, | ||
{ | ||
ResourceName: "google_apphub_service_project_attachment.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"service_project_attachment_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccApphubServiceProjectAttachment_serviceProjectAttachmentUpdateFull(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_apphub_service_project_attachment" "example2" { | ||
service_project_attachment_id = google_project.service_project_full_new.project_id | ||
service_project = google_project.service_project_full_new.project_id | ||
} | ||
resource "google_project" "service_project_full_new" { | ||
project_id ="tf-test-project-2%{random_suffix}" | ||
name = "Service Project Full New" | ||
} | ||
`, context) | ||
} |
56 changes: 0 additions & 56 deletions
56
mmv1/third_party/terraform/services/apphub/resource_apphub_service_project_test.go
This file was deleted.
Oops, something went wrong.