Skip to content

Commit

Permalink
samples: Add docstring to all code samples (#171)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
TrucHLe and gcf-owl-bot[bot] authored Apr 28, 2022
1 parent 8eb1665 commit f65cc89
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@


def create_analysis(conversation_name: str) -> contact_center_insights_v1.Analysis:
"""Creates an analysis.
Args:
conversation_name:
The parent resource of the analysis.
Format is 'projects/{project_id}/locations/{location_id}/conversations/{conversation_id}'.
For example, 'projects/my-project/locations/us-central1/conversations/123456789'.
Returns:
An analysis.
"""
# Construct an analysis.
analysis = contact_center_insights_v1.Analysis()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ def create_conversation(
transcript_uri: str = "gs://cloud-samples-data/ccai/chat_sample.json",
audio_uri: str = "gs://cloud-samples-data/ccai/voice_6912.txt",
) -> contact_center_insights_v1.Conversation:
"""Creates a conversation.
Args:
project_id:
The project identifier. For example, 'my-project'.
transcript_uri:
The Cloud Storage URI that points to a file that contains the
conversation transcript. Format is 'gs://{bucket_name}/{file.json}'.
For example, 'gs://cloud-samples-data/ccai/chat_sample.json'.
audio_uri:
The Cloud Storage URI that points to a file that contains the
conversation audio. Format is 'gs://{bucket_name}/{file.json}'.
For example, 'gs://cloud-samples-data/ccai/voice_6912.txt'.
Returns:
A conversation.
"""
# Construct a parent resource.
parent = (
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ def create_conversation_with_ttl(
transcript_uri: str = "gs://cloud-samples-data/ccai/chat_sample.json",
audio_uri: str = "gs://cloud-samples-data/ccai/voice_6912.txt",
) -> contact_center_insights_v1.Conversation:
"""Creates a conversation with a TTL value.
Args:
project_id:
The project identifier. For example, 'my-project'.
transcript_uri:
The Cloud Storage URI that points to a file that contains the
conversation transcript. Format is 'gs://{bucket_name}/{file.json}'.
For example, 'gs://cloud-samples-data/ccai/chat_sample.json'.
audio_uri:
The Cloud Storage URI that points to a file that contains the
conversation audio. Format is 'gs://{bucket_name}/{file.json}'.
For example, 'gs://cloud-samples-data/ccai/voice_6912.txt'.
Returns:
A conversation.
"""
# Construct a parent resource.
parent = (
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@


def create_issue_model(project_id: str) -> contact_center_insights_v1.IssueModel:
"""Creates an issue model.
Args:
project_id:
The project identifier. For example, 'my-project'.
Returns:
An issue model.
"""
# Construct a parent resource.
parent = (
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
def create_phrase_matcher_all_of(
project_id: str,
) -> contact_center_insights_v1.PhraseMatcher:
"""Creates a phrase matcher that matches all specified queries.
Args:
project_id:
The project identifier. For example, 'my-project'.
Returns:
A phrase matcher.
"""
# Construct a parent resource.
parent = (
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
def create_phrase_matcher_any_of(
project_id: str,
) -> contact_center_insights_v1.PhraseMatcher:
"""Creates a phrase matcher that matches any of the specified queries.
Args:
project_id:
The project identifier. For example, 'my-project'.
Returns:
A phrase matcher.
"""
# Construct a parent resource.
parent = (
contact_center_insights_v1.ContactCenterInsightsClient.common_location_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@
def enable_pubsub_notifications(
project_id: str, topic_create_conversation: str, topic_create_analysis: str
) -> None:
"""Enables Cloud Pub/Sub notifications for specified events.
Args:
project_id:
The project identifier. For example, 'my-project'.
topic_create_conversation:
The Cloud Pub/Sub topic to notify of conversation creation events.
Format is 'projects/{project_id}/topics/{topic_id}'.
For example, 'projects/my-project/topics/my-topic'.
topic_create_analysis:
The Cloud Pub/Sub topic to notify of analysis creation events.
Format is 'projects/{project_id}/topics/{topic_id}'.
For example, 'projects/my-project/topics/my-topic'.
Returns:
None.
"""
# Construct a settings resource.
settings = contact_center_insights_v1.Settings()
settings.name = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def export_to_bigquery(
bigquery_dataset_id: str,
bigquery_table_id: str,
) -> None:
"""Exports data to BigQuery.
Args:
project_id:
The project identifier that owns the data source to be exported.
For example, 'my-project'.
bigquery_project_id:
The project identifier that owns the BigQuery sink to export data to.
For example, 'my-project'.
bigquery_dataset_id:
The BigQuery dataset identifier. For example, 'my-dataset'.
bigquery_table_id:
The BigQuery table identifier. For example, 'my-table'.
Returns:
None.
"""
# Construct an export request.
request = contact_center_insights_v1.ExportInsightsDataRequest()
request.parent = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@


def get_operation(operation_name: str) -> operations_pb2.Operation:
"""Gets an operation.
Args:
operation_name:
The operation name.
Format is 'projects/{project_id}/locations/{location_id}/operations/{operation_id}'.
For example, 'projects/my-project/locations/us-central1/operations/123456789'.
Returns:
An operation.
"""
# Construct an Insights client that will authenticate via Application Default Credentials.
# See authentication details at https://cloud.google.com/docs/authentication/production.
insights_client = contact_center_insights_v1.ContactCenterInsightsClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@


def set_project_ttl(project_id: str) -> None:
"""Sets a project-level TTL for all incoming conversations.
Args:
project_id:
The project identifier. For example, 'my-project'.
Returns:
None.
"""
# Construct a settings resource.
settings = contact_center_insights_v1.Settings()
settings.name = (
Expand Down

0 comments on commit f65cc89

Please sign in to comment.