Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
76 changes: 76 additions & 0 deletions mmv1/products/dialogflow/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright 2024 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Copyright 2024 Google Inc.
# Copyright 2025 Google Inc.

Copy link
Contributor

Choose a reason for hiding this comment

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

2025

# 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: '{{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:
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

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

Choose a reason for hiding this comment

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

This should be versionId. Also, this looks like it's not included in the URL anywhere, so this should probably be removed?

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
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'
37 changes: 37 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,37 @@
resource "google_project" "project" {
provider = google-beta
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove provider declaration

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

Choose a reason for hiding this comment

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

Remove in this whole example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To save time I'm not understanding why this is succeeding in my local environment and failing in the CICD environment. Is there anything I can do to mirror CICD to save churn?

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you running the test in the terraform-provider-google repo or google-beta? It may be a CI-only thing, but we restrict GA examples/tests from using google-beta declarations because it can get confusing. So if you're adding a beta-only test you need them, but if it's a GA test you can't have them.

Copy link
Contributor Author

@Spheny1 Spheny1 Oct 7, 2025

Choose a reason for hiding this comment

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

I removed the provider declaration. Are there any more changes needed before trying CICD step again?

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" {
description = "Dialogflow Version"
project = google_project.project.project_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Project doesn't belong here, I think this needs parent though?

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)
}
Loading