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

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: added API for continuous test (#91)
PiperOrigin-RevId: 374994233

Source-Link: googleapis/googleapis@31313cb

Source-Link: googleapis/googleapis-gen@e8bc2a6
  • Loading branch information
gcf-owl-bot[bot] committed May 21, 2021
1 parent 750a055 commit 81d4f53
Show file tree
Hide file tree
Showing 11 changed files with 1,416 additions and 27 deletions.
12 changes: 12 additions & 0 deletions google/cloud/dialogflowcx_v3beta1/__init__.py
Expand Up @@ -73,14 +73,20 @@
from .types.entity_type import ListEntityTypesRequest
from .types.entity_type import ListEntityTypesResponse
from .types.entity_type import UpdateEntityTypeRequest
from .types.environment import ContinuousTestResult
from .types.environment import CreateEnvironmentRequest
from .types.environment import DeleteEnvironmentRequest
from .types.environment import Environment
from .types.environment import GetEnvironmentRequest
from .types.environment import ListContinuousTestResultsRequest
from .types.environment import ListContinuousTestResultsResponse
from .types.environment import ListEnvironmentsRequest
from .types.environment import ListEnvironmentsResponse
from .types.environment import LookupEnvironmentHistoryRequest
from .types.environment import LookupEnvironmentHistoryResponse
from .types.environment import RunContinuousTestMetadata
from .types.environment import RunContinuousTestRequest
from .types.environment import RunContinuousTestResponse
from .types.environment import UpdateEnvironmentRequest
from .types.experiment import CreateExperimentRequest
from .types.experiment import DeleteExperimentRequest
Expand Down Expand Up @@ -252,6 +258,7 @@
"BatchRunTestCasesResponse",
"CalculateCoverageRequest",
"CalculateCoverageResponse",
"ContinuousTestResult",
"ConversationTurn",
"CreateAgentRequest",
"CreateEntityTypeRequest",
Expand Down Expand Up @@ -333,6 +340,8 @@
"IntentsClient",
"ListAgentsRequest",
"ListAgentsResponse",
"ListContinuousTestResultsRequest",
"ListContinuousTestResultsResponse",
"ListEntityTypesRequest",
"ListEntityTypesResponse",
"ListEnvironmentsRequest",
Expand Down Expand Up @@ -377,6 +386,9 @@
"ResourceName",
"ResponseMessage",
"RestoreAgentRequest",
"RunContinuousTestMetadata",
"RunContinuousTestRequest",
"RunContinuousTestResponse",
"RunTestCaseMetadata",
"RunTestCaseRequest",
"RunTestCaseResponse",
Expand Down
20 changes: 20 additions & 0 deletions google/cloud/dialogflowcx_v3beta1/gapic_metadata.json
Expand Up @@ -193,6 +193,11 @@
"get_environment"
]
},
"ListContinuousTestResults": {
"methods": [
"list_continuous_test_results"
]
},
"ListEnvironments": {
"methods": [
"list_environments"
Expand All @@ -203,6 +208,11 @@
"lookup_environment_history"
]
},
"RunContinuousTest": {
"methods": [
"run_continuous_test"
]
},
"UpdateEnvironment": {
"methods": [
"update_environment"
Expand All @@ -228,6 +238,11 @@
"get_environment"
]
},
"ListContinuousTestResults": {
"methods": [
"list_continuous_test_results"
]
},
"ListEnvironments": {
"methods": [
"list_environments"
Expand All @@ -238,6 +253,11 @@
"lookup_environment_history"
]
},
"RunContinuousTest": {
"methods": [
"run_continuous_test"
]
},
"UpdateEnvironment": {
"methods": [
"update_environment"
Expand Down
Expand Up @@ -49,8 +49,18 @@ class EnvironmentsAsyncClient:
DEFAULT_ENDPOINT = EnvironmentsClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = EnvironmentsClient.DEFAULT_MTLS_ENDPOINT

continuous_test_result_path = staticmethod(
EnvironmentsClient.continuous_test_result_path
)
parse_continuous_test_result_path = staticmethod(
EnvironmentsClient.parse_continuous_test_result_path
)
environment_path = staticmethod(EnvironmentsClient.environment_path)
parse_environment_path = staticmethod(EnvironmentsClient.parse_environment_path)
test_case_result_path = staticmethod(EnvironmentsClient.test_case_result_path)
parse_test_case_result_path = staticmethod(
EnvironmentsClient.parse_test_case_result_path
)
version_path = staticmethod(EnvironmentsClient.version_path)
parse_version_path = staticmethod(EnvironmentsClient.parse_version_path)
common_billing_account_path = staticmethod(
Expand Down Expand Up @@ -691,6 +701,151 @@ async def lookup_environment_history(
# Done; return the response.
return response

async def run_continuous_test(
self,
request: environment.RunContinuousTestRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Kicks off a continuous test under the specified
[Environment][google.cloud.dialogflow.cx.v3beta1.Environment].
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.RunContinuousTestRequest`):
The request object. The request message for
[Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3beta1.Environments.RunContinuousTest].
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.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.
The result type for the operation will be
:class:`google.cloud.dialogflowcx_v3beta1.types.RunContinuousTestResponse`
The response message for
[Environments.RunContinuousTest][google.cloud.dialogflow.cx.v3beta1.Environments.RunContinuousTest].
"""
# Create or coerce a protobuf request object.
request = environment.RunContinuousTestRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.run_continuous_test,
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(
(("environment", request.environment),)
),
)

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

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
environment.RunContinuousTestResponse,
metadata_type=environment.RunContinuousTestMetadata,
)

# Done; return the response.
return response

async def list_continuous_test_results(
self,
request: environment.ListContinuousTestResultsRequest = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListContinuousTestResultsAsyncPager:
r"""Fetches a list of continuous test results for a given
environment.
Args:
request (:class:`google.cloud.dialogflowcx_v3beta1.types.ListContinuousTestResultsRequest`):
The request object. The request message for
[Environments.ListContinuousTestResults][google.cloud.dialogflow.cx.v3beta1.Environments.ListContinuousTestResults].
parent (:class:`str`):
Required. The environment to list results for. Format:
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/ environments/<Environment ID>``.
This corresponds to the ``parent`` 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.dialogflowcx_v3beta1.services.environments.pagers.ListContinuousTestResultsAsyncPager:
The response message for
[Environments.ListTestCaseResults][].
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# 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([parent])
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 = environment.ListContinuousTestResultsRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_continuous_test_results,
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((("parent", request.parent),)),
)

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

# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListContinuousTestResultsAsyncPager(
method=rpc, request=request, response=response, metadata=metadata,
)

# Done; return the response.
return response


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down

0 comments on commit 81d4f53

Please sign in to comment.