com.google.cloud.alloydb.v1.stub.HttpJsonAlloyDBAdminStub Maven / Gradle / Ivy
/*
* Copyright 2022 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.alloydb.v1.stub;
import static com.google.cloud.alloydb.v1.AlloyDBAdminClient.ListBackupsPagedResponse;
import static com.google.cloud.alloydb.v1.AlloyDBAdminClient.ListClustersPagedResponse;
import static com.google.cloud.alloydb.v1.AlloyDBAdminClient.ListInstancesPagedResponse;
import static com.google.cloud.alloydb.v1.AlloyDBAdminClient.ListLocationsPagedResponse;
import static com.google.cloud.alloydb.v1.AlloyDBAdminClient.ListSupportedDatabaseFlagsPagedResponse;
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.UnaryCallable;
import com.google.cloud.alloydb.v1.Backup;
import com.google.cloud.alloydb.v1.BatchCreateInstancesRequest;
import com.google.cloud.alloydb.v1.BatchCreateInstancesResponse;
import com.google.cloud.alloydb.v1.Cluster;
import com.google.cloud.alloydb.v1.CreateBackupRequest;
import com.google.cloud.alloydb.v1.CreateClusterRequest;
import com.google.cloud.alloydb.v1.CreateInstanceRequest;
import com.google.cloud.alloydb.v1.DeleteBackupRequest;
import com.google.cloud.alloydb.v1.DeleteClusterRequest;
import com.google.cloud.alloydb.v1.DeleteInstanceRequest;
import com.google.cloud.alloydb.v1.FailoverInstanceRequest;
import com.google.cloud.alloydb.v1.GetBackupRequest;
import com.google.cloud.alloydb.v1.GetClusterRequest;
import com.google.cloud.alloydb.v1.GetInstanceRequest;
import com.google.cloud.alloydb.v1.Instance;
import com.google.cloud.alloydb.v1.ListBackupsRequest;
import com.google.cloud.alloydb.v1.ListBackupsResponse;
import com.google.cloud.alloydb.v1.ListClustersRequest;
import com.google.cloud.alloydb.v1.ListClustersResponse;
import com.google.cloud.alloydb.v1.ListInstancesRequest;
import com.google.cloud.alloydb.v1.ListInstancesResponse;
import com.google.cloud.alloydb.v1.ListSupportedDatabaseFlagsRequest;
import com.google.cloud.alloydb.v1.ListSupportedDatabaseFlagsResponse;
import com.google.cloud.alloydb.v1.OperationMetadata;
import com.google.cloud.alloydb.v1.RestartInstanceRequest;
import com.google.cloud.alloydb.v1.RestoreClusterRequest;
import com.google.cloud.alloydb.v1.UpdateBackupRequest;
import com.google.cloud.alloydb.v1.UpdateClusterRequest;
import com.google.cloud.alloydb.v1.UpdateInstanceRequest;
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.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 AlloyDBAdmin service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
@BetaApi
public class HttpJsonAlloyDBAdminStub extends AlloyDBAdminStub {
private static final TypeRegistry typeRegistry =
TypeRegistry.newBuilder()
.add(BatchCreateInstancesResponse.getDescriptor())
.add(Empty.getDescriptor())
.add(Cluster.getDescriptor())
.add(Backup.getDescriptor())
.add(OperationMetadata.getDescriptor())
.add(Instance.getDescriptor())
.build();
private static final ApiMethodDescriptor
listClustersMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/ListClusters")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/clusters",
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, "orderBy", request.getOrderBy());
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(ListClustersResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor getClusterMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/GetCluster")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/clusters/*}",
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(Cluster.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createClusterMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/CreateCluster")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/clusters",
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, "clusterId", request.getClusterId());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("cluster", request.getCluster(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreateClusterRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updateClusterMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/UpdateCluster")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{cluster.name=projects/*/locations/*/clusters/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "cluster.name", request.getCluster().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(
fields, "allowMissing", request.getAllowMissing());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("cluster", request.getCluster(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdateClusterRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deleteClusterMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/DeleteCluster")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/clusters/*}",
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, "etag", request.getEtag());
serializer.putQueryParam(fields, "force", request.getForce());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeleteClusterRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
restoreClusterMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/RestoreCluster")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/clusters:restore",
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(
(RestoreClusterRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
listInstancesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/ListInstances")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*/clusters/*}/instances",
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, "orderBy", request.getOrderBy());
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(ListInstancesResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getInstanceMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/GetInstance")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/clusters/*/instances/*}",
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, "view", request.getViewValue());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Instance.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createInstanceMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/CreateInstance")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*/clusters/*}/instances",
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, "instanceId", request.getInstanceId());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("instance", request.getInstance(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreateInstanceRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
batchCreateInstancesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/BatchCreateInstances")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*/clusters/*}/instances:batchCreate",
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, "requestId", request.getRequestId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("requests", request.getRequests(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(BatchCreateInstancesRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updateInstanceMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/UpdateInstance")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{instance.name=projects/*/locations/*/clusters/*/instances/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "instance.name", request.getInstance().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(
fields, "allowMissing", request.getAllowMissing());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("instance", request.getInstance(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdateInstanceRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deleteInstanceMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/DeleteInstance")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/clusters/*/instances/*}",
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, "etag", request.getEtag());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeleteInstanceRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
failoverInstanceMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/FailoverInstance")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/clusters/*/instances/*}:failover",
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(
(FailoverInstanceRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
restartInstanceMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/RestartInstance")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/clusters/*/instances/*}:restart",
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(
(RestartInstanceRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
listBackupsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/ListBackups")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/backups",
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, "orderBy", request.getOrderBy());
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(ListBackupsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor getBackupMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/GetBackup")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/backups/*}",
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(Backup.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createBackupMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/CreateBackup")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/backups",
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, "backupId", request.getBackupId());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("backup", request.getBackup(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreateBackupRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updateBackupMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/UpdateBackup")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{backup.name=projects/*/locations/*/backups/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "backup.name", request.getBackup().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(
fields, "allowMissing", request.getAllowMissing());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("backup", request.getBackup(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdateBackupRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deleteBackupMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/DeleteBackup")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=projects/*/locations/*/backups/*}",
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, "etag", request.getEtag());
serializer.putQueryParam(fields, "requestId", request.getRequestId());
serializer.putQueryParam(
fields, "validateOnly", request.getValidateOnly());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeleteBackupRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor<
ListSupportedDatabaseFlagsRequest, ListSupportedDatabaseFlagsResponse>
listSupportedDatabaseFlagsMethodDescriptor =
ApiMethodDescriptor
.newBuilder()
.setFullMethodName("google.cloud.alloydb.v1.AlloyDBAdmin/ListSupportedDatabaseFlags")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=projects/*/locations/*}/supportedDatabaseFlags",
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, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListSupportedDatabaseFlagsResponse.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(
"/v1/{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(
"/v1/{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 listClustersCallable;
private final UnaryCallable
listClustersPagedCallable;
private final UnaryCallable getClusterCallable;
private final UnaryCallable createClusterCallable;
private final OperationCallable
createClusterOperationCallable;
private final UnaryCallable updateClusterCallable;
private final OperationCallable
updateClusterOperationCallable;
private final UnaryCallable deleteClusterCallable;
private final OperationCallable
deleteClusterOperationCallable;
private final UnaryCallable restoreClusterCallable;
private final OperationCallable
restoreClusterOperationCallable;
private final UnaryCallable listInstancesCallable;
private final UnaryCallable
listInstancesPagedCallable;
private final UnaryCallable getInstanceCallable;
private final UnaryCallable createInstanceCallable;
private final OperationCallable
createInstanceOperationCallable;
private final UnaryCallable batchCreateInstancesCallable;
private final OperationCallable<
BatchCreateInstancesRequest, BatchCreateInstancesResponse, OperationMetadata>
batchCreateInstancesOperationCallable;
private final UnaryCallable updateInstanceCallable;
private final OperationCallable
updateInstanceOperationCallable;
private final UnaryCallable deleteInstanceCallable;
private final OperationCallable
deleteInstanceOperationCallable;
private final UnaryCallable failoverInstanceCallable;
private final OperationCallable
failoverInstanceOperationCallable;
private final UnaryCallable restartInstanceCallable;
private final OperationCallable
restartInstanceOperationCallable;
private final UnaryCallable listBackupsCallable;
private final UnaryCallable
listBackupsPagedCallable;
private final UnaryCallable getBackupCallable;
private final UnaryCallable createBackupCallable;
private final OperationCallable
createBackupOperationCallable;
private final UnaryCallable updateBackupCallable;
private final OperationCallable
updateBackupOperationCallable;
private final UnaryCallable deleteBackupCallable;
private final OperationCallable
deleteBackupOperationCallable;
private final UnaryCallable
listSupportedDatabaseFlagsCallable;
private final UnaryCallable<
ListSupportedDatabaseFlagsRequest, ListSupportedDatabaseFlagsPagedResponse>
listSupportedDatabaseFlagsPagedCallable;
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 HttpJsonAlloyDBAdminStub create(AlloyDBAdminStubSettings settings)
throws IOException {
return new HttpJsonAlloyDBAdminStub(settings, ClientContext.create(settings));
}
public static final HttpJsonAlloyDBAdminStub create(ClientContext clientContext)
throws IOException {
return new HttpJsonAlloyDBAdminStub(
AlloyDBAdminStubSettings.newHttpJsonBuilder().build(), clientContext);
}
public static final HttpJsonAlloyDBAdminStub create(
ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
return new HttpJsonAlloyDBAdminStub(
AlloyDBAdminStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of HttpJsonAlloyDBAdminStub, 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 HttpJsonAlloyDBAdminStub(AlloyDBAdminStubSettings settings, ClientContext clientContext)
throws IOException {
this(settings, clientContext, new HttpJsonAlloyDBAdminCallableFactory());
}
/**
* Constructs an instance of HttpJsonAlloyDBAdminStub, 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 HttpJsonAlloyDBAdminStub(
AlloyDBAdminStubSettings settings,
ClientContext clientContext,
HttpJsonStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
HttpJsonCallSettings listClustersTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listClustersMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings getClusterTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getClusterMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings createClusterTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createClusterMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings updateClusterTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateClusterMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings deleteClusterTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteClusterMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings restoreClusterTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(restoreClusterMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings
listInstancesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listInstancesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings getInstanceTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getInstanceMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings createInstanceTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createInstanceMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings
batchCreateInstancesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(batchCreateInstancesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings updateInstanceTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateInstanceMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings deleteInstanceTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deleteInstanceMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings failoverInstanceTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(failoverInstanceMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings restartInstanceTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(restartInstanceMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings listBackupsTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listBackupsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings getBackupTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getBackupMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings createBackupTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createBackupMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings updateBackupTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updateBackupMethodDescriptor)
.setTypeRegistry(typeRegistry)
.build();
HttpJsonCallSettings