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

Commit 0b5b07a

Browse files
feat: Add ability to update phrase matchers (#93)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 407647313 Source-Link: googleapis/googleapis@33fd29d Source-Link: https://github.com/googleapis/googleapis-gen/commit/6abc897d85d6d22d6c4bfa31d21d7acce4048c79 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmFiYzg5N2Q4NWQ2ZDIyZDZjNGJmYTMxZDIxZDdhY2NlNDA0OGM3OSJ9 feat: Add issue model stats to time series feat: Add display name to issue model stats
1 parent 835d958 commit 0b5b07a

File tree

13 files changed

+553
-0
lines changed

13 files changed

+553
-0
lines changed

google/cloud/contact_center_insights/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
from google.cloud.contact_center_insights_v1.types.contact_center_insights import (
151151
UpdateIssueRequest,
152152
)
153+
from google.cloud.contact_center_insights_v1.types.contact_center_insights import (
154+
UpdatePhraseMatcherRequest,
155+
)
153156
from google.cloud.contact_center_insights_v1.types.contact_center_insights import (
154157
UpdateSettingsRequest,
155158
)
@@ -255,6 +258,7 @@
255258
"UpdateConversationRequest",
256259
"UpdateIssueModelRequest",
257260
"UpdateIssueRequest",
261+
"UpdatePhraseMatcherRequest",
258262
"UpdateSettingsRequest",
259263
"ConversationView",
260264
"Analysis",

google/cloud/contact_center_insights_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from .types.contact_center_insights import UpdateConversationRequest
6161
from .types.contact_center_insights import UpdateIssueModelRequest
6262
from .types.contact_center_insights import UpdateIssueRequest
63+
from .types.contact_center_insights import UpdatePhraseMatcherRequest
6364
from .types.contact_center_insights import UpdateSettingsRequest
6465
from .types.contact_center_insights import ConversationView
6566
from .types.resources import Analysis
@@ -186,5 +187,6 @@
186187
"UpdateConversationRequest",
187188
"UpdateIssueModelRequest",
188189
"UpdateIssueRequest",
190+
"UpdatePhraseMatcherRequest",
189191
"UpdateSettingsRequest",
190192
)

google/cloud/contact_center_insights_v1/gapic_metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
"update_issue_model"
146146
]
147147
},
148+
"UpdatePhraseMatcher": {
149+
"methods": [
150+
"update_phrase_matcher"
151+
]
152+
},
148153
"UpdateSettings": {
149154
"methods": [
150155
"update_settings"
@@ -290,6 +295,11 @@
290295
"update_issue_model"
291296
]
292297
},
298+
"UpdatePhraseMatcher": {
299+
"methods": [
300+
"update_phrase_matcher"
301+
]
302+
},
293303
"UpdateSettings": {
294304
"methods": [
295305
"update_settings"

google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,85 @@ async def delete_phrase_matcher(
21072107
request, retry=retry, timeout=timeout, metadata=metadata,
21082108
)
21092109

2110+
async def update_phrase_matcher(
2111+
self,
2112+
request: Union[contact_center_insights.UpdatePhraseMatcherRequest, dict] = None,
2113+
*,
2114+
phrase_matcher: resources.PhraseMatcher = None,
2115+
update_mask: field_mask_pb2.FieldMask = None,
2116+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2117+
timeout: float = None,
2118+
metadata: Sequence[Tuple[str, str]] = (),
2119+
) -> resources.PhraseMatcher:
2120+
r"""Updates a phrase matcher.
2121+
2122+
Args:
2123+
request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]):
2124+
The request object. The request to update a phrase
2125+
matcher.
2126+
phrase_matcher (:class:`google.cloud.contact_center_insights_v1.types.PhraseMatcher`):
2127+
Required. The new values for the
2128+
phrase matcher.
2129+
2130+
This corresponds to the ``phrase_matcher`` field
2131+
on the ``request`` instance; if ``request`` is provided, this
2132+
should not be set.
2133+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
2134+
The list of fields to be updated.
2135+
This corresponds to the ``update_mask`` field
2136+
on the ``request`` instance; if ``request`` is provided, this
2137+
should not be set.
2138+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2139+
should be retried.
2140+
timeout (float): The timeout for this request.
2141+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2142+
sent along with the request as metadata.
2143+
2144+
Returns:
2145+
google.cloud.contact_center_insights_v1.types.PhraseMatcher:
2146+
The phrase matcher resource.
2147+
"""
2148+
# Create or coerce a protobuf request object.
2149+
# Sanity check: If we got a request object, we should *not* have
2150+
# gotten any keyword arguments that map to the request.
2151+
has_flattened_params = any([phrase_matcher, update_mask])
2152+
if request is not None and has_flattened_params:
2153+
raise ValueError(
2154+
"If the `request` argument is set, then none of "
2155+
"the individual field arguments should be set."
2156+
)
2157+
2158+
request = contact_center_insights.UpdatePhraseMatcherRequest(request)
2159+
2160+
# If we have keyword arguments corresponding to fields on the
2161+
# request, apply these.
2162+
if phrase_matcher is not None:
2163+
request.phrase_matcher = phrase_matcher
2164+
if update_mask is not None:
2165+
request.update_mask = update_mask
2166+
2167+
# Wrap the RPC method; this adds retry and timeout information,
2168+
# and friendly error handling.
2169+
rpc = gapic_v1.method_async.wrap_method(
2170+
self._client._transport.update_phrase_matcher,
2171+
default_timeout=None,
2172+
client_info=DEFAULT_CLIENT_INFO,
2173+
)
2174+
2175+
# Certain fields should be provided within the metadata header;
2176+
# add these here.
2177+
metadata = tuple(metadata) + (
2178+
gapic_v1.routing_header.to_grpc_metadata(
2179+
(("phrase_matcher.name", request.phrase_matcher.name),)
2180+
),
2181+
)
2182+
2183+
# Send the request.
2184+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2185+
2186+
# Done; return the response.
2187+
return response
2188+
21102189
async def calculate_stats(
21112190
self,
21122191
request: Union[contact_center_insights.CalculateStatsRequest, dict] = None,

google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,85 @@ def delete_phrase_matcher(
23762376
request, retry=retry, timeout=timeout, metadata=metadata,
23772377
)
23782378

2379+
def update_phrase_matcher(
2380+
self,
2381+
request: Union[contact_center_insights.UpdatePhraseMatcherRequest, dict] = None,
2382+
*,
2383+
phrase_matcher: resources.PhraseMatcher = None,
2384+
update_mask: field_mask_pb2.FieldMask = None,
2385+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
2386+
timeout: float = None,
2387+
metadata: Sequence[Tuple[str, str]] = (),
2388+
) -> resources.PhraseMatcher:
2389+
r"""Updates a phrase matcher.
2390+
2391+
Args:
2392+
request (Union[google.cloud.contact_center_insights_v1.types.UpdatePhraseMatcherRequest, dict]):
2393+
The request object. The request to update a phrase
2394+
matcher.
2395+
phrase_matcher (google.cloud.contact_center_insights_v1.types.PhraseMatcher):
2396+
Required. The new values for the
2397+
phrase matcher.
2398+
2399+
This corresponds to the ``phrase_matcher`` field
2400+
on the ``request`` instance; if ``request`` is provided, this
2401+
should not be set.
2402+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
2403+
The list of fields to be updated.
2404+
This corresponds to the ``update_mask`` field
2405+
on the ``request`` instance; if ``request`` is provided, this
2406+
should not be set.
2407+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2408+
should be retried.
2409+
timeout (float): The timeout for this request.
2410+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2411+
sent along with the request as metadata.
2412+
2413+
Returns:
2414+
google.cloud.contact_center_insights_v1.types.PhraseMatcher:
2415+
The phrase matcher resource.
2416+
"""
2417+
# Create or coerce a protobuf request object.
2418+
# Sanity check: If we got a request object, we should *not* have
2419+
# gotten any keyword arguments that map to the request.
2420+
has_flattened_params = any([phrase_matcher, update_mask])
2421+
if request is not None and has_flattened_params:
2422+
raise ValueError(
2423+
"If the `request` argument is set, then none of "
2424+
"the individual field arguments should be set."
2425+
)
2426+
2427+
# Minor optimization to avoid making a copy if the user passes
2428+
# in a contact_center_insights.UpdatePhraseMatcherRequest.
2429+
# There's no risk of modifying the input as we've already verified
2430+
# there are no flattened fields.
2431+
if not isinstance(request, contact_center_insights.UpdatePhraseMatcherRequest):
2432+
request = contact_center_insights.UpdatePhraseMatcherRequest(request)
2433+
# If we have keyword arguments corresponding to fields on the
2434+
# request, apply these.
2435+
if phrase_matcher is not None:
2436+
request.phrase_matcher = phrase_matcher
2437+
if update_mask is not None:
2438+
request.update_mask = update_mask
2439+
2440+
# Wrap the RPC method; this adds retry and timeout information,
2441+
# and friendly error handling.
2442+
rpc = self._transport._wrapped_methods[self._transport.update_phrase_matcher]
2443+
2444+
# Certain fields should be provided within the metadata header;
2445+
# add these here.
2446+
metadata = tuple(metadata) + (
2447+
gapic_v1.routing_header.to_grpc_metadata(
2448+
(("phrase_matcher.name", request.phrase_matcher.name),)
2449+
),
2450+
)
2451+
2452+
# Send the request.
2453+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2454+
2455+
# Done; return the response.
2456+
return response
2457+
23792458
def calculate_stats(
23802459
self,
23812460
request: Union[contact_center_insights.CalculateStatsRequest, dict] = None,

google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ def _prep_wrapped_messages(self, client_info):
212212
default_timeout=None,
213213
client_info=client_info,
214214
),
215+
self.update_phrase_matcher: gapic_v1.method.wrap_method(
216+
self.update_phrase_matcher,
217+
default_timeout=None,
218+
client_info=client_info,
219+
),
215220
self.calculate_stats: gapic_v1.method.wrap_method(
216221
self.calculate_stats, default_timeout=None, client_info=client_info,
217222
),
@@ -480,6 +485,15 @@ def delete_phrase_matcher(
480485
]:
481486
raise NotImplementedError()
482487

488+
@property
489+
def update_phrase_matcher(
490+
self,
491+
) -> Callable[
492+
[contact_center_insights.UpdatePhraseMatcherRequest],
493+
Union[resources.PhraseMatcher, Awaitable[resources.PhraseMatcher]],
494+
]:
495+
raise NotImplementedError()
496+
483497
@property
484498
def calculate_stats(
485499
self,

google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,34 @@ def delete_phrase_matcher(
945945
)
946946
return self._stubs["delete_phrase_matcher"]
947947

948+
@property
949+
def update_phrase_matcher(
950+
self,
951+
) -> Callable[
952+
[contact_center_insights.UpdatePhraseMatcherRequest], resources.PhraseMatcher
953+
]:
954+
r"""Return a callable for the update phrase matcher method over gRPC.
955+
956+
Updates a phrase matcher.
957+
958+
Returns:
959+
Callable[[~.UpdatePhraseMatcherRequest],
960+
~.PhraseMatcher]:
961+
A function that, when called, will call the underlying RPC
962+
on the server.
963+
"""
964+
# Generate a "stub function" on-the-fly which will actually make
965+
# the request.
966+
# gRPC handles serialization and deserialization, so we just need
967+
# to pass in the functions for each.
968+
if "update_phrase_matcher" not in self._stubs:
969+
self._stubs["update_phrase_matcher"] = self.grpc_channel.unary_unary(
970+
"/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher",
971+
request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize,
972+
response_deserializer=resources.PhraseMatcher.deserialize,
973+
)
974+
return self._stubs["update_phrase_matcher"]
975+
948976
@property
949977
def calculate_stats(
950978
self,

google/cloud/contact_center_insights_v1/services/contact_center_insights/transports/grpc_asyncio.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,35 @@ def delete_phrase_matcher(
973973
)
974974
return self._stubs["delete_phrase_matcher"]
975975

976+
@property
977+
def update_phrase_matcher(
978+
self,
979+
) -> Callable[
980+
[contact_center_insights.UpdatePhraseMatcherRequest],
981+
Awaitable[resources.PhraseMatcher],
982+
]:
983+
r"""Return a callable for the update phrase matcher method over gRPC.
984+
985+
Updates a phrase matcher.
986+
987+
Returns:
988+
Callable[[~.UpdatePhraseMatcherRequest],
989+
Awaitable[~.PhraseMatcher]]:
990+
A function that, when called, will call the underlying RPC
991+
on the server.
992+
"""
993+
# Generate a "stub function" on-the-fly which will actually make
994+
# the request.
995+
# gRPC handles serialization and deserialization, so we just need
996+
# to pass in the functions for each.
997+
if "update_phrase_matcher" not in self._stubs:
998+
self._stubs["update_phrase_matcher"] = self.grpc_channel.unary_unary(
999+
"/google.cloud.contactcenterinsights.v1.ContactCenterInsights/UpdatePhraseMatcher",
1000+
request_serializer=contact_center_insights.UpdatePhraseMatcherRequest.serialize,
1001+
response_deserializer=resources.PhraseMatcher.deserialize,
1002+
)
1003+
return self._stubs["update_phrase_matcher"]
1004+
9761005
@property
9771006
def calculate_stats(
9781007
self,

google/cloud/contact_center_insights_v1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
UpdateConversationRequest,
5858
UpdateIssueModelRequest,
5959
UpdateIssueRequest,
60+
UpdatePhraseMatcherRequest,
6061
UpdateSettingsRequest,
6162
ConversationView,
6263
)
@@ -145,6 +146,7 @@
145146
"UpdateConversationRequest",
146147
"UpdateIssueModelRequest",
147148
"UpdateIssueRequest",
149+
"UpdatePhraseMatcherRequest",
148150
"UpdateSettingsRequest",
149151
"ConversationView",
150152
"Analysis",

0 commit comments

Comments
 (0)