Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

feat: Launch UploadConversation endpoint #301

Merged
merged 2 commits into from Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file.
6 changes: 6 additions & 0 deletions google/cloud/contact_center_insights/__init__.py
Expand Up @@ -84,6 +84,8 @@
UpdatePhraseMatcherRequest,
UpdateSettingsRequest,
UpdateViewRequest,
UploadConversationMetadata,
UploadConversationRequest,
)
from google.cloud.contact_center_insights_v1.types.resources import (
Analysis,
Expand Down Expand Up @@ -120,6 +122,7 @@
PhraseMatchRule,
PhraseMatchRuleConfig,
PhraseMatchRuleGroup,
RedactionConfig,
RuntimeAnnotation,
SentimentData,
Settings,
Expand Down Expand Up @@ -190,6 +193,8 @@
"UpdatePhraseMatcherRequest",
"UpdateSettingsRequest",
"UpdateViewRequest",
"UploadConversationMetadata",
"UploadConversationRequest",
"ConversationView",
"Analysis",
"AnalysisResult",
Expand Down Expand Up @@ -225,6 +230,7 @@
"PhraseMatchRule",
"PhraseMatchRuleConfig",
"PhraseMatchRuleGroup",
"RedactionConfig",
"RuntimeAnnotation",
"SentimentData",
"Settings",
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/contact_center_insights_v1/__init__.py
Expand Up @@ -82,6 +82,8 @@
UpdatePhraseMatcherRequest,
UpdateSettingsRequest,
UpdateViewRequest,
UploadConversationMetadata,
UploadConversationRequest,
)
from .types.resources import (
Analysis,
Expand Down Expand Up @@ -118,6 +120,7 @@
PhraseMatchRule,
PhraseMatchRuleConfig,
PhraseMatchRuleGroup,
RedactionConfig,
RuntimeAnnotation,
SentimentData,
Settings,
Expand Down Expand Up @@ -214,6 +217,7 @@
"PhraseMatchRuleConfig",
"PhraseMatchRuleGroup",
"PhraseMatcher",
"RedactionConfig",
"RuntimeAnnotation",
"SentimentData",
"Settings",
Expand All @@ -229,5 +233,7 @@
"UpdatePhraseMatcherRequest",
"UpdateSettingsRequest",
"UpdateViewRequest",
"UploadConversationMetadata",
"UploadConversationRequest",
"View",
)
15 changes: 15 additions & 0 deletions google/cloud/contact_center_insights_v1/gapic_metadata.json
Expand Up @@ -194,6 +194,11 @@
"methods": [
"update_view"
]
},
"UploadConversation": {
"methods": [
"upload_conversation"
]
}
}
},
Expand Down Expand Up @@ -384,6 +389,11 @@
"methods": [
"update_view"
]
},
"UploadConversation": {
"methods": [
"upload_conversation"
]
}
}
},
Expand Down Expand Up @@ -574,6 +584,11 @@
"methods": [
"update_view"
]
},
"UploadConversation": {
"methods": [
"upload_conversation"
]
}
}
}
Expand Down
Expand Up @@ -381,6 +381,104 @@ async def sample_create_conversation():
# Done; return the response.
return response

async def upload_conversation(
self,
request: Optional[
Union[contact_center_insights.UploadConversationRequest, dict]
] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Create a longrunning conversation upload operation.
This method differs from CreateConversation by allowing
audio transcription and optional DLP redaction.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import contact_center_insights_v1

async def sample_upload_conversation():
# Create a client
client = contact_center_insights_v1.ContactCenterInsightsAsyncClient()

# Initialize request argument(s)
request = contact_center_insights_v1.UploadConversationRequest(
parent="parent_value",
)

# Make the request
operation = client.upload_conversation(request=request)

print("Waiting for operation to complete...")

response = (await operation).result()

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.contact_center_insights_v1.types.UploadConversationRequest, dict]]):
The request object. Request to upload a conversation.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.contact_center_insights_v1.types.Conversation`
The conversation resource.

"""
# Create or coerce a protobuf request object.
request = contact_center_insights.UploadConversationRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.upload_conversation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
resources.Conversation,
metadata_type=contact_center_insights.UploadConversationMetadata,
)

# Done; return the response.
return response

async def update_conversation(
self,
request: Optional[
Expand Down
Expand Up @@ -742,6 +742,105 @@ def sample_create_conversation():
# Done; return the response.
return response

def upload_conversation(
self,
request: Optional[
Union[contact_center_insights.UploadConversationRequest, dict]
] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Create a longrunning conversation upload operation.
This method differs from CreateConversation by allowing
audio transcription and optional DLP redaction.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import contact_center_insights_v1

def sample_upload_conversation():
# Create a client
client = contact_center_insights_v1.ContactCenterInsightsClient()

# Initialize request argument(s)
request = contact_center_insights_v1.UploadConversationRequest(
parent="parent_value",
)

# Make the request
operation = client.upload_conversation(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.contact_center_insights_v1.types.UploadConversationRequest, dict]):
The request object. Request to upload a conversation.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.api_core.operation.Operation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.contact_center_insights_v1.types.Conversation`
The conversation resource.

"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
# in a contact_center_insights.UploadConversationRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, contact_center_insights.UploadConversationRequest):
request = contact_center_insights.UploadConversationRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.upload_conversation]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation.from_gapic(
response,
self._transport.operations_client,
resources.Conversation,
metadata_type=contact_center_insights.UploadConversationMetadata,
)

# Done; return the response.
return response

def update_conversation(
self,
request: Optional[
Expand Down
Expand Up @@ -132,6 +132,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.upload_conversation: gapic_v1.method.wrap_method(
self.upload_conversation,
default_timeout=None,
client_info=client_info,
),
self.update_conversation: gapic_v1.method.wrap_method(
self.update_conversation,
default_timeout=None,
Expand Down Expand Up @@ -337,6 +342,15 @@ def create_conversation(
]:
raise NotImplementedError()

@property
def upload_conversation(
self,
) -> Callable[
[contact_center_insights.UploadConversationRequest],
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
]:
raise NotImplementedError()

@property
def update_conversation(
self,
Expand Down
Expand Up @@ -277,6 +277,36 @@ def create_conversation(
)
return self._stubs["create_conversation"]

@property
def upload_conversation(
self,
) -> Callable[
[contact_center_insights.UploadConversationRequest], operations_pb2.Operation
]:
r"""Return a callable for the upload conversation method over gRPC.

Create a longrunning conversation upload operation.
This method differs from CreateConversation by allowing
audio transcription and optional DLP redaction.

Returns:
Callable[[~.UploadConversationRequest],
~.Operation]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "upload_conversation" not in self._stubs:
self._stubs["upload_conversation"] = self.grpc_channel.unary_unary(
"/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UploadConversation",
request_serializer=contact_center_insights.UploadConversationRequest.serialize,
response_deserializer=operations_pb2.Operation.FromString,
)
return self._stubs["upload_conversation"]

@property
def update_conversation(
self,
Expand Down