All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.cloud.spanner.admin.database.v1.stub.HttpJsonDatabaseAdminStub Maven / Gradle / Ivy

There is a newer version: 6.81.1
Show newest version
/*
 * 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.spanner.admin.database.v1.stub;

import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse;
import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse;
import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse;
import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse;
import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse;
import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabasesPagedResponse;

import com.google.api.HttpRule;
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.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
import com.google.spanner.admin.database.v1.Backup;
import com.google.spanner.admin.database.v1.BackupSchedule;
import com.google.spanner.admin.database.v1.CopyBackupMetadata;
import com.google.spanner.admin.database.v1.CopyBackupRequest;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.CreateBackupRequest;
import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest;
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
import com.google.spanner.admin.database.v1.CreateDatabaseRequest;
import com.google.spanner.admin.database.v1.Database;
import com.google.spanner.admin.database.v1.DeleteBackupRequest;
import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest;
import com.google.spanner.admin.database.v1.DropDatabaseRequest;
import com.google.spanner.admin.database.v1.GetBackupRequest;
import com.google.spanner.admin.database.v1.GetBackupScheduleRequest;
import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest;
import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse;
import com.google.spanner.admin.database.v1.GetDatabaseRequest;
import com.google.spanner.admin.database.v1.ListBackupOperationsRequest;
import com.google.spanner.admin.database.v1.ListBackupOperationsResponse;
import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest;
import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse;
import com.google.spanner.admin.database.v1.ListBackupsRequest;
import com.google.spanner.admin.database.v1.ListBackupsResponse;
import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest;
import com.google.spanner.admin.database.v1.ListDatabaseOperationsResponse;
import com.google.spanner.admin.database.v1.ListDatabaseRolesRequest;
import com.google.spanner.admin.database.v1.ListDatabaseRolesResponse;
import com.google.spanner.admin.database.v1.ListDatabasesRequest;
import com.google.spanner.admin.database.v1.ListDatabasesResponse;
import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata;
import com.google.spanner.admin.database.v1.RestoreDatabaseRequest;
import com.google.spanner.admin.database.v1.UpdateBackupRequest;
import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest;
import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseRequest;
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 DatabaseAdmin service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(CreateDatabaseMetadata.getDescriptor()) .add(Empty.getDescriptor()) .add(CreateBackupMetadata.getDescriptor()) .add(RestoreDatabaseMetadata.getDescriptor()) .add(Database.getDescriptor()) .add(Backup.getDescriptor()) .add(CopyBackupMetadata.getDescriptor()) .add(UpdateDatabaseMetadata.getDescriptor()) .add(UpdateDatabaseDdlMetadata.getDescriptor()) .build(); private static final ApiMethodDescriptor listDatabasesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/databases", 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(ListDatabasesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createDatabaseMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CreateDatabase") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/databases", 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( (CreateDatabaseRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor getDatabaseMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/instances/*/databases/*}", 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(Database.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateDatabaseMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabase") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{database.name=projects/*/instances/*/databases/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "database.name", request.getDatabase().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("database", request.getDatabase(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdateDatabaseRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor updateDatabaseDdlMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabaseDdl") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{database=projects/*/instances/*/databases/*}/ddl", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "database", request.getDatabase()); 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().clearDatabase().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdateDatabaseDdlRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor dropDatabaseMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/DropDatabase") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{database=projects/*/instances/*/databases/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "database", request.getDatabase()); 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(Empty.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getDatabaseDdlMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetDatabaseDdl") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{database=projects/*/instances/*/databases/*}/ddl", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "database", request.getDatabase()); 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(GetDatabaseDdlResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor setIamPolicyMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/SetIamPolicy") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "resource", request.getResource()); return fields; }) .setAdditionalPaths( "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy", "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:setIamPolicy") .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().clearResource().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Policy.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getIamPolicyMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetIamPolicy") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "resource", request.getResource()); return fields; }) .setAdditionalPaths( "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy", "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:getIamPolicy") .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().clearResource().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Policy.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor testIamPermissionsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/TestIamPermissions") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "resource", request.getResource()); return fields; }) .setAdditionalPaths( "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions", "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:testIamPermissions", "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions") .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().clearResource().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createBackupMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/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, "encryptionConfig", request.getEncryptionConfig()); 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 copyBackupMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/backups:copy", 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( (CopyBackupRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor getBackupMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetBackup") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/instances/*/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 updateBackupMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackup") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{backup.name=projects/*/instances/*/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, "updateMask", request.getUpdateMask()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("backup", request.getBackup(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Backup.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteBackupMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackup") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/instances/*/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(Empty.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listBackupsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/ListBackups") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/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, "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 restoreDatabaseMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/databases: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( (RestoreDatabaseRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor< ListDatabaseOperationsRequest, ListDatabaseOperationsResponse> listDatabaseOperationsMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseOperations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/databaseOperations", 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(ListDatabaseOperationsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor< ListBackupOperationsRequest, ListBackupOperationsResponse> listBackupOperationsMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/ListBackupOperations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*}/backupOperations", 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(ListBackupOperationsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listDatabaseRolesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseRoles") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*/databases/*}/databaseRoles", 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(ListDatabaseRolesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createBackupScheduleMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/CreateBackupSchedule") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules", 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, "backupScheduleId", request.getBackupScheduleId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("backupSchedule", request.getBackupSchedule(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(BackupSchedule.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getBackupScheduleMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetBackupSchedule") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}", 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(BackupSchedule.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateBackupScheduleMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackupSchedule") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{backupSchedule.name=projects/*/instances/*/databases/*/backupSchedules/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "backupSchedule.name", request.getBackupSchedule().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("backupSchedule", request.getBackupSchedule(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(BackupSchedule.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteBackupScheduleMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackupSchedule") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}", 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(Empty.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listBackupSchedulesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.spanner.admin.database.v1.DatabaseAdmin/ListBackupSchedules") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules", 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(ListBackupSchedulesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private final UnaryCallable listDatabasesCallable; private final UnaryCallable listDatabasesPagedCallable; private final UnaryCallable createDatabaseCallable; private final OperationCallable createDatabaseOperationCallable; private final UnaryCallable getDatabaseCallable; private final UnaryCallable updateDatabaseCallable; private final OperationCallable updateDatabaseOperationCallable; private final UnaryCallable updateDatabaseDdlCallable; private final OperationCallable updateDatabaseDdlOperationCallable; private final UnaryCallable dropDatabaseCallable; private final UnaryCallable getDatabaseDdlCallable; private final UnaryCallable setIamPolicyCallable; private final UnaryCallable getIamPolicyCallable; private final UnaryCallable testIamPermissionsCallable; private final UnaryCallable createBackupCallable; private final OperationCallable createBackupOperationCallable; private final UnaryCallable copyBackupCallable; private final OperationCallable copyBackupOperationCallable; private final UnaryCallable getBackupCallable; private final UnaryCallable updateBackupCallable; private final UnaryCallable deleteBackupCallable; private final UnaryCallable listBackupsCallable; private final UnaryCallable listBackupsPagedCallable; private final UnaryCallable restoreDatabaseCallable; private final OperationCallable restoreDatabaseOperationCallable; private final UnaryCallable listDatabaseOperationsCallable; private final UnaryCallable listDatabaseOperationsPagedCallable; private final UnaryCallable listBackupOperationsCallable; private final UnaryCallable listBackupOperationsPagedCallable; private final UnaryCallable listDatabaseRolesCallable; private final UnaryCallable listDatabaseRolesPagedCallable; private final UnaryCallable createBackupScheduleCallable; private final UnaryCallable getBackupScheduleCallable; private final UnaryCallable updateBackupScheduleCallable; private final UnaryCallable deleteBackupScheduleCallable; private final UnaryCallable listBackupSchedulesCallable; private final UnaryCallable listBackupSchedulesPagedCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonDatabaseAdminStub create(DatabaseAdminStubSettings settings) throws IOException { return new HttpJsonDatabaseAdminStub(settings, ClientContext.create(settings)); } public static final HttpJsonDatabaseAdminStub create(ClientContext clientContext) throws IOException { return new HttpJsonDatabaseAdminStub( DatabaseAdminStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonDatabaseAdminStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonDatabaseAdminStub( DatabaseAdminStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonDatabaseAdminStub, 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 HttpJsonDatabaseAdminStub( DatabaseAdminStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonDatabaseAdminCallableFactory()); } /** * Constructs an instance of HttpJsonDatabaseAdminStub, 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 HttpJsonDatabaseAdminStub( DatabaseAdminStubSettings 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( "/v1/{name=projects/*/instances/*/databases/*/operations/*}:cancel") .addAdditionalBindings( HttpRule.newBuilder() .setPost("/v1/{name=projects/*/instances/*/operations/*}:cancel") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setPost( "/v1/{name=projects/*/instances/*/backups/*/operations/*}:cancel") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setPost( "/v1/{name=projects/*/instanceConfigs/*/operations/*}:cancel") .build()) .build()) .put( "google.longrunning.Operations.DeleteOperation", HttpRule.newBuilder() .setDelete("/v1/{name=projects/*/instances/*/databases/*/operations/*}") .addAdditionalBindings( HttpRule.newBuilder() .setDelete("/v1/{name=projects/*/instances/*/operations/*}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setDelete( "/v1/{name=projects/*/instances/*/backups/*/operations/*}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setDelete("/v1/{name=projects/*/instanceConfigs/*/operations/*}") .build()) .build()) .put( "google.longrunning.Operations.GetOperation", HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instances/*/databases/*/operations/*}") .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instances/*/operations/*}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instances/*/backups/*/operations/*}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instanceConfigs/*/operations/*}") .build()) .build()) .put( "google.longrunning.Operations.ListOperations", HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instances/*/databases/*/operations}") .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instances/*/operations}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instances/*/backups/*/operations}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=projects/*/instanceConfigs/*/operations}") .build()) .build()) .build()); HttpJsonCallSettings listDatabasesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listDatabasesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings createDatabaseTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createDatabaseMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getDatabaseTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getDatabaseMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateDatabaseTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateDatabaseMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("database.name", String.valueOf(request.getDatabase().getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateDatabaseDdlTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateDatabaseDdlMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("database", String.valueOf(request.getDatabase())); return builder.build(); }) .build(); HttpJsonCallSettings dropDatabaseTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(dropDatabaseMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("database", String.valueOf(request.getDatabase())); return builder.build(); }) .build(); HttpJsonCallSettings getDatabaseDdlTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getDatabaseDdlMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("database", String.valueOf(request.getDatabase())); return builder.build(); }) .build(); HttpJsonCallSettings setIamPolicyTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(setIamPolicyMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("resource", String.valueOf(request.getResource())); return builder.build(); }) .build(); HttpJsonCallSettings getIamPolicyTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getIamPolicyMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("resource", String.valueOf(request.getResource())); return builder.build(); }) .build(); HttpJsonCallSettings testIamPermissionsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(testIamPermissionsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("resource", String.valueOf(request.getResource())); return builder.build(); }) .build(); HttpJsonCallSettings createBackupTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createBackupMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings copyBackupTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(copyBackupMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getBackupTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getBackupMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateBackupTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateBackupMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("backup.name", String.valueOf(request.getBackup().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteBackupTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteBackupMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listBackupsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listBackupsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings restoreDatabaseTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(restoreDatabaseMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listDatabaseOperationsTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listDatabaseOperationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listBackupOperationsTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listBackupOperationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listDatabaseRolesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listDatabaseRolesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings createBackupScheduleTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createBackupScheduleMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getBackupScheduleTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getBackupScheduleMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateBackupScheduleTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateBackupScheduleMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "backup_schedule.name", String.valueOf(request.getBackupSchedule().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteBackupScheduleTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listBackupSchedulesTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(listBackupSchedulesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); this.listDatabasesCallable = callableFactory.createUnaryCallable( listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); this.listDatabasesPagedCallable = callableFactory.createPagedCallable( listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); this.createDatabaseCallable = callableFactory.createUnaryCallable( createDatabaseTransportSettings, settings.createDatabaseSettings(), clientContext); this.createDatabaseOperationCallable = callableFactory.createOperationCallable( createDatabaseTransportSettings, settings.createDatabaseOperationSettings(), clientContext, httpJsonOperationsStub); this.getDatabaseCallable = callableFactory.createUnaryCallable( getDatabaseTransportSettings, settings.getDatabaseSettings(), clientContext); this.updateDatabaseCallable = callableFactory.createUnaryCallable( updateDatabaseTransportSettings, settings.updateDatabaseSettings(), clientContext); this.updateDatabaseOperationCallable = callableFactory.createOperationCallable( updateDatabaseTransportSettings, settings.updateDatabaseOperationSettings(), clientContext, httpJsonOperationsStub); this.updateDatabaseDdlCallable = callableFactory.createUnaryCallable( updateDatabaseDdlTransportSettings, settings.updateDatabaseDdlSettings(), clientContext); this.updateDatabaseDdlOperationCallable = callableFactory.createOperationCallable( updateDatabaseDdlTransportSettings, settings.updateDatabaseDdlOperationSettings(), clientContext, httpJsonOperationsStub); this.dropDatabaseCallable = callableFactory.createUnaryCallable( dropDatabaseTransportSettings, settings.dropDatabaseSettings(), clientContext); this.getDatabaseDdlCallable = callableFactory.createUnaryCallable( getDatabaseDdlTransportSettings, settings.getDatabaseDdlSettings(), clientContext); this.setIamPolicyCallable = callableFactory.createUnaryCallable( setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); this.getIamPolicyCallable = callableFactory.createUnaryCallable( getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); this.testIamPermissionsCallable = callableFactory.createUnaryCallable( testIamPermissionsTransportSettings, settings.testIamPermissionsSettings(), clientContext); this.createBackupCallable = callableFactory.createUnaryCallable( createBackupTransportSettings, settings.createBackupSettings(), clientContext); this.createBackupOperationCallable = callableFactory.createOperationCallable( createBackupTransportSettings, settings.createBackupOperationSettings(), clientContext, httpJsonOperationsStub); this.copyBackupCallable = callableFactory.createUnaryCallable( copyBackupTransportSettings, settings.copyBackupSettings(), clientContext); this.copyBackupOperationCallable = callableFactory.createOperationCallable( copyBackupTransportSettings, settings.copyBackupOperationSettings(), clientContext, httpJsonOperationsStub); this.getBackupCallable = callableFactory.createUnaryCallable( getBackupTransportSettings, settings.getBackupSettings(), clientContext); this.updateBackupCallable = callableFactory.createUnaryCallable( updateBackupTransportSettings, settings.updateBackupSettings(), clientContext); this.deleteBackupCallable = callableFactory.createUnaryCallable( deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); this.listBackupsCallable = callableFactory.createUnaryCallable( listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); this.listBackupsPagedCallable = callableFactory.createPagedCallable( listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); this.restoreDatabaseCallable = callableFactory.createUnaryCallable( restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); this.restoreDatabaseOperationCallable = callableFactory.createOperationCallable( restoreDatabaseTransportSettings, settings.restoreDatabaseOperationSettings(), clientContext, httpJsonOperationsStub); this.listDatabaseOperationsCallable = callableFactory.createUnaryCallable( listDatabaseOperationsTransportSettings, settings.listDatabaseOperationsSettings(), clientContext); this.listDatabaseOperationsPagedCallable = callableFactory.createPagedCallable( listDatabaseOperationsTransportSettings, settings.listDatabaseOperationsSettings(), clientContext); this.listBackupOperationsCallable = callableFactory.createUnaryCallable( listBackupOperationsTransportSettings, settings.listBackupOperationsSettings(), clientContext); this.listBackupOperationsPagedCallable = callableFactory.createPagedCallable( listBackupOperationsTransportSettings, settings.listBackupOperationsSettings(), clientContext); this.listDatabaseRolesCallable = callableFactory.createUnaryCallable( listDatabaseRolesTransportSettings, settings.listDatabaseRolesSettings(), clientContext); this.listDatabaseRolesPagedCallable = callableFactory.createPagedCallable( listDatabaseRolesTransportSettings, settings.listDatabaseRolesSettings(), clientContext); this.createBackupScheduleCallable = callableFactory.createUnaryCallable( createBackupScheduleTransportSettings, settings.createBackupScheduleSettings(), clientContext); this.getBackupScheduleCallable = callableFactory.createUnaryCallable( getBackupScheduleTransportSettings, settings.getBackupScheduleSettings(), clientContext); this.updateBackupScheduleCallable = callableFactory.createUnaryCallable( updateBackupScheduleTransportSettings, settings.updateBackupScheduleSettings(), clientContext); this.deleteBackupScheduleCallable = callableFactory.createUnaryCallable( deleteBackupScheduleTransportSettings, settings.deleteBackupScheduleSettings(), clientContext); this.listBackupSchedulesCallable = callableFactory.createUnaryCallable( listBackupSchedulesTransportSettings, settings.listBackupSchedulesSettings(), clientContext); this.listBackupSchedulesPagedCallable = callableFactory.createPagedCallable( listBackupSchedulesTransportSettings, settings.listBackupSchedulesSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(listDatabasesMethodDescriptor); methodDescriptors.add(createDatabaseMethodDescriptor); methodDescriptors.add(getDatabaseMethodDescriptor); methodDescriptors.add(updateDatabaseMethodDescriptor); methodDescriptors.add(updateDatabaseDdlMethodDescriptor); methodDescriptors.add(dropDatabaseMethodDescriptor); methodDescriptors.add(getDatabaseDdlMethodDescriptor); methodDescriptors.add(setIamPolicyMethodDescriptor); methodDescriptors.add(getIamPolicyMethodDescriptor); methodDescriptors.add(testIamPermissionsMethodDescriptor); methodDescriptors.add(createBackupMethodDescriptor); methodDescriptors.add(copyBackupMethodDescriptor); methodDescriptors.add(getBackupMethodDescriptor); methodDescriptors.add(updateBackupMethodDescriptor); methodDescriptors.add(deleteBackupMethodDescriptor); methodDescriptors.add(listBackupsMethodDescriptor); methodDescriptors.add(restoreDatabaseMethodDescriptor); methodDescriptors.add(listDatabaseOperationsMethodDescriptor); methodDescriptors.add(listBackupOperationsMethodDescriptor); methodDescriptors.add(listDatabaseRolesMethodDescriptor); methodDescriptors.add(createBackupScheduleMethodDescriptor); methodDescriptors.add(getBackupScheduleMethodDescriptor); methodDescriptors.add(updateBackupScheduleMethodDescriptor); methodDescriptors.add(deleteBackupScheduleMethodDescriptor); methodDescriptors.add(listBackupSchedulesMethodDescriptor); return methodDescriptors; } public HttpJsonOperationsStub getHttpJsonOperationsStub() { return httpJsonOperationsStub; } @Override public UnaryCallable listDatabasesCallable() { return listDatabasesCallable; } @Override public UnaryCallable listDatabasesPagedCallable() { return listDatabasesPagedCallable; } @Override public UnaryCallable createDatabaseCallable() { return createDatabaseCallable; } @Override public OperationCallable createDatabaseOperationCallable() { return createDatabaseOperationCallable; } @Override public UnaryCallable getDatabaseCallable() { return getDatabaseCallable; } @Override public UnaryCallable updateDatabaseCallable() { return updateDatabaseCallable; } @Override public OperationCallable updateDatabaseOperationCallable() { return updateDatabaseOperationCallable; } @Override public UnaryCallable updateDatabaseDdlCallable() { return updateDatabaseDdlCallable; } @Override public OperationCallable updateDatabaseDdlOperationCallable() { return updateDatabaseDdlOperationCallable; } @Override public UnaryCallable dropDatabaseCallable() { return dropDatabaseCallable; } @Override public UnaryCallable getDatabaseDdlCallable() { return getDatabaseDdlCallable; } @Override public UnaryCallable setIamPolicyCallable() { return setIamPolicyCallable; } @Override public UnaryCallable getIamPolicyCallable() { return getIamPolicyCallable; } @Override public UnaryCallable testIamPermissionsCallable() { return testIamPermissionsCallable; } @Override public UnaryCallable createBackupCallable() { return createBackupCallable; } @Override public OperationCallable createBackupOperationCallable() { return createBackupOperationCallable; } @Override public UnaryCallable copyBackupCallable() { return copyBackupCallable; } @Override public OperationCallable copyBackupOperationCallable() { return copyBackupOperationCallable; } @Override public UnaryCallable getBackupCallable() { return getBackupCallable; } @Override public UnaryCallable updateBackupCallable() { return updateBackupCallable; } @Override public UnaryCallable deleteBackupCallable() { return deleteBackupCallable; } @Override public UnaryCallable listBackupsCallable() { return listBackupsCallable; } @Override public UnaryCallable listBackupsPagedCallable() { return listBackupsPagedCallable; } @Override public UnaryCallable restoreDatabaseCallable() { return restoreDatabaseCallable; } @Override public OperationCallable restoreDatabaseOperationCallable() { return restoreDatabaseOperationCallable; } @Override public UnaryCallable listDatabaseOperationsCallable() { return listDatabaseOperationsCallable; } @Override public UnaryCallable listDatabaseOperationsPagedCallable() { return listDatabaseOperationsPagedCallable; } @Override public UnaryCallable listBackupOperationsCallable() { return listBackupOperationsCallable; } @Override public UnaryCallable listBackupOperationsPagedCallable() { return listBackupOperationsPagedCallable; } @Override public UnaryCallable listDatabaseRolesCallable() { return listDatabaseRolesCallable; } @Override public UnaryCallable listDatabaseRolesPagedCallable() { return listDatabaseRolesPagedCallable; } @Override public UnaryCallable createBackupScheduleCallable() { return createBackupScheduleCallable; } @Override public UnaryCallable getBackupScheduleCallable() { return getBackupScheduleCallable; } @Override public UnaryCallable updateBackupScheduleCallable() { return updateBackupScheduleCallable; } @Override public UnaryCallable deleteBackupScheduleCallable() { return deleteBackupScheduleCallable; } @Override public UnaryCallable listBackupSchedulesCallable() { return listBackupSchedulesCallable; } @Override public UnaryCallable listBackupSchedulesPagedCallable() { return listBackupSchedulesPagedCallable; } @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); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy