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

Commit a43d1e9

Browse files
feat(v2): added export documentation method (#449)
- [x] Regenerate this pull request now. PiperOrigin-RevId: 417030293 Source-Link: googleapis/googleapis@ebef8e6 Source-Link: https://github.com/googleapis/googleapis-gen/commit/13951268b009d98d82355ccd9647f4350590609d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTM5NTEyNjhiMDA5ZDk4ZDgyMzU1Y2NkOTY0N2Y0MzUwNTkwNjA5ZCJ9 feat(v2): added filter in list documentations request feat(v2): added option to import custom metadata from Google Cloud Storage in reload document request feat(v2): added option to apply partial update to the smart messaging allowlist in reload document request feat(v2): added filter in list knowledge bases request
1 parent 0f60629 commit a43d1e9

File tree

14 files changed

+520
-4
lines changed

14 files changed

+520
-4
lines changed

google/cloud/dialogflow/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
from google.cloud.dialogflow_v2.types.document import CreateDocumentRequest
160160
from google.cloud.dialogflow_v2.types.document import DeleteDocumentRequest
161161
from google.cloud.dialogflow_v2.types.document import Document
162+
from google.cloud.dialogflow_v2.types.document import ExportDocumentRequest
162163
from google.cloud.dialogflow_v2.types.document import GetDocumentRequest
163164
from google.cloud.dialogflow_v2.types.document import KnowledgeOperationMetadata
164165
from google.cloud.dialogflow_v2.types.document import ListDocumentsRequest
@@ -192,6 +193,7 @@
192193
from google.cloud.dialogflow_v2.types.fulfillment import Fulfillment
193194
from google.cloud.dialogflow_v2.types.fulfillment import GetFulfillmentRequest
194195
from google.cloud.dialogflow_v2.types.fulfillment import UpdateFulfillmentRequest
196+
from google.cloud.dialogflow_v2.types.gcs import GcsDestination
195197
from google.cloud.dialogflow_v2.types.human_agent_assistant_event import (
196198
HumanAgentAssistantEvent,
197199
)
@@ -376,6 +378,7 @@
376378
"CreateDocumentRequest",
377379
"DeleteDocumentRequest",
378380
"Document",
381+
"ExportDocumentRequest",
379382
"GetDocumentRequest",
380383
"KnowledgeOperationMetadata",
381384
"ListDocumentsRequest",
@@ -409,6 +412,7 @@
409412
"Fulfillment",
410413
"GetFulfillmentRequest",
411414
"UpdateFulfillmentRequest",
415+
"GcsDestination",
412416
"HumanAgentAssistantEvent",
413417
"BatchDeleteIntentsRequest",
414418
"BatchUpdateIntentsRequest",

google/cloud/dialogflow_v2/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
from .types.document import CreateDocumentRequest
110110
from .types.document import DeleteDocumentRequest
111111
from .types.document import Document
112+
from .types.document import ExportDocumentRequest
112113
from .types.document import GetDocumentRequest
113114
from .types.document import KnowledgeOperationMetadata
114115
from .types.document import ListDocumentsRequest
@@ -142,6 +143,7 @@
142143
from .types.fulfillment import Fulfillment
143144
from .types.fulfillment import GetFulfillmentRequest
144145
from .types.fulfillment import UpdateFulfillmentRequest
146+
from .types.gcs import GcsDestination
145147
from .types.human_agent_assistant_event import HumanAgentAssistantEvent
146148
from .types.intent import BatchDeleteIntentsRequest
147149
from .types.intent import BatchUpdateIntentsRequest
@@ -302,9 +304,11 @@
302304
"EventInput",
303305
"ExportAgentRequest",
304306
"ExportAgentResponse",
307+
"ExportDocumentRequest",
305308
"FaqAnswer",
306309
"Fulfillment",
307310
"FulfillmentsClient",
311+
"GcsDestination",
308312
"GetAgentRequest",
309313
"GetContextRequest",
310314
"GetConversationProfileRequest",

google/cloud/dialogflow_v2/gapic_metadata.json

+10
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@
360360
"delete_document"
361361
]
362362
},
363+
"ExportDocument": {
364+
"methods": [
365+
"export_document"
366+
]
367+
},
363368
"GetDocument": {
364369
"methods": [
365370
"get_document"
@@ -395,6 +400,11 @@
395400
"delete_document"
396401
]
397402
},
403+
"ExportDocument": {
404+
"methods": [
405+
"export_document"
406+
]
407+
},
398408
"GetDocument": {
399409
"methods": [
400410
"get_document"

google/cloud/dialogflow_v2/services/documents/async_client.py

+78
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,84 @@ async def reload_document(
766766
# Done; return the response.
767767
return response
768768

769+
async def export_document(
770+
self,
771+
request: Union[document.ExportDocumentRequest, dict] = None,
772+
*,
773+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
774+
timeout: float = None,
775+
metadata: Sequence[Tuple[str, str]] = (),
776+
) -> operation_async.AsyncOperation:
777+
r"""Exports a smart messaging candidate document into the specified
778+
destination.
779+
780+
This method is a `long-running
781+
operation <https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation>`__.
782+
The returned ``Operation`` type has the following
783+
method-specific fields:
784+
785+
- ``metadata``:
786+
[KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]
787+
- ``response``: [Document][google.cloud.dialogflow.v2.Document]
788+
789+
Args:
790+
request (Union[google.cloud.dialogflow_v2.types.ExportDocumentRequest, dict]):
791+
The request object. Request message for
792+
[Documents.ExportDocument][google.cloud.dialogflow.v2.Documents.ExportDocument].
793+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
794+
should be retried.
795+
timeout (float): The timeout for this request.
796+
metadata (Sequence[Tuple[str, str]]): Strings which should be
797+
sent along with the request as metadata.
798+
799+
Returns:
800+
google.api_core.operation_async.AsyncOperation:
801+
An object representing a long-running operation.
802+
803+
The result type for the operation will be
804+
:class:`google.cloud.dialogflow_v2.types.Document` A
805+
knowledge document to be used by a
806+
[KnowledgeBase][google.cloud.dialogflow.v2.KnowledgeBase].
807+
808+
For more information, see the [knowledge base
809+
guide](\ https://cloud.google.com/dialogflow/docs/how/knowledge-bases).
810+
811+
Note: The projects.agent.knowledgeBases.documents
812+
resource is deprecated; only use
813+
projects.knowledgeBases.documents.
814+
815+
"""
816+
# Create or coerce a protobuf request object.
817+
request = document.ExportDocumentRequest(request)
818+
819+
# Wrap the RPC method; this adds retry and timeout information,
820+
# and friendly error handling.
821+
rpc = gapic_v1.method_async.wrap_method(
822+
self._client._transport.export_document,
823+
default_timeout=None,
824+
client_info=DEFAULT_CLIENT_INFO,
825+
)
826+
827+
# Certain fields should be provided within the metadata header;
828+
# add these here.
829+
metadata = tuple(metadata) + (
830+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
831+
)
832+
833+
# Send the request.
834+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
835+
836+
# Wrap the response in an operation future.
837+
response = operation_async.from_gapic(
838+
response,
839+
self._client._transport.operations_client,
840+
document.Document,
841+
metadata_type=document.KnowledgeOperationMetadata,
842+
)
843+
844+
# Done; return the response.
845+
return response
846+
769847
async def __aenter__(self):
770848
return self
771849

google/cloud/dialogflow_v2/services/documents/client.py

+79
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,85 @@ def reload_document(
962962
# Done; return the response.
963963
return response
964964

965+
def export_document(
966+
self,
967+
request: Union[document.ExportDocumentRequest, dict] = None,
968+
*,
969+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
970+
timeout: float = None,
971+
metadata: Sequence[Tuple[str, str]] = (),
972+
) -> operation.Operation:
973+
r"""Exports a smart messaging candidate document into the specified
974+
destination.
975+
976+
This method is a `long-running
977+
operation <https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation>`__.
978+
The returned ``Operation`` type has the following
979+
method-specific fields:
980+
981+
- ``metadata``:
982+
[KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]
983+
- ``response``: [Document][google.cloud.dialogflow.v2.Document]
984+
985+
Args:
986+
request (Union[google.cloud.dialogflow_v2.types.ExportDocumentRequest, dict]):
987+
The request object. Request message for
988+
[Documents.ExportDocument][google.cloud.dialogflow.v2.Documents.ExportDocument].
989+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
990+
should be retried.
991+
timeout (float): The timeout for this request.
992+
metadata (Sequence[Tuple[str, str]]): Strings which should be
993+
sent along with the request as metadata.
994+
995+
Returns:
996+
google.api_core.operation.Operation:
997+
An object representing a long-running operation.
998+
999+
The result type for the operation will be
1000+
:class:`google.cloud.dialogflow_v2.types.Document` A
1001+
knowledge document to be used by a
1002+
[KnowledgeBase][google.cloud.dialogflow.v2.KnowledgeBase].
1003+
1004+
For more information, see the [knowledge base
1005+
guide](\ https://cloud.google.com/dialogflow/docs/how/knowledge-bases).
1006+
1007+
Note: The projects.agent.knowledgeBases.documents
1008+
resource is deprecated; only use
1009+
projects.knowledgeBases.documents.
1010+
1011+
"""
1012+
# Create or coerce a protobuf request object.
1013+
# Minor optimization to avoid making a copy if the user passes
1014+
# in a document.ExportDocumentRequest.
1015+
# There's no risk of modifying the input as we've already verified
1016+
# there are no flattened fields.
1017+
if not isinstance(request, document.ExportDocumentRequest):
1018+
request = document.ExportDocumentRequest(request)
1019+
1020+
# Wrap the RPC method; this adds retry and timeout information,
1021+
# and friendly error handling.
1022+
rpc = self._transport._wrapped_methods[self._transport.export_document]
1023+
1024+
# Certain fields should be provided within the metadata header;
1025+
# add these here.
1026+
metadata = tuple(metadata) + (
1027+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1028+
)
1029+
1030+
# Send the request.
1031+
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1032+
1033+
# Wrap the response in an operation future.
1034+
response = operation.from_gapic(
1035+
response,
1036+
self._transport.operations_client,
1037+
document.Document,
1038+
metadata_type=document.KnowledgeOperationMetadata,
1039+
)
1040+
1041+
# Done; return the response.
1042+
return response
1043+
9651044
def __enter__(self):
9661045
return self
9671046

google/cloud/dialogflow_v2/services/documents/transports/base.py

+12
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def _prep_wrapped_messages(self, client_info):
145145
self.reload_document: gapic_v1.method.wrap_method(
146146
self.reload_document, default_timeout=None, client_info=client_info,
147147
),
148+
self.export_document: gapic_v1.method.wrap_method(
149+
self.export_document, default_timeout=None, client_info=client_info,
150+
),
148151
}
149152

150153
def close(self):
@@ -217,5 +220,14 @@ def reload_document(
217220
]:
218221
raise NotImplementedError()
219222

223+
@property
224+
def export_document(
225+
self,
226+
) -> Callable[
227+
[document.ExportDocumentRequest],
228+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
229+
]:
230+
raise NotImplementedError()
231+
220232

221233
__all__ = ("DocumentsTransport",)

google/cloud/dialogflow_v2/services/documents/transports/grpc.py

+36
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,42 @@ def reload_document(
445445
)
446446
return self._stubs["reload_document"]
447447

448+
@property
449+
def export_document(
450+
self,
451+
) -> Callable[[document.ExportDocumentRequest], operations_pb2.Operation]:
452+
r"""Return a callable for the export document method over gRPC.
453+
454+
Exports a smart messaging candidate document into the specified
455+
destination.
456+
457+
This method is a `long-running
458+
operation <https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation>`__.
459+
The returned ``Operation`` type has the following
460+
method-specific fields:
461+
462+
- ``metadata``:
463+
[KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]
464+
- ``response``: [Document][google.cloud.dialogflow.v2.Document]
465+
466+
Returns:
467+
Callable[[~.ExportDocumentRequest],
468+
~.Operation]:
469+
A function that, when called, will call the underlying RPC
470+
on the server.
471+
"""
472+
# Generate a "stub function" on-the-fly which will actually make
473+
# the request.
474+
# gRPC handles serialization and deserialization, so we just need
475+
# to pass in the functions for each.
476+
if "export_document" not in self._stubs:
477+
self._stubs["export_document"] = self.grpc_channel.unary_unary(
478+
"/google.cloud.dialogflow.v2.Documents/ExportDocument",
479+
request_serializer=document.ExportDocumentRequest.serialize,
480+
response_deserializer=operations_pb2.Operation.FromString,
481+
)
482+
return self._stubs["export_document"]
483+
448484
def close(self):
449485
self.grpc_channel.close()
450486

google/cloud/dialogflow_v2/services/documents/transports/grpc_asyncio.py

+38
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,44 @@ def reload_document(
459459
)
460460
return self._stubs["reload_document"]
461461

462+
@property
463+
def export_document(
464+
self,
465+
) -> Callable[
466+
[document.ExportDocumentRequest], Awaitable[operations_pb2.Operation]
467+
]:
468+
r"""Return a callable for the export document method over gRPC.
469+
470+
Exports a smart messaging candidate document into the specified
471+
destination.
472+
473+
This method is a `long-running
474+
operation <https://cloud.google.com/dialogflow/cx/docs/how/long-running-operation>`__.
475+
The returned ``Operation`` type has the following
476+
method-specific fields:
477+
478+
- ``metadata``:
479+
[KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]
480+
- ``response``: [Document][google.cloud.dialogflow.v2.Document]
481+
482+
Returns:
483+
Callable[[~.ExportDocumentRequest],
484+
Awaitable[~.Operation]]:
485+
A function that, when called, will call the underlying RPC
486+
on the server.
487+
"""
488+
# Generate a "stub function" on-the-fly which will actually make
489+
# the request.
490+
# gRPC handles serialization and deserialization, so we just need
491+
# to pass in the functions for each.
492+
if "export_document" not in self._stubs:
493+
self._stubs["export_document"] = self.grpc_channel.unary_unary(
494+
"/google.cloud.dialogflow.v2.Documents/ExportDocument",
495+
request_serializer=document.ExportDocumentRequest.serialize,
496+
response_deserializer=operations_pb2.Operation.FromString,
497+
)
498+
return self._stubs["export_document"]
499+
462500
def close(self):
463501
return self.grpc_channel.close()
464502

google/cloud/dialogflow_v2/types/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
CreateDocumentRequest,
9191
DeleteDocumentRequest,
9292
Document,
93+
ExportDocumentRequest,
9394
GetDocumentRequest,
9495
KnowledgeOperationMetadata,
9596
ListDocumentsRequest,
@@ -130,6 +131,7 @@
130131
GetFulfillmentRequest,
131132
UpdateFulfillmentRequest,
132133
)
134+
from .gcs import GcsDestination
133135
from .human_agent_assistant_event import HumanAgentAssistantEvent
134136
from .intent import (
135137
BatchDeleteIntentsRequest,
@@ -286,6 +288,7 @@
286288
"CreateDocumentRequest",
287289
"DeleteDocumentRequest",
288290
"Document",
291+
"ExportDocumentRequest",
289292
"GetDocumentRequest",
290293
"KnowledgeOperationMetadata",
291294
"ListDocumentsRequest",
@@ -319,6 +322,7 @@
319322
"Fulfillment",
320323
"GetFulfillmentRequest",
321324
"UpdateFulfillmentRequest",
325+
"GcsDestination",
322326
"HumanAgentAssistantEvent",
323327
"BatchDeleteIntentsRequest",
324328
"BatchUpdateIntentsRequest",

0 commit comments

Comments
 (0)