Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
147 changes: 147 additions & 0 deletions mmv1/products/contactcenterinsights/AssessmentRule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Copyright 2026 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: AssessmentRule
description: |
The CCAI Insights project wide assessment rule. This assessment rule will be
applied to all conversations from the previous sampling cycle that match the
sample rule defined in the assessment rule. One project can have multiple
assessment rules.
references:
guides:
'Configure assessment rules using the API': 'https://cloud.google.com/contact-center/insights/docs/assessment-rule'
api: 'https://cloud.google.com/contact-center/insights/docs/reference/rest/v1/projects.locations.assessmentRules'
base_url: projects/{{project}}/locations/{{location}}/assessmentRules
update_mask: true
self_link: projects/{{project}}/locations/{{location}}/assessmentRules/{{name}}
create_url: projects/{{project}}/locations/{{location}}/assessmentRules?assessmentRuleId={{assessment_rule_id}}
update_verb: PATCH
id_format: projects/{{project}}/locations/{{location}}/assessmentRules/{{name}}
import_format:
- projects/{{project}}/locations/{{location}}/assessmentRules/{{name}}
examples:
- name: 'contact_center_insights_assessment_rule_basic'
primary_resource_id: 'assessment_rule_basic'
vars:
resource_name: 'assessmentrulebasic'
test_vars_overrides:
'id_suffix': 'strings.ToLower(acctest.RandString(t, 10))'
- name: 'contact_center_insights_assessment_rule_full'
primary_resource_id: 'assessment_rule_full'
vars:
resource_name: 'assessmentrulefull'
test_vars_overrides:
'id_suffix': 'strings.ToLower(acctest.RandString(t, 10))'
autogen_status: QXNzZXNzbWVudFJ1bGU=
parameters:
- name: location
type: String
required: true
description: Location of the resource.
immutable: true
url_param_only: true
- name: assessmentRuleId
type: String
description: |-
A unique ID for the new AssessmentRule. This ID will become the final
component of the AssessmentRule's resource name. If no ID is specified,
a server-generated ID will be used.

This value should be 4-64 characters and must match the regular
expression `^[A-Za-z0-9]{4,64}$`.
immutable: true
url_param_only: true
properties:
- name: active
type: Boolean
description: |-
If true, apply this rule to conversations. Otherwise, this rule is
inactive.
- name: createTime
type: String
description: The time at which this assessment rule was created.
output: true
- name: displayName
type: String
description: Display Name of the assessment rule.
- name: name
type: String
description: |-
Identifier. The resource name of the assessment rule.
Format:
projects/{project}/locations/{location}/assessmentRules/{assessment_rule}
output: true
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl'
- name: sampleRule
type: NestedObject
description: Message for sampling conversations.
properties:
- name: conversationFilter
type: String
description: |-
To specify the filter for the conversions that should apply this sample
rule. An empty filter means this sample rule applies to all conversations.
- name: dimension
type: String
description: |-
Group by dimension to sample the conversation. If no dimension is
provided, the sampling will be applied to the project level.
Current supported dimensions is 'quality_metadata.agent_info.agent_id'.
- name: samplePercentage
type: Double
description: |-
Percentage of conversations that we should sample based on the dimension
between [0, 100].
conflicts:
- sample_row
- name: sampleRow
type: Integer
description: Number of the conversations that we should sample based on the dimension.
conflicts:
- sample_percentage
- name: scheduleInfo
type: NestedObject
description: Message for schedule info.
properties:
- name: endTime
type: String
description: |-
End time of the schedule. If not specified, will keep scheduling new
Copy link
Contributor

Choose a reason for hiding this comment

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

this field could use a formatting explanation

pipelines for execution util the schedule is no longer active or deleted.
- name: schedule
type: String
description: |-
The groc expression.
Format: `every number [synchronized]`
Time units can be: minutes, hours
Synchronized is optional and indicates that the schedule should be
synchronized to the start of the interval: every 5 minutes synchronized
means 00:00, 00:05 ...
Otherwise the start time is random within the interval.
Example: `every 5 minutes`
could be 00:02, 00:07, 00:12, ...
- name: startTime
type: String
description: |-
Start time of the schedule. If not specified, will start as soon as the
Copy link
Contributor

Choose a reason for hiding this comment

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

as could this

schedule is created.
- name: timeZone
type: String
description: |-
The timezone to use for the groc expression.
If not specified, defaults to UTC.
- name: updateTime
type: String
description: The most recent time at which this assessment rule was updated.
output: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_contact_center_insights_assessment_rule" "{{$.PrimaryResourceId}}" {
display_name = "{{index $.Vars "resource_name"}}"
assessment_rule_id = "assessmentrulebasic%{id_suffix}"
location = "us-central1"
sample_rule {
sample_percentage = 0.5
}
schedule_info {
schedule = "every 5 minutes"
}
active = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "google_contact_center_insights_assessment_rule" "{{$.PrimaryResourceId}}" {
display_name = "{{index $.Vars "resource_name"}}"
assessment_rule_id = "assessmentrulefull%{id_suffix}"
location = "us-central1"
sample_rule {
sample_percentage = 0.5
conversation_filter = "medium=\"CHAT\""
}
schedule_info {
schedule = "every 5 minutes"
time_zone = "America/Los_Angeles"
}
active = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package contactcenterinsights_test

import (
"strings"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
)

func TestAccContactCenterInsightsAssessmentRule_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": strings.ToLower(acctest.RandString(t, 10)),
"project_number": envvar.GetTestProjectNumberFromEnv(),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccContactCenterInsightsAssessmentRule_full(context),
},
{
ResourceName: "google_contact_center_insights_assessment_rule.assessment_rule_full",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "assessment_rule_id"},
},
{
Config: testAccContactCenterInsightsAssessmentRule_update(context),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("google_contact_center_insights_assessment_rule.assessment_rule_full", plancheck.ResourceActionUpdate),
},
},
},
{
ResourceName: "google_contact_center_insights_assessment_rule.assessment_rule_full",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "assessment_rule_id"},
},
},
})
}

func TestAccContactCenterInsightsAssessmentRule_sampleRow(t *testing.T) {
t.Parallel()

now := time.Now().UTC()
startTime := now.Add(1 * time.Hour).Format(time.RFC3339)
endTime := now.Add(2 * time.Hour).Format(time.RFC3339)

context := map[string]interface{}{
"random_suffix": strings.ToLower(acctest.RandString(t, 10)),
"project_number": envvar.GetTestProjectNumberFromEnv(),
"start_time": startTime,
"end_time": endTime,
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccContactCenterInsightsAssessmentRule_sampleRow(context),
},
{
ResourceName: "google_contact_center_insights_assessment_rule.assessment_rule_sample_row",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "assessment_rule_id", "schedule_info.0.start_time", "schedule_info.0.end_time"},
},
},
})
}

func testAccContactCenterInsightsAssessmentRule_full(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_contact_center_insights_assessment_rule" "assessment_rule_full" {
display_name = "assessment-rule-display-name-%{random_suffix}"
assessment_rule_id = "rule%{random_suffix}"
location = "us-central1"
sample_rule {
sample_percentage = 0.5
conversation_filter = "medium=\"CHAT\""
}
schedule_info {
schedule = "every 5 minutes"
time_zone = "UTC"
}
active = true
}
`, context)
}

func testAccContactCenterInsightsAssessmentRule_update(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_contact_center_insights_assessment_rule" "assessment_rule_full" {
display_name = "assessment-rule-display-name-%{random_suffix}-updated"
assessment_rule_id = "rule%{random_suffix}"
location = "us-central1"
sample_rule {
sample_percentage = 0.5
conversation_filter = "medium=\"PHONE_CALL\""
}
schedule_info {
schedule = "every 5 minutes"
time_zone = "America/New_York"
}
active = false
}
`, context)
}

func testAccContactCenterInsightsAssessmentRule_sampleRow(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_contact_center_insights_assessment_rule" "assessment_rule_sample_row" {
display_name = "assessment-rule-sample-row-%{random_suffix}"
assessment_rule_id = "rowrule%{random_suffix}"
location = "us-central1"
sample_rule {
sample_row = 10
dimension = "quality_metadata.agent_info.agent_id"
conversation_filter = "medium=\"CHAT\""
}
schedule_info {
schedule = "every 1 hours"
start_time = "%{start_time}"
end_time = "%{end_time}"
time_zone = "UTC"
}
active = true
}
`, context)
}
Loading