-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add Version Resource #15114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Version Resource #15114
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
47362e3
Create version.yaml
Spheny1 f0bdab3
Create dialogflow_version_full.tf.tmpl
Spheny1 fb07969
Create resource_dialogflow_version_test.go
Spheny1 b7c8aaa
Update resource_dialogflow_version_test.go
Spheny1 1eda0cb
Update version.yaml
Spheny1 4dbfbd9
Update resource_dialogflow_version_test.go
Spheny1 5f18e0f
Update dialogflow_version_full.tf.tmpl
Spheny1 3c0bcf7
Update dialogflow_version_full.tf.tmpl to have its own project
Spheny1 8a27ca1
Update version.yaml to work with example
Spheny1 4c23d87
Update version.yaml
Spheny1 df8ddcf
Update dialogflow_version_full.tf.tmpl
Spheny1 a9d035a
Update version.yaml
Spheny1 d645f42
Update resource_dialogflow_version_test.go
Spheny1 1fcc8ce
Update dialogflow_version_full.tf.tmpl
Spheny1 1995b06
Update dialogflow_version_full.tf.tmpl
Spheny1 847eaf5
adding custom import
Spheny1 98568cb
Update version.yaml
Spheny1 f5febd9
Update version.yaml
Spheny1 14e49d8
Update version.yaml
Spheny1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,78 @@ | ||
| # Copyright 2025 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: 'Version' | ||
| description: | | ||
| You can create multiple versions of your agent and publish them to separate environments. | ||
| references: | ||
| guides: | ||
| 'Official Documentation': 'https://cloud.google.com/dialogflow/docs/' | ||
| api: 'https://docs.cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.agent.versions' | ||
| docs: | ||
| id_format: '{{parent}}/versions/{{name}}' | ||
| base_url: '{{parent}}/versions' | ||
| update_verb: 'PATCH' | ||
| update_mask: true | ||
| import_format: | ||
| - '{{parent}}/versions/{{name}}' | ||
| timeouts: | ||
| insert_minutes: 40 | ||
| update_minutes: 40 | ||
| delete_minutes: 20 | ||
| custom_code: | ||
| custom_import: 'templates/terraform/custom_import/dialogflowcx_version.go.tmpl' | ||
| exclude_sweeper: true | ||
| examples: | ||
| - name: 'dialogflow_version_full' | ||
| primary_resource_id: 'full_version' | ||
| vars: | ||
| project_id: 'my-proj' | ||
| test_env_vars: | ||
| org_id: 'ORG_ID' | ||
| billing_acct: 'BILLING_ACCT' | ||
| external_providers: | ||
| - "time" | ||
| parameters: | ||
| properties: | ||
| - name: 'parent' | ||
| type: String | ||
| description: | | ||
| The Flow to create an Version for. | ||
| Format: projects/<Project ID>/agent. | ||
| url_param_only: true | ||
| immutable: true | ||
| - name: 'name' | ||
| type: String | ||
| description: | | ||
| The unique identifier of this agent version. | ||
| output: true | ||
| custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl' | ||
| - name: 'versionNumber' | ||
| type: Integer | ||
| description: | | ||
| The sequential number of this version. | ||
| output: true | ||
| - name: 'description' | ||
| type: String | ||
| description: | | ||
| The developer-provided description of this version. | ||
| - name: 'status' | ||
| type: Enum | ||
| description: | | ||
| The status of this version. | ||
| output: true | ||
| enum_values: | ||
| - 'IN_PROGRESS' | ||
| - 'READY' | ||
| - 'FAILED' | ||
34 changes: 34 additions & 0 deletions
34
mmv1/templates/terraform/examples/dialogflow_version_full.tf.tmpl
This file contains hidden or 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,34 @@ | ||
| resource "google_project" "project" { | ||
| project_id = "{{index $.Vars "project_id"}}" | ||
| name = "{{index $.Vars "project_id"}}" | ||
| org_id = "{{index $.TestEnvVars "org_id"}}" | ||
| billing_account = "{{index $.TestEnvVars "billing_acct"}}" | ||
| deletion_policy = "DELETE" | ||
| } | ||
| resource "google_project_service" "dialogflow" { | ||
| project = google_project.project.project_id | ||
| service = "dialogflow.googleapis.com" | ||
| } | ||
| resource "time_sleep" "wait_enable_service_api" { | ||
| depends_on = [ | ||
| google_project_service.dialogflow | ||
| ] | ||
| create_duration = "30s" | ||
| } | ||
| resource "google_project_service_identity" "gcp_sa" { | ||
| service = "dialogflow.googleapis.com" | ||
| project = google_project.project.project_id | ||
| depends_on = [time_sleep.wait_enable_service_api] | ||
| } | ||
| resource "google_dialogflow_agent" "basic_agent" { | ||
| display_name = "example_agent" | ||
| default_language_code = "en-us" | ||
| time_zone = "America/New_York" | ||
| project = google_project.project.project_id | ||
| depends_on = [time_sleep.wait_enable_service_api] | ||
| } | ||
| resource "google_dialogflow_version" "full_version" { | ||
slevenick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| description = "Dialogflow Version" | ||
| parent = "projects/${google_project.project.project_id}/agent" | ||
| depends_on = [google_dialogflow_agent.basic_agent] | ||
| } | ||
125 changes: 125 additions & 0 deletions
125
mmv1/third_party/terraform/services/dialogflow/resource_dialogflow_version_test.go
This file contains hidden or 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,125 @@ | ||
| package dialogflow_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-provider-google/google/acctest" | ||
| "github.com/hashicorp/terraform-provider-google/google/envvar" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
| ) | ||
|
|
||
| func TestAccDialogflowVersion_update(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| context := map[string]interface{}{ | ||
| "org_id": envvar.GetTestOrgFromEnv(t), | ||
| "billing_account": envvar.GetTestBillingAccountFromEnv(t), | ||
| "random_suffix": acctest.RandString(t, 10), | ||
| } | ||
|
|
||
| acctest.VcrTest(t, resource.TestCase{ | ||
| PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
| ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
| Steps: []resource.TestStep{ | ||
| { | ||
| Config: testAccDialogflowVersion_full1(context), | ||
| }, | ||
| { | ||
| ResourceName: "google_dialogflow_version.foobar", | ||
| RefreshState: true, | ||
| }, | ||
| { | ||
| Config: testAccDialogflowVersion_full2(context), | ||
| }, | ||
| { | ||
| ResourceName: "google_dialogflow_version.foobar", | ||
| RefreshState: true, | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func testAccDialogflowVersion_full1(context map[string]interface{}) string { | ||
| return acctest.Nprintf(` | ||
| resource "google_project" "agent_project" { | ||
| name = "tf-test-dialogflow-%{random_suffix}" | ||
| project_id = "tf-test-dialogflow-%{random_suffix}" | ||
| org_id = "%{org_id}" | ||
| billing_account = "%{billing_account}" | ||
| deletion_policy = "DELETE" | ||
| } | ||
|
|
||
| resource "google_project_service" "agent_project" { | ||
| project = google_project.agent_project.project_id | ||
| service = "dialogflow.googleapis.com" | ||
| disable_dependent_services = false | ||
| } | ||
|
|
||
| resource "google_service_account" "dialogflow_service_account" { | ||
| account_id = "tf-test-dialogflow-%{random_suffix}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "agent_create" { | ||
| project = google_project_service.agent_project.project | ||
| role = "roles/dialogflow.admin" | ||
| member = "serviceAccount:${google_service_account.dialogflow_service_account.email}" | ||
| } | ||
|
|
||
| resource "google_dialogflow_agent" "agent" { | ||
| project = google_project.agent_project.project_id | ||
| display_name = "tf-test-agent-%{random_suffix}" | ||
| default_language_code = "en" | ||
| time_zone = "America/New_York" | ||
| depends_on = [google_project_iam_member.agent_create] | ||
| } | ||
|
|
||
| resource "google_dialogflow_version" "foobar" { | ||
| depends_on = [google_dialogflow_agent.agent] | ||
| parent = "projects/${google_project.agent_project.project_id}/agent" | ||
| description = "tf-test-description-%{random_suffix}" | ||
| } | ||
| `, context) | ||
| } | ||
|
|
||
| func testAccDialogflowVersion_full2(context map[string]interface{}) string { | ||
| return acctest.Nprintf(` | ||
| resource "google_project" "agent_project" { | ||
| name = "tf-test-dialogflow-%{random_suffix}" | ||
| project_id = "tf-test-dialogflow-%{random_suffix}" | ||
| org_id = "%{org_id}" | ||
| billing_account = "%{billing_account}" | ||
| deletion_policy = "DELETE" | ||
| } | ||
|
|
||
| resource "google_project_service" "agent_project" { | ||
| project = google_project.agent_project.project_id | ||
| service = "dialogflow.googleapis.com" | ||
| disable_dependent_services = false | ||
| } | ||
|
|
||
| resource "google_service_account" "dialogflow_service_account" { | ||
| account_id = "tf-test-dialogflow-%{random_suffix}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "agent_create" { | ||
| project = google_project_service.agent_project.project | ||
| role = "roles/dialogflow.admin" | ||
| member = "serviceAccount:${google_service_account.dialogflow_service_account.email}" | ||
| } | ||
|
|
||
| resource "google_dialogflow_agent" "agent" { | ||
| project = google_project.agent_project.project_id | ||
| display_name = "tf-test-agent-%{random_suffix}" | ||
| default_language_code = "en" | ||
| time_zone = "America/New_York" | ||
| depends_on = [google_project_iam_member.agent_create] | ||
| } | ||
|
|
||
| resource "google_dialogflow_version" "foobar" { | ||
| depends_on = [google_dialogflow_agent.agent] | ||
| parent = "projects/${google_project.agent_project.project_id}/agent" | ||
| description = "tf-test-version-%{random_suffix}2" | ||
| } | ||
| `, context) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove as this is empty