Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions mmv1/products/dialogflow/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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://cloud.google.com/dialogflow/docs/reference/rest/v2/projects/agent/versions'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Page 404s

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:
Copy link
Contributor

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

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.
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False is default, can remove

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs fix

- name: 'status'
type: Enum
description: |
The status of this version.
output: true
enum_values:
- 'VERSION_STATUS_UNSPECIFIED'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UNSPECIFIED is generally an invalid value to use, so it can be removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs fix

- 'IN_PROGRESS'
- 'READY'
- 'FAILED'
34 changes: 34 additions & 0 deletions mmv1/templates/terraform/examples/dialogflow_version_full.tf.tmpl
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" {
description = "Dialogflow Version"
parent = "projects/${google_project.project.project_id}/agent"
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]
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)
}
Loading