diff --git a/google/cloud/contact_center_insights/__init__.py b/google/cloud/contact_center_insights/__init__.py index 4f3f328..cdf0e98 100644 --- a/google/cloud/contact_center_insights/__init__.py +++ b/google/cloud/contact_center_insights/__init__.py @@ -42,6 +42,12 @@ from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( CreateConversationRequest, ) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + CreateIssueModelMetadata, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + CreateIssueModelRequest, +) from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( CreatePhraseMatcherRequest, ) @@ -51,9 +57,24 @@ from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( DeleteConversationRequest, ) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + DeleteIssueModelMetadata, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + DeleteIssueModelRequest, +) from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( DeletePhraseMatcherRequest, ) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + DeployIssueModelMetadata, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + DeployIssueModelRequest, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + DeployIssueModelResponse, +) from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( ExportInsightsDataMetadata, ) @@ -111,9 +132,24 @@ from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( ListPhraseMatchersResponse, ) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + UndeployIssueModelMetadata, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + UndeployIssueModelRequest, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + UndeployIssueModelResponse, +) from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( UpdateConversationRequest, ) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + UpdateIssueModelRequest, +) +from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( + UpdateIssueRequest, +) from google.cloud.contact_center_insights_v1.types.contact_center_insights import ( UpdateSettingsRequest, ) @@ -183,10 +219,17 @@ "CreateAnalysisOperationMetadata", "CreateAnalysisRequest", "CreateConversationRequest", + "CreateIssueModelMetadata", + "CreateIssueModelRequest", "CreatePhraseMatcherRequest", "DeleteAnalysisRequest", "DeleteConversationRequest", + "DeleteIssueModelMetadata", + "DeleteIssueModelRequest", "DeletePhraseMatcherRequest", + "DeployIssueModelMetadata", + "DeployIssueModelRequest", + "DeployIssueModelResponse", "ExportInsightsDataMetadata", "ExportInsightsDataRequest", "ExportInsightsDataResponse", @@ -206,7 +249,12 @@ "ListIssuesResponse", "ListPhraseMatchersRequest", "ListPhraseMatchersResponse", + "UndeployIssueModelMetadata", + "UndeployIssueModelRequest", + "UndeployIssueModelResponse", "UpdateConversationRequest", + "UpdateIssueModelRequest", + "UpdateIssueRequest", "UpdateSettingsRequest", "ConversationView", "Analysis", diff --git a/google/cloud/contact_center_insights_v1/__init__.py b/google/cloud/contact_center_insights_v1/__init__.py index 5610124..2e2e6fa 100644 --- a/google/cloud/contact_center_insights_v1/__init__.py +++ b/google/cloud/contact_center_insights_v1/__init__.py @@ -24,10 +24,17 @@ from .types.contact_center_insights import CreateAnalysisOperationMetadata from .types.contact_center_insights import CreateAnalysisRequest from .types.contact_center_insights import CreateConversationRequest +from .types.contact_center_insights import CreateIssueModelMetadata +from .types.contact_center_insights import CreateIssueModelRequest from .types.contact_center_insights import CreatePhraseMatcherRequest from .types.contact_center_insights import DeleteAnalysisRequest from .types.contact_center_insights import DeleteConversationRequest +from .types.contact_center_insights import DeleteIssueModelMetadata +from .types.contact_center_insights import DeleteIssueModelRequest from .types.contact_center_insights import DeletePhraseMatcherRequest +from .types.contact_center_insights import DeployIssueModelMetadata +from .types.contact_center_insights import DeployIssueModelRequest +from .types.contact_center_insights import DeployIssueModelResponse from .types.contact_center_insights import ExportInsightsDataMetadata from .types.contact_center_insights import ExportInsightsDataRequest from .types.contact_center_insights import ExportInsightsDataResponse @@ -47,7 +54,12 @@ from .types.contact_center_insights import ListIssuesResponse from .types.contact_center_insights import ListPhraseMatchersRequest from .types.contact_center_insights import ListPhraseMatchersResponse +from .types.contact_center_insights import UndeployIssueModelMetadata +from .types.contact_center_insights import UndeployIssueModelRequest +from .types.contact_center_insights import UndeployIssueModelResponse from .types.contact_center_insights import UpdateConversationRequest +from .types.contact_center_insights import UpdateIssueModelRequest +from .types.contact_center_insights import UpdateIssueRequest from .types.contact_center_insights import UpdateSettingsRequest from .types.contact_center_insights import ConversationView from .types.resources import Analysis @@ -110,10 +122,17 @@ "CreateAnalysisOperationMetadata", "CreateAnalysisRequest", "CreateConversationRequest", + "CreateIssueModelMetadata", + "CreateIssueModelRequest", "CreatePhraseMatcherRequest", "DeleteAnalysisRequest", "DeleteConversationRequest", + "DeleteIssueModelMetadata", + "DeleteIssueModelRequest", "DeletePhraseMatcherRequest", + "DeployIssueModelMetadata", + "DeployIssueModelRequest", + "DeployIssueModelResponse", "DialogflowIntent", "DialogflowInteractionData", "DialogflowSource", @@ -161,6 +180,11 @@ "SilenceData", "SmartComposeSuggestionData", "SmartReplyData", + "UndeployIssueModelMetadata", + "UndeployIssueModelRequest", + "UndeployIssueModelResponse", "UpdateConversationRequest", + "UpdateIssueModelRequest", + "UpdateIssueRequest", "UpdateSettingsRequest", ) diff --git a/google/cloud/contact_center_insights_v1/gapic_metadata.json b/google/cloud/contact_center_insights_v1/gapic_metadata.json index 0656eb8..3656348 100644 --- a/google/cloud/contact_center_insights_v1/gapic_metadata.json +++ b/google/cloud/contact_center_insights_v1/gapic_metadata.json @@ -30,6 +30,11 @@ "create_conversation" ] }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, "CreatePhraseMatcher": { "methods": [ "create_phrase_matcher" @@ -45,11 +50,21 @@ "delete_conversation" ] }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, "DeletePhraseMatcher": { "methods": [ "delete_phrase_matcher" ] }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, "ExportInsightsData": { "methods": [ "export_insights_data" @@ -110,11 +125,26 @@ "list_phrase_matchers" ] }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, "UpdateConversation": { "methods": [ "update_conversation" ] }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, "UpdateSettings": { "methods": [ "update_settings" @@ -145,6 +175,11 @@ "create_conversation" ] }, + "CreateIssueModel": { + "methods": [ + "create_issue_model" + ] + }, "CreatePhraseMatcher": { "methods": [ "create_phrase_matcher" @@ -160,11 +195,21 @@ "delete_conversation" ] }, + "DeleteIssueModel": { + "methods": [ + "delete_issue_model" + ] + }, "DeletePhraseMatcher": { "methods": [ "delete_phrase_matcher" ] }, + "DeployIssueModel": { + "methods": [ + "deploy_issue_model" + ] + }, "ExportInsightsData": { "methods": [ "export_insights_data" @@ -225,11 +270,26 @@ "list_phrase_matchers" ] }, + "UndeployIssueModel": { + "methods": [ + "undeploy_issue_model" + ] + }, "UpdateConversation": { "methods": [ "update_conversation" ] }, + "UpdateIssue": { + "methods": [ + "update_issue" + ] + }, + "UpdateIssueModel": { + "methods": [ + "update_issue_model" + ] + }, "UpdateSettings": { "methods": [ "update_settings" diff --git a/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py b/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py index c1d8519..7ca7689 100644 --- a/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py +++ b/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py @@ -34,6 +34,7 @@ from google.cloud.contact_center_insights_v1.types import contact_center_insights from google.cloud.contact_center_insights_v1.types import resources from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO @@ -63,6 +64,10 @@ class ContactCenterInsightsAsyncClient: parse_issue_model_path = staticmethod( ContactCenterInsightsClient.parse_issue_model_path ) + participant_path = staticmethod(ContactCenterInsightsClient.participant_path) + parse_participant_path = staticmethod( + ContactCenterInsightsClient.parse_participant_path + ) phrase_matcher_path = staticmethod(ContactCenterInsightsClient.phrase_matcher_path) parse_phrase_matcher_path = staticmethod( ContactCenterInsightsClient.parse_phrase_matcher_path @@ -955,6 +960,175 @@ async def export_insights_data( # Done; return the response. return response + async def create_issue_model( + self, + request: contact_center_insights.CreateIssueModelRequest = None, + *, + parent: str = None, + issue_model: resources.IssueModel = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates an issue model. + + Args: + request (:class:`google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest`): + The request object. The request to create an issue + model. + parent (:class:`str`): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): + Required. The issue model to create. + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.IssueModel` + The issue model resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, issue_model]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = contact_center_insights.CreateIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_issue_model, + 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.IssueModel, + metadata_type=contact_center_insights.CreateIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def update_issue_model( + self, + request: contact_center_insights.UpdateIssueModelRequest = None, + *, + issue_model: resources.IssueModel = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Updates an issue model. + + Args: + request (:class:`google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest`): + The request object. The request to update an issue + model. + issue_model (:class:`google.cloud.contact_center_insights_v1.types.IssueModel`): + Required. The new values for the + issue model. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = contact_center_insights.UpdateIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_issue_model, + 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( + (("issue_model.name", request.issue_model.name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + async def get_issue_model( self, request: contact_center_insights.GetIssueModelRequest = None, @@ -1091,6 +1265,264 @@ async def list_issue_models( # Done; return the response. return response + async def delete_issue_model( + self, + request: contact_center_insights.DeleteIssueModelRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes an issue model. + + Args: + request (:class:`google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest`): + The request object. The request to delete an issue + model. + name (:class:`str`): + Required. The name of the issue model + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = contact_center_insights.DeleteIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_issue_model, + 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((("name", request.name),)), + ) + + # 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, + empty_pb2.Empty, + metadata_type=contact_center_insights.DeleteIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def deploy_issue_model( + self, + request: contact_center_insights.DeployIssueModelRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Args: + request (:class:`google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest`): + The request object. The request to deploy an issue + model. + name (:class:`str`): + Required. The issue model to deploy. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.DeployIssueModelResponse` + The response to deploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = contact_center_insights.DeployIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.deploy_issue_model, + 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((("name", request.name),)), + ) + + # 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, + contact_center_insights.DeployIssueModelResponse, + metadata_type=contact_center_insights.DeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + async def undeploy_issue_model( + self, + request: contact_center_insights.UndeployIssueModelRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Args: + request (:class:`google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest`): + The request object. The request to undeploy an issue + model. + name (:class:`str`): + Required. The issue model to + undeploy. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.UndeployIssueModelResponse` + The response to undeploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = contact_center_insights.UndeployIssueModelRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.undeploy_issue_model, + 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((("name", request.name),)), + ) + + # 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, + contact_center_insights.UndeployIssueModelResponse, + metadata_type=contact_center_insights.UndeployIssueModelMetadata, + ) + + # Done; return the response. + return response + async def get_issue( self, request: contact_center_insights.GetIssueRequest = None, @@ -1227,6 +1659,84 @@ async def list_issues( # Done; return the response. return response + async def update_issue( + self, + request: contact_center_insights.UpdateIssueRequest = None, + *, + issue: resources.Issue = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Updates an issue. + + Args: + request (:class:`google.cloud.contact_center_insights_v1.types.UpdateIssueRequest`): + The request object. The request to update an issue. + issue (:class:`google.cloud.contact_center_insights_v1.types.Issue`): + Required. The new values for the + issue. + + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = contact_center_insights.UpdateIssueRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_issue, + 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( + (("issue.name", request.issue.name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + async def calculate_issue_model_stats( self, request: contact_center_insights.CalculateIssueModelStatsRequest = None, diff --git a/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py b/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py index 64ed034..c419cac 100644 --- a/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py +++ b/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py @@ -38,6 +38,7 @@ from google.cloud.contact_center_insights_v1.types import contact_center_insights from google.cloud.contact_center_insights_v1.types import resources from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ContactCenterInsightsTransport, DEFAULT_CLIENT_INFO @@ -236,6 +237,22 @@ def parse_issue_model_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def participant_path(project: str, conversation: str, participant: str,) -> str: + """Returns a fully-qualified participant string.""" + return "projects/{project}/conversations/{conversation}/participants/{participant}".format( + project=project, conversation=conversation, participant=participant, + ) + + @staticmethod + def parse_participant_path(path: str) -> Dict[str, str]: + """Parses a participant path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/conversations/(?P.+?)/participants/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def phrase_matcher_path(project: str, location: str, phrase_matcher: str,) -> str: """Returns a fully-qualified phrase_matcher string.""" @@ -1211,6 +1228,175 @@ def export_insights_data( # Done; return the response. return response + def create_issue_model( + self, + request: contact_center_insights.CreateIssueModelRequest = None, + *, + parent: str = None, + issue_model: resources.IssueModel = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Creates an issue model. + + Args: + request (google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest): + The request object. The request to create an issue + model. + parent (str): + Required. The parent resource of the + issue model. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The issue model to create. + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.IssueModel` + The issue model resource. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, issue_model]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.CreateIssueModelRequest. + # 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.CreateIssueModelRequest): + request = contact_center_insights.CreateIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if issue_model is not None: + request.issue_model = issue_model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_issue_model] + + # 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.IssueModel, + metadata_type=contact_center_insights.CreateIssueModelMetadata, + ) + + # Done; return the response. + return response + + def update_issue_model( + self, + request: contact_center_insights.UpdateIssueModelRequest = None, + *, + issue_model: resources.IssueModel = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.IssueModel: + r"""Updates an issue model. + + Args: + request (google.cloud.contact_center_insights_v1.types.UpdateIssueModelRequest): + The request object. The request to update an issue + model. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The new values for the + issue model. + + This corresponds to the ``issue_model`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.cloud.contact_center_insights_v1.types.IssueModel: + The issue model resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue_model, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateIssueModelRequest. + # 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.UpdateIssueModelRequest): + request = contact_center_insights.UpdateIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue_model is not None: + request.issue_model = issue_model + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("issue_model.name", request.issue_model.name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + def get_issue_model( self, request: contact_center_insights.GetIssueModelRequest = None, @@ -1347,6 +1533,264 @@ def list_issue_models( # Done; return the response. return response + def delete_issue_model( + self, + request: contact_center_insights.DeleteIssueModelRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deletes an issue model. + + Args: + request (google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest): + The request object. The request to delete an issue + model. + name (str): + Required. The name of the issue model + to delete. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated + empty messages in your APIs. A typical example is to + use it as the request or the response type of an API + method. For instance: + + service Foo { + rpc Bar(google.protobuf.Empty) returns + (google.protobuf.Empty); + + } + + The JSON representation for Empty is empty JSON + object {}. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeleteIssueModelRequest. + # 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.DeleteIssueModelRequest): + request = contact_center_insights.DeleteIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # 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, + empty_pb2.Empty, + metadata_type=contact_center_insights.DeleteIssueModelMetadata, + ) + + # Done; return the response. + return response + + def deploy_issue_model( + self, + request: contact_center_insights.DeployIssueModelRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Args: + request (google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest): + The request object. The request to deploy an issue + model. + name (str): + Required. The issue model to deploy. + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.DeployIssueModelResponse` + The response to deploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.DeployIssueModelRequest. + # 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.DeployIssueModelRequest): + request = contact_center_insights.DeployIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.deploy_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # 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, + contact_center_insights.DeployIssueModelResponse, + metadata_type=contact_center_insights.DeployIssueModelMetadata, + ) + + # Done; return the response. + return response + + def undeploy_issue_model( + self, + request: contact_center_insights.UndeployIssueModelRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Args: + request (google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest): + The request object. The request to undeploy an issue + model. + name (str): + Required. The issue model to + undeploy. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.UndeployIssueModelResponse` + The response to undeploy an issue model. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UndeployIssueModelRequest. + # 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.UndeployIssueModelRequest): + request = contact_center_insights.UndeployIssueModelRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.undeploy_issue_model] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # 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, + contact_center_insights.UndeployIssueModelResponse, + metadata_type=contact_center_insights.UndeployIssueModelMetadata, + ) + + # Done; return the response. + return response + def get_issue( self, request: contact_center_insights.GetIssueRequest = None, @@ -1483,6 +1927,84 @@ def list_issues( # Done; return the response. return response + def update_issue( + self, + request: contact_center_insights.UpdateIssueRequest = None, + *, + issue: resources.Issue = None, + update_mask: field_mask_pb2.FieldMask = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> resources.Issue: + r"""Updates an issue. + + Args: + request (google.cloud.contact_center_insights_v1.types.UpdateIssueRequest): + The request object. The request to update an issue. + issue (google.cloud.contact_center_insights_v1.types.Issue): + Required. The new values for the + issue. + + This corresponds to the ``issue`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + This corresponds to the ``update_mask`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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.cloud.contact_center_insights_v1.types.Issue: + The issue resource. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([issue, update_mask]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a contact_center_insights.UpdateIssueRequest. + # 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.UpdateIssueRequest): + request = contact_center_insights.UpdateIssueRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if issue is not None: + request.issue = issue + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_issue] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("issue.name", request.issue.name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + def calculate_issue_model_stats( self, request: contact_center_insights.CalculateIssueModelStatsRequest = None, diff --git a/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py b/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py index 037dc9a..1c91d8a 100644 --- a/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py +++ b/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py @@ -190,18 +190,38 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_issue_model: gapic_v1.method.wrap_method( + self.create_issue_model, default_timeout=None, client_info=client_info, + ), + self.update_issue_model: gapic_v1.method.wrap_method( + self.update_issue_model, default_timeout=None, client_info=client_info, + ), self.get_issue_model: gapic_v1.method.wrap_method( self.get_issue_model, default_timeout=None, client_info=client_info, ), self.list_issue_models: gapic_v1.method.wrap_method( self.list_issue_models, default_timeout=None, client_info=client_info, ), + self.delete_issue_model: gapic_v1.method.wrap_method( + self.delete_issue_model, default_timeout=None, client_info=client_info, + ), + self.deploy_issue_model: gapic_v1.method.wrap_method( + self.deploy_issue_model, default_timeout=None, client_info=client_info, + ), + self.undeploy_issue_model: gapic_v1.method.wrap_method( + self.undeploy_issue_model, + default_timeout=None, + client_info=client_info, + ), self.get_issue: gapic_v1.method.wrap_method( self.get_issue, default_timeout=None, client_info=client_info, ), self.list_issues: gapic_v1.method.wrap_method( self.list_issues, default_timeout=None, client_info=client_info, ), + self.update_issue: gapic_v1.method.wrap_method( + self.update_issue, default_timeout=None, client_info=client_info, + ), self.calculate_issue_model_stats: gapic_v1.method.wrap_method( self.calculate_issue_model_stats, default_timeout=None, @@ -337,6 +357,24 @@ def export_insights_data( ]: raise NotImplementedError() + @property + def create_issue_model( + self, + ) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def update_issue_model( + self, + ) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + Union[resources.IssueModel, Awaitable[resources.IssueModel]], + ]: + raise NotImplementedError() + @property def get_issue_model( self, @@ -358,6 +396,33 @@ def list_issue_models( ]: raise NotImplementedError() + @property + def delete_issue_model( + self, + ) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def deploy_issue_model( + self, + ) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def undeploy_issue_model( + self, + ) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def get_issue( self, @@ -379,6 +444,15 @@ def list_issues( ]: raise NotImplementedError() + @property + def update_issue( + self, + ) -> Callable[ + [contact_center_insights.UpdateIssueRequest], + Union[resources.Issue, Awaitable[resources.Issue]], + ]: + raise NotImplementedError() + @property def calculate_issue_model_stats( self, diff --git a/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py b/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py index b5e4ab4..75856fe 100644 --- a/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py +++ b/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py @@ -523,6 +523,62 @@ def export_insights_data( ) return self._stubs["export_insights_data"] + @property + def create_issue_model( + self, + ) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], operations_pb2.Operation + ]: + r"""Return a callable for the create issue model method over gRPC. + + Creates an issue model. + + Returns: + Callable[[~.CreateIssueModelRequest], + ~.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 "create_issue_model" not in self._stubs: + self._stubs["create_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel", + request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_issue_model"] + + @property + def update_issue_model( + self, + ) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], resources.IssueModel + ]: + r"""Return a callable for the update issue model method over gRPC. + + Updates an issue model. + + Returns: + Callable[[~.UpdateIssueModelRequest], + ~.IssueModel]: + 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 "update_issue_model" not in self._stubs: + self._stubs["update_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel", + request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs["update_issue_model"] + @property def get_issue_model( self, @@ -578,6 +634,94 @@ def list_issue_models( ) return self._stubs["list_issue_models"] + @property + def delete_issue_model( + self, + ) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], operations_pb2.Operation + ]: + r"""Return a callable for the delete issue model method over gRPC. + + Deletes an issue model. + + Returns: + Callable[[~.DeleteIssueModelRequest], + ~.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 "delete_issue_model" not in self._stubs: + self._stubs["delete_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel", + request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_issue_model"] + + @property + def deploy_issue_model( + self, + ) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], operations_pb2.Operation + ]: + r"""Return a callable for the deploy issue model method over gRPC. + + Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Returns: + Callable[[~.DeployIssueModelRequest], + ~.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 "deploy_issue_model" not in self._stubs: + self._stubs["deploy_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel", + request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["deploy_issue_model"] + + @property + def undeploy_issue_model( + self, + ) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], operations_pb2.Operation + ]: + r"""Return a callable for the undeploy issue model method over gRPC. + + Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Returns: + Callable[[~.UndeployIssueModelRequest], + ~.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 "undeploy_issue_model" not in self._stubs: + self._stubs["undeploy_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel", + request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["undeploy_issue_model"] + @property def get_issue( self, @@ -633,6 +777,32 @@ def list_issues( ) return self._stubs["list_issues"] + @property + def update_issue( + self, + ) -> Callable[[contact_center_insights.UpdateIssueRequest], resources.Issue]: + r"""Return a callable for the update issue method over gRPC. + + Updates an issue. + + Returns: + Callable[[~.UpdateIssueRequest], + ~.Issue]: + 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 "update_issue" not in self._stubs: + self._stubs["update_issue"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue", + request_serializer=contact_center_insights.UpdateIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs["update_issue"] + @property def calculate_issue_model_stats( self, diff --git a/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py b/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py index 14ed57f..4714cd8 100644 --- a/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py +++ b/google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py @@ -539,6 +539,64 @@ def export_insights_data( ) return self._stubs["export_insights_data"] + @property + def create_issue_model( + self, + ) -> Callable[ + [contact_center_insights.CreateIssueModelRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the create issue model method over gRPC. + + Creates an issue model. + + Returns: + Callable[[~.CreateIssueModelRequest], + Awaitable[~.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 "create_issue_model" not in self._stubs: + self._stubs["create_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/CreateIssueModel", + request_serializer=contact_center_insights.CreateIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["create_issue_model"] + + @property + def update_issue_model( + self, + ) -> Callable[ + [contact_center_insights.UpdateIssueModelRequest], + Awaitable[resources.IssueModel], + ]: + r"""Return a callable for the update issue model method over gRPC. + + Updates an issue model. + + Returns: + Callable[[~.UpdateIssueModelRequest], + Awaitable[~.IssueModel]]: + 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 "update_issue_model" not in self._stubs: + self._stubs["update_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssueModel", + request_serializer=contact_center_insights.UpdateIssueModelRequest.serialize, + response_deserializer=resources.IssueModel.deserialize, + ) + return self._stubs["update_issue_model"] + @property def get_issue_model( self, @@ -596,6 +654,97 @@ def list_issue_models( ) return self._stubs["list_issue_models"] + @property + def delete_issue_model( + self, + ) -> Callable[ + [contact_center_insights.DeleteIssueModelRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the delete issue model method over gRPC. + + Deletes an issue model. + + Returns: + Callable[[~.DeleteIssueModelRequest], + Awaitable[~.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 "delete_issue_model" not in self._stubs: + self._stubs["delete_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeleteIssueModel", + request_serializer=contact_center_insights.DeleteIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["delete_issue_model"] + + @property + def deploy_issue_model( + self, + ) -> Callable[ + [contact_center_insights.DeployIssueModelRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the deploy issue model method over gRPC. + + Deploys an issue model. Returns an error if a model + is already deployed. An issue model can only be used in + analysis after it has been deployed. + + Returns: + Callable[[~.DeployIssueModelRequest], + Awaitable[~.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 "deploy_issue_model" not in self._stubs: + self._stubs["deploy_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/DeployIssueModel", + request_serializer=contact_center_insights.DeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["deploy_issue_model"] + + @property + def undeploy_issue_model( + self, + ) -> Callable[ + [contact_center_insights.UndeployIssueModelRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the undeploy issue model method over gRPC. + + Undeploys an issue model. + An issue model can not be used in analysis after it has + been undeployed. + + Returns: + Callable[[~.UndeployIssueModelRequest], + Awaitable[~.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 "undeploy_issue_model" not in self._stubs: + self._stubs["undeploy_issue_model"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UndeployIssueModel", + request_serializer=contact_center_insights.UndeployIssueModelRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["undeploy_issue_model"] + @property def get_issue( self, @@ -653,6 +802,34 @@ def list_issues( ) return self._stubs["list_issues"] + @property + def update_issue( + self, + ) -> Callable[ + [contact_center_insights.UpdateIssueRequest], Awaitable[resources.Issue] + ]: + r"""Return a callable for the update issue method over gRPC. + + Updates an issue. + + Returns: + Callable[[~.UpdateIssueRequest], + Awaitable[~.Issue]]: + 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 "update_issue" not in self._stubs: + self._stubs["update_issue"] = self.grpc_channel.unary_unary( + "/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdateIssue", + request_serializer=contact_center_insights.UpdateIssueRequest.serialize, + response_deserializer=resources.Issue.deserialize, + ) + return self._stubs["update_issue"] + @property def calculate_issue_model_stats( self, diff --git a/google/cloud/contact_center_insights_v1/types/__init__.py b/google/cloud/contact_center_insights_v1/types/__init__.py index a7af4bf..1ec7a43 100644 --- a/google/cloud/contact_center_insights_v1/types/__init__.py +++ b/google/cloud/contact_center_insights_v1/types/__init__.py @@ -21,10 +21,17 @@ CreateAnalysisOperationMetadata, CreateAnalysisRequest, CreateConversationRequest, + CreateIssueModelMetadata, + CreateIssueModelRequest, CreatePhraseMatcherRequest, DeleteAnalysisRequest, DeleteConversationRequest, + DeleteIssueModelMetadata, + DeleteIssueModelRequest, DeletePhraseMatcherRequest, + DeployIssueModelMetadata, + DeployIssueModelRequest, + DeployIssueModelResponse, ExportInsightsDataMetadata, ExportInsightsDataRequest, ExportInsightsDataResponse, @@ -44,7 +51,12 @@ ListIssuesResponse, ListPhraseMatchersRequest, ListPhraseMatchersResponse, + UndeployIssueModelMetadata, + UndeployIssueModelRequest, + UndeployIssueModelResponse, UpdateConversationRequest, + UpdateIssueModelRequest, + UpdateIssueRequest, UpdateSettingsRequest, ConversationView, ) @@ -97,10 +109,17 @@ "CreateAnalysisOperationMetadata", "CreateAnalysisRequest", "CreateConversationRequest", + "CreateIssueModelMetadata", + "CreateIssueModelRequest", "CreatePhraseMatcherRequest", "DeleteAnalysisRequest", "DeleteConversationRequest", + "DeleteIssueModelMetadata", + "DeleteIssueModelRequest", "DeletePhraseMatcherRequest", + "DeployIssueModelMetadata", + "DeployIssueModelRequest", + "DeployIssueModelResponse", "ExportInsightsDataMetadata", "ExportInsightsDataRequest", "ExportInsightsDataResponse", @@ -120,7 +139,12 @@ "ListIssuesResponse", "ListPhraseMatchersRequest", "ListPhraseMatchersResponse", + "UndeployIssueModelMetadata", + "UndeployIssueModelRequest", + "UndeployIssueModelResponse", "UpdateConversationRequest", + "UpdateIssueModelRequest", + "UpdateIssueRequest", "UpdateSettingsRequest", "ConversationView", "Analysis", diff --git a/google/cloud/contact_center_insights_v1/types/contact_center_insights.py b/google/cloud/contact_center_insights_v1/types/contact_center_insights.py index 5dd356a..96a9f74 100644 --- a/google/cloud/contact_center_insights_v1/types/contact_center_insights.py +++ b/google/cloud/contact_center_insights_v1/types/contact_center_insights.py @@ -43,12 +43,24 @@ "ExportInsightsDataRequest", "ExportInsightsDataMetadata", "ExportInsightsDataResponse", + "CreateIssueModelRequest", + "CreateIssueModelMetadata", + "UpdateIssueModelRequest", "ListIssueModelsRequest", "ListIssueModelsResponse", "GetIssueModelRequest", + "DeleteIssueModelRequest", + "DeleteIssueModelMetadata", + "DeployIssueModelRequest", + "DeployIssueModelResponse", + "DeployIssueModelMetadata", + "UndeployIssueModelRequest", + "UndeployIssueModelResponse", + "UndeployIssueModelMetadata", "GetIssueRequest", "ListIssuesRequest", "ListIssuesResponse", + "UpdateIssueRequest", "CalculateIssueModelStatsRequest", "CalculateIssueModelStatsResponse", "CreatePhraseMatcherRequest", @@ -484,6 +496,56 @@ class ExportInsightsDataResponse(proto.Message): r"""Response for an export insights operation. """ +class CreateIssueModelRequest(proto.Message): + r"""The request to create an issue model. + + Attributes: + parent (str): + Required. The parent resource of the issue + model. + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The issue model to create. + """ + + parent = proto.Field(proto.STRING, number=1,) + issue_model = proto.Field(proto.MESSAGE, number=2, message=resources.IssueModel,) + + +class CreateIssueModelMetadata(proto.Message): + r"""Metadata for creating an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.CreateIssueModelRequest): + The original request for creation. + """ + + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + request = proto.Field(proto.MESSAGE, number=3, message="CreateIssueModelRequest",) + + +class UpdateIssueModelRequest(proto.Message): + r"""The request to update an issue model. + + Attributes: + issue_model (google.cloud.contact_center_insights_v1.types.IssueModel): + Required. The new values for the issue model. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + issue_model = proto.Field(proto.MESSAGE, number=1, message=resources.IssueModel,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + + class ListIssueModelsRequest(proto.Message): r"""Request to list issue models. @@ -520,6 +582,105 @@ class GetIssueModelRequest(proto.Message): name = proto.Field(proto.STRING, number=1,) +class DeleteIssueModelRequest(proto.Message): + r"""The request to delete an issue model. + + Attributes: + name (str): + Required. The name of the issue model to + delete. + """ + + name = proto.Field(proto.STRING, number=1,) + + +class DeleteIssueModelMetadata(proto.Message): + r"""Metadata for deleting an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.DeleteIssueModelRequest): + The original request for deletion. + """ + + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + request = proto.Field(proto.MESSAGE, number=3, message="DeleteIssueModelRequest",) + + +class DeployIssueModelRequest(proto.Message): + r"""The request to deploy an issue model. + + Attributes: + name (str): + Required. The issue model to deploy. + """ + + name = proto.Field(proto.STRING, number=1,) + + +class DeployIssueModelResponse(proto.Message): + r"""The response to deploy an issue model. """ + + +class DeployIssueModelMetadata(proto.Message): + r"""Metadata for deploying an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.DeployIssueModelRequest): + The original request for deployment. + """ + + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + request = proto.Field(proto.MESSAGE, number=3, message="DeployIssueModelRequest",) + + +class UndeployIssueModelRequest(proto.Message): + r"""The request to undeploy an issue model. + + Attributes: + name (str): + Required. The issue model to undeploy. + """ + + name = proto.Field(proto.STRING, number=1,) + + +class UndeployIssueModelResponse(proto.Message): + r"""The response to undeploy an issue model. """ + + +class UndeployIssueModelMetadata(proto.Message): + r"""Metadata for undeploying an issue model. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation was + created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the operation finished + running. + request (google.cloud.contact_center_insights_v1.types.UndeployIssueModelRequest): + The original request for undeployment. + """ + + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + request = proto.Field(proto.MESSAGE, number=3, message="UndeployIssueModelRequest",) + + class GetIssueRequest(proto.Message): r"""The request to get an issue. @@ -553,6 +714,22 @@ class ListIssuesResponse(proto.Message): issues = proto.RepeatedField(proto.MESSAGE, number=1, message=resources.Issue,) +class UpdateIssueRequest(proto.Message): + r"""The request to update an issue. + + Attributes: + issue (google.cloud.contact_center_insights_v1.types.Issue): + Required. The new values for the issue. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + The list of fields to be updated. + """ + + issue = proto.Field(proto.MESSAGE, number=1, message=resources.Issue,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + + class CalculateIssueModelStatsRequest(proto.Message): r"""Request to get statistics of an issue model. diff --git a/google/cloud/contact_center_insights_v1/types/resources.py b/google/cloud/contact_center_insights_v1/types/resources.py index 6f7c094..77c9797 100644 --- a/google/cloud/contact_center_insights_v1/types/resources.py +++ b/google/cloud/contact_center_insights_v1/types/resources.py @@ -711,6 +711,9 @@ class IssueModel(proto.Message): the issue model was updated. state (google.cloud.contact_center_insights_v1.types.IssueModel.State): Output only. State of the model. + input_data_config (google.cloud.contact_center_insights_v1.types.IssueModel.InputDataConfig): + Configs for the input data that used to + create the issue model. training_stats (google.cloud.contact_center_insights_v1.types.IssueModelLabelStats): Output only. Immutable. The issue model's label statistics on its training data. @@ -725,11 +728,26 @@ class State(proto.Enum): UNDEPLOYING = 4 DELETING = 5 + class InputDataConfig(proto.Message): + r"""Configs for the input data used to create the issue model. + Attributes: + medium (google.cloud.contact_center_insights_v1.types.Conversation.Medium): + Required. Medium of conversations used in + training data. + training_conversations_count (int): + Output only. Number of conversations used in + training. Output only. + """ + + medium = proto.Field(proto.ENUM, number=1, enum="Conversation.Medium",) + training_conversations_count = proto.Field(proto.INT64, number=2,) + name = proto.Field(proto.STRING, number=1,) display_name = proto.Field(proto.STRING, number=2,) create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) state = proto.Field(proto.ENUM, number=5, enum=State,) + input_data_config = proto.Field(proto.MESSAGE, number=6, message=InputDataConfig,) training_stats = proto.Field( proto.MESSAGE, number=7, message="IssueModelLabelStats", ) @@ -978,6 +996,8 @@ class Settings(proto.Message): created. - "export-insights-data": Notify each time an export is complete. + - "update-conversation": Notify each time a conversation is + updated via UpdateConversation. Values are Pub/Sub topics. The format of each Pub/Sub topic is: projects/{project}/topics/{topic} @@ -1228,6 +1248,13 @@ class ConversationParticipant(proto.Message): r"""The call participant speaking for a given utterance. Attributes: + dialogflow_participant_name (str): + The name of the participant provided by + Dialogflow. Format: + projects/{project}/locations/{location}/conversations/{conversation}/participants/{participant} + user_id (str): + A user-specified ID representing the + participant. dialogflow_participant (str): The name of the Dialogflow participant. Format: @@ -1244,6 +1271,10 @@ class Role(proto.Enum): END_USER = 3 ANY_AGENT = 4 + dialogflow_participant_name = proto.Field( + proto.STRING, number=5, oneof="participant", + ) + user_id = proto.Field(proto.STRING, number=6, oneof="participant",) dialogflow_participant = proto.Field(proto.STRING, number=1,) role = proto.Field(proto.ENUM, number=2, enum=Role,) diff --git a/scripts/fixup_contact_center_insights_v1_keywords.py b/scripts/fixup_contact_center_insights_v1_keywords.py index 7b591b9..017402a 100644 --- a/scripts/fixup_contact_center_insights_v1_keywords.py +++ b/scripts/fixup_contact_center_insights_v1_keywords.py @@ -43,10 +43,13 @@ class contact_center_insightsCallTransformer(cst.CSTTransformer): 'calculate_stats': ('location', 'filter', ), 'create_analysis': ('parent', 'analysis', ), 'create_conversation': ('parent', 'conversation', 'conversation_id', ), + 'create_issue_model': ('parent', 'issue_model', ), 'create_phrase_matcher': ('parent', 'phrase_matcher', ), 'delete_analysis': ('name', ), 'delete_conversation': ('name', 'force', ), + 'delete_issue_model': ('name', ), 'delete_phrase_matcher': ('name', ), + 'deploy_issue_model': ('name', ), 'export_insights_data': ('parent', 'big_query_destination', 'filter', 'kms_key', ), 'get_analysis': ('name', ), 'get_conversation': ('name', 'view', ), @@ -59,7 +62,10 @@ class contact_center_insightsCallTransformer(cst.CSTTransformer): 'list_issue_models': ('parent', ), 'list_issues': ('parent', ), 'list_phrase_matchers': ('parent', 'page_size', 'page_token', 'filter', ), + 'undeploy_issue_model': ('name', ), 'update_conversation': ('conversation', 'update_mask', ), + 'update_issue': ('issue', 'update_mask', ), + 'update_issue_model': ('issue_model', 'update_mask', ), 'update_settings': ('settings', 'update_mask', ), } diff --git a/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py b/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py index d757a83..945f402 100644 --- a/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py +++ b/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py @@ -3134,10 +3134,988 @@ async def test_export_insights_data_flattened_error_async(): ) +def test_create_issue_model( + transport: str = "grpc", + request_type=contact_center_insights.CreateIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_issue_model_from_dict(): + test_create_issue_model(request_type=dict) + + +def test_create_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + client.create_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + +@pytest.mark.asyncio +async def test_create_issue_model_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.CreateIssueModelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.CreateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_issue_model_async_from_dict(): + await test_create_issue_model_async(request_type=dict) + + +def test_create_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateIssueModelRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.CreateIssueModelRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.create_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_issue_model( + parent="parent_value", issue_model=resources.IssueModel(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].issue_model == resources.IssueModel(name="name_value") + + +def test_create_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent="parent_value", + issue_model=resources.IssueModel(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_issue_model( + parent="parent_value", issue_model=resources.IssueModel(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].issue_model == resources.IssueModel(name="name_value") + + +@pytest.mark.asyncio +async def test_create_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_issue_model( + contact_center_insights.CreateIssueModelRequest(), + parent="parent_value", + issue_model=resources.IssueModel(name="name_value"), + ) + + +def test_update_issue_model( + transport: str = "grpc", + request_type=contact_center_insights.UpdateIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel( + name="name_value", + display_name="display_name_value", + state=resources.IssueModel.State.UNDEPLOYED, + ) + response = client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +def test_update_issue_model_from_dict(): + test_update_issue_model(request_type=dict) + + +def test_update_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + client.update_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + +@pytest.mark.asyncio +async def test_update_issue_model_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateIssueModelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel( + name="name_value", + display_name="display_name_value", + state=resources.IssueModel.State.UNDEPLOYED, + ) + ) + response = await client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +@pytest.mark.asyncio +async def test_update_issue_model_async_from_dict(): + await test_update_issue_model_async(request_type=dict) + + +def test_update_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueModelRequest() + + request.issue_model.name = "issue_model.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + call.return_value = resources.IssueModel() + client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "issue_model.name=issue_model.name/value",) in kw[ + "metadata" + ] + + +@pytest.mark.asyncio +async def test_update_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueModelRequest() + + request.issue_model.name = "issue_model.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel() + ) + await client.update_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "issue_model.name=issue_model.name/value",) in kw[ + "metadata" + ] + + +def test_update_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue_model( + issue_model=resources.IssueModel(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].issue_model == resources.IssueModel(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +def test_update_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue_model( + issue_model=resources.IssueModel(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].issue_model == resources.IssueModel(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue_model( + contact_center_insights.UpdateIssueModelRequest(), + issue_model=resources.IssueModel(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + def test_get_issue_model( transport: str = "grpc", request_type=contact_center_insights.GetIssueModelRequest ): - client = ContactCenterInsightsClient( + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel( + name="name_value", + display_name="display_name_value", + state=resources.IssueModel.State.UNDEPLOYED, + ) + response = client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +def test_get_issue_model_from_dict(): + test_get_issue_model(request_type=dict) + + +def test_get_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + client.get_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + +@pytest.mark.asyncio +async def test_get_issue_model_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.GetIssueModelRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel( + name="name_value", + display_name="display_name_value", + state=resources.IssueModel.State.UNDEPLOYED, + ) + ) + response = await client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.GetIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.IssueModel) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == resources.IssueModel.State.UNDEPLOYED + + +@pytest.mark.asyncio +async def test_get_issue_model_async_from_dict(): + await test_get_issue_model_async(request_type=dict) + + +def test_get_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueModelRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + call.return_value = resources.IssueModel() + client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.GetIssueModelRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel() + ) + await client.get_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_issue_model(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_issue_model( + contact_center_insights.GetIssueModelRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.IssueModel() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.IssueModel() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_issue_model(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_issue_model( + contact_center_insights.GetIssueModelRequest(), name="name_value", + ) + + +def test_list_issue_models( + transport: str = "grpc", request_type=contact_center_insights.ListIssueModelsRequest +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + response = client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +def test_list_issue_models_from_dict(): + test_list_issue_models(request_type=dict) + + +def test_list_issue_models_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + client.list_issue_models() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + +@pytest.mark.asyncio +async def test_list_issue_models_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.ListIssueModelsRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListIssueModelsResponse() + ) + response = await client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.ListIssueModelsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + + +@pytest.mark.asyncio +async def test_list_issue_models_async_from_dict(): + await test_list_issue_models_async(request_type=dict) + + +def test_list_issue_models_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssueModelsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + call.return_value = contact_center_insights.ListIssueModelsResponse() + client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_issue_models_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.ListIssueModelsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListIssueModelsResponse() + ) + await client.list_issue_models(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_issue_models_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_issue_models(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_issue_models_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_issue_models_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_issue_models), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = contact_center_insights.ListIssueModelsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + contact_center_insights.ListIssueModelsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_issue_models(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_issue_models_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_issue_models( + contact_center_insights.ListIssueModelsRequest(), parent="parent_value", + ) + + +def test_delete_issue_model( + transport: str = "grpc", + request_type=contact_center_insights.DeleteIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_issue_model_from_dict(): + test_delete_issue_model(request_type=dict) + + +def test_delete_issue_model_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + client.delete_issue_model() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + +@pytest.mark.asyncio +async def test_delete_issue_model_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.DeleteIssueModelRequest, +): + client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3146,32 +4124,198 @@ def test_get_issue_model( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel( - name="name_value", - display_name="display_name_value", - state=resources.IssueModel.State.UNDEPLOYED, + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") ) - response = client.get_issue_model(request) + response = await client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeleteIssueModelRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_issue_model_async_from_dict(): + await test_delete_issue_model_async(request_type=dict) + + +def test_delete_issue_model_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueModelRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueModelRequest() + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_issue_model_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.DeleteIssueModelRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.delete_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_issue_model_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_issue_model(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_delete_issue_model_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_issue_model( + contact_center_insights.DeleteIssueModelRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_issue_model_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_issue_model(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_issue_model_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_issue_model( + contact_center_insights.DeleteIssueModelRequest(), name="name_value", + ) + + +def test_deploy_issue_model( + transport: str = "grpc", + request_type=contact_center_insights.DeployIssueModelRequest, +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.deploy_issue_model(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.DeployIssueModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == resources.IssueModel.State.UNDEPLOYED + assert isinstance(response, future.Future) -def test_get_issue_model_from_dict(): - test_get_issue_model(request_type=dict) +def test_deploy_issue_model_from_dict(): + test_deploy_issue_model(request_type=dict) -def test_get_issue_model_empty_call(): +def test_deploy_issue_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ContactCenterInsightsClient( @@ -3179,17 +4323,19 @@ def test_get_issue_model_empty_call(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: - client.get_issue_model() + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: + client.deploy_issue_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueModelRequest() + assert args[0] == contact_center_insights.DeployIssueModelRequest() @pytest.mark.asyncio -async def test_get_issue_model_async( +async def test_deploy_issue_model_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.GetIssueModelRequest, + request_type=contact_center_insights.DeployIssueModelRequest, ): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3200,49 +4346,46 @@ async def test_get_issue_model_async( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IssueModel( - name="name_value", - display_name="display_name_value", - state=resources.IssueModel.State.UNDEPLOYED, - ) + operations_pb2.Operation(name="operations/spam") ) - response = await client.get_issue_model(request) + response = await client.deploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.GetIssueModelRequest() + assert args[0] == contact_center_insights.DeployIssueModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.IssueModel) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == resources.IssueModel.State.UNDEPLOYED + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_get_issue_model_async_from_dict(): - await test_get_issue_model_async(request_type=dict) +async def test_deploy_issue_model_async_from_dict(): + await test_deploy_issue_model_async(request_type=dict) -def test_get_issue_model_field_headers(): +def test_deploy_issue_model_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.GetIssueModelRequest() + request = contact_center_insights.DeployIssueModelRequest() request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: - call.return_value = resources.IssueModel() - client.get_issue_model(request) + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.deploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -3255,23 +4398,25 @@ def test_get_issue_model_field_headers(): @pytest.mark.asyncio -async def test_get_issue_model_field_headers_async(): +async def test_deploy_issue_model_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.GetIssueModelRequest() + request = contact_center_insights.DeployIssueModelRequest() request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IssueModel() + operations_pb2.Operation(name="operations/op") ) - await client.get_issue_model(request) + await client.deploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -3283,18 +4428,20 @@ async def test_get_issue_model_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_get_issue_model_flattened(): +def test_deploy_issue_model_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel() + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_issue_model(name="name_value",) + client.deploy_issue_model(name="name_value",) # Establish that the underlying call was made with the expected # request object values. @@ -3303,7 +4450,7 @@ def test_get_issue_model_flattened(): assert args[0].name == "name_value" -def test_get_issue_model_flattened_error(): +def test_deploy_issue_model_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3311,28 +4458,30 @@ def test_get_issue_model_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.get_issue_model( - contact_center_insights.GetIssueModelRequest(), name="name_value", + client.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_get_issue_model_flattened_async(): +async def test_deploy_issue_model_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_issue_model), "__call__") as call: + with mock.patch.object( + type(client.transport.deploy_issue_model), "__call__" + ) as call: # Designate an appropriate return value for the call. - call.return_value = resources.IssueModel() + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - resources.IssueModel() + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_issue_model(name="name_value",) + response = await client.deploy_issue_model(name="name_value",) # Establish that the underlying call was made with the expected # request object values. @@ -3342,7 +4491,7 @@ async def test_get_issue_model_flattened_async(): @pytest.mark.asyncio -async def test_get_issue_model_flattened_error_async(): +async def test_deploy_issue_model_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3350,13 +4499,14 @@ async def test_get_issue_model_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.get_issue_model( - contact_center_insights.GetIssueModelRequest(), name="name_value", + await client.deploy_issue_model( + contact_center_insights.DeployIssueModelRequest(), name="name_value", ) -def test_list_issue_models( - transport: str = "grpc", request_type=contact_center_insights.ListIssueModelsRequest +def test_undeploy_issue_model( + transport: str = "grpc", + request_type=contact_center_insights.UndeployIssueModelRequest, ): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3368,26 +4518,26 @@ def test_list_issue_models( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssueModelsResponse() - response = client.list_issue_models(request) + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.undeploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssueModelsRequest() + assert args[0] == contact_center_insights.UndeployIssueModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + assert isinstance(response, future.Future) -def test_list_issue_models_from_dict(): - test_list_issue_models(request_type=dict) +def test_undeploy_issue_model_from_dict(): + test_undeploy_issue_model(request_type=dict) -def test_list_issue_models_empty_call(): +def test_undeploy_issue_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ContactCenterInsightsClient( @@ -3396,18 +4546,18 @@ def test_list_issue_models_empty_call(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: - client.list_issue_models() + client.undeploy_issue_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssueModelsRequest() + assert args[0] == contact_center_insights.UndeployIssueModelRequest() @pytest.mark.asyncio -async def test_list_issue_models_async( +async def test_undeploy_issue_model_async( transport: str = "grpc_asyncio", - request_type=contact_center_insights.ListIssueModelsRequest, + request_type=contact_center_insights.UndeployIssueModelRequest, ): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -3419,45 +4569,45 @@ async def test_list_issue_models_async( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListIssueModelsResponse() + operations_pb2.Operation(name="operations/spam") ) - response = await client.list_issue_models(request) + response = await client.undeploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == contact_center_insights.ListIssueModelsRequest() + assert args[0] == contact_center_insights.UndeployIssueModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, contact_center_insights.ListIssueModelsResponse) + assert isinstance(response, future.Future) @pytest.mark.asyncio -async def test_list_issue_models_async_from_dict(): - await test_list_issue_models_async(request_type=dict) +async def test_undeploy_issue_model_async_from_dict(): + await test_undeploy_issue_model_async(request_type=dict) -def test_list_issue_models_field_headers(): +def test_undeploy_issue_model_field_headers(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.ListIssueModelsRequest() + request = contact_center_insights.UndeployIssueModelRequest() - request.parent = "parent/value" + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: - call.return_value = contact_center_insights.ListIssueModelsResponse() - client.list_issue_models(request) + call.return_value = operations_pb2.Operation(name="operations/op") + client.undeploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 @@ -3466,29 +4616,29 @@ def test_list_issue_models_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] @pytest.mark.asyncio -async def test_list_issue_models_field_headers_async(): +async def test_undeploy_issue_model_field_headers_async(): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. - request = contact_center_insights.ListIssueModelsRequest() + request = contact_center_insights.UndeployIssueModelRequest() - request.parent = "parent/value" + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListIssueModelsResponse() + operations_pb2.Operation(name="operations/op") ) - await client.list_issue_models(request) + await client.undeploy_issue_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) @@ -3497,32 +4647,32 @@ async def test_list_issue_models_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_list_issue_models_flattened(): +def test_undeploy_issue_model_flattened(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssueModelsResponse() + call.return_value = operations_pb2.Operation(name="operations/op") # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_issue_models(parent="parent_value",) + client.undeploy_issue_model(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + assert args[0].name == "name_value" -def test_list_issue_models_flattened_error(): +def test_undeploy_issue_model_flattened_error(): client = ContactCenterInsightsClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3530,40 +4680,40 @@ def test_list_issue_models_flattened_error(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - client.list_issue_models( - contact_center_insights.ListIssueModelsRequest(), parent="parent_value", + client.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), name="name_value", ) @pytest.mark.asyncio -async def test_list_issue_models_flattened_async(): +async def test_undeploy_issue_model_flattened_async(): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client.transport.list_issue_models), "__call__" + type(client.transport.undeploy_issue_model), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = contact_center_insights.ListIssueModelsResponse() + call.return_value = operations_pb2.Operation(name="operations/op") call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - contact_center_insights.ListIssueModelsResponse() + operations_pb2.Operation(name="operations/spam") ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_issue_models(parent="parent_value",) + response = await client.undeploy_issue_model(name="name_value",) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + assert args[0].name == "name_value" @pytest.mark.asyncio -async def test_list_issue_models_flattened_error_async(): +async def test_undeploy_issue_model_flattened_error_async(): client = ContactCenterInsightsAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) @@ -3571,8 +4721,8 @@ async def test_list_issue_models_flattened_error_async(): # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): - await client.list_issue_models( - contact_center_insights.ListIssueModelsRequest(), parent="parent_value", + await client.undeploy_issue_model( + contact_center_insights.UndeployIssueModelRequest(), name="name_value", ) @@ -3992,6 +5142,227 @@ async def test_list_issues_flattened_error_async(): ) +def test_update_issue( + transport: str = "grpc", request_type=contact_center_insights.UpdateIssueRequest +): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue( + name="name_value", display_name="display_name_value", + ) + response = client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + + +def test_update_issue_from_dict(): + test_update_issue(request_type=dict) + + +def test_update_issue_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + client.update_issue() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + +@pytest.mark.asyncio +async def test_update_issue_async( + transport: str = "grpc_asyncio", + request_type=contact_center_insights.UpdateIssueRequest, +): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + resources.Issue(name="name_value", display_name="display_name_value",) + ) + response = await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == contact_center_insights.UpdateIssueRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, resources.Issue) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + + +@pytest.mark.asyncio +async def test_update_issue_async_from_dict(): + await test_update_issue_async(request_type=dict) + + +def test_update_issue_field_headers(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueRequest() + + request.issue.name = "issue.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value = resources.Issue() + client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "issue.name=issue.name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_issue_field_headers_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = contact_center_insights.UpdateIssueRequest() + + request.issue.name = "issue.name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + await client.update_issue(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "issue.name=issue.name/value",) in kw["metadata"] + + +def test_update_issue_flattened(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_issue( + issue=resources.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].issue == resources.Issue(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +def test_update_issue_flattened_error(): + client = ContactCenterInsightsClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_issue_flattened_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_issue), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = resources.Issue() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Issue()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_issue( + issue=resources.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].issue == resources.Issue(name="name_value") + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + + +@pytest.mark.asyncio +async def test_update_issue_flattened_error_async(): + client = ContactCenterInsightsAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_issue( + contact_center_insights.UpdateIssueRequest(), + issue=resources.Issue(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + def test_calculate_issue_model_stats( transport: str = "grpc", request_type=contact_center_insights.CalculateIssueModelStatsRequest, @@ -6102,10 +7473,16 @@ def test_contact_center_insights_base_transport(): "list_analyses", "delete_analysis", "export_insights_data", + "create_issue_model", + "update_issue_model", "get_issue_model", "list_issue_models", + "delete_issue_model", + "deploy_issue_model", + "undeploy_issue_model", "get_issue", "list_issues", + "update_issue", "calculate_issue_model_stats", "create_phrase_matcher", "get_phrase_matcher", @@ -6608,10 +7985,36 @@ def test_parse_issue_model_path(): assert expected == actual -def test_phrase_matcher_path(): +def test_participant_path(): project = "oyster" - location = "nudibranch" - phrase_matcher = "cuttlefish" + conversation = "nudibranch" + participant = "cuttlefish" + expected = "projects/{project}/conversations/{conversation}/participants/{participant}".format( + project=project, conversation=conversation, participant=participant, + ) + actual = ContactCenterInsightsClient.participant_path( + project, conversation, participant + ) + assert expected == actual + + +def test_parse_participant_path(): + expected = { + "project": "mussel", + "conversation": "winkle", + "participant": "nautilus", + } + path = ContactCenterInsightsClient.participant_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_participant_path(path) + assert expected == actual + + +def test_phrase_matcher_path(): + project = "scallop" + location = "abalone" + phrase_matcher = "squid" expected = "projects/{project}/locations/{location}/phraseMatchers/{phrase_matcher}".format( project=project, location=location, phrase_matcher=phrase_matcher, ) @@ -6623,9 +8026,9 @@ def test_phrase_matcher_path(): def test_parse_phrase_matcher_path(): expected = { - "project": "mussel", - "location": "winkle", - "phrase_matcher": "nautilus", + "project": "clam", + "location": "whelk", + "phrase_matcher": "octopus", } path = ContactCenterInsightsClient.phrase_matcher_path(**expected) @@ -6635,8 +8038,8 @@ def test_parse_phrase_matcher_path(): def test_settings_path(): - project = "scallop" - location = "abalone" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}/settings".format( project=project, location=location, ) @@ -6646,8 +8049,8 @@ def test_settings_path(): def test_parse_settings_path(): expected = { - "project": "squid", - "location": "clam", + "project": "cuttlefish", + "location": "mussel", } path = ContactCenterInsightsClient.settings_path(**expected) @@ -6657,7 +8060,7 @@ def test_parse_settings_path(): def test_common_billing_account_path(): - billing_account = "whelk" + billing_account = "winkle" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -6667,7 +8070,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "octopus", + "billing_account": "nautilus", } path = ContactCenterInsightsClient.common_billing_account_path(**expected) @@ -6677,7 +8080,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "oyster" + folder = "scallop" expected = "folders/{folder}".format(folder=folder,) actual = ContactCenterInsightsClient.common_folder_path(folder) assert expected == actual @@ -6685,7 +8088,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nudibranch", + "folder": "abalone", } path = ContactCenterInsightsClient.common_folder_path(**expected) @@ -6695,7 +8098,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "cuttlefish" + organization = "squid" expected = "organizations/{organization}".format(organization=organization,) actual = ContactCenterInsightsClient.common_organization_path(organization) assert expected == actual @@ -6703,7 +8106,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "mussel", + "organization": "clam", } path = ContactCenterInsightsClient.common_organization_path(**expected) @@ -6713,7 +8116,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "winkle" + project = "whelk" expected = "projects/{project}".format(project=project,) actual = ContactCenterInsightsClient.common_project_path(project) assert expected == actual @@ -6721,7 +8124,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nautilus", + "project": "octopus", } path = ContactCenterInsightsClient.common_project_path(**expected) @@ -6731,8 +8134,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "scallop" - location = "abalone" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -6742,8 +8145,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "squid", - "location": "clam", + "project": "cuttlefish", + "location": "mussel", } path = ContactCenterInsightsClient.common_location_path(**expected)