-
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
Add Version Resource #15114
Changes from 9 commits
47362e3
f0bdab3
fb07969
b7c8aaa
1eda0cb
4dbfbd9
5f18e0f
3c0bcf7
8a27ca1
4c23d87
df8ddcf
a9d035a
d645f42
1fcc8ce
1995b06
847eaf5
98568cb
f5febd9
14e49d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # 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: '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://cloud.google.com/dialogflow/docs/reference/rest/v2/projects/agent/versions' | ||
|
||
| docs: | ||
| id_format: '{{name}}' | ||
| base_url: 'projects/{{project}}/agent/versions' | ||
| self_link: '{{name}}' | ||
| update_verb: 'PATCH' | ||
| update_mask: true | ||
| import_format: | ||
| - 'projects/{{project}}/agent/versions/{{version_id}}' | ||
| timeouts: | ||
| insert_minutes: 40 | ||
| update_minutes: 40 | ||
| delete_minutes: 20 | ||
| custom_code: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove as this is empty |
||
| 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: 'name' | ||
| type: String | ||
| description: | | ||
| The unique identifier of this agent version. | ||
| output: true | ||
| - name: 'versionNumber' | ||
| type: Integer | ||
| description: | | ||
| The sequential number of this version. | ||
| output: true | ||
| - name: 'version_id' | ||
|
||
| type: String | ||
| description: 'The numeric ID of the version, used to construct the URL.' | ||
| url_param_only: true | ||
| - name: 'description' | ||
| type: String | ||
| description: | | ||
| The developer-provided description of this version. | ||
| required: false | ||
|
||
| - name: 'status' | ||
| type: Enum | ||
| description: | | ||
| The status of this version. | ||
| output: true | ||
| enum_values: | ||
| - 'VERSION_STATUS_UNSPECIFIED' | ||
|
||
| - 'IN_PROGRESS' | ||
| - 'READY' | ||
| - 'FAILED' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| resource "google_project" "project" { | ||
| provider = google-beta | ||
|
||
| 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" { | ||
| provider = google-beta | ||
|
||
| 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" { | ||
| provider = google-beta | ||
| 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" | ||
| project = google_project.project.project_id | ||
|
||
| depends_on = [google_dialogflow_agent.basic_agent] | ||
| } | ||
| 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] | ||
| project = google_project.agent_project.project_id | ||
| 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] | ||
| project = google_project.agent_project.project_id | ||
| description = "tf-test-version-%{random_suffix}2" | ||
| } | ||
| `, context) | ||
| } |
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.