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

Commit

Permalink
feat: Add ability to update phrase matchers (#93)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 407647313

Source-Link: googleapis/googleapis@33fd29d

Source-Link: googleapis/googleapis-gen@6abc897
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFiYzg5N2Q4NWQ2ZDIyZDZjNGJmYTMxZDIxZDdhY2NlNDA0OGM3OSJ9

feat: Add issue model stats to time series
feat: Add display name to issue model stats
  • Loading branch information
gcf-owl-bot[bot] committed Nov 5, 2021
1 parent 835d958 commit 0b5b07a
Show file tree
Hide file tree
Showing 13 changed files with 553 additions and 0 deletions.
4 changes: 4 additions & 0 deletions google/cloud/contact_center_insights/__init__.py
Expand Up @@ -150,6 +150,9 @@
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 (
UpdatePhraseMatcherRequest,
)
from google.cloud.contact_center_insights_v1.types.contact_center_insights import (
UpdateSettingsRequest,
)
Expand Down Expand Up @@ -255,6 +258,7 @@
"UpdateConversationRequest",
"UpdateIssueModelRequest",
"UpdateIssueRequest",
"UpdatePhraseMatcherRequest",
"UpdateSettingsRequest",
"ConversationView",
"Analysis",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/contact_center_insights_v1/__init__.py
Expand Up @@ -60,6 +60,7 @@
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 UpdatePhraseMatcherRequest
from .types.contact_center_insights import UpdateSettingsRequest
from .types.contact_center_insights import ConversationView
from .types.resources import Analysis
Expand Down Expand Up @@ -186,5 +187,6 @@
"UpdateConversationRequest",
"UpdateIssueModelRequest",
"UpdateIssueRequest",
"UpdatePhraseMatcherRequest",
"UpdateSettingsRequest",
)
10 changes: 10 additions & 0 deletions google/cloud/contact_center_insights_v1/gapic_metadata.json
Expand Up @@ -145,6 +145,11 @@
"update_issue_model"
]
},
"UpdatePhraseMatcher": {
"methods": [
"update_phrase_matcher"
]
},
"UpdateSettings": {
"methods": [
"update_settings"
Expand Down Expand Up @@ -290,6 +295,11 @@
"update_issue_model"
]
},
"UpdatePhraseMatcher": {
"methods": [
"update_phrase_matcher"
]
},
"UpdateSettings": {
"methods": [
"update_settings"
Expand Down
Expand Up @@ -2107,6 +2107,85 @@ async def delete_phrase_matcher(
request, retry=retry, timeout=timeout, metadata=metadata,
)

async def update_phrase_matcher(
self,
request: Union[contact_center_insights.UpdatePhraseMatcherRequest, dict] = None,
*,
phrase_matcher: resources.PhraseMatcher = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> resources.PhraseMatcher:
r"""Updates a phrase matcher.
Args:
request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]):
The request object. The request to update a phrase
matcher.
phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`):
Required. The new values for the
phrase matcher.
This corresponds to the ``phrase_matcher`` 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.PhraseMatcher:
The phrase matcher 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([phrase_matcher, 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.UpdatePhraseMatcherRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if phrase_matcher is not None:
request.phrase_matcher = phrase_matcher
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_phrase_matcher,
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(
(("phrase_matcher.name", request.phrase_matcher.name),)
),
)

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

# Done; return the response.
return response

async def calculate_stats(
self,
request: Union[contact_center_insights.CalculateStatsRequest, dict] = None,
Expand Down
Expand Up @@ -2376,6 +2376,85 @@ def delete_phrase_matcher(
request, retry=retry, timeout=timeout, metadata=metadata,
)

def update_phrase_matcher(
self,
request: Union[contact_center_insights.UpdatePhraseMatcherRequest, dict] = None,
*,
phrase_matcher: resources.PhraseMatcher = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> resources.PhraseMatcher:
r"""Updates a phrase matcher.
Args:
request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]):
The request object. The request to update a phrase
matcher.
phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher):
Required. The new values for the
phrase matcher.
This corresponds to the ``phrase_matcher`` 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.PhraseMatcher:
The phrase matcher 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([phrase_matcher, 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.UpdatePhraseMatcherRequest.
# 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.UpdatePhraseMatcherRequest):
request = contact_center_insights.UpdatePhraseMatcherRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if phrase_matcher is not None:
request.phrase_matcher = phrase_matcher
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_phrase_matcher]

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

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

# Done; return the response.
return response

def calculate_stats(
self,
request: Union[contact_center_insights.CalculateStatsRequest, dict] = None,
Expand Down
Expand Up @@ -212,6 +212,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.update_phrase_matcher: gapic_v1.method.wrap_method(
self.update_phrase_matcher,
default_timeout=None,
client_info=client_info,
),
self.calculate_stats: gapic_v1.method.wrap_method(
self.calculate_stats, default_timeout=None, client_info=client_info,
),
Expand Down Expand Up @@ -480,6 +485,15 @@ def delete_phrase_matcher(
]:
raise NotImplementedError()

@property
def update_phrase_matcher(
self,
) -> Callable[
[contact_center_insights.UpdatePhraseMatcherRequest],
Union[resources.PhraseMatcher, Awaitable[resources.PhraseMatcher]],
]:
raise NotImplementedError()

@property
def calculate_stats(
self,
Expand Down
Expand Up @@ -945,6 +945,34 @@ def delete_phrase_matcher(
)
return self._stubs["delete_phrase_matcher"]

@property
def update_phrase_matcher(
self,
) -> Callable[
[contact_center_insights.UpdatePhraseMatcherRequest], resources.PhraseMatcher
]:
r"""Return a callable for the update phrase matcher method over gRPC.
Updates a phrase matcher.
Returns:
Callable[[~.UpdatePhraseMatcherRequest],
~.PhraseMatcher]:
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_phrase_matcher" not in self._stubs:
self._stubs["update_phrase_matcher"] = self.grpc_channel.unary_unary(
"/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher",
request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize,
response_deserializer=resources.PhraseMatcher.deserialize,
)
return self._stubs["update_phrase_matcher"]

@property
def calculate_stats(
self,
Expand Down
Expand Up @@ -973,6 +973,35 @@ def delete_phrase_matcher(
)
return self._stubs["delete_phrase_matcher"]

@property
def update_phrase_matcher(
self,
) -> Callable[
[contact_center_insights.UpdatePhraseMatcherRequest],
Awaitable[resources.PhraseMatcher],
]:
r"""Return a callable for the update phrase matcher method over gRPC.
Updates a phrase matcher.
Returns:
Callable[[~.UpdatePhraseMatcherRequest],
Awaitable[~.PhraseMatcher]]:
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_phrase_matcher" not in self._stubs:
self._stubs["update_phrase_matcher"] = self.grpc_channel.unary_unary(
"/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher",
request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize,
response_deserializer=resources.PhraseMatcher.deserialize,
)
return self._stubs["update_phrase_matcher"]

@property
def calculate_stats(
self,
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/contact_center_insights_v1/types/__init__.py
Expand Up @@ -57,6 +57,7 @@
UpdateConversationRequest,
UpdateIssueModelRequest,
UpdateIssueRequest,
UpdatePhraseMatcherRequest,
UpdateSettingsRequest,
ConversationView,
)
Expand Down Expand Up @@ -145,6 +146,7 @@
"UpdateConversationRequest",
"UpdateIssueModelRequest",
"UpdateIssueRequest",
"UpdatePhraseMatcherRequest",
"UpdateSettingsRequest",
"ConversationView",
"Analysis",
Expand Down

0 comments on commit 0b5b07a

Please sign in to comment.