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

Commit 5a6f18e

Browse files
feat: add validation support to v2; add output_audio_config_mask to detect_intent method in v2beta1 and v2; add sub agent to v2beta1 (via synth) (#179)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/fa96c3f5-6491-43e0-b831-7e7e62b78e08/targets
1 parent 713846b commit 5a6f18e

29 files changed

+1337
-1053
lines changed

CONTRIBUTING.rst

Lines changed: 0 additions & 219 deletions
This file was deleted.

dialogflow_v2/gapic/agents_client.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from dialogflow_v2.gapic.transports import agents_grpc_transport
4040
from dialogflow_v2.proto import agent_pb2
4141
from dialogflow_v2.proto import agent_pb2_grpc
42+
from dialogflow_v2.proto import validation_result_pb2
4243
from google.longrunning import operations_pb2
4344
from google.protobuf import empty_pb2
4445
from google.protobuf import field_mask_pb2
@@ -932,3 +933,80 @@ def restore_agent(
932933
empty_pb2.Empty,
933934
metadata_type=struct_pb2.Struct,
934935
)
936+
937+
def get_validation_result(
938+
self,
939+
parent=None,
940+
language_code=None,
941+
retry=google.api_core.gapic_v1.method.DEFAULT,
942+
timeout=google.api_core.gapic_v1.method.DEFAULT,
943+
metadata=None,
944+
):
945+
"""
946+
Gets agent validation result. Agent validation is performed during
947+
training time and is updated automatically when training is completed.
948+
949+
Example:
950+
>>> import dialogflow_v2
951+
>>>
952+
>>> client = dialogflow_v2.AgentsClient()
953+
>>>
954+
>>> response = client.get_validation_result()
955+
956+
Args:
957+
parent (str): Required. The project that the agent is associated with. Format:
958+
``projects/<Project ID>``.
959+
language_code (str): Optional. The language for which you want a validation result. If not
960+
specified, the agent's default language is used. `Many
961+
languages <https://cloud.google.com/dialogflow/docs/reference/language>`__
962+
are supported. Note: languages must be enabled in the agent before they
963+
can be used.
964+
retry (Optional[google.api_core.retry.Retry]): A retry object used
965+
to retry requests. If ``None`` is specified, requests will
966+
be retried using a default configuration.
967+
timeout (Optional[float]): The amount of time, in seconds, to wait
968+
for the request to complete. Note that if ``retry`` is
969+
specified, the timeout applies to each individual attempt.
970+
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
971+
that is provided to the method.
972+
973+
Returns:
974+
A :class:`~google.cloud.dialogflow_v2.types.ValidationResult` instance.
975+
976+
Raises:
977+
google.api_core.exceptions.GoogleAPICallError: If the request
978+
failed for any reason.
979+
google.api_core.exceptions.RetryError: If the request failed due
980+
to a retryable error and retry attempts failed.
981+
ValueError: If the parameters are invalid.
982+
"""
983+
# Wrap the transport method to add retry and timeout logic.
984+
if "get_validation_result" not in self._inner_api_calls:
985+
self._inner_api_calls[
986+
"get_validation_result"
987+
] = google.api_core.gapic_v1.method.wrap_method(
988+
self.transport.get_validation_result,
989+
default_retry=self._method_configs["GetValidationResult"].retry,
990+
default_timeout=self._method_configs["GetValidationResult"].timeout,
991+
client_info=self._client_info,
992+
)
993+
994+
request = agent_pb2.GetValidationResultRequest(
995+
parent=parent, language_code=language_code
996+
)
997+
if metadata is None:
998+
metadata = []
999+
metadata = list(metadata)
1000+
try:
1001+
routing_header = [("parent", parent)]
1002+
except AttributeError:
1003+
pass
1004+
else:
1005+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
1006+
routing_header
1007+
)
1008+
metadata.append(routing_metadata)
1009+
1010+
return self._inner_api_calls["get_validation_result"](
1011+
request, retry=retry, timeout=timeout, metadata=metadata
1012+
)

dialogflow_v2/gapic/agents_client_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"retry_codes_name": "idempotent",
5858
"retry_params_name": "default",
5959
},
60+
"GetValidationResult": {
61+
"timeout_millis": 60000,
62+
"retry_codes_name": "idempotent",
63+
"retry_params_name": "default",
64+
},
6065
},
6166
}
6267
}

dialogflow_v2/gapic/contexts_client.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from dialogflow_v2.proto import agent_pb2_grpc
3939
from dialogflow_v2.proto import context_pb2
4040
from dialogflow_v2.proto import context_pb2_grpc
41+
from dialogflow_v2.proto import validation_result_pb2
4142
from google.longrunning import operations_pb2
4243
from google.protobuf import empty_pb2
4344
from google.protobuf import field_mask_pb2
@@ -260,7 +261,11 @@ def list_contexts(
260261
261262
Args:
262263
parent (str): Required. The session to list all contexts from. Format:
263-
``projects/<Project ID>/agent/sessions/<Session ID>``.
264+
``projects/<Project ID>/agent/sessions/<Session ID>`` or
265+
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``.
266+
If ``Environment ID`` is not specified, we assume default 'draft'
267+
environment. If ``User ID`` is not specified, we assume default '-'
268+
user.
264269
page_size (int): The maximum number of resources contained in the
265270
underlying API response. If page streaming is performed per-
266271
resource, this parameter does not affect the return value. If page
@@ -349,7 +354,12 @@ def get_context(
349354
350355
Args:
351356
name (str): Required. The name of the context. Format:
352-
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``.
357+
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``
358+
or
359+
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>``.
360+
If ``Environment ID`` is not specified, we assume default 'draft'
361+
environment. If ``User ID`` is not specified, we assume default '-'
362+
user.
353363
retry (Optional[google.api_core.retry.Retry]): A retry object used
354364
to retry requests. If ``None`` is specified, requests will
355365
be retried using a default configuration.
@@ -425,7 +435,11 @@ def create_context(
425435
426436
Args:
427437
parent (str): Required. The session to create a context for. Format:
428-
``projects/<Project ID>/agent/sessions/<Session ID>``.
438+
``projects/<Project ID>/agent/sessions/<Session ID>`` or
439+
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``.
440+
If ``Environment ID`` is not specified, we assume default 'draft'
441+
environment. If ``User ID`` is not specified, we assume default '-'
442+
user.
429443
context (Union[dict, ~google.cloud.dialogflow_v2.types.Context]): Required. The context to create.
430444
431445
If a dict is provided, it must be of the same form as the protobuf
@@ -579,7 +593,12 @@ def delete_context(
579593
580594
Args:
581595
name (str): Required. The name of the context to delete. Format:
582-
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``.
596+
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``
597+
or
598+
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>``.
599+
If ``Environment ID`` is not specified, we assume default 'draft'
600+
environment. If ``User ID`` is not specified, we assume default '-'
601+
user.
583602
retry (Optional[google.api_core.retry.Retry]): A retry object used
584603
to retry requests. If ``None`` is specified, requests will
585604
be retried using a default configuration.
@@ -646,7 +665,11 @@ def delete_all_contexts(
646665
647666
Args:
648667
parent (str): Required. The name of the session to delete all contexts from. Format:
649-
``projects/<Project ID>/agent/sessions/<Session ID>``.
668+
``projects/<Project ID>/agent/sessions/<Session ID>`` or
669+
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``.
670+
If ``Environment ID`` is not specified we assume default 'draft'
671+
environment. If ``User ID`` is not specified, we assume default '-'
672+
user.
650673
retry (Optional[google.api_core.retry.Retry]): A retry object used
651674
to retry requests. If ``None`` is specified, requests will
652675
be retried using a default configuration.

0 commit comments

Comments
 (0)