com.google.cloud.dialogflow.cx.v3beta1.stub.HttpJsonTestCasesStub Maven / Gradle / Ivy
Show all versions of google-cloud-dialogflow-cx Show documentation
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.dialogflow.cx.v3beta1.stub;
import static com.google.cloud.dialogflow.cx.v3beta1.TestCasesClient.ListLocationsPagedResponse;
import static com.google.cloud.dialogflow.cx.v3beta1.TestCasesClient.ListTestCaseResultsPagedResponse;
import static com.google.cloud.dialogflow.cx.v3beta1.TestCasesClient.ListTestCasesPagedResponse;
import com.google.api.HttpRule;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.httpjson.ApiMethodDescriptor;
import com.google.api.gax.httpjson.HttpJsonCallSettings;
import com.google.api.gax.httpjson.HttpJsonOperationSnapshot;
import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
import com.google.api.gax.httpjson.ProtoMessageResponseParser;
import com.google.api.gax.httpjson.ProtoRestSerializer;
import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.dialogflow.cx.v3beta1.BatchDeleteTestCasesRequest;
import com.google.cloud.dialogflow.cx.v3beta1.BatchRunTestCasesMetadata;
import com.google.cloud.dialogflow.cx.v3beta1.BatchRunTestCasesRequest;
import com.google.cloud.dialogflow.cx.v3beta1.BatchRunTestCasesResponse;
import com.google.cloud.dialogflow.cx.v3beta1.CalculateCoverageRequest;
import com.google.cloud.dialogflow.cx.v3beta1.CalculateCoverageResponse;
import com.google.cloud.dialogflow.cx.v3beta1.CreateTestCaseRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ExportTestCasesMetadata;
import com.google.cloud.dialogflow.cx.v3beta1.ExportTestCasesRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ExportTestCasesResponse;
import com.google.cloud.dialogflow.cx.v3beta1.GetTestCaseRequest;
import com.google.cloud.dialogflow.cx.v3beta1.GetTestCaseResultRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ImportTestCasesMetadata;
import com.google.cloud.dialogflow.cx.v3beta1.ImportTestCasesRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ImportTestCasesResponse;
import com.google.cloud.dialogflow.cx.v3beta1.ListTestCaseResultsRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ListTestCaseResultsResponse;
import com.google.cloud.dialogflow.cx.v3beta1.ListTestCasesRequest;
import com.google.cloud.dialogflow.cx.v3beta1.ListTestCasesResponse;
import com.google.cloud.dialogflow.cx.v3beta1.RunTestCaseMetadata;
import com.google.cloud.dialogflow.cx.v3beta1.RunTestCaseRequest;
import com.google.cloud.dialogflow.cx.v3beta1.RunTestCaseResponse;
import com.google.cloud.dialogflow.cx.v3beta1.TestCase;
import com.google.cloud.dialogflow.cx.v3beta1.TestCaseResult;
import com.google.cloud.dialogflow.cx.v3beta1.UpdateTestCaseRequest;
import com.google.cloud.location.GetLocationRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* REST stub implementation for the TestCases service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@BetaApi
@Generated("by gapic-generator-java")
public class HttpJsonTestCasesStub extends TestCasesStub {
private static final TypeRegistry typeRegistry =
TypeRegistry.newBuilder()
.add(RunTestCaseResponse.getDescriptor())
.add(ImportTestCasesMetadata.getDescriptor())
.add(BatchRunTestCasesResponse.getDescriptor())
.add(ImportTestCasesResponse.getDescriptor())
.add(ExportTestCasesMetadata.getDescriptor())
.add(RunTestCaseMetadata.getDescriptor())
.add(BatchRunTestCasesMetadata.getDescriptor())
.add(ExportTestCasesResponse.getDescriptor())
.build();
private static final ApiMethodDescriptor
listTestCasesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/ListTestCases")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*}/testCases",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "view", request.getViewValue());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListTestCasesResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
batchDeleteTestCasesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.dialogflow.cx.v3beta1.TestCases/BatchDeleteTestCases")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*}/testCases:batchDelete",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Empty.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getTestCaseMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/GetTestCase")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{name=projects/*/locations/*/agents/*/testCases/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(TestCase.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createTestCaseMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/CreateTestCase")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*}/testCases",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("testCase", request.getTestCase(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(TestCase.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
updateTestCaseMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/UpdateTestCase")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{testCase.name=projects/*/locations/*/agents/*/testCases/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "testCase.name", request.getTestCase().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("testCase", request.getTestCase(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(TestCase.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
runTestCaseMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/RunTestCase")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{name=projects/*/locations/*/agents/*/testCases/*}:run",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(RunTestCaseRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
batchRunTestCasesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/BatchRunTestCases")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*}/testCases:batchRun",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(BatchRunTestCasesRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
calculateCoverageMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/CalculateCoverage")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{agent=projects/*/locations/*/agents/*}/testCases:calculateCoverage",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "agent", request.getAgent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "type", request.getTypeValue());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(CalculateCoverageResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
importTestCasesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/ImportTestCases")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*}/testCases:import",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(ImportTestCasesRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
exportTestCasesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/ExportTestCases")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*}/testCases:export",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(ExportTestCasesRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
listTestCaseResultsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/ListTestCaseResults")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{parent=projects/*/locations/*/agents/*/testCases/*}/results",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "filter", request.getFilter());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListTestCaseResultsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getTestCaseResultMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.dialogflow.cx.v3beta1.TestCases/GetTestCaseResult")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{name=projects/*/locations/*/agents/*/testCases/*/results/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(TestCaseResult.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
listLocationsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.location.Locations/ListLocations")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{name=projects/*}/locations",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListLocationsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getLocationMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.location.Locations/GetLocation")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v3beta1/{name=projects/*/locations/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Location.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private final UnaryCallable listTestCasesCallable;
private final UnaryCallable
listTestCasesPagedCallable;
private final UnaryCallable batchDeleteTestCasesCallable;
private final UnaryCallable getTestCaseCallable;
private final UnaryCallable createTestCaseCallable;
private final UnaryCallable updateTestCaseCallable;
private final UnaryCallable runTestCaseCallable;
private final OperationCallable
runTestCaseOperationCallable;
private final UnaryCallable batchRunTestCasesCallable;
private final OperationCallable<
BatchRunTestCasesRequest, BatchRunTestCasesResponse, BatchRunTestCasesMetadata>
batchRunTestCasesOperationCallable;
private final UnaryCallable
calculateCoverageCallable;
private final UnaryCallable importTestCasesCallable;
private final OperationCallable<
ImportTestCasesRequest, ImportTestCasesResponse, ImportTestCasesMetadata>
importTestCasesOperationCallable;
private final UnaryCallable exportTestCasesCallable;
private final OperationCallable<
ExportTestCasesRequest, ExportTestCasesResponse, ExportTestCasesMetadata>
exportTestCasesOperationCallable;
private final UnaryCallable
listTestCaseResultsCallable;
private final UnaryCallable
listTestCaseResultsPagedCallable;
private final UnaryCallable getTestCaseResultCallable;
private final UnaryCallable listLocationsCallable;
private final UnaryCallable
listLocationsPagedCallable;
private final UnaryCallable getLocationCallable;
private final BackgroundResource backgroundResources;
private final HttpJsonOperationsStub httpJsonOperationsStub;
private final HttpJsonStubCallableFactory callableFactory;
public static final HttpJsonTestCasesStub create(TestCasesStubSettings settings)
throws IOException {
return new HttpJsonTestCasesStub(settings, ClientContext.create(settings));
}
public static final HttpJsonTestCasesStub create(ClientContext clientContext) throws IOException {
return new HttpJsonTestCasesStub(
TestCasesStubSettings.newHttpJsonBuilder().build(), clientContext);
}
public static final HttpJsonTestCasesStub create(
ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
return new HttpJsonTestCasesStub(
TestCasesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of HttpJsonTestCasesStub, using the given settings. This is protected so
* that it is easy to make a subclass, but otherwise, the static factory methods should be
* preferred.
*/
protected HttpJsonTestCasesStub(TestCasesStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new HttpJsonTestCasesCallableFactory());
}
/**
* Constructs an instance of HttpJsonTestCasesStub, using the given settings. This is protected so
* that it is easy to make a subclass, but otherwise, the static factory methods should be
* preferred.
*/
protected HttpJsonTestCasesStub(
TestCasesStubSettings settings,
ClientContext clientContext,
HttpJsonStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(
clientContext,
callableFactory,
typeRegistry,
ImmutableMap.builder()
.put(
"google.longrunning.Operations.CancelOperation",
HttpRule.newBuilder()
.setPost("/v3beta1/{name=projects/*/operations/*}:cancel")
.addAdditionalBindings(
HttpRule.newBuilder()
.setPost(
"/v3beta1/{name=projects/*/locations/*/operations/*}:cancel")
.build())
.build())
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder()
.setGet("/v3beta1/{name=projects/*/operations/*}")
.addAdditionalBindings(
HttpRule.newBuilder()
.setGet("/v3beta1/{name=projects/*/locations/*/operations/*}")
.build())
.build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder()
.setGet("/v3beta1/{name=projects/*}/operations")
.addAdditionalBindings(
HttpRule.newBuilder()
.setGet("/v3beta1/{name=projects/*/locations/*}/operations")
.build())
.build())
.build());
HttpJsonCallSettings
listTestCasesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listTestCasesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings batchDeleteTestCasesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(batchDeleteTestCasesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings getTestCaseTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getTestCaseMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings createTestCaseTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createTestCaseMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings updateTestCaseTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateTestCaseMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("test_case.name", String.valueOf(request.getTestCase().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings runTestCaseTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(runTestCaseMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings batchRunTestCasesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(batchRunTestCasesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
calculateCoverageTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(calculateCoverageMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("agent", String.valueOf(request.getAgent()));
return builder.build();
})
.build();
HttpJsonCallSettings importTestCasesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(importTestCasesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings exportTestCasesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(exportTestCasesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
listTestCaseResultsTransportSettings =
HttpJsonCallSettings
.newBuilder()
.setMethodDescriptor(listTestCaseResultsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
getTestCaseResultTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getTestCaseResultMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
listLocationsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listLocationsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings getLocationTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getLocationMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
this.listTestCasesCallable =
callableFactory.createUnaryCallable(
listTestCasesTransportSettings, settings.listTestCasesSettings(), clientContext);
this.listTestCasesPagedCallable =
callableFactory.createPagedCallable(
listTestCasesTransportSettings, settings.listTestCasesSettings(), clientContext);
this.batchDeleteTestCasesCallable =
callableFactory.createUnaryCallable(
batchDeleteTestCasesTransportSettings,
settings.batchDeleteTestCasesSettings(),
clientContext);
this.getTestCaseCallable =
callableFactory.createUnaryCallable(
getTestCaseTransportSettings, settings.getTestCaseSettings(), clientContext);
this.createTestCaseCallable =
callableFactory.createUnaryCallable(
createTestCaseTransportSettings, settings.createTestCaseSettings(), clientContext);
this.updateTestCaseCallable =
callableFactory.createUnaryCallable(
updateTestCaseTransportSettings, settings.updateTestCaseSettings(), clientContext);
this.runTestCaseCallable =
callableFactory.createUnaryCallable(
runTestCaseTransportSettings, settings.runTestCaseSettings(), clientContext);
this.runTestCaseOperationCallable =
callableFactory.createOperationCallable(
runTestCaseTransportSettings,
settings.runTestCaseOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.batchRunTestCasesCallable =
callableFactory.createUnaryCallable(
batchRunTestCasesTransportSettings,
settings.batchRunTestCasesSettings(),
clientContext);
this.batchRunTestCasesOperationCallable =
callableFactory.createOperationCallable(
batchRunTestCasesTransportSettings,
settings.batchRunTestCasesOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.calculateCoverageCallable =
callableFactory.createUnaryCallable(
calculateCoverageTransportSettings,
settings.calculateCoverageSettings(),
clientContext);
this.importTestCasesCallable =
callableFactory.createUnaryCallable(
importTestCasesTransportSettings, settings.importTestCasesSettings(), clientContext);
this.importTestCasesOperationCallable =
callableFactory.createOperationCallable(
importTestCasesTransportSettings,
settings.importTestCasesOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.exportTestCasesCallable =
callableFactory.createUnaryCallable(
exportTestCasesTransportSettings, settings.exportTestCasesSettings(), clientContext);
this.exportTestCasesOperationCallable =
callableFactory.createOperationCallable(
exportTestCasesTransportSettings,
settings.exportTestCasesOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.listTestCaseResultsCallable =
callableFactory.createUnaryCallable(
listTestCaseResultsTransportSettings,
settings.listTestCaseResultsSettings(),
clientContext);
this.listTestCaseResultsPagedCallable =
callableFactory.createPagedCallable(
listTestCaseResultsTransportSettings,
settings.listTestCaseResultsSettings(),
clientContext);
this.getTestCaseResultCallable =
callableFactory.createUnaryCallable(
getTestCaseResultTransportSettings,
settings.getTestCaseResultSettings(),
clientContext);
this.listLocationsCallable =
callableFactory.createUnaryCallable(
listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
this.listLocationsPagedCallable =
callableFactory.createPagedCallable(
listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
this.getLocationCallable =
callableFactory.createUnaryCallable(
getLocationTransportSettings, settings.getLocationSettings(), clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
@InternalApi
public static List getMethodDescriptors() {
List methodDescriptors = new ArrayList<>();
methodDescriptors.add(listTestCasesMethodDescriptor);
methodDescriptors.add(batchDeleteTestCasesMethodDescriptor);
methodDescriptors.add(getTestCaseMethodDescriptor);
methodDescriptors.add(createTestCaseMethodDescriptor);
methodDescriptors.add(updateTestCaseMethodDescriptor);
methodDescriptors.add(runTestCaseMethodDescriptor);
methodDescriptors.add(batchRunTestCasesMethodDescriptor);
methodDescriptors.add(calculateCoverageMethodDescriptor);
methodDescriptors.add(importTestCasesMethodDescriptor);
methodDescriptors.add(exportTestCasesMethodDescriptor);
methodDescriptors.add(listTestCaseResultsMethodDescriptor);
methodDescriptors.add(getTestCaseResultMethodDescriptor);
methodDescriptors.add(listLocationsMethodDescriptor);
methodDescriptors.add(getLocationMethodDescriptor);
return methodDescriptors;
}
public HttpJsonOperationsStub getHttpJsonOperationsStub() {
return httpJsonOperationsStub;
}
@Override
public UnaryCallable listTestCasesCallable() {
return listTestCasesCallable;
}
@Override
public UnaryCallable
listTestCasesPagedCallable() {
return listTestCasesPagedCallable;
}
@Override
public UnaryCallable batchDeleteTestCasesCallable() {
return batchDeleteTestCasesCallable;
}
@Override
public UnaryCallable getTestCaseCallable() {
return getTestCaseCallable;
}
@Override
public UnaryCallable createTestCaseCallable() {
return createTestCaseCallable;
}
@Override
public UnaryCallable updateTestCaseCallable() {
return updateTestCaseCallable;
}
@Override
public UnaryCallable runTestCaseCallable() {
return runTestCaseCallable;
}
@Override
public OperationCallable
runTestCaseOperationCallable() {
return runTestCaseOperationCallable;
}
@Override
public UnaryCallable batchRunTestCasesCallable() {
return batchRunTestCasesCallable;
}
@Override
public OperationCallable<
BatchRunTestCasesRequest, BatchRunTestCasesResponse, BatchRunTestCasesMetadata>
batchRunTestCasesOperationCallable() {
return batchRunTestCasesOperationCallable;
}
@Override
public UnaryCallable
calculateCoverageCallable() {
return calculateCoverageCallable;
}
@Override
public UnaryCallable importTestCasesCallable() {
return importTestCasesCallable;
}
@Override
public OperationCallable
importTestCasesOperationCallable() {
return importTestCasesOperationCallable;
}
@Override
public UnaryCallable exportTestCasesCallable() {
return exportTestCasesCallable;
}
@Override
public OperationCallable
exportTestCasesOperationCallable() {
return exportTestCasesOperationCallable;
}
@Override
public UnaryCallable
listTestCaseResultsCallable() {
return listTestCaseResultsCallable;
}
@Override
public UnaryCallable
listTestCaseResultsPagedCallable() {
return listTestCaseResultsPagedCallable;
}
@Override
public UnaryCallable getTestCaseResultCallable() {
return getTestCaseResultCallable;
}
@Override
public UnaryCallable listLocationsCallable() {
return listLocationsCallable;
}
@Override
public UnaryCallable
listLocationsPagedCallable() {
return listLocationsPagedCallable;
}
@Override
public UnaryCallable getLocationCallable() {
return getLocationCallable;
}
@Override
public final void close() {
try {
backgroundResources.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException("Failed to close resource", e);
}
}
@Override
public void shutdown() {
backgroundResources.shutdown();
}
@Override
public boolean isShutdown() {
return backgroundResources.isShutdown();
}
@Override
public boolean isTerminated() {
return backgroundResources.isTerminated();
}
@Override
public void shutdownNow() {
backgroundResources.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return backgroundResources.awaitTermination(duration, unit);
}
}