Skip to content

Commit 10b4a62

Browse files
samples: Add docstring to all code samples (#171)
* samples: Add docstring to all code samples * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 4100cac commit 10b4a62

10 files changed

+126
-0
lines changed

contact-center-insights/snippets/create_analysis.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717

1818

1919
def create_analysis(conversation_name: str) -> contact_center_insights_v1.Analysis:
20+
"""Creates an analysis.
21+
22+
Args:
23+
conversation_name:
24+
The parent resource of the analysis.
25+
Format is 'projects/{project_id}/locations/{location_id}/conversations/{conversation_id}'.
26+
For example, 'projects/my-project/locations/us-central1/conversations/123456789'.
27+
28+
Returns:
29+
An analysis.
30+
"""
2031
# Construct an analysis.
2132
analysis = contact_center_insights_v1.Analysis()
2233

contact-center-insights/snippets/create_conversation.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ def create_conversation(
2121
transcript_uri: str = "gs://cloud-samples-data/ccai/chat_sample.json",
2222
audio_uri: str = "gs://cloud-samples-data/ccai/voice_6912.txt",
2323
) -> contact_center_insights_v1.Conversation:
24+
"""Creates a conversation.
25+
26+
Args:
27+
project_id:
28+
The project identifier. For example, 'my-project'.
29+
transcript_uri:
30+
The Cloud Storage URI that points to a file that contains the
31+
conversation transcript. Format is 'gs://{bucket_name}/{file.json}'.
32+
For example, 'gs://cloud-samples-data/ccai/chat_sample.json'.
33+
audio_uri:
34+
The Cloud Storage URI that points to a file that contains the
35+
conversation audio. Format is 'gs://{bucket_name}/{file.json}'.
36+
For example, 'gs://cloud-samples-data/ccai/voice_6912.txt'.
37+
38+
Returns:
39+
A conversation.
40+
"""
2441
# Construct a parent resource.
2542
parent = (
2643
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(

contact-center-insights/snippets/create_conversation_with_ttl.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ def create_conversation_with_ttl(
2323
transcript_uri: str = "gs://cloud-samples-data/ccai/chat_sample.json",
2424
audio_uri: str = "gs://cloud-samples-data/ccai/voice_6912.txt",
2525
) -> contact_center_insights_v1.Conversation:
26+
"""Creates a conversation with a TTL value.
27+
28+
Args:
29+
project_id:
30+
The project identifier. For example, 'my-project'.
31+
transcript_uri:
32+
The Cloud Storage URI that points to a file that contains the
33+
conversation transcript. Format is 'gs://{bucket_name}/{file.json}'.
34+
For example, 'gs://cloud-samples-data/ccai/chat_sample.json'.
35+
audio_uri:
36+
The Cloud Storage URI that points to a file that contains the
37+
conversation audio. Format is 'gs://{bucket_name}/{file.json}'.
38+
For example, 'gs://cloud-samples-data/ccai/voice_6912.txt'.
39+
40+
Returns:
41+
A conversation.
42+
"""
2643
# Construct a parent resource.
2744
parent = (
2845
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(

contact-center-insights/snippets/create_issue_model.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717

1818

1919
def create_issue_model(project_id: str) -> contact_center_insights_v1.IssueModel:
20+
"""Creates an issue model.
21+
22+
Args:
23+
project_id:
24+
The project identifier. For example, 'my-project'.
25+
26+
Returns:
27+
An issue model.
28+
"""
2029
# Construct a parent resource.
2130
parent = (
2231
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(

contact-center-insights/snippets/create_phrase_matcher_all_of.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
def create_phrase_matcher_all_of(
2020
project_id: str,
2121
) -> contact_center_insights_v1.PhraseMatcher:
22+
"""Creates a phrase matcher that matches all specified queries.
23+
24+
Args:
25+
project_id:
26+
The project identifier. For example, 'my-project'.
27+
28+
Returns:
29+
A phrase matcher.
30+
"""
2231
# Construct a parent resource.
2332
parent = (
2433
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(

contact-center-insights/snippets/create_phrase_matcher_any_of.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
def create_phrase_matcher_any_of(
2020
project_id: str,
2121
) -> contact_center_insights_v1.PhraseMatcher:
22+
"""Creates a phrase matcher that matches any of the specified queries.
23+
24+
Args:
25+
project_id:
26+
The project identifier. For example, 'my-project'.
27+
28+
Returns:
29+
A phrase matcher.
30+
"""
2231
# Construct a parent resource.
2332
parent = (
2433
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(

contact-center-insights/snippets/enable_pubsub_notifications.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@
2020
def enable_pubsub_notifications(
2121
project_id: str, topic_create_conversation: str, topic_create_analysis: str
2222
) -> None:
23+
"""Enables Cloud Pub/Sub notifications for specified events.
24+
25+
Args:
26+
project_id:
27+
The project identifier. For example, 'my-project'.
28+
topic_create_conversation:
29+
The Cloud Pub/Sub topic to notify of conversation creation events.
30+
Format is 'projects/{project_id}/topics/{topic_id}'.
31+
For example, 'projects/my-project/topics/my-topic'.
32+
topic_create_analysis:
33+
The Cloud Pub/Sub topic to notify of analysis creation events.
34+
Format is 'projects/{project_id}/topics/{topic_id}'.
35+
For example, 'projects/my-project/topics/my-topic'.
36+
37+
Returns:
38+
None.
39+
"""
2340
# Construct a settings resource.
2441
settings = contact_center_insights_v1.Settings()
2542
settings.name = (

contact-center-insights/snippets/export_to_bigquery.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ def export_to_bigquery(
2222
bigquery_dataset_id: str,
2323
bigquery_table_id: str,
2424
) -> None:
25+
"""Exports data to BigQuery.
26+
27+
Args:
28+
project_id:
29+
The project identifier that owns the data source to be exported.
30+
For example, 'my-project'.
31+
bigquery_project_id:
32+
The project identifier that owns the BigQuery sink to export data to.
33+
For example, 'my-project'.
34+
bigquery_dataset_id:
35+
The BigQuery dataset identifier. For example, 'my-dataset'.
36+
bigquery_table_id:
37+
The BigQuery table identifier. For example, 'my-table'.
38+
39+
Returns:
40+
None.
41+
"""
2542
# Construct an export request.
2643
request = contact_center_insights_v1.ExportInsightsDataRequest()
2744
request.parent = (

contact-center-insights/snippets/get_operation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919

2020

2121
def get_operation(operation_name: str) -> operations_pb2.Operation:
22+
"""Gets an operation.
23+
24+
Args:
25+
operation_name:
26+
The operation name.
27+
Format is 'projects/{project_id}/locations/{location_id}/operations/{operation_id}'.
28+
For example, 'projects/my-project/locations/us-central1/operations/123456789'.
29+
30+
Returns:
31+
An operation.
32+
"""
2233
# Construct an Insights client that will authenticate via Application Default Credentials.
2334
# See authentication details at https://cloud.google.com/docs/authentication/production.
2435
insights_client = contact_center_insights_v1.ContactCenterInsightsClient()

contact-center-insights/snippets/set_project_ttl.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020

2121

2222
def set_project_ttl(project_id: str) -> None:
23+
"""Sets a project-level TTL for all incoming conversations.
24+
25+
Args:
26+
project_id:
27+
The project identifier. For example, 'my-project'.
28+
29+
Returns:
30+
None.
31+
"""
2332
# Construct a settings resource.
2433
settings = contact_center_insights_v1.Settings()
2534
settings.name = (

0 commit comments

Comments
 (0)