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

Commit

Permalink
feat: add validation support to v2; add output_audio_config_mask to…
Browse files Browse the repository at this point in the history
… `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
  • Loading branch information
yoshi-automation committed Mar 26, 2020
1 parent 713846b commit 5a6f18e
Show file tree
Hide file tree
Showing 29 changed files with 1,337 additions and 1,053 deletions.
219 changes: 0 additions & 219 deletions CONTRIBUTING.rst

This file was deleted.

78 changes: 78 additions & 0 deletions dialogflow_v2/gapic/agents_client.py
Expand Up @@ -39,6 +39,7 @@
from dialogflow_v2.gapic.transports import agents_grpc_transport
from dialogflow_v2.proto import agent_pb2
from dialogflow_v2.proto import agent_pb2_grpc
from dialogflow_v2.proto import validation_result_pb2
from google.longrunning import operations_pb2
from google.protobuf import empty_pb2
from google.protobuf import field_mask_pb2
Expand Down Expand Up @@ -932,3 +933,80 @@ def restore_agent(
empty_pb2.Empty,
metadata_type=struct_pb2.Struct,
)

def get_validation_result(
self,
parent=None,
language_code=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Gets agent validation result. Agent validation is performed during
training time and is updated automatically when training is completed.
Example:
>>> import dialogflow_v2
>>>
>>> client = dialogflow_v2.AgentsClient()
>>>
>>> response = client.get_validation_result()
Args:
parent (str): Required. The project that the agent is associated with. Format:
``projects/<Project ID>``.
language_code (str): Optional. The language for which you want a validation result. If not
specified, the agent's default language is used. `Many
languages <https://cloud.google.com/dialogflow/docs/reference/language>`__
are supported. Note: languages must be enabled in the agent before they
can be used.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
timeout (Optional[float]): The amount of time, in seconds, to wait
for the request to complete. Note that if ``retry`` is
specified, the timeout applies to each individual attempt.
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
that is provided to the method.
Returns:
A :class:`~google.cloud.dialogflow_v2.types.ValidationResult` instance.
Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
failed for any reason.
google.api_core.exceptions.RetryError: If the request failed due
to a retryable error and retry attempts failed.
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "get_validation_result" not in self._inner_api_calls:
self._inner_api_calls[
"get_validation_result"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.get_validation_result,
default_retry=self._method_configs["GetValidationResult"].retry,
default_timeout=self._method_configs["GetValidationResult"].timeout,
client_info=self._client_info,
)

request = agent_pb2.GetValidationResultRequest(
parent=parent, language_code=language_code
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("parent", parent)]
except AttributeError:
pass
else:
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
routing_header
)
metadata.append(routing_metadata)

return self._inner_api_calls["get_validation_result"](
request, retry=retry, timeout=timeout, metadata=metadata
)
5 changes: 5 additions & 0 deletions dialogflow_v2/gapic/agents_client_config.py
Expand Up @@ -57,6 +57,11 @@
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"GetValidationResult": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
},
}
}
Expand Down
33 changes: 28 additions & 5 deletions dialogflow_v2/gapic/contexts_client.py
Expand Up @@ -38,6 +38,7 @@
from dialogflow_v2.proto import agent_pb2_grpc
from dialogflow_v2.proto import context_pb2
from dialogflow_v2.proto import context_pb2_grpc
from dialogflow_v2.proto import validation_result_pb2
from google.longrunning import operations_pb2
from google.protobuf import empty_pb2
from google.protobuf import field_mask_pb2
Expand Down Expand Up @@ -260,7 +261,11 @@ def list_contexts(
Args:
parent (str): Required. The session to list all contexts from. Format:
``projects/<Project ID>/agent/sessions/<Session ID>``.
``projects/<Project ID>/agent/sessions/<Session ID>`` or
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``.
If ``Environment ID`` is not specified, we assume default 'draft'
environment. If ``User ID`` is not specified, we assume default '-'
user.
page_size (int): The maximum number of resources contained in the
underlying API response. If page streaming is performed per-
resource, this parameter does not affect the return value. If page
Expand Down Expand Up @@ -349,7 +354,12 @@ def get_context(
Args:
name (str): Required. The name of the context. Format:
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``.
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``
or
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>``.
If ``Environment ID`` is not specified, we assume default 'draft'
environment. If ``User ID`` is not specified, we assume default '-'
user.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand Down Expand Up @@ -425,7 +435,11 @@ def create_context(
Args:
parent (str): Required. The session to create a context for. Format:
``projects/<Project ID>/agent/sessions/<Session ID>``.
``projects/<Project ID>/agent/sessions/<Session ID>`` or
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``.
If ``Environment ID`` is not specified, we assume default 'draft'
environment. If ``User ID`` is not specified, we assume default '-'
user.
context (Union[dict, ~google.cloud.dialogflow_v2.types.Context]): Required. The context to create.
If a dict is provided, it must be of the same form as the protobuf
Expand Down Expand Up @@ -579,7 +593,12 @@ def delete_context(
Args:
name (str): Required. The name of the context to delete. Format:
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``.
``projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>``
or
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>``.
If ``Environment ID`` is not specified, we assume default 'draft'
environment. If ``User ID`` is not specified, we assume default '-'
user.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand Down Expand Up @@ -646,7 +665,11 @@ def delete_all_contexts(
Args:
parent (str): Required. The name of the session to delete all contexts from. Format:
``projects/<Project ID>/agent/sessions/<Session ID>``.
``projects/<Project ID>/agent/sessions/<Session ID>`` or
``projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>``.
If ``Environment ID`` is not specified we assume default 'draft'
environment. If ``User ID`` is not specified, we assume default '-'
user.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand Down

0 comments on commit 5a6f18e

Please sign in to comment.